VB识别鼠标左右键
VB识别鼠标按下事件是MouseDown事件,这个事件中可以识别鼠标不同的按键,可是如果要求分辨出先按下哪个键,这样可以识别吗?举例说明一下:要求先按下鼠标右键,再按下鼠...
VB识别鼠标按下事件是MouseDown事件,这个事件中可以识别鼠标不同的按键,可是如果要求分辨出先按下哪个键,这样可以识别吗?举例说明一下:要求 先按下鼠标右键,再按下鼠标左键,最后两个键一起放开,当上述事件发生时,执行一些代码。应该怎么实现?
展开
1个回答
2013-06-18
展开全部
MouseDown事件中 有个button变量 当鼠标右键按下时 button的值为vbRightButton,左键按下为vbRightButton,滚轮按下为4知道这个就好实现你所说的功能了你在Mousedown事件中添加下面代码:if button = vbRightButton thenmsgbox "按下右键"elseif button = vbLeftButton thenmsgbox "按下左键"判断左右键同时放开代码如下:Option Explicit
Dim OldButton As Byte
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
If OldButton + Button = 3 Then
MsgBox "鼠标左右键同时放开'"
End If
OldButton = Button
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
OldButton = 0
End Sub
Dim OldButton As Byte
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
If OldButton + Button = 3 Then
MsgBox "鼠标左右键同时放开'"
End If
OldButton = Button
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
OldButton = 0
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询