Click and Double-click problem
-
Hello! I'm sure you guys with tons of experience had same dilemma some time in your carrier. I got in my mind almost impossible task to implement from my project manager. I have to implement click and double click on the same button control. The idea is that single-click would do some action A and double click would do action B that is totally unrelated to action A. At first look it seems ok, but windows manifest double-click like single-click followed by double-click event. So how would I know that single-click will be followed by double-click event and not do anything on the first event but just the second one and execute just action B? In my mind there is no solution to this problem except delaying the single-click event for the time in which double-click may happen. This can result that clients would complain that single-click is slow responsive. Please help me or direct me to some resources so I can convince myself or my project manager that there is or is not the solution for the given problem. Best regards,
Rostfrei
-
Hello! I'm sure you guys with tons of experience had same dilemma some time in your carrier. I got in my mind almost impossible task to implement from my project manager. I have to implement click and double click on the same button control. The idea is that single-click would do some action A and double click would do action B that is totally unrelated to action A. At first look it seems ok, but windows manifest double-click like single-click followed by double-click event. So how would I know that single-click will be followed by double-click event and not do anything on the first event but just the second one and execute just action B? In my mind there is no solution to this problem except delaying the single-click event for the time in which double-click may happen. This can result that clients would complain that single-click is slow responsive. Please help me or direct me to some resources so I can convince myself or my project manager that there is or is not the solution for the given problem. Best regards,
Rostfrei
When you get the first
WM_LBUTTONDOWN
, start a timer whose timeout value is at leastGetDoubleClickTime()
. If the timer expires before you getWM_LBUTTONDBLCLK
, then do your single-click action.Rostfrei wrote:
This can result that clients would complain that single-click is slow responsive.
Bill them for the time spent researching time travel so your code can see into the future to determine whether the user is going to double-click. ;)
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?