VB识别鼠标左右键
发布网友
发布时间:2022-05-12 15:17
我来回答
共1个回答
热心网友
时间:2023-10-11 13:58
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