just a quick one, how do i tell in the on click event if it was a right or left click?
Printable View
just a quick one, how do i tell in the on click event if it was a right or left click?
As far as I know, you can't distinguish the identity of the button in a Click event. You'll have to use either a MouseDown or MouseUp event to capture which button it was.
You could use the GetAsyncKeyState api function to do it.
Code:Private Declare Function GetAsyncKeyState _
Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Label1_Click()
If GetAsyncKeyState(vbLeftButton) Then Caption = "Left Button"
If GetAsyncKeyState(vbRightButton) Then Caption = "Right Button"
PopupMenu MyPopupmenu
End Sub
Or the mouseup Event:
Matt, why had you posted twice?Code:Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Code
'Button =
' 1: Left, 2:Right, 4:Middle
End Sub
1 = Left
2 = Right
3 = Middle
Sometimes that happens. That's what I get for using a Dial-Up Connection :rolleyes:.
Someday, I'll get a Cable or DSL or T3 and I will rule the world! Muhahahahahahahaha :D