i am using OnLButtonUp and OnLButtonDblClk in my application but whenever i double click OnLButtonDblClk and OnLButtonUp both called but i wanted only OnLButtonDblClk to be called not OnLButtonUp . How to do this?
i am using OnLButtonUp and OnLButtonDblClk in my application but whenever i double click
Share
The problem is that whenever the user double clicks there are four messages sent:
This only happens if the user clicks the second time within the “double click time” (use
::GetDoubleClickTime()to get it).So what you can do is set a timer (with a timeout value equal to the double click time) when the user first clicks and if the second click comes before the timer goes off, you have a double click and you can disregard the button up message.
If the timer goes off, you call your button-up handler.
This technique has the drawback that it delays a bit the response to “Button Up” or single click, depending how you do it, but there’s no easy way to discard just the Button Up messages when there’s a double click.
EDIT:
If you just want to discard the second WM_LBUTTONUP, you can use a flag. You set it when you receive WM_LBUTTONDBLCLK. Then in the handler for WM_LBUTTONUP you do nothing if it’s set (and then you clear it, of course).