CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Monitoring right clicks and right double clicks

    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,


  2. #2
    Join Date
    Jan 2000
    Posts
    11

    Re: Monitoring right clicks and right double clicks

    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.


  3. #3
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: Monitoring right clicks and right double clicks

    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
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

  4. #4
    Join Date
    Sep 1999
    Location
    CA
    Posts
    83

    Thanks to both of you!!!

    Thank you!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured