★★★敬請留意★★★:和微軟一模一樣的記事本的原始碼(1) (轉)
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 Integer
Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINT
X As Long
Y As Long
End 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 Long
End Type
Private Declare Function PageSetupDlg Lib "comdlg32.dll" Alias "PageSetupDlgA" _
(pPagesetupdlg As PageSetupDlg) As Long
Dim PageSetup As PageSetupDlg
Dim Pflag As Long
Dim Pmode As Long
Dim 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 = False
mnuUndo.Enabled = False
mnuCopy.Enabled = False
mnuDelete.Enabled = False
If Clipboard.GetText() <> "" Then
mnuPaste.Enabled = True
Else
mnuPaste.Enabled = False
End If
'Text1.SelAlignment = Null
Changed = 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
End
End If
End Sub
Private Sub Form_resize()
Text1.Top = ScaleTop
Text1.Left = ScaleLeft
Text1.Width = ScaleWidth
Text1.Height = ScaleHeight
End Sub
Private Sub mnuAbout_Click()
Form4.Show
End Sub
Private Sub mnuAll_Click()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub mnuCline_Click()
mnuCline.Checked = Not mnuCline.Checked
If mnuCline.Checked = True Then
Text1.RightMargin = 0
Else
Text1.RightMargin = 2500
End If
End Sub
Private Sub mnuCopy_Click()
SendKeys "^{insert}"
End Sub
Private Sub mnuDate_Click()
Dstring = FormatDateTime(Now, 4) + Space(2) + FormatDateTime(Now, 2)
SendKeys Dstring
End 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
End
End If
End Sub
Private Sub mnuFind_Click()
Form2.Show
End Sub
Private Sub mnuFont_Click()
CommonDialog1.FontName = Text1.SelFontName
CommonDialog1.FLAGS = Fontnstants.cdlCFScreenFonts
CommonDialog1.FontStrikethru = Text1.SelStrikeThru
CommonDialog1.FontBold = Text1.SelBold
CommonDialog1.FontItalic = Text1.SelItalic
CommonDialog1.FontUnderline = Text1.SelUnderline
CommonDialog1.FontSize = Text1.SelFontSize
CommonDialog1.FontStrikethru = Text1.SelStrikeThru
CommonDialog1.Color = Text1.SelColor
CommonDialog1.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.FontBold
Text1.Font.Italic = CommonDialog1.FontItalic
Text1.Font.Name = CommonDialog1.FontName
Text1.Font.Size = CommonDialog1.FontSize
End Sub
Private Sub mnuGoto_Click()
Form3.Show
'Form3.SetFocus = Form3.Text1.Text
End Sub
Private Sub mnuHelpTopic_Click()
'App.HelpFile = "e:notepadnote.CHM"
'SendKeys "{F1}"
'yeah = Execute(Form1.hwnd, "open", "e:notepadnote.CHM", Null, Null, SW_SHOWNORMAL)
'Shell "e:notepadnote.chm", vbNormalFocus
'Shell "hh " + App.Path + "note.chm", vbNormalFocus
'Shell "e:notepadnote.CHM", vbNormalFocus
htmlhelp hwnd, "d:notepadnote.CHM", 0, 0
End Sub
Private Sub mnuJian_Click()
SendKeys "+{del}"
End Sub
Private Sub mnuline7_Click(Index As Integer)
Dim i As Integer
CommonDialog1.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 If
End If
Text1.Text = ""
Form1.Caption = "NoTitled-notePad"
Changed = False
End Sub
Private Sub mnuNext_Click()
If Gstring <> "" Then
Form2.Visible = False
Form2.Command1_Click
Else
Form2.Visible = True
End 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 If
End If
CommonDialog1.ShowOpen
file = CommonDialog1.FileName
If file <> "" Then
Form1.Caption = file
Open file For Input As #1
If Not EOF(file) Then Text1.Text = Input(LOF(1), #1)
Close #1
Changed = False
End If
End 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.SetFocus
End 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 + cdlPDion
'End If
CommonDialog1.ShowPrinter
On Error GoTo trip
Printer.Print ""
If CommonDialog1.hDC > 0 Then Text1.Print CommonDialog1.hDC
Printer.EndDoc
trip: End Sub
Private Sub mnuReplace_Click()
FrmReplace.Show
End Sub
Private Sub mnuSave_Click()
If Form1.Caption = "NoTitled-notePad" Then
CommonDialog1.DialogTitle = "save"
CommonDialog1.ShowSave
file = 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 #1
End If
End Sub
Private Sub mnuSaveAs_Click()
CommonDialog1.DialogTitle = "save as "
CommonDialog1.ShowSave
file = CommonDialog1.FileName
If file <> "" Then
Form1.Caption = file
Open file For Output As #1
Print #1, Text1.Text
Close #1
End If
End Sub
Private Sub mnuUndo_Click()
SendKeys "^{z}"
End Sub
Private Sub Text1_Change()
Changed = True
mnuUndo.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 = False
End If
End Sub
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-989356/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ★★★敬請留意★★★:和微軟一模一樣的記事本的原始碼(2) (轉)微軟原始碼
- ★★★敬請留意★★★:和微軟一模一樣的記事本的原始碼(3) (轉)微軟原始碼
- ★★★敬請留意★★★:和微軟一模一樣的記事本的原始碼(4) (轉)微軟原始碼
- ★★★敬請留意★★★:和微軟一模一樣的記事本的原始碼(5) (轉)微軟原始碼
- 我寫的一段"記事本"的程式,請高手指教. (轉)
- 這樣下載的網頁為什麼在記事本中顯示和控制檯上不一樣???網頁
- 《怎樣閱讀一本書》的筆記筆記
- 開發一款記事本
- 解決一開機就自動開啟記事本的辦法(轉)
- 深入OKHttp原始碼分析(一)----同步和非同步請求流程和原始碼分析HTTP原始碼非同步
- Python:遊戲:寫一個和 XP 上一模一樣的“掃雷”Python遊戲
- 對抗樣本學習筆記(一)筆記
- spring事務管理原始碼分析(一)配置和事務增強代理的生成流程Spring原始碼
- 用C#寫一個記事本五C#
- 使用C#寫出一個簡單的記事本程式C#
- 請問關於本書原始碼……原始碼
- 如何從和C盤一模一樣的F盤啟動系統
- 一對一交友原始碼,需要申請的資料有哪些?原始碼
- Okhttp原始碼閱讀(一)——一個請求是怎麼發生的HTTP原始碼
- OkHttp 原始碼分析(一)—— 請求流程HTTP原始碼
- 有沒有和laravel一樣的golang框架!請推薦一下!LaravelGolang框架
- excel表格複製貼上格式怎麼能一模一樣 表格怎麼複製一個一模一樣的Excel
- 原始碼分析axios(1)~原始碼分析、模擬axios的建立原始碼iOS
- 關於Laravel的二、三事(1)一次請求的生命週期Laravel
- 這個長得和 a 一模一樣,但是卻不是 a的字元是什麼字元
- 怎樣開發一對一直播原始碼?原始碼
- 一個俄羅斯方塊的原始碼 (轉)原始碼
- 原始碼解析:Git的第一個提交是什麼樣的?原始碼Git
- 關於spring事務原始碼的一些小理解Spring原始碼
- BIO到NIO原始碼的一些事兒之BIO原始碼
- AFL二三事 -- 原始碼分析 1原始碼
- OkHttpClient原始碼分析(一)—— 同步、非同步請求分析和Dispatcher的任務排程HTTPclient原始碼非同步
- windows10的記事本在哪裡_win10開啟記事本的步驟WindowsWin10
- 筆記本和微軟平板電腦的實際區別筆記微軟
- 記事本介面
- QT記事本QT
- BIO到NIO原始碼的一些事兒之NIO 中原始碼
- BIO到NIO原始碼的一些事兒之NIO 上原始碼