如何获取窗体外鼠标点击事件

aeae12 2008-11-28 11:58:18
就是能提示出是点了左键还是右键

请高人指点

我水平很菜最好能写点代码

谢谢
...全文
241 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ZOUYONG0929 2008-11-29
  • 打赏
  • 举报
回复
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

End Sub

Button As Integer 是你想要的答案
aeae12 2008-11-29
  • 打赏
  • 举报
回复
谢谢老张
SYSSZ 2008-11-29
  • 打赏
  • 举报
回复
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCapture Lib "user32" () As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
x = ReleaseCapture()
MsgBox x
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 100
GetCapture
End Sub

Private Sub Timer1_Timer()
x = GetAsyncKeyState(1) '获得左键状态
If x = -32767 Then
MsgBox "我点击了左键!"
Exit Sub
End If
x = GetAsyncKeyState(2) '获得右键状态
If x = -32767 Then
MsgBox "我点击了右键!"
Exit Sub
End If

End Sub
duyin2004 2008-11-29
  • 打赏
  • 举报
回复
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Text1.Text = "op"'1点击左键
If Button = 2 Then Text2.Text = "kk" '2点击右键
End Sub
看看文本显示就清楚了

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧