★★★ Please pay attention to ★★★: The source code of the same notepad in Microsoft (1)

zhaozj2021-02-11  208

Private declare function htmlhelp lib _ "hhctrl.ocx" alias "htmlhelpa" _ (Byval Hwndcaller as stay, _byval pszfile as string, Byval _UCommand as long, Byval Dwdata as long) As long

DIM Changed as Boolean

Dim Button As INTEGERPRIVATE TYPE RECT AS Long Top As Long Right As Long Bottom As LONGEND TYPE

Private Type Pointapi X As Long Y As Longend Type

Private Type PageSetupDlg lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long FLAGS As Long ptPaperSize As POINTAPI rtMinMargin As Rect rtMargin As Rect hInstance As Long lCustData As Long lpfnPageSetupHook As Long lpfnPagePaintHook As Long lpPageSetupTemplateName As String hPageSetupTemplate As LongEnd Type

Private Declare Function PageSetupDlg Lib "comdlg32.dll" Alias ​​"PageSetupDlgA" _ (pPagesetupdlg As PageSetupDlg) As LongDim PageSetup As PageSetupDlgDim Pflag As LongDim Pmode As LongDim Psize As POINTAPI

PRIVATE SUB FORM_LOAD () Form1.caption = "notitled-notepad"

Mnuundo.caption = "Undo (& U)" CHR (9) "Ctrl Z" MNUJian.caption = "Cut (& T) CHR (9) " Ctrl X "Mnucopy.caption =" copy ( & C) " CHR (9) " Ctrl C "mnupaste.caption =" Paste (& P) CHR (9) "Ctrl V" mnujian.enabled = falseMnuundo.Nabled = falsemnucopy.enabled = false

Mnudelete.enabled = falseif clipboard.getText () <> "" "" the mnupaste.enabled = trueelse mnupaste.enabled = falsement = nullchanged = false

End Sub

Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer) If Changed = True Then Button = MsgBox (Form1.Caption "file has changed," Chr (13) "do you save?", VbYesNoCancel vbExclamation) If Button = Vbyes damaVe_click end elseif button = vbno dam = true else endend iFend Sub

Private sub form_resize () text1.top = scaletoptext1.left = schelalefttext1.width = scalewidthtext1.height = scaleheight

End Sub

Private sub mnuabout_click () form4.shownd SUB

Private sub mnuall_click () text1.selstart = 0text1.sellength = len (text1.text) End Sub

Private sub mnucline_click ()

Mnucline.checked = not mnuCline.checked = true kilse text1.rightmargin = 2500nd ifend subrgin = 2500nd ifend subrgin = 2500nd ifend

Private sub mnucopy_click ()

SendKeys "^ {INSERT}"

End Sub

Private sub mnudate_click () DString = formatdatetime (now, 4) Space (2) formatdatetime (now, 2) SendKeys DSTRINGEND SUB

Private sub mnudelete_click () text1.seltext = "" "" End Sub

Private sub mnuexit_click ()

If Changed = True Then Button = MsgBox (Form1.Caption "file has changed," Chr (13) "do you save?", VbYesNoCancel vbExclamation) If Button = vbYes Then mnuSave_Click ElseIf Button = vbNo Then End End If Else Endend IF

End Sub

Private sub mnufind_click () Form2.Shownd Sub

Private Sub mnuFont_Click () CommonDialog1.FontName = Text1.SelFontNameCommonDialog1.FLAGS = FontsConstants.cdlCFScreenFontsCommonDialog1.FontStrikethru = Text1.SelStrikeThruCommonDialog1.FontBold = Text1.SelBoldCommonDialog1.FontItalic = Text1.SelItalicCommonDialog1.FontUnderline = Text1.SelUnderlineCommonDialog1.FontSize = Text1.SelFontSizeCommonDialog1.FontStrikethru = Text1.SelStrikeThruCommonDialog1.Color = Text1.SelColorCommonDialog1.ShowFont'Text1.SelFontName = CommonDialog1.FontName'Text1.SelStrikeThru = CommonDialog1.FontStrikethru'Text1.SelBold = CommonDialog1.FontBold'Text1.SelColor = CommonDialog1.Color'Text1.SelItalic = CommonDialog1 .FontItalic'Text1.SelUnderline = CommonDialog1.FontUnderline'Text1.SelFontSize = CommonDialog1.FontSize'Text1.SelStrikeThru = CommonDialog1.FontStrikethruText1.Font.Bold = CommonDialog1.FontBoldText1.Font.Italic = CommonDialog1.FontItalicText1.Font.Name = CommonDialog1.FontNameText1 .FONT.SIZE = CommonDialog1.fontsize

End Sub

Private sub mnugoto_click () form3.show'FORM3.SETFOCUS = FORM3.TEXT1.TEXTEND SUB

Private sub mnuhelptopic_click ()

'App.helpfile = "E: /NOTEPAD/note.chm"' sendKeys "{f1}" 'yeah = shellexecute (form1.hwnd, "open", "e: / notepad/note.chm", null, null, SW_SHOWNORMAL) 'Shell "E: /NOTEPAD/Note.chm", VBNORMALFOCUS'SHELL "HH" app.path "/note.chm", VBNORMALFOCUS'SHELL "E: /NOTEPAD/note.chm", VBNORMALFOCUSHTMLHELP HWND, "D: / Notepad/note.chm", 0, 0nd Sub

Private sub mnujian_click ()

SendKeys " {DEL}"

End Sub

Private sub mnuline7_click (index as integer) Dim i as integercommondialog1.showundenend Sub

Private Sub mnuNew_Click () If Changed = True Then Button = MsgBox (Form1.Caption "file has changed," Chr (13) "do you save?", VbYesNoCancel vbExclamation) If Button = vbYes Then mnuSave_Click End IfEnd IfText1 .Text = "" Form1.caption = "notitled-notepad" Changed = false

Private sub mnunext_click ()

IF gstring <> ""1 Form2.visible = false form2.command1_clickelse form2.visible = truendiff

End Sub

Private Sub mnuOpen_Click () If Changed = True Then Button = MsgBox (Form1.Caption "file has changed," Chr (13) "do you save?", VbYesNoCancel vbExclamation) If Button = vbYes Then mnuSave_Click End IfEnd IfCommonDialog1 .Showopenfile = commondialog1.filename

If File <> "" "c) file for input as # 1 if not eof (file) TEXT1.TEXT = INPUT (Lof (1), # 1) Close # 1changed = falseEnd IFEND SUB

Private sub mnupage_click ()

With PageSetup .lStructSize = Len (PageSetup) .hwndOwner = hwnd PageSetupDlg PageSetup Pflag = .FLAGS Psize = .ptPaperSize Pmode = .hDevMode End With 'Pflag = PageSetupDlg (PageSetup)' Text1.SetFocusEnd Sub

Private sub mnupaste_click () sendKeys " {insert}" end SUB

Private Sub mnuPrint_Click () CommonDialog1.FLAGS = Pmode'If Text1.SelLength = 0 Then 'CommonDialog1.FLAGS = cdlPDReturnDC cdlPDAllPages'Else' CommonDialog1.FLAGS = cdlPDReturnDC cdlPDSelection'End IfCommonDialog1.ShowPrinterOn Error GoTo tripPrinter.Print "" If CommonDialog1 .hdc> 0 THEN TEXT1.PRINT Commondialog1.hdcprinter.Enddoc

Trip: End Sub

Private sub mnureplace_click () frmReplace.shownd Sub

Private sub mnusave_click () if Form1.caption = "notitled-notepad" then

Commondialog1.dialogtitle = "save" Commondialog1.showsavefile = comMMondialog1.FileName if File <> "" ""1 Form1.caption = file open file for output as # 1 print # 1, text1.text close # 1 Endix

Else file = form1.caption open file for output as # 1 print # 1, text1.text close # 1END IFEND SUB

Private Sub mnuSaveAs_Click () CommonDialog1.DialogTitle = "save as" CommonDialog1.ShowSavefile = CommonDialog1.FileNameIf file <> "" Then Form1.Caption = file Open file For Output As # 1 Print # 1, Text1.Text Close # 1End IfEnd Sub

Private sub mnuundo_click () sendkeys "^ {z}" end sub

Private sub text1_change () Changed = truemnuundo.enabled = TRUE

End Sub

Private Sub Text1_SelChange () If Text1.SelLength <> 0 Then mnuJian.Enabled = True mnuCopy.Enabled = True mnuDelete.Enabled = True Else mnuJian.Enabled = False mnuCopy.Enabled = False mnuDelete.Enabled = FalseEnd IfEnd Sub

转载请注明原文地址:https://www.9cbs.com/read-6052.html

New Post(0)