VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   4200
      Top             =   420
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox Text1 
      Height          =   3135
      Left            =   60
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Text            =   "V6bj08-07.frx":0000
      Top             =   60
      Width           =   4515
   End
   Begin VB.Menu FileMenu 
      Caption         =   "文件"
      Begin VB.Menu FileNew 
         Caption         =   "新建"
         Shortcut        =   ^N
      End
      Begin VB.Menu FileOpen 
         Caption         =   "打开"
         Shortcut        =   ^O
      End
      Begin VB.Menu Bar1 
         Caption         =   "-"
      End
      Begin VB.Menu FileSave 
         Caption         =   "保存"
         Shortcut        =   ^S
      End
      Begin VB.Menu FileSaveAs 
         Caption         =   "另存为"
      End
      Begin VB.Menu bar2 
         Caption         =   "-"
      End
      Begin VB.Menu RunMenu 
         Caption         =   ""
         Index           =   0
         Visible         =   0   'False
      End
      Begin VB.Menu bar3 
         Caption         =   "-"
         Visible         =   0   'False
      End
      Begin VB.Menu FileExit 
         Caption         =   "退出"
      End
   End
   Begin VB.Menu EditMenu 
      Caption         =   "编辑"
      Begin VB.Menu EditCopy 
         Caption         =   "复制"
         Shortcut        =   ^C
      End
      Begin VB.Menu EditCut 
         Caption         =   "剪切"
         Shortcut        =   ^X
      End
      Begin VB.Menu EditPaste 
         Caption         =   "粘贴"
         Shortcut        =   ^V
      End
   End
   Begin VB.Menu MenuDel 
      Caption         =   "删除菜单项"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim iMenucount
Private Sub EditCopy_Click()
    st = Text1.SelText          '将选中的内容存放到st变量中
    EditCopy.Enabled = False    '进行复制后,剪切和复制按钮无效
    EditCut.Enabled = False
    EditPaste.Enabled = True    '粘贴按钮有效
End Sub

Private Sub EditCut_Click()
    st = Text1.SelText          '将选中的内容存放到st变量中
    Text1.SelText = ""          '将选中的内容清除,实现了剪切
    EditCopy.Enabled = False
    EditCut.Enabled = False
    EditPaste.Enabled = True
End Sub

Private Sub EditPaste_Click()
    Text1.Text = Left(Text1, Text1.SelStart) + st + Mid(Text1, Text1.SelStart + 1)
End Sub

Private Sub FileExit_Click()
    End
End Sub

Private Sub FileOpen_Click()
    On Error GoTo nofile                            ' 设置错误陷阱
    CommonDialog1.InitDir = "C:\Windows"            ' 设置属性（可以在设计中完成）
    CommonDialog1.Filter = "文本文件 | *.Txt"
    CommonDialog1.CancelError = True
    CommonDialog1.ShowOpen                          ' 或用Action = 1
    Text1.Text = ""
    Open CommonDialog1.FileName For Input As #1     ' 打开文件进行读操作
    Do While Not EOF(1)
        Line Input #1, inputdata                    ' 读一行数据
        Text1.Text = Text1.Text + inputdata + Chr(13) + Chr(10)
    Loop
    Close #1                                        ' 关闭文件
    iMenucount = iMenucount + 1
    If iMenucount < 5 Then
    bar3.Visible = True
    Load RunMenu(iMenucount)                        ' 装入新菜单项
    RunMenu(iMenucount).Caption = CommonDialog1.FileName
    RunMenu(iMenucount).Visible = True
    Else
    i = iMenucount Mod 4                            ' 第五个以后的文件刷新数组控件的标题
    If i = 0 Then i = 4
    RunMenu(i).Caption = CommonDialog1.FileName
    End If
    Exit Sub
nofile:                                             ' 错误处理
    If Err.Number = 32755 Then Exit Sub             ' 单击"取消"按钮
End Sub

Private Sub MenuDel_Click()
    Dim n As Integer
        If iMenucount > 4 Then              ' 如果文件数大于4
        n = 4
    Else
        n = iMenucount
    End If
    For i = 1 To n
    Unload RunMenu(i)                       ' 删除菜单项
    Next i
    iMenucount = 0                          ' 重置文件打开数
    bar3.Visible = False                    ' 隐含分隔线
End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then PopupMenu EditMenu, vbPopupMenuCenterAlign
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Text1.SelText <> "" Then
      EditCut.Enabled = True     ' 当拖动鼠标选中要操作的文本后,剪切、复制按钮有效
      EditCopy.Enabled = True
      EditPaste.Enabled = False
    Else
      EditCut.Enabled = False    ' 当拖动鼠标未选中文本,剪切、复制按钮无效
      EditCopy.Enabled = False
      EditPaste.Enabled = True
    End If
End Sub

