Re: mouse button status
- From: "Eddards" <eddards@xxxxxxxxxxx>
- Date: Fri, 4 Sep 2009 13:21:58 -0400
I think what I actually need is kinda like a button that repeats a function.
For instance, as long as you hold a certain button down a character is sent
out the serial port.
Repeated at a rate of once per second or a variable time.
When you release the button it stops.
I have looked at a repeatbutton class but dont quite understand it.
Thanks.
"AliR" <AliR@xxxxxxxxxxxxx> wrote in message
news:upDMWsXLKHA.1492@xxxxxxxxxxxxxxxxxxxxxxx
Displaying a message box is a bit more involved than simply changing the
text of a button. Actually since you want to change the text of a
messagebox then you can't really use a messagebox, you will have to use a
modeless dialog.
If you were to simply change the text of a control on your dialog, then
first you catch the WM_LBUTTONDOWN message
void CMyAppDlg::OnLButtonDown(....)
{
c_ButtonStatus.SetWindowText(_T("L Button Dn"));
}
then you catch the WM_LBUTTONUP message
void CMyAppDlg::OnLButtonUp(...)
{
c_ButtonStatus.SetWindowText(_T("L Button Up"));
}
Now if you want to do the modeless dialog then in the OnLButtonDown, you
would create/show the modeless dialog, and then in the OnLButtonUp you
would change the text in the dialog. With that said, I'm not exactly sure
you would get the OnLButtonUp message if you were to popup another dialog
in your OnLButtonDown, I would have to write a sample to test this, but
I'm pretty sure that it would go to the new dialog.
With the first case, keep in mind that if you do this and the user clicks
in your window and then moves the mouse outside of your window, and then
releases the mouse you will not get the up message, unless you capture the
mouse.
void CMyAppDlg::OnLButtonDown(....)
{
SetCapture();
c_ButtonStatus.SetWindowText(_T("L Button Dn"));
}
void CMyAppDlg::OnLButtonUp(...)
{
ReleaseCapture();
c_ButtonStatus.SetWindowText(_T("L Button Up"));
}
AliR.
"Eddards" <eddards@xxxxxxxxxxx> wrote in message
news:MvSdnW1uRZZ2qTzXnZ2dnUVZ_qudnZ2d@xxxxxxxxxxxxxxx
How do I change the code below to display message that the left mouse
button is down and update the message when released?
void CMyAppDlg::OnTest()
{
//if left button is held down
c_ButtonStatus.SetWindowText("L Button Dn"); //display's message when
LButton is clicked.
//if left button is released
// c_ButtonStatus.SetWindowText("L Button Up"); //display's message
when LButton is released.
}
.
- Follow-Ups:
- Re: mouse button status
- From: AliR
- Re: mouse button status
- References:
- mouse button status
- From: Eddards
- Re: mouse button status
- From: AliR
- mouse button status
- Prev by Date: Re: mouse button status
- Next by Date: Re: mouse button status
- Previous by thread: Re: mouse button status
- Next by thread: Re: mouse button status
- Index(es):
Relevant Pages
|