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

📄 frmevents.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmEvents 
   Caption         =   "Fig. 12.3: Mouse Events"
   ClientHeight    =   3195
   ClientLeft      =   2715
   ClientTop       =   2040
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   Begin VB.CheckBox chkMove 
      Caption         =   "Enable MouseMove"
      Height          =   495
      Left            =   3240
      TabIndex        =   1
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton cmdClear 
      Caption         =   "Clear"
      Height          =   495
      Left            =   1680
      TabIndex        =   0
      Top             =   2520
      Width           =   1215
   End
End
Attribute VB_Name = "frmEvents"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 12.3
' Demonstrating mouse events
Option Explicit          ' General declaration

Private Sub Form_Load()
   Call Randomize        ' Randomize
End Sub

Private Sub cmdClear_Click()
   Call Cls     ' Clear Form
End Sub

Private Sub Form_Click()
   
   ' Randomly set Form ForeColor
   Select Case (1 + Int(Rnd() * 4))
      Case 1
         ForeColor = vbBlack
      Case 2
         ForeColor = vbMagenta
      Case 3
         ForeColor = vbRed
      Case 4
         ForeColor = vbBlue
   End Select
   
End Sub

Private Sub Form_DblClick()

   ' Randomly set Form BackColor
   Select Case (1 + Int(Rnd() * 4))
      Case 1
         BackColor = vbWhite
      Case 2
         BackColor = vbYellow
      Case 3
         BackColor = vbGreen
      Case 4
         BackColor = vbCyan
   End Select

   ' Change chkMove BackColor to Form's BackColor
   chkMove.BackColor = BackColor
End Sub

Private Sub Form_MouseDown(Button As Integer, _
                           Shift As Integer, X As Single, _
                           Y As Single)
                           
   CurrentX = X        ' Set x coordinate
   CurrentY = Y        ' Set y coordinate
   Print "MouseDown"
End Sub

Private Sub Form_MouseUp(Button As Integer, _
                         Shift As Integer, X As Single, _
                         Y As Single)
                         
   ' Reverse coordinates
   CurrentX = Y
   CurrentY = X
   Print "MouseUp"
End Sub

Private Sub Form_MouseMove(Button As Integer, _
                           Shift As Integer, X As Single, _
                           Y As Single)
 
   ' If checked enable printing operations
   If chkMove.Value = 1 Then
      CurrentX = X
      CurrentY = Y
      Print "MouseMove"
   End If
   
End Sub

⌨️ 快捷键说明

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