📄 frmmain2.frm
字号:
jl_bz = Me.RichTextBox1.Text
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
End If
End Sub
Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)
On Error Resume Next
Select Case Button.Key
Case "新建"
LoadNewDoc
Case "打开"
mnuFileOpen_Click
Case "保存"
mnuFileSave_Click
Case "打印"
mnuFilePrint_Click
Case "剪切"
mnuEditCut_Click
Case "复制"
mnuEditCopy_Click
Case "粘贴"
mnuEditPaste_Click
Case "粗体"
Me.RichTextBox1.SelBold = Not Me.RichTextBox1.SelBold
Button.Value = IIf(Me.RichTextBox1.SelBold, tbrPressed, tbrUnpressed)
Case "斜体"
Me.RichTextBox1.SelItalic = Not Me.RichTextBox1.SelItalic
Button.Value = IIf(Me.RichTextBox1.SelItalic, tbrPressed, tbrUnpressed)
Case "下划线"
Me.RichTextBox1.SelUnderline = Not Me.RichTextBox1.SelUnderline
Button.Value = IIf(Me.RichTextBox1.SelUnderline, tbrPressed, tbrUnpressed)
Case "左对齐"
Me.RichTextBox1.SelAlignment = rtfLeft
Case "置中"
Me.RichTextBox1.SelAlignment = rtfCenter
Case "右对齐"
Me.RichTextBox1.SelAlignment = rtfRight
Case "退出"
Unload Me
End Select
End Sub
Private Sub mnuHelpAbout_Click()
MsgBox "版本 " & App.Major & "." & App.Minor & "." & App.Revision
End Sub
Private Sub mnuHelpSearchForHelpOn_Click()
Dim nRet As Integer
'如果这个工程没有帮助文件,显示消息给用户
'可以在“工程属性”对话框中为应用程序设置帮助文件
If Len(App.HelpFile) = 0 Then
MsgBox "无法显示帮助目录,该工程没有相关联的帮助。", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0)
If err Then
MsgBox err.Description
End If
End If
End Sub
Private Sub mnuHelpContents_Click()
Dim nRet As Integer
'如果这个工程没有帮助文件,显示消息给用户
'可以在“工程属性”对话框中为应用程序设置帮助文件
If Len(App.HelpFile) = 0 Then
MsgBox "无法显示帮助目录,该工程没有相关联的帮助。", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0)
If err Then
MsgBox err.Description
End If
End If
End Sub
Private Sub mnuViewWebBrowser_Click()
'应做:添加 'mnuViewWebBrowser_Click' 代码。
MsgBox "添加 'mnuViewWebBrowser_Click' 代码。"
End Sub
Private Sub mnuViewOptions_Click()
'应做:添加 'mnuViewOptions_Click' 代码。
MsgBox "添加 'mnuViewOptions_Click' 代码。"
End Sub
Private Sub mnuViewRefresh_Click()
'应做:添加 'mnuViewRefresh_Click' 代码。
MsgBox "添加 'mnuViewRefresh_Click' 代码。"
End Sub
Private Sub mnuViewStatusBar_Click()
mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
sbStatusBar.Visible = mnuViewStatusBar.Checked
End Sub
Private Sub mnuViewToolbar_Click()
mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
tbToolBar.Visible = mnuViewToolbar.Checked
End Sub
Private Sub mnuEditPasteSpecial_Click()
'应做:添加 'mnuEditPasteSpecial_Click' 代码。
MsgBox "添加 'mnuEditPasteSpecial_Click' 代码。"
End Sub
Private Sub mnuEditPaste_Click()
On Error Resume Next
Me.RichTextBox1.SelRTF = Clipboard.GetText
End Sub
Private Sub mnuEditCopy_Click()
On Error Resume Next
Clipboard.SetText Me.RichTextBox1.SelRTF
End Sub
Private Sub mnuEditCut_Click()
On Error Resume Next
Clipboard.SetText Me.RichTextBox1.SelRTF
Me.RichTextBox1.SelText = vbNullString
End Sub
Private Sub mnuEditUndo_Click()
'应做:添加 'mnuEditUndo_Click' 代码。
MsgBox "添加 'mnuEditUndo_Click' 代码。"
End Sub
Private Sub mnuFileExit_Click()
'卸载窗体
Unload Me
End Sub
Private Sub mnuFileSend_Click()
'应做:添加 'mnuFileSend_Click' 代码。
MsgBox "添加 'mnuFileSend_Click' 代码。"
End Sub
Private Sub mnuFilePrint_Click()
'‘' On Error Resume Next
If ActiveForm Is Nothing Then Exit Sub
With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If Me.RichTextBox1.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
If err <> MSComDlg.cdlCancel Then
Me.RichTextBox1.SelPrint .hDC
End If
End With
End Sub
Private Sub mnuFilePrintPreview_Click()
'应做:添加 'mnuFilePrintPreview_Click' 代码。
MsgBox "添加 'mnuFilePrintPreview_Click' 代码。"
End Sub
Private Sub mnuFilePageSetup_Click()
On Error Resume Next
With dlgCommonDialog
.DialogTitle = "页面设置"
.CancelError = True
.ShowPrinter
End With
End Sub
Private Sub mnuFileProperties_Click()
'应做:添加 'mnuFileProperties_Click' 代码。
MsgBox "添加 'mnuFileProperties_Click' 代码。"
End Sub
Private Sub mnuFileSaveAll_Click()
'应做:添加 'mnuFileSaveAll_Click' 代码。
MsgBox "添加 'mnuFileSaveAll_Click' 代码。"
End Sub
Private Sub mnuFileSaveAs_Click()
Dim sFile As String
If ActiveForm Is Nothing Then Exit Sub
With dlgCommonDialog
.DialogTitle = "另存为"
.CancelError = False
'ToDo: 设置 common dialog 控件的标志和属性
.Filter = "所有文件 (*.*)|*.*"
.ShowSave
If Len(.filename) = 0 Then
Exit Sub
End If
sFile = .filename
End With
ActiveForm.Caption = sFile
Me.RichTextBox1.SaveFile sFile
End Sub
Private Sub mnuFileSave_Click()
' Dim sFile As String
'If Left$(ActiveForm.Caption, 8) = "Document" Then
' With dlgCommonDialog
' .DialogTitle = "保存"
'.CancelError = False
'ToDo: 设置 common dialog 控件的标志和属性
'.Filter = "所有文件 (*.*)|*.*"
'.ShowSave
'If Len(.filename) = 0 Then
' Exit Sub
' End If
' sFile = .filename
' End With
' Me.RichTextBox1.SaveFile sFile
' Else
sFile = ActiveForm.Caption
' Me.RichTextBox1.SaveFile sFile
'End If
jl_bz = Me.RichTextBox1.TextRTF
End Sub
Private Sub mnuFileClose_Click()
'应做:添加 'mnuFileClose_Click' 代码。
MsgBox "添加 'mnuFileClose_Click' 代码。"
End Sub
Private Sub mnuFileOpen_Click()
Dim sFile As String
'If ActiveForm Is Nothing Then LoadNewDoc
With dlgCommonDialog
.DialogTitle = "打开"
.CancelError = False
'ToDo: 设置 common dialog 控件的标志和属性
.Filter = "所有文件 (*.*)|*.*"
.ShowOpen
If Len(.filename) = 0 Then
Exit Sub
End If
sFile = .filename
End With
Me.RichTextBox1.LoadFile sFile
' ActiveForm.Caption = sFile
End Sub
Private Sub mnuFileNew_Click()
LoadNewDoc
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -