How can I know if the user is pressing on a CButton for more than 250msec? (MFC CButton)
-
Hello, This question is for an MFC application. How can I know if the user is pressing on a button for more than 250msec? As far I know, I get the BN_CLICKED only once, and only when the user releases the button :( Any hint?:confused:
-- **Ricky Marek** (_AKA: rbid_)
-- "Things are only impossible until they are not" --- Jean-Luc Picard My articles -
Hello, This question is for an MFC application. How can I know if the user is pressing on a button for more than 250msec? As far I know, I get the BN_CLICKED only once, and only when the user releases the button :( Any hint?:confused:
-- **Ricky Marek** (_AKA: rbid_)
-- "Things are only impossible until they are not" --- Jean-Luc Picard My articlesCreate your own button class
CMyButton
, which subclasses the existingCButton
. Add a handler for theWM_LBUTTONDOWN
message toCMyButton
. In the handler, post a notification to the parent dialog like this:WPARAM wParam = MAKEWPARAM(GetDlgCtrlID(),BN\_PRESSED); LPARAM lParam = (LPARAM)m\_hWnd; GetParent()->PostMessage(WM\_COMMAND,wParam,lParam);
where
BN_PRESSED
is a notification code you've defined. In your dialog, add a handler for theBN_PRESSED
notification. In the handler, start a timer (try usingQueryPerformanceCounter
). In yourBN_CLICKED
handler, get the value of the timer and compare the difference.
Software Zen:
delete this;