views:

37

answers:

1

I'm writing an app (in C++) which uses WM_LBUTTONDBLCLK.

It's all working fine except but I don't always get the DBLCLK message. Quite often I get two WM_LBUTTONDOWN messages instead.

I've looked at the mouse position - it doesn't move.

I've looked at the time between the two WM_LBUTTONDOWN messages - it's well within the value returned by GetDoubleClickTime()

I'm returning 0 for WM_LBUTTONDOWN, WM_LBUTTONUP and WM_LBUTTONDBLCLK.

What would cause this? I'm stumped.

PS: I've tried Windows XP and 7 - same result.

A: 

CS_DBLCLKS from: http://hyper.sunjapan.com.cn/~hz/win32/classy32.htm

The CS_DBLCLKS style causes Windows to detect a double-click (the user clicking the left mouse button twice in quick succession) for an application. Here is how Windows responds to a double-click event:

If a window does not have the CS_DBLCLKS style, Windows sends the following message sequence to the window: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDOWN, and WM_LBUTTONUP.

If a window does have the CS_DBLCLKS style, Windows sends the following message sequence: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP.

That is, the second WM_LBUTTONDOWN message is replaced by a WM_LBUTTONDBLCLK message.
Other messages may be mixed within these message sequences, so an application should not rely on the messages being contiguous.

An application can detect a double-click event without using the CS_DBLCLKS style. See Dr. GUI's "Simulating Mouse Button Clicks" article in the Microsoft Development Library.

All standard Windows controls, the dialog class, and the desktop class have the CS_DBLCLKS style. Custom controls must have this style in order to work with the Dialog Editor.

Romain Hippeau