📄 frmmain.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form FrmMain
Caption = "我的记事本 - 无标题"
ClientHeight = 3090
ClientLeft = 8160
ClientTop = 2580
ClientWidth = 4695
Icon = "FrmMain.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4695
Begin MSComDlg.CommonDialog CD1
Left = 1560
Top = 1920
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3135
Left = 0
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 1
Top = 0
Visible = 0 'False
Width = 4695
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3135
Left = 0
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 0
Width = 4695
End
Begin VB.Menu files
Caption = "文件(&F)"
Begin VB.Menu file
Caption = "新建(&N)"
Index = 0
Shortcut = ^N
End
Begin VB.Menu file
Caption = "打开(&O)..."
Index = 1
Shortcut = ^O
End
Begin VB.Menu file
Caption = "保存(&S)"
Index = 2
Shortcut = ^S
End
Begin VB.Menu file
Caption = "另存为(&A)..."
Index = 3
End
Begin VB.Menu file
Caption = "退出(&E)"
Index = 4
End
End
Begin VB.Menu edit
Caption = "编辑(&E)"
Begin VB.Menu edi
Caption = "剪切(&X)"
Index = 0
Shortcut = ^X
End
Begin VB.Menu edi
Caption = "复制(&C)"
Index = 1
Shortcut = ^C
End
Begin VB.Menu edi
Caption = "粘贴(&V)"
Index = 2
Shortcut = ^V
End
Begin VB.Menu edi
Caption = "删除(&D)"
Index = 3
Shortcut = {DEL}
End
End
Begin VB.Menu format
Caption = "格式(&O)"
Begin VB.Menu fmt
Caption = "自动换行(&A)"
Checked = -1 'True
Index = 0
End
Begin VB.Menu fmt
Caption = "字体(&T)..."
Index = 1
End
Begin VB.Menu fmt
Caption = "背景色(&B)..."
Index = 2
End
End
Begin VB.Menu help
Caption = "帮助(&H)"
Begin VB.Menu hlp
Caption = "关于(&A)..."
End
End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Ut As Byte
Private Sub edi_Click(Index As Integer)
i = Index
Select Case i
Case 0
Clipboard.SetText Text1.SelText
Text1.SelText = ""
Case 1
Clipboard.SetText Text1.SelText
Case 2
Text1.SelText = Clipboard.GetText
Case 3
Text1.SelText = ""
End Select
End Sub
Private Sub file_Click(Index As Integer)
n = Index
Select Case n
Case 0
Text1.Text = ""
CD1.FileName = ""
Me.Caption = "我的记事本 - 无标题"
Case 1
CD1.ShowOpen
If CD1.FileName <> "" Then
Text1.Text = ""
Open CD1.FileName For Input As #1
ST = ""
Do Until EOF(1)
Line Input #1, RL
ST = ST & RL & Chr(13) & Chr(10)
Loop
Close #1
Text1.Text = ST
Me.Caption = "我的记事本 - " & CD1.FileTitle
End If
Case 2
If CD1.FileName = "" Then CD1.ShowSave
If CD1.FileName <> "" Then
Open CD1.FileName For Output As #1
Print #1, Text1.Text
Close #1
Me.Caption = "我的记事本 - " & CD1.FileTitle
End If
Case 3
CD1.ShowSave
If CD1.FileName <> "" Then
Open CD1.FileName For Output As #1
Print #1, Text1.Text
Close #1
Me.Caption = "我的记事本 - " & CD1.FileTitle
End If
Case 4
Text1.Text = ""
End
End Select
End Sub
Private Sub fmt_Click(Index As Integer)
n = Index
Select Case n
Case 0
If fmt(0).Checked Then
Text1.Visible = False
Text2.Visible = True
fmt(0).Checked = False
With Text2
.Width = Text1.Width
.Height = Text1.Height
.FontBold = Text1.FontBold
.FontItalic = Text1.FontItalic
.FontName = Text1.FontName
.FontSize = Text1.FontSize
.FontStrikethru = Text1.FontStrikethru
.FontUnderline = Text1.FontUnderline
.ForeColor = Text1.ForeColor
.BackColor = Text1.BackColor
.Text = Text1.Text
End With
Else
Text1.Visible = True
Text2.Visible = False
fmt(0).Checked = True
With Text1
.Width = Text2.Width
.Height = Text2.Height
.FontBold = Text2.FontBold
.FontItalic = Text2.FontItalic
.FontName = Text2.FontName
.FontSize = Text2.FontSize
.FontStrikethru = Text2.FontStrikethru
.FontUnderline = Text2.FontUnderline
.ForeColor = Text2.ForeColor
.BackColor = Text2.BackColor
.Text = Text2.Text
End With
End If
Case 1
CD1.Flags = cdlCFBoth Or cdlCFEffects Or cdlCFApply
CD1.ShowFont
With Text1
.FontBold = CD1.FontBold
.FontItalic = CD1.FontItalic
.FontName = CD1.FontName
.FontSize = CD1.FontSize
.FontStrikethru = CD1.FontStrikethru
.FontUnderline = CD1.FontUnderline
.ForeColor = CD1.Color
End With
With Text2
.FontBold = CD1.FontBold
.FontItalic = CD1.FontItalic
.FontName = CD1.FontName
.FontSize = CD1.FontSize
.FontStrikethru = CD1.FontStrikethru
.FontUnderline = CD1.FontUnderline
.ForeColor = CD1.Color
End With
Case 2
CD1.ShowColor
Text1.BackColor = CD1.Color
Text2.BackColor = CD1.Color
End Select
End Sub
Private Sub Form_Load()
CD1.Filter = "文本文件(*.txt)|*.txt"
CD1.InitDir = "c:\"
End Sub
Private Sub Form_Resize()
With Text1
.Left = 0
.Top = 0
.Height = Me.ScaleHeight
.Width = Me.ScaleWidth
End With
With Text2
.Left = 0
.Top = 0
.Height = Me.ScaleHeight
.Width = Me.ScaleWidth
End With
End Sub
Private Sub hlp_Click()
frmAbout.Show 1
End Sub
Private Sub Text2_Change()
Ut = 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -