Click to See Complete Forum and Search --> : Monitoring right clicks and right double clicks


bcyde
January 25th, 2000, 01:12 PM
I was wondering what the sub would be to monitor if a user right clicks (actually right double-clicks) on a control. Any help would be greatly appreciated.
Thanks,

fotisgpap
January 25th, 2000, 01:18 PM
You can easily get the right click using the mousedown event and checking if the Button variable is 2.
DblClick event always fires if you do a doubleclick on you control even if it is with a left or right button.
You can trap both events. The first one fired is the MouseDown and then comes the DblClick. Check the Button from MouseDown, make a boolean true if Button=2 and the check the doubleclick if this boolean is true to do your action.

Aaron Young
January 25th, 2000, 01:26 PM
You could use a Couple of Timer Controls and the GetAsyncKeyState API to monitor Clicks in the O/S, ie.

private Declare Function GetAsyncKeyState Lib "user32" (byval vKey as Long) as Integer
private Const VK_LBUTTON = &H1
private Const VK_RBUTTON = &H2

private bClick as Boolean

private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = true
End Sub

private Sub Timer1_Timer()
If GetAsyncKeyState(VK_RBUTTON) then
While GetAsyncKeyState(VK_RBUTTON)
Wend
If bClick then
'Double Right Click Code Here
bClick = false
Timer2.Enabled = false
Caption = "Double Click"
else
'First Right Click, Watch for Possible 2nd
Timer2.Interval = 200
Timer2.Enabled = true
bClick = true
End If
End If
End Sub

private Sub Timer2_Timer()
'Single Right Click Code Here
Timer2.Enabled = false
Caption = "Click"
bClick = false
End Sub





Aaron Young
Analyst Programmer
ajyoung@pressenter.com
aarony@redwingsoftware.com

bcyde
January 25th, 2000, 01:43 PM
Thank you!