📄 mdiform1.frm
字号:
Begin VB.Menu mEditPaste
Caption = "粘贴[&V]"
Shortcut = ^V
End
Begin VB.Menu step3
Caption = "-"
End
Begin VB.Menu mEditSelAll
Caption = "全选[&A]"
Shortcut = ^A
End
Begin VB.Menu timedate
Caption = "时间/日期"
Shortcut = {F5}
End
End
Begin VB.Menu geshi
Caption = "格式"
Begin VB.Menu mycolor
Caption = "颜色"
End
Begin VB.Menu ziti
Caption = "字体"
End
End
Begin VB.Menu mView
Caption = "视图[&V]"
Begin VB.Menu mViewToolbar
Caption = "工具栏[&T]"
End
Begin VB.Menu mViewStat
Caption = "状态栏[&S]"
End
Begin VB.Menu xuanxiang
Caption = "选项(&O)"
End
End
Begin VB.Menu mWindow
Caption = "窗口[&W]"
WindowList = -1 'True
Begin VB.Menu mWindowTitle
Caption = "平铺[&T]"
End
Begin VB.Menu mWindowCa
Caption = "层叠[&C]"
End
End
Begin VB.Menu help
Caption = "帮助(&H)"
Begin VB.Menu about
Caption = "关于(&A)"
End
End
End
Attribute VB_Name = "MDIForm1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim documentcount As Integer
Private Sub about_Click() '************关于******************
MsgBox " 谢谢合作!"
End Sub
Private Sub MDIForm_Load() '************窗体加载时初始化******************
mViewToolbar.Checked = True
mViewStat.Checked = True
documentcount = 1
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
End
End Sub
Private Sub mEditCopy_Click() '***************复制***************
Clipboard.SetText MDIForm1.ActiveForm.ActiveControl.SelText
End Sub
Private Sub mEditCut_Click() '***************剪切***************
Clipboard.SetText MDIForm1.ActiveForm.ActiveControl.SelText
MDIForm1.ActiveForm.ActiveControl.SelText = ""
End Sub
Private Sub mEditPaste_Click() '***************粘贴***************
MDIForm1.ActiveForm.ActiveControl.SelText = Clipboard.GetText
End Sub
Private Sub mEditSelAll_Click() '***************全选***************
Me.ActiveForm.RichTextBox1.SelStart = 0
Me.ActiveForm.RichTextBox1.SelLength = Len(Me.ActiveForm.RichTextBox1.Text)
End Sub
Private Sub mFileExit_Click() '***************文档退出***************
Unload MDIForm1
End Sub
Private Sub mFileNew_Click() '***************新建***************
Dim frmNew As New Form1
documentcount = documentcount + 1
frmNew.Caption = "文档" & documentcount
frmNew.Show '***************显示文档***************
End Sub
Private Sub mFileOpen_Click() '***************打开***************
Dim strOpen As String
CommonDialog1.FileName = ""
CommonDialog1.Filter = " 文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" '***************打开文件过滤器***************
CommonDialog1.DialogTitle = "打开文件" '打开对话框标题
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit Sub
strOpen = CommonDialog1.FileName
If Dir$(strOpen) <> "" Then
For Each frmA In Forms '查询是否是已经打开过的文件
If frmA.Name = "Form1" Then
If frmA.OpenFile = strOpen Then
frmA.SetFocus '如果是已经打开过则不必再打开
Exit Sub
End If
End If
Next
Dim frmNew As New Form1 '在新建的窗体中打开
frmNew.Visible = True
frmNew.Show
frmNew.OpenFile = strOpen '记录当前打开的文件路径
frmNew.RichTextBox1.LoadFile strOpen, 1
frmNew.Caption = strOpen '在标题栏显示文件的路径
frmNew.HasChanged = False
Else
MsgBox "文件不存在!", vbOKOnly, "打开文件"
End If
End Sub
Private Sub mFilePrint_Click() '**************打印***************
Dim Beginpage, Endpage, Numcopies, Orientation, i
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.ShowPrinter
Beginpage = CommonDialog1.FromPage
Endpage = CommonDialog1.ToPage
Numcopies = CommonDialog1.Copies
Orientation = CommonDialog1.Orientation '页面定向
For i = 1 To Numcopies
Next
Exit Sub
ErrHandler:
Exit Sub
End Sub
Private Sub mFileSave_Click() '***************保存***************
Me.ActiveForm.SaveFile
End Sub
Private Sub mFileSaveAs_Click() '***************另存为***************
Me.ActiveForm.SaveFileAs
End Sub
Private Sub mViewStat_Click() '***************状态栏***************
If mViewStat.Checked Then
StatusBar1.Visible = False
mViewStat.Checked = False
Else
StatusBar1.Visible = True
mViewStat.Checked = True
End If
End Sub
Private Sub mViewToolbar_Click() '***************单击工具栏***************
If mViewToolbar.Checked Then
Toolbar1.Visible = False
mViewToolbar.Checked = False
Else
Toolbar1.Visible = True
mViewToolbar.Checked = True
End If
End Sub
Private Sub mWindowCa_Click()
Me.Arrange 0 '层叠
End Sub
Private Sub mWindowTitle_Click()
Me.Arrange 1 '平铺
End Sub
Private Sub mycolor_Click() '***************颜色***************
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.ShowColor
MDIForm1.ActiveForm.RichTextBox1.SelColor = CommonDialog1.Color '***************将选中的内容变色***************
Exit Sub
ErrHandler:
Exit Sub
End Sub
Private Sub timedate_Click() '***************显示时间***************
MDIForm1.ActiveForm.ActiveControl.SelText = Str$(Now)
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) '***************工具栏***************
Select Case Button.Key
Case "New"
mFileNew_Click
Case "Open"
mFileOpen_Click
Case "Save"
mFileSave_Click
Case "Print"
mFilePrint_Click
Case "Cut"
mEditCut_Click
Case "Copy"
mEditCopy_Click
Case "Paste"
mEditPaste_Click
End Select
End Sub
Private Sub xuanxiang_Click() '***************选项***************
MsgBox "请参考其它功能!"
End Sub
Private Sub ziti_Click() '***************字体***************
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects '设置flags属性,以便显示字体对话框
CommonDialog1.ShowFont
MDIForm1.ActiveForm.RichTextBox1.SelColor = CommonDialog1.Color
MDIForm1.ActiveForm.RichTextBox1.SelBold = CommonDialog1.FontBold '是否选定'粗体'
MDIForm1.ActiveForm.RichTextBox1.SelItalic = CommonDialog1.FontItalic '斜体
MDIForm1.ActiveForm.RichTextBox1.SelFontName = CommonDialog1.FontName
MDIForm1.ActiveForm.RichTextBox1.SelFontSize = CommonDialog1.FontSize
MDIForm1.ActiveForm.RichTextBox1.SelStrikeThru = CommonDialog1.FontStrikethru '删除线
MDIForm1.ActiveForm.RichTextBox1.SelUnderline = CommonDialog1.FontUnderline '下划线
Exit Sub
ErrHandler:
Exit Sub
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -