Up-down problem in all controls

The place for threads about TimoSoft ButtonControls.
Post Reply
TickTick
Lt. Commander
Posts: 54
Joined: 17 Feb 2009, 01:41

Up-down problem in all controls

Post by TickTick » 08 Nov 2009, 08:28

When you click a native MS control quickly, and then suddenly stop clicking and hold the mouse down, the control will always reflect the mouse down. In all your controls, this is not the case: Sometimes the control shows a down state, sometimes and up state.

Edit: Well, I must be fair: The MS combo also has this bug...

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Up-down problem in all controls

Post by TiKu » 08 Nov 2009, 10:47

Yeah, I know. But I have absolutly no clue why this is happening.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

TickTick
Lt. Commander
Posts: 54
Joined: 17 Feb 2009, 01:41

Re: Up-down problem in all controls

Post by TickTick » 08 Nov 2009, 14:53

This is a known behaviour which confuses some people.

Post this code into a form:

Option Explicit

Private bDown As Boolean

Private Sub Form_DblClick()

Debug.Print "dblclick"

End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Debug.Print "down"

bDown = True

End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Debug.Print "up"

Debug.Assert bDown

bDown = False

End Sub

Now click quickly on the form.
The code will stop here:

down
up
dblclick
up

You see?
I cannot see your code, but I think you assume that when the event "DblClick" occured, the mouse is always up (which doesn't have to be the case).

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Up-down problem in all controls

Post by TiKu » 09 Nov 2009, 15:51

It's not that easy.
First, the events simply reflect the messages sent to the control window by Windows. So if you see an event sequence of Down, Up, DblClick, Up, this means that the control window received WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, WM_LBUTTONUP. If I remember correctly, this message sequence is the same for a trivial C++ app (dialog + button), which does nothing more than logging the messages the button receives. So there's nothing wrong with the events.
Second, the button (and any other control of mine) is drawn by Windows, not by my code. The internal state (down/up) of the button is also managed by Windows. So the wrong state seems to be Windows' fault. On the other hand, I cannot reproduce this behavior with a C++ app, so it really seems to be my code that's wrong.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

Post Reply