frmpopup.frm

来自「Visual Basic 6 大学教程的代码」· FRM 代码 · 共 75 行

FRM
75
字号
VERSION 5.00
Begin VB.Form frmPopUp 
   Caption         =   "Fig. 10.35: Pop Up Menus"
   ClientHeight    =   1560
   ClientLeft      =   2460
   ClientTop       =   2505
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   1560
   ScaleWidth      =   4680
   Begin VB.Label lblText 
      BorderStyle     =   1  'Fixed Single
      Caption         =   "TEXT"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   105
      TabIndex        =   0
      Top             =   120
      Width           =   4290
   End
   Begin VB.Menu mnuPopUp 
      Caption         =   "PopUp"
      Visible         =   0   'False
      Begin VB.Menu mnuitmRight 
         Caption         =   "&Right"
      End
      Begin VB.Menu mnuitmCenter 
         Caption         =   "&Center"
      End
      Begin VB.Menu mnuitmLeft 
         Caption         =   "&Left"
      End
   End
End
Attribute VB_Name = "frmPopUp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 10.35
' Demonstrating pop up menus
Option Explicit     ' General Declaration

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _
                         X As Single, Y As Single)

   ' When right button is clicked display Pop Up menu
   If Button = vbRightButton Then
      Call PopupMenu(mnuPopUp)
   End If
   
End Sub

Private Sub mnuitmLeft_Click()
   lblText.Alignment = vbLeftJustify
End Sub

Private Sub mnuitmRight_Click()
   lblText.Alignment = vbRightJustify
End Sub

Private Sub mnuitmCenter_Click()
   lblText.Alignment = vbCenter
End Sub


⌨️ 快捷键说明

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