Results 1 to 7 of 7

Thread: Dectecting Both Mouse Buttons Pressed

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    28

    Arrow

    How do I determine if the user pressed both the left and right mouse buttons at the same time?

    The catch is that I want to know this information from the MouseDown event, not the MouseMove event.

    MouseDown - Button = the button which caused the event

    MouseMove - Button = collective state of pressed buttons

    It's the latter Button state that I want, but I do not want to have to use the MouseMove event?

    Any ideas?

  2. #2
    Frenzied Member JasonLpz's Avatar
    Join Date
    Mar 2001
    Location
    Brooklyn, NY
    Posts
    1,335
    i dont know the code but all u have to do is make it so when you press the eft it checks the right and if the right is down then execute code if not then do else.
    - JayWare
    Live to love. Not to Hate

    Im to busy to have a site. But I got one and still working on it.

    http://dre3k.net/

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    28

    Exclamation Hmmm

    ...but that won't work will it?

    In the MouseDown event Button = vbLeft or vbRightButton, so it can't be both?

  4. #4
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Originally posted by redbird77
    How do I determine if the user pressed both the left and right mouse buttons at the same time?

    The catch is that I want to know this information from the MouseDown event, not the MouseMove event.

    MouseDown - Button = the button which caused the event

    MouseMove - Button = collective state of pressed buttons

    It's the latter Button state that I want, but I do not want to have to use the MouseMove event?

    Any ideas?
    Try this

    Button = vbLeftButton + vbRightButton

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    28

    Unhappy

    I've tried vbLeftButton + vbRightButton (which = 3).

    But I think that only works in the MouseMove event. In the MouseDown event I'm only seeing Button as equal to 1 or 2.

  6. #6
    Guest
    Surly you can only catch one button, unless you are realy good at pressing both at the same time.


    This catches to button presses
    (code)
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

    If Button = 1 Then
    MsgBox "Left"
    End If

    If Button = 2 Then
    MsgBox "Right"
    End If

    End Sub
    (\code)

  7. #7
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Originally posted by redbird77
    I've tried vbLeftButton + vbRightButton (which = 3).

    But I think that only works in the MouseMove event. In the MouseDown event I'm only seeing Button as equal to 1 or 2.
    Yes, it SHOULD work, I did that before. MouseDown/KeyDown Event is use to capture the number of buttons/keys pressed at a time.

    You can try doing this

    Select case Button
    Case vbLeftButton
    frmOut.txtButton.Text = "Left"
    Case vbRightButton
    frmOut.txtButton.Text = "Right"
    Case vbMiddleButton
    frmOut.txtButton.Text = "Middle"
    Case vbLeftButton + vbRightButton
    frmOut.txtButton.Text = "L+R"
    Case vbLeftButton + vbMiddleButton
    frmOut.txtButton.Text = "L+M"
    Case vbMiddleButton + vbRightButton
    frmOut.txtButton.Text = "M+R"
    End Select

    Well, of course you gotta create the textbox named txtButton on a form named frmOut

    Good Luck!

    Harddisk

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