Click to See Complete Forum and Search --> : DblClick/Click Mouse Events


WWWJax
October 4th, 2001, 02:12 PM
I have a picture box and I want to execute one event if the right mouse button is pressed ( I am using the MouseUP where Button=2) and another event if I doubleclick or left mouse button click.

For some reason the MouseUP Button=2 event works fine, but the Dblclick event or the Click or MouseDown click doesn't fire when used in my same form module.
I've heard about an order of precedence on mouse events. MouseDn comes first, then MouseUp, then Click, then Doubleclick. Does this mean that if I have a Mouseup event for a picture box that I cannot assign a Doubleclick to that same picture box?

To test the events...
I created a new project and created one simple picture box and applied the Click and DblClick event to it. The event only worked if I 'Right' clicked or 'Right' Doubleclicked. Why would that be?

My mouse operates properly but something must be changing the features of my mouse during Run time.

Thanks.

Wendell W. Wilson
Software Engineer
St. Petersburg, FL

DSJ
October 4th, 2001, 02:41 PM
If you have a MouseClick event, the DblClick event will never fire... you can still use MouseDown and MouseUp however.

MKSa
October 4th, 2001, 04:02 PM
It seems to me that your mouse button settings were changed to Left-handed. When you click, the order of events will be: MouseDown then MouseUp then Click. On double click the order is: MouseDown then MouseUp then Click then DblClick. In both cases the MouseDown,MouseUp and Click events will fire.

WWWJax
October 4th, 2001, 04:03 PM
Thanks. But then how do I have a Picture box take on a certain event for a left button MouseDn event and have the same Picture box take on a different event for a right button MouseDn event?
The following code works for a right mouse click, but not for a left click. I thought the values for Button can be 0, 1, or 2.

private Sub Picture1_MouseDown(Index as Integer, Button as Integer, Shift as Integer, X as Single, Y as Single)
If Button = 2 then
Debug.print "Right Mouse Button was Pressed!"
else
Debug.print "Another Button was Pushed!!"; Button
End If

End Sub




Thanks.

Wendell W. Wilson
Software Engineer
St. Petersburg, FL

DSJ
October 4th, 2001, 04:17 PM
With the following code I get:
1 Left (on a left-click)
2 Right (on a right-click)
4 Other (on a wheel-click)

private Sub Picture1_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
Select Case Button
Case vbRightButton
MsgBox Button & " Right"
Case vbLeftButton
MsgBox Button & " Left"
Case else
MsgBox Button & " Other"
End Select

End Sub

WWWJax
October 4th, 2001, 04:26 PM
Thanks. I did check my mouse settings. They're ok. My mouse works fine.
The MouseDown event fires for my Picture Box, but only if the right mouse button is pressed. I want to use MouseDown for the left mouse button.
When I use an 'if button = 1' condition, for the left mouse button, I never get a response. i.e. the left button doesn't register.
Any suggestions?

Wendell W. Wilson
Software Engineer
St. Petersburg, FL

MKSa
October 4th, 2001, 04:43 PM
I read again your previous posting and you mention that when you right click Button=2, that corresponds to a right button. By the way the sequence of events is the same for right and left clicking. To differentiate between them you check the Button value in any of these events.
Did you try to trace the Click event with other controls like a textbox?