Results 1 to 8 of 8

Thread: Check for Right Mouse Button

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2001
    Posts
    430

    Check for Right Mouse Button

    Can you check if the Right Mouse Button (vbRightButton) has been used on a Label?

    I already have a Label1_Click() event for the left button. When I left click on any label1 in my label1 control array an event will occure. How can I triger an event with the right button.

    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    In the MouseDown event, put:

    If Button = vbRightButton Then
    Msgbox "Right Mouse Button Clicked"
    End If

  3. #3
    nullus
    Guest

    Smile

    VB Code:
    1. Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.   If (Button = vbRightButton) Then
    3.     'do stuff
    4.   End If
    5. End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2001
    Posts
    430
    Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single

    Using this I get:

    Procedure declared does not match discription of event or procedure having the same name.

    Is this because of the control array?

  5. #5
    nullus
    Guest
    yep, use this instead:

    VB Code:
    1. Private Sub Label1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    2.   Select Case Index
    3.     Case 1
    4.       If (Button = vbRightButton) Then
    5.         'do stuff
    6.       End If
    7.   End Select
    8. End Sub

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2001
    Posts
    430
    Thanks... That works better.

    I did change from MouseUP to MouseDown. MouseUP performed both left and right events.

  7. #7
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Originally posted by Mikey
    Thanks... That works better.
    I did change from MouseUP to MouseDown. MouseUP performed both left and right events.
    Hi
    Just for future reference... the mouse up and mouse down events will both allow u to check for left and right mouse buttons. There must have been some other error in ur code. Also, MouseUp is the conventional event for things like popup menus.
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2001
    Posts
    430
    I'll keep that in mind... thanks

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