请问如何判断鼠标左右键同时按下的情况
在mouse_down事件中只能判断左键或者右键,如何能够判断出左键和右同时按下呢?

解决方案 »

  1.   

    Private blnLeft As Boolean
    Private blnRight As BooleanPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            If blnRight = True Then
                Call LeftRight
            Else
                blnLeft = True
            End If
        End If
        If Button = vbRightButton Then
            If blnLeft = True Then
                Call LeftRight
            Else
                blnRight = True
            End If
        End If
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then blnLeft = False
        If Button = vbRightButton Then blnRight = False
    End SubPrivate Sub LeftRight()
        MsgBox "Left + Right"
        blnLeft = False
        blnRight = False
    End Sub
      

  2.   

    以上代码的作用是当鼠标左右键同时按下时显示“Left + Right”