7,763
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
Private Type PointAPI
X As Long
Y As Long
End Type
Dim MousePos As PointAPI
Dim NewX As Long
Dim NewY As Long
Private Sub Command2_Click()
Print "有没有办法去响应控件(commandbutton)事件?"
End Sub
Private Sub Form_Load()
Me.WindowState = 2
Command2.Enabled = False
End Sub
Private Sub Timer1_Timer()
GetCursorPos MousePos
NewX = MousePos.X * Screen.TwipsPerPixelX
NewY = MousePos.Y * Screen.TwipsPerPixelY - 300
Label1 = NewX
Label2 = NewY
If NewX >= Command2.Left And NewX <= Command2.Left + Command2.Width And NewY >= Command2.Top And NewY <= Command2.Height + Command2.Top Then
Command2_Click
Else
Command2.Enabled = False
Me.Cls
End If
End Sub