📄 7-2.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.MDIForm frmMDI
BackColor = &H8000000C&
Caption = "MDI 记事本"
ClientHeight = 4995
ClientLeft = 915
ClientTop = 2205
ClientWidth = 7395
LinkTopic = "MDIForm1"
Begin VB.PictureBox picToolbar
Align = 1 'Align Top
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 0
ScaleHeight = 345
ScaleWidth = 7335
TabIndex = 0
Top = 0
Width = 7395
Begin MSComDlg.CommonDialog CMDialog1
Left = 1995
Top = 0
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
DefaultExt = "TXT"
Filter = "文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*"
FilterIndex = 557
FontSize = 1.27584e-37
End
Begin VB.Image imgPasteButtonUp
Height = 330
Left = 5280
Picture = "7-2.frx":0000
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgPasteButtonDn
Height = 330
Left = 4920
Picture = "7-2.frx":01E2
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgCopyButtonDn
Height = 330
Left = 4200
Picture = "7-2.frx":03C4
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgCopyButtonUp
Height = 330
Left = 4560
Picture = "7-2.frx":05A6
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgCutButtonDn
Height = 330
Left = 3840
Picture = "7-2.frx":0788
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgCutButtonUp
Height = 330
Left = 3480
Picture = "7-2.frx":096A
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgFileOpenButtonDn
Height = 330
Left = 2760
Picture = "7-2.frx":0B4C
Top = 0
Visible = 0 'False
Width = 360
End
Begin VB.Image imgFileOpenButtonUp
Height = 330
Left = 3120
Picture = "7-2.frx":0CD6
Top = 0
Visible = 0 'False
Width = 360
End
Begin VB.Image imgFileNewButtonUp
Height = 330
Left = 2400
Picture = "7-2.frx":0E60
Top = 0
Visible = 0 'False
Width = 360
End
Begin VB.Image imgFileNewButtonDn
Height = 330
Left = 2040
Picture = "7-2.frx":0FEA
Top = 0
Visible = 0 'False
Width = 375
End
Begin VB.Image imgPasteButton
Height = 330
Left = 1560
Picture = "7-2.frx":11CC
ToolTipText = "粘贴"
Top = 0
Width = 375
End
Begin VB.Image imgCopyButton
Height = 330
Left = 1200
Picture = "7-2.frx":13AE
ToolTipText = "复制"
Top = 0
Width = 375
End
Begin VB.Image imgCutButton
Height = 330
Left = 840
Picture = "7-2.frx":1590
ToolTipText = "剪切"
Top = 0
Width = 375
End
Begin VB.Image imgFileOpenButton
Height = 330
Left = 360
Picture = "7-2.frx":1772
ToolTipText = "打开文件"
Top = 0
Width = 360
End
Begin VB.Image imgFileNewButton
Height = 330
Left = 0
Picture = "7-2.frx":18FC
ToolTipText = "新建文件"
Top = 0
Width = 360
End
End
Begin VB.Menu mnuFile
Caption = "文件(&F)"
Begin VB.Menu mnuFileNew
Caption = "新建(&N)"
End
Begin VB.Menu mnuFileOpen
Caption = "打开(&O)"
End
Begin VB.Menu mnuFileExit
Caption = "退出(&X)"
End
Begin VB.Menu mnuRecentFile
Caption = "-"
Index = 0
Visible = 0 'False
End
Begin VB.Menu mnuRecentFile
Caption = "最近处理文件1"
Index = 1
Visible = 0 'False
End
Begin VB.Menu mnuRecentFile
Caption = "最近处理文件2"
Index = 2
Visible = 0 'False
End
Begin VB.Menu mnuRecentFile
Caption = "最近处理文件3"
Index = 3
Visible = 0 'False
End
Begin VB.Menu mnuRecentFile
Caption = "最近处理文件4"
Index = 4
Visible = 0 'False
End
Begin VB.Menu mnuRecentFile
Caption = "最近处理文件5"
Index = 5
Visible = 0 'False
End
End
Begin VB.Menu mnuOptions
Caption = "选项(&O)"
Begin VB.Menu mnuOptionsToolbar
Caption = "工具栏(&T)"
End
End
End
Attribute VB_Name = "frmMDI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*** MDI 记事本事例应用程序 ***
'*** 主 MDI 窗体 ***
'************************************
Option Explicit
Private Sub imgCopyButton_Click()
' 刷新图象。
imgCopyButton.Refresh
' 调用复制过程
EditCopyProc
End Sub
Private Sub imgCopyButton_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示按下状态时图片。
imgCopyButton.Picture = imgCopyButtonDn.Picture
End Sub
Private Sub imgCopyButton_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 如果按下按钮,判断鼠标是否在按钮上。
' 是,则显示按下状态时图片;否,则显示弹起状态时图片。
Select Case Button
Case 1
If x <= 0 Or x > imgCopyButton.Width Or Y < 0 Or Y > imgCopyButton.Height Then
imgCopyButton.Picture = imgCopyButtonUp.Picture
Else
imgCopyButton.Picture = imgCopyButtonDn.Picture
End If
End Select
End Sub
Private Sub imgCopyButton_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示弹起状态时图片。
imgCopyButton.Picture = imgCopyButtonUp.Picture
End Sub
Private Sub imgCutButton_Click()
' 刷新图象。
imgCutButton.Refresh
' 调用剪切过程。
EditCutProc
End Sub
Private Sub imgCutButton_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示按下状态时图片。
imgCutButton.Picture = imgCutButtonDn.Picture
End Sub
Private Sub imgCutButton_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 如果按钮被按下,显示弹起状态图片当鼠标
' 被拖拽出按钮区域的时候;否则,
' 显示按下的状态。
Select Case Button
Case 1
If x <= 0 Or x > imgCutButton.Width Or Y < 0 Or Y > imgCutButton.Height Then
imgCutButton.Picture = imgCutButtonUp.Picture
Else
imgCutButton.Picture = imgCutButtonDn.Picture
End If
End Select
End Sub
Private Sub imgCutButton_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示弹起状态时图片。
imgCutButton.Picture = imgCutButtonUp.Picture
End Sub
Private Sub imgFileNewButton_Click()
' 刷新图象。
imgFileNewButton.Refresh
' 调用新建文件过程。
FileNew
End Sub
Private Sub imgFileNewButton_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示按下状态时图片。
imgFileNewButton.Picture = imgFileNewButtonDn.Picture
End Sub
Private Sub imgFileNewButton_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 如果按钮被按下,显示弹起状态图片当鼠标
' 被拖拽出按钮区域的时候;否则,
' 显示按下的状态。
Select Case Button
Case 1
If x <= 0 Or x > imgFileNewButton.Width Or Y < 0 Or Y > imgFileNewButton.Height Then
imgFileNewButton.Picture = imgFileNewButtonUp.Picture
Else
imgFileNewButton.Picture = imgFileNewButtonDn.Picture
End If
End Select
End Sub
Private Sub imgFileNewButton_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示弹起状态时图片。
imgFileNewButton.Picture = imgFileNewButtonUp.Picture
End Sub
Private Sub imgFileOpenButton_Click()
' 刷新图象。
imgFileOpenButton.Refresh
' 调用文件打开过程。
FileOpenProc
End Sub
Private Sub imgFileOpenButton_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示按下状态时图片。
imgFileOpenButton.Picture = imgFileOpenButtonDn.Picture
End Sub
Private Sub imgFileOpenButton_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 如果按钮被按下,显示弹起状态图片当鼠标
' 被拖拽出按钮区域的时候;否则,
' 显示按下的状态。
Select Case Button
Case 1
If x <= 0 Or x > imgFileOpenButton.Width Or Y < 0 Or Y > imgFileOpenButton.Height Then
imgFileOpenButton.Picture = imgFileOpenButtonUp.Picture
Else
imgFileOpenButton.Picture = imgFileOpenButtonDn.Picture
End If
End Select
End Sub
Private Sub imgFileOpenButton_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示弹起状态时图片。
imgFileOpenButton.Picture = imgFileOpenButtonUp.Picture
End Sub
Private Sub imgPasteButton_Click()
' 刷新图象。
imgPasteButton.Refresh
' 调用文件打开过程。
EditPasteProc
End Sub
Private Sub imgPasteButton_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示按下状态时图片。
imgPasteButton.Picture = imgPasteButtonDn.Picture
End Sub
Private Sub imgPasteButton_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 如果按钮被按下,显示弹起状态图片当鼠标
' 被拖拽出按钮区域的时候;否则,
' 显示按下的状态。
Select Case Button
Case 1
If x <= 0 Or x > imgPasteButton.Width Or Y < 0 Or Y > imgPasteButton.Height Then
imgPasteButton.Picture = imgPasteButtonUp.Picture
Else
imgPasteButton.Picture = imgPasteButtonDn.Picture
End If
End Select
End Sub
Private Sub imgPasteButton_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
' 显示弹起状态时图片。
imgPasteButton.Picture = imgPasteButtonUp.Picture
End Sub
Private Sub MDIForm_Load()
' 应用程序从此处开始(启动窗体的 Load 事件)。
Show
' 总是将工作目录设到应用程序所在目录。
ChDir App.Path
' 初始化文档窗体数组,并显示第一个子窗体。
ReDim Document(1)
ReDim FState(1)
Document(1).Tag = 1
FState(1).Dirty = False
' 读系统注册表并适当地设置最近使用的菜单文件列表控件数组。
GetRecentFiles
' 设置决定函数 FindIt 搜索方向的全局变量 gFindDirection 。
gFindDirection = 1
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
' 如果未取消 Unload 事件 (在记事本窗体的 QueryUnload 事件),
' 则没有留下任何文档窗口,所以继续执行并结束应用程序。
If Not AnyPadsLeft() Then
End
End If
End Sub
Private Sub mnuFileExit_Click()
' 退出应用程序。
End
End Sub
Private Sub mnuFileNew_Click()
' 调用新建文件过程。
FileNew
End Sub
Private Sub mnuFileOpen_Click()
' 调用文件打开过程。
FileOpenProc
End Sub
Private Sub mnuOptions_Click()
' 切换工具栏的可见性。
mnuOptionsToolbar.Checked = frmMDI.picToolbar.Visible
End Sub
Private Sub mnuOptionsToolbar_Click()
' 调用工具栏过程,传递一个对该窗体的引用。
OptionsToolbarProc Me
End Sub
Private Sub mnuRecentFile_Click(index As Integer)
' 调用文件打开过程,传递一个对选定文件名的引用。
OpenFile (mnuRecentFile(index).Caption)
' 更新最近打开的文件列表。
GetRecentFiles
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -