Re: On LeftButton Down Event
Code:
OnLButtonDown()
{
AfxMessageBox("Left Button is down mode .");
}
......
OnLButtonUp()
{
AfxMessageBox("Left Button is Up mode. ");
}
Re: On LeftButton Down Event
Can you post more code............
But why do you want this..Do you need to compute difference between Down Event and Up Event..if it so you can use system time to compute this....or you can use timer..using continous loop..seems to be improper...
-Anant
Re: On LeftButton Down Event
Have a look in MSDN for message handler WM_LBUTTONDOWN and WM_LBUTTONUP you will get the things with your self.
and if you want you also can go for WM_NOTIFY The WM_NOTIFY message is sent by a common control to its parent window when an event has occurred or the control requires some information.
if Still Some problem Let us know
thankyou
Re: On LeftButton Down Event
Hello,
If you have subclassed CButton, you can handle WM_LBUTTONDOWN and WM_LBUTTONUP messages to take appropriate action when left mouse button is pressed / released on that button. But you have to take care of a few things.
There is a possibility that you press your left mouse button elsewhere and release it on the button. There can be vice-versa event where mouse button is pressed on the button and released elsewhere. In both cases, it does not generate a BN_CLICKED event. You may have to check in your program whether the pressing and releasing of left mouse button is done on the button itself.
While handling the messages WM_LBUTTONDOWN and WM_LBUTTONUP, framework inserts default calls of CButton::OnLButtonDown / CButton::OnLButtonUp in the respective message handler functions. If they are removed or bypassed, pressing the button will not generate a BN_CLICKED notification message.
If I understood your need correctly, the best method I can suggest is to start a timer when WM_LBUTTONDOWN message is handled, do the incrementing part in the timer and kill the timer in the handler of WM_LBUTTONUP.
Here is how I handled the mouse messages:
Code:
void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
GetParent()->SetTimer(WM_USER, 1000, NULL);
CButton::OnLButtonDown(nFlags, point);
}
void CMyButton::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
GetParent()->KillTimer(WM_USER);
CButton::OnLButtonUp(nFlags, point);
}
Here is how I incremented the variable in WM_TIMER message handler of the dialog box:
Code:
void CButtonDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UpdateData(TRUE);
m_Edit++;
UpdateData(FALSE);
CDialog::OnTimer(nIDEvent);
}
I have assumed that the application is dialog based and added an edit box with variable m_Edit attached with it. The increment is displayed in the edit box.
Regards.
Pravin.