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

📄 frmnote.frm

📁 我同学艾大桥的记事本程序
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin MSComDlg.CommonDialog cmdiag1og 
      Left            =   7680
      Top             =   2880
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      FileName        =   "未定标题"
   End
   Begin RichTextLib.RichTextBox rtxtfile 
      Height          =   5130
      Left            =   0
      TabIndex        =   0
      Top             =   870
      Width           =   8760
      _ExtentX        =   15452
      _ExtentY        =   9049
      _Version        =   393217
      HideSelection   =   0   'False
      ScrollBars      =   2
      DisableNoScroll =   -1  'True
      AutoVerbMenu    =   -1  'True
      TextRTF         =   $"frmnote.frx":1BE0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Menu file 
      Caption         =   "文件(&F)"
      WindowList      =   -1  'True
      Begin VB.Menu filenew 
         Caption         =   "新建(&N)..."
         Shortcut        =   ^N
      End
      Begin VB.Menu fileopen 
         Caption         =   "打开(&O)..."
         Shortcut        =   ^O
      End
      Begin VB.Menu filesave 
         Caption         =   "保存(&S)..."
         Shortcut        =   ^S
      End
      Begin VB.Menu fileresave 
         Caption         =   "另存为(&A)..."
      End
      Begin VB.Menu fg1 
         Caption         =   "-"
      End
      Begin VB.Menu pagedesign 
         Caption         =   "页面设置(&U)..."
      End
      Begin VB.Menu viewer 
         Caption         =   "预览(&V)"
      End
      Begin VB.Menu printer 
         Caption         =   "打印(&P)..."
         Shortcut        =   ^P
      End
      Begin VB.Menu fg2 
         Caption         =   "-"
      End
      Begin VB.Menu exit 
         Caption         =   "退出(&X)..."
      End
   End
   Begin VB.Menu edit 
      Caption         =   "编辑(&E)"
      Begin VB.Menu cx 
         Caption         =   "撤消(&U)"
         Shortcut        =   ^Z
      End
      Begin VB.Menu fg3 
         Caption         =   "-"
      End
      Begin VB.Menu cut 
         Caption         =   "剪切(&T)"
         Enabled         =   0   'False
         Shortcut        =   ^X
      End
      Begin VB.Menu copy 
         Caption         =   "复制(&C)"
         Enabled         =   0   'False
         Shortcut        =   ^C
      End
      Begin VB.Menu paster 
         Caption         =   "粘贴(&P)"
         Shortcut        =   ^V
      End
      Begin VB.Menu del 
         Caption         =   "删除(&L)"
         Enabled         =   0   'False
         Shortcut        =   {DEL}
      End
      Begin VB.Menu fg4 
         Caption         =   "-"
      End
      Begin VB.Menu find 
         Caption         =   "查找(&F)..."
         Enabled         =   0   'False
         Shortcut        =   ^F
      End
      Begin VB.Menu findnext 
         Caption         =   "查找下一个(&N)"
         Enabled         =   0   'False
         Shortcut        =   {F3}
      End
      Begin VB.Menu replace 
         Caption         =   "替换(&R)..."
         Enabled         =   0   'False
         Shortcut        =   ^H
      End
      Begin VB.Menu conv 
         Caption         =   "转到(&G)..."
         Shortcut        =   ^G
      End
      Begin VB.Menu fg5 
         Caption         =   "-"
      End
      Begin VB.Menu selall 
         Caption         =   "全选(&A)"
         Enabled         =   0   'False
         Shortcut        =   ^A
      End
      Begin VB.Menu datetime 
         Caption         =   "时间/日期(&D)"
         Shortcut        =   {F5}
      End
   End
   Begin VB.Menu view 
      Caption         =   "查看(&V)"
      Begin VB.Menu tool 
         Caption         =   "工具栏(&T)"
         Checked         =   -1  'True
      End
      Begin VB.Menu format 
         Caption         =   "格式栏(&F)"
         Checked         =   -1  'True
      End
      Begin VB.Menu statu 
         Caption         =   "状态栏(&S)"
         Checked         =   -1  'True
      End
   End
   Begin VB.Menu option 
      Caption         =   "格式(&O)"
      Begin VB.Menu font 
         Caption         =   "字体(&F)..."
      End
      Begin VB.Menu dl 
         Caption         =   "段落(&P)..."
      End
      Begin VB.Menu color 
         Caption         =   "颜色(&C)..."
         Begin VB.Menu bore 
            Caption         =   "前景"
         End
         Begin VB.Menu back 
            Caption         =   "背景"
         End
      End
   End
   Begin VB.Menu help 
      Caption         =   "帮助(&H)"
      Begin VB.Menu helptop 
         Caption         =   "帮助主题(&H)"
      End
      Begin VB.Menu fg7 
         Caption         =   "-"
      End
      Begin VB.Menu aboutnote 
         Caption         =   "关于记事本(&A)"
      End
   End
End
Attribute VB_Name = "frmnote"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'记事本程序 微软公司记事本的仿制品
'作者:艾大桥
'2004年11月4日
'问题1:如何能够在替换时能够先暂停一会
'问题2:如何实现“转到”,“页面设置”,“预览”和“撤消”功能
'问题3:如何实现工具栏,格式栏选定与取消时窗体和文本框的状态与之相应变化
Option Explicit
Private bolchange As Boolean                  '测试文件是否被修改过
Private Const inth As Integer = 945          '初始状态时文本下边框与窗体下边框的距离
Private Const intw As Integer = 120           '初始状态时文本右边框与窗体右边框的距离
Private intstat As Integer                    '判断用户的选择

Private Sub Form_Load()                       '初始化窗体
    Dim inti As Integer                       '初始化字体
    For inti = 0 To Screen.FontCount - 1
       cmbfont.AddItem Screen.Fonts(inti)
   Next
   cmbfont.Text = "宋体"
   
   For inti = 8 To 72                         '初始化字号
      cmbsize.AddItem inti
   Next
   cmbsize.Text = "10"
   trbfmt.Buttons(5).Value = tbrPressed
   
End Sub

Private Sub form_resize()                     '窗体大小改变时使文本边框与窗体框距离不变
  rtxtfile.Width = frmnote.Width - rtxtfile.Left - intw
  rtxtfile.Height = Abs(frmnote.Height - rtxtfile.Top - inth) '防止窗体最小化时产生负数造成程序出错故用ABS函数
  cbrtool.Width = frmnote.Width                '使工具栏的宽度与窗体宽度保持一致。
  
End Sub

Private Sub Form_Unload(Cancel As Integer)      '退出程序
 
  If bolchange = True Then
    Call save
    If intstat = 2 Then Cancel = 1             '如果用户选择“CANCLE”则不退出程序
  End If
  
End Sub



Private Sub rtxtfile_change()               '测试文本内容是否改变
  bolchange = True                          '每当文件改变就使该测试值为TRUE
  
  If rtxtfile.Text <> "" Then               '当文本不为空时,相关功能启用
     Me.cx.Enabled = True
     Me.find.Enabled = True
     Me.findnext.Enabled = True
     Me.replace.Enabled = True
     Me.selall.Enabled = True
     Me.tbrtool.Buttons(8).Enabled = True
     Me.tbrtool.Buttons(13).Enabled = True
     
Else
     Me.cx.Enabled = False
     Me.find.Enabled = False
     Me.findnext.Enabled = False
     Me.replace.Enabled = False
     Me.selall.Enabled = False
     Me.tbrtool.Buttons(8).Enabled = False
     Me.tbrtool.Buttons(13).Enabled = False
     bolchange = False
End If

End Sub

Private Sub save()                          '如果文件内容改变则根据用户的选择进行操作
                                            '弹出与微软记事本一样的对话框
  intstat = MsgBox(Left(frmnote.Caption, Len(frmnote.Caption) - 4) _
            + "文件的文字已经改变。" + Chr(13) + "想保存文件吗?", 3 + 48, "记事本")
  If intstat = 6 Then Call fileresave_Click '如果用户选择“YES”则调用“另存为”过程
  
End Sub

                                            '文件操作
                                            
Private Sub filenew_Click()                 '新建文件

  If bolchange Then
     Call save
     If intstat = 2 Then Exit Sub           '如果用户选择“CANCLE”则退出该过程
  End If
  
    rtxtfile.Text = ""
    frmnote.Caption = "未定标题-记事本"     '按微软记事本样式显示标题
    bolchange = False
    
End Sub

Private Sub fileopen_Click()               '打开文件
   If bolchange Then Call save
   
   With cmdiag1og
        .Filter = "WORD文档(*.doc)|*.doc|文本文件(*.txt)|*.txt|RTF格式(*.rtf)|*.rtf|所有文件(*.*)|*.*"
        .FilterIndex = 2
        .ShowOpen                          '按预定格式显示打开对话框
   End With

  rtxtfile.LoadFile Me.cmdiag1og.FileName    '将指定文件内容导出
  frmnote.Caption = cmdiag1og.FileTitle + "-记事本"
  bolchange = False
  
End Sub
Private Sub filesave_Click()                '保存文件
    If frmnote.Caption = "未定标题-记事本" Then Call fileresave_Click
    
    rtxtfile.SaveFile Me.cmdiag1og.FileName, 1 '将文本内容保存到指定文件
    frmnote.Caption = Me.cmdiag1og.FileTitle + "-记事本"
    bolchange = False

End Sub
Private Sub fileresave_Click()                '另存为
  
  With cmdiag1og                             '文件过滤器定义
      .Filter = "WORD文件(*.doc)|*.doc|文本文件(*.txt)|*.txt|RTF格式(*.rtf)|*.rtf|所有文件(*.*)|(*.*)"
      .FilterIndex = 2                       '默认为“*.txt”格式
      .Flags = 2                           '当同一文件夹中有同名文件时给出提示。
      .ShowSave                            '显示“另保为”对话框
        
 End With
 
    rtxtfile.SaveFile Me.cmdiag1og.FileName, 1 '将文本内容保存到指定文件
    frmnote.Caption = Me.cmdiag1og.FileTitle + "-记事本"
    bolchange = False
    
End Sub


Private Sub pagedesign_Click()              '页面

End Sub


Private Sub viewer_Click()           '预览

End Sub


⌨️ 快捷键说明

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