⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 例[14-4].frm

📁 蒋加伏主编VB程序设计第四版PPT及全部课本源码 北京邮电大学出版社 Visual Basic 程序设计教程(第四版) 主编 蒋加伏 张林峰 找了好久的(不带密码的)
💻 FRM
字号:
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Begin VB.Form Form1 
   Caption         =   "例[14-4]简单的记事本程序"
   ClientHeight    =   3195
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   4995
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4995
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   2040
      Top             =   720
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin ComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   375
      Left            =   0
      TabIndex        =   2
      Top             =   2820
      Width           =   4995
      _ExtentX        =   8811
      _ExtentY        =   661
      SimpleText      =   ""
      _Version        =   327682
      BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
         NumPanels       =   5
         BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Text            =   "光标位置"
            TextSave        =   "光标位置"
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            TextSave        =   ""
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Style           =   1
            Enabled         =   0   'False
            TextSave        =   "CAPS"
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Style           =   3
            TextSave        =   "Ins"
            Object.Tag             =   ""
         EndProperty
         BeginProperty Panel5 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            Object.Tag             =   ""
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   405
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   4995
      _ExtentX        =   8811
      _ExtentY        =   714
      ButtonWidth     =   609
      ButtonHeight    =   556
      Appearance      =   1
      ImageList       =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   12
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "新建"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "打开"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "保存"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "打印"
            ImageIndex      =   4
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "剪切"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "复制"
            ImageIndex      =   6
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "粘贴"
            ImageIndex      =   7
         EndProperty
         BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "加粗"
            ImageIndex      =   8
            Style           =   1
         EndProperty
         BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "倾斜"
            ImageIndex      =   9
            Style           =   1
         EndProperty
         BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "左对齐"
            ImageIndex      =   10
            Style           =   2
         EndProperty
         BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "居中对齐"
            ImageIndex      =   11
            Style           =   2
         EndProperty
         BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "右对齐"
            ImageIndex      =   12
            Style           =   2
         EndProperty
      EndProperty
      Begin MSComDlg.CommonDialog CD1 
         Left            =   4440
         Top             =   1680
         _ExtentX        =   847
         _ExtentY        =   847
         _Version        =   393216
      End
   End
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   2760
      Top             =   600
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   15
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   12
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":0000
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":0542
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":0A84
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":0FC6
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":1508
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":1A4A
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":1F8C
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":24CE
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":25E0
            Key             =   ""
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":26F2
            Key             =   ""
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":2804
            Key             =   ""
         EndProperty
         BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "例[14-4].frx":2916
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin RichTextLib.RichTextBox RT1 
      Height          =   2055
      Left            =   120
      TabIndex        =   0
      Top             =   480
      Width           =   4695
      _ExtentX        =   8281
      _ExtentY        =   3625
      _Version        =   393217
      Enabled         =   -1  'True
      TextRTF         =   $"例[14-4].frx":2A28
   End
   Begin VB.Menu file 
      Caption         =   "文件(&F)"
      Begin VB.Menu FileNew 
         Caption         =   "新建"
         Shortcut        =   ^N
      End
      Begin VB.Menu FileOpen 
         Caption         =   "打开"
         Shortcut        =   ^O
      End
      Begin VB.Menu FileSave 
         Caption         =   "保存"
         Shortcut        =   ^S
      End
      Begin VB.Menu Filebar1 
         Caption         =   "-"
      End
      Begin VB.Menu FilePrint 
         Caption         =   "打印"
         Shortcut        =   ^P
      End
      Begin VB.Menu Filebar2 
         Caption         =   "-"
      End
      Begin VB.Menu FileExit 
         Caption         =   "退出"
         Shortcut        =   ^E
      End
   End
   Begin VB.Menu Edit 
      Caption         =   "编辑(&E)"
      Begin VB.Menu EditCut 
         Caption         =   "剪切"
         Shortcut        =   ^X
      End
      Begin VB.Menu EditCopy 
         Caption         =   "复制"
         Shortcut        =   ^C
      End
      Begin VB.Menu EditPaste 
         Caption         =   "粘贴"
         Shortcut        =   ^V
      End
   End
   Begin VB.Menu Format 
      Caption         =   "格式(&O)"
      Begin VB.Menu FormatFont 
         Caption         =   "字体"
         Shortcut        =   ^F
      End
      Begin VB.Menu FormatColor 
         Caption         =   "颜色"
         Shortcut        =   ^R
      End
   End
   Begin VB.Menu Help 
      Caption         =   "帮助"
      Begin VB.Menu Helpexp 
         Caption         =   "使用说明"
         Shortcut        =   ^H
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub FileNew_Click()                      '将RichTextBox控件清空,修改窗体标题栏
  RT1.Text = ""
  Form1.Caption = "新文件"
End Sub
Private Sub FileOpen_Click()
  CD1.Filter = "文本文件|*.txt|RTF文件|*.rtf"    '设置“打开”对话框的过滤器
  CD1.ShowOpen
  RT1.LoadFile CD1.FileName, 1    '将“打开”对话框中选定的文本文件装入RichTextBox控件中
End Sub
Private Sub FileSave_Click()
  CD1.ShowSave
  RT1.SaveFile CD1.FileName, 1   '将RichTextBox控件中的内容存入“另存为”对话框中选定的文本文件
End Sub
Private Sub FilePrint_Click()
  CD1.ShowPrinter
  Printer.Print RT1.Text         '将RichTextBox控件中的内容在打印机上输出
End Sub
Private Sub FileExit_Click()
  Dim result As Integer
  If Me.Caption = "新文件" And RT1.Text = "" Then   '判断用户是否修改了文件
      Unload Me
  Else
     result = MsgBox("文件已经修改,要保存吗?", vbYesNoCancel, "提示")  '若用户修改了文件,则弹出对话框询问用户是否保存文件
     Select Case result
     Case 2                                         '用户单击了“取消”按钮
       Exit Sub
     Case 6                                         '用户单击了“是”按钮
       FileSave_Click
     Case 7                                         '用户单击了“取消”按钮
       Unload Me
  End Select
  End If
End Sub
Private Sub EditCut_Click()
  Clipboard.Clear                                  '清空剪贴板对象中内容
  Clipboard.SetText RT1.SelText                    '将选中文本放入剪贴板
  RT1.SelText = ""                                 '将选中文本在原位置删除
End Sub
Private Sub EditCopy_Click()
  Clipboard.Clear
  Clipboard.SetText RT1.SelText
End Sub
Private Sub EditPaste_Click()
  RT1.SelText = Clipboard.GetText()               '将剪贴板内容放到光标位置
End Sub
Private Sub FormatFont_Click()                    '根据字体对话中选择的内容设置字体
   CD1.Flags = cdlCFBoth + cdlCFEffects
   CD1.ShowFont
   RT1.SelFontName = CD1.FontName
   RT1.SelFontSize = CD1.FontSize
   RT1.SelBold = CD1.FontBold
   RT1.SelItalic = CD1.FontItalic
   RT1.SelStrikeThru = CD1.FontStrikethru
   RT1.SelUnderline = CD1.FontUnderline
End Sub
Private Sub FormatColor_Click()                  '根据颜色对话中选择的内容设置字体颜色
  CD1.ShowColor
  RT1.SelColor = CD1.Color
End Sub
Private Sub Helpexp_Click()                      '系统说明和帮助,实质上是在RT1文本框中输入一些文字
    RT1.Text = ""
    RT1.Text = "这是一个用VB做的简单的记事本,……"
End Sub
Private Sub RT1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  If Button = 2 Then                             '如果在RichTextBox控件上单击右键,出现“格式”弹出菜单
    PopupMenu Format
  End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
  On Error Resume Next                          '遇到错误忽略,继续执行下一条语句
  Select Case Button.Key                        '根据按钮的关键字识别单击的是那个按钮,并调用相应的菜单事件过程
  Case "新建"
    FileNew_Click
  Case "打开"
    FileOpen_Click
  Case "保存"
    FileSave_Click
  Case "打印"
    FilePrint_Click
  Case "退出"
    FileExit_Click
  Case "剪切"
    EditCut_Click
  Case "复制"
    EditCopy_Click
  Case "粘贴"
    EditPaste_Click
  Case "加粗"
    RT1.SelBold = Button.Value                 '根据按钮是否被按下来决定是字体否加粗
  Case "倾斜"
    RT1.SelItalic = Button.Value               '根据按钮是否被按下来决定是字体否倾斜
  Case "左对齐"
    RT1.SelAlignment = rtfLeft                 '设置文字左对齐
  Case "居中对齐"
    RT1.SelAlignment = rtfCenter               '设置文字居中对齐
  Case "右对齐"
     RT1.SelAlignment = rtfRight               '设置文字右对齐
  End Select
End Sub
Private Sub RT1_Click()
  StatusBar1.Panels(2).Text = RT1.SelStart     '获取光标的当前位置显示在状态栏第二个窗格中
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -