Private Declare Function htmlhelp Lib _ "hhctrl.ocx" Alias "HtmlHelpA" _ (ByVal hwndCaller As Long, _ByVal pszFile As String, ByVal _uCommand As Long, ByVal dwData As Long) As Long
Dim Changed As Boolean
Dim Button As IntegerPrivate Type Rect Left 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 = "撤消(&U)" + Chr(9) + "Ctrl+Z"mnuJian.Caption = "剪切(&T)" + Chr(9) + "Ctrl+X"mnuCopy.Caption = "复制(&C)" + Chr(9) + "Ctrl+C"mnuPaste.Caption = "粘贴(&P)" + Chr(9) + "Ctrl+V"mnuJian.Enabled = FalsemnuUndo.Enabled = FalsemnuCopy.Enabled = False
mnuDelete.Enabled = FalseIf Clipboard.GetText() <> "" Then mnuPaste.Enabled = TrueElse mnuPaste.Enabled = FalseEnd If'Text1.SelAlignment = 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 Then mnuSave_Click End ElseIf Button = vbNo Then End End If Cancel = True Else EndEnd If
End Sub
Private Sub Form_resize()Text1.Top = ScaleTopText1.Left = ScaleLeftText1.Width = ScaleWidthText1.Height = ScaleHeight
End Sub
Private Sub mnuAbout_Click()Form4.ShowEnd Sub
Private Sub mnuAll_Click()Text1.SelStart = 0Text1.SelLength = Len(Text1.Text)End Sub
Private Sub mnuCline_Click()
mnuCline.Checked = Not mnuCline.CheckedIf mnuCline.Checked = True Then Text1.RightMargin = 0Else Text1.RightMargin = 2500End IfEnd Sub
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.ShowEnd 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.FontStrikethru
Text1.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, 0End Sub
Private Sub mnuJian_Click()
SendKeys "+{del}"
End Sub
Private Sub mnuline7_Click(Index As Integer)Dim i As IntegerCommonDialog1.ShowOpen
End 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 = FalseEnd Sub
Private Sub mnuNext_Click()
If Gstring <> "" Then Form2.Visible = False Form2.Command1_ClickElse Form2.Visible = TrueEnd If
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 <> "" ThenForm1.Caption = fileOpen file For Input As #1 If Not EOF(file) Then 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.ShowEnd Sub
Private Sub mnuSave_Click()If Form1.Caption = "NoTitled-notePad" Then
CommonDialog1.DialogTitle = "save"CommonDialog1.ShowSavefile = CommonDialog1.FileName If file <> "" Then Form1.Caption = file Open file For Output As #1 Print #1, Text1.Text Close #1 End If
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