pexam10_3.frm

来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 255 行

FRM
255
字号
VERSION 5.00
Begin VB.Form form1 
   Caption         =   "设计菜单示例"
   ClientHeight    =   1605
   ClientLeft      =   5940
   ClientTop       =   4590
   ClientWidth     =   3540
   BeginProperty Font 
      Name            =   "宋体"
      Size            =   12
      Charset         =   134
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   ScaleHeight     =   1605
   ScaleWidth      =   3540
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1335
      Left            =   120
      MultiLine       =   -1  'True
      TabIndex        =   0
      Text            =   "pexam10_3.frx":0000
      Top             =   120
      Width           =   3255
   End
   Begin VB.Menu AA 
      Caption         =   "字体(&F)"
      Begin VB.Menu AA1 
         Caption         =   "宋体"
         Index           =   1
         Shortcut        =   ^A
      End
      Begin VB.Menu AA1 
         Caption         =   "黑体"
         Index           =   2
         Shortcut        =   ^B
      End
      Begin VB.Menu AA1 
         Caption         =   "-"
         Index           =   3
      End
      Begin VB.Menu AA1 
         Caption         =   "隶书"
         Index           =   4
         Shortcut        =   ^C
      End
      Begin VB.Menu AA1 
         Caption         =   "楷体_GB2312"
         Index           =   5
         Shortcut        =   ^D
      End
   End
   Begin VB.Menu BB 
      Caption         =   "字号(&S)"
      Begin VB.Menu BB1 
         Caption         =   "14"
         Index           =   1
      End
      Begin VB.Menu BB1 
         Caption         =   "16"
         Index           =   2
      End
      Begin VB.Menu BB1 
         Caption         =   "18"
         Index           =   3
      End
      Begin VB.Menu BB1 
         Caption         =   "20"
         Index           =   4
      End
   End
   Begin VB.Menu CC 
      Caption         =   "颜色(&C)"
      Begin VB.Menu CC1 
         Caption         =   "红色"
      End
      Begin VB.Menu CC2 
         Caption         =   "绿色"
      End
      Begin VB.Menu CC3 
         Caption         =   "蓝色"
      End
   End
   Begin VB.Menu DD 
      Caption         =   "效果(&E)"
      Begin VB.Menu DD1 
         Caption         =   "删除线"
      End
      Begin VB.Menu DD2 
         Caption         =   "下划线"
      End
      Begin VB.Menu DD3 
         Caption         =   "粗体"
      End
      Begin VB.Menu DD4 
         Caption         =   "斜体"
      End
   End
   Begin VB.Menu EE 
      Caption         =   "文本框快捷菜单"
      Visible         =   0   'False
      Begin VB.Menu EE1 
         Caption         =   "增加1磅"
      End
      Begin VB.Menu EE2 
         Caption         =   "减少1磅"
      End
      Begin VB.Menu EE3 
         Caption         =   "锁定"
      End
   End
   Begin VB.Menu FF 
      Caption         =   "窗体快捷菜单"
      Visible         =   0   'False
      Begin VB.Menu FF1 
         Caption         =   "红色背景"
      End
      Begin VB.Menu FF2 
         Caption         =   "绿色背景"
      End
      Begin VB.Menu FF3 
         Caption         =   "默认背景"
      End
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Fcolor As Long
Private Sub AA1_Click(Index As Integer)
Text1.Font = AA1(Index).Caption
End Sub

Private Sub BB1_Click(Index As Integer)
Text1.FontSize = Val(BB1(Index).Caption)
End Sub

Private Sub CC1_Click()
Text1.ForeColor = vbRed
End Sub

Private Sub CC2_Click()
Text1.ForeColor = vbGreen
End Sub

Private Sub CC3_Click()
Text1.ForeColor = vbBlue
End Sub

Private Sub Command1_Click()
a = Val(InputBox("请输入字体"))
End Sub

Private Sub DD1_Click()
If DD1.Checked = True Then
  Text1.FontStrikethru = False
  DD1.Checked = False
Else
  Text1.FontStrikethru = True
  DD1.Checked = True
End If
End Sub

Private Sub DD2_Click()
If DD2.Checked = True Then
  Text1.FontUnderline = False
  DD2.Checked = False
Else
  Text1.FontUnderline = True
  DD2.Checked = True
End If
End Sub

Private Sub DD3_Click()
If DD3.Checked = True Then
  Text1.FontBold = False
  DD3.Checked = False
Else
  Text1.FontBold = True
  DD3.Checked = True
End If
End Sub

Private Sub DD4_Click()
If DD4.Checked = True Then
  Text1.FontItalic = False
  DD4.Checked = False
Else
  Text1.FontItalic = True
  DD4.Checked = True
End If
End Sub

Private Sub EE1_Click()
  Text1.FontSize = Text1.FontSize + 1
End Sub

Private Sub EE2_Click()
   Text1.FontSize = Text1.FontSize - 1
End Sub

Private Sub EE3_Click()
  If EE3.Caption = "锁定" Then
    EE3.Caption = "取消锁定"
    Text1.Locked = True
  Else
    EE3.Caption = "锁定"
    Text1.Locked = False
  End If
End Sub

Private Sub FF1_Click()
  form1.BackColor = vbRed
End Sub

Private Sub FF2_Click()
  form1.BackColor = vbGreen
End Sub

Private Sub FF3_Click()
  form1.BackColor = Fcolor  '&H8000000F
End Sub

Private Sub Form_Load()
  Fcolor = form1.BackColor
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 2 Then
    PopupMenu FF, 8 Or 0, , , FF3
  End If
End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 2 Then
    PopupMenu EE, 0 Or 0
  End If
End Sub

⌨️ 快捷键说明

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