Mouse out of dialog
-
If I launch a non modal dialog from a CFormView, how can I know if the mouse leave the surface of the CNonModalDlg ? Preferable I should know inside of CNonModalDialog ... I override
OnMouseMove(UINT nFlags, CPoint point)
void CNonMOdalDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call defaultCPoint pt(point); // to not mess up point CRect rectDialog; GetWindowRect(&rectDialog); ScreenToClient(&rectDialog); if(! rectDialog.PtInRect(pt)) TRACE("################################ooouttt\\n"); CDialog::OnMouseMove(nFlags, point);
}
but when I leave the dialog surface, the TRACE are not signal me ...
-
If I launch a non modal dialog from a CFormView, how can I know if the mouse leave the surface of the CNonModalDlg ? Preferable I should know inside of CNonModalDialog ... I override
OnMouseMove(UINT nFlags, CPoint point)
void CNonMOdalDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call defaultCPoint pt(point); // to not mess up point CRect rectDialog; GetWindowRect(&rectDialog); ScreenToClient(&rectDialog); if(! rectDialog.PtInRect(pt)) TRACE("################################ooouttt\\n"); CDialog::OnMouseMove(nFlags, point);
}
but when I leave the dialog surface, the TRACE are not signal me ...
You set mouse capture to make it send mouse messages to your window even when out of it's area. SetCapture function (Windows)[^] There is an example in there of tracking the cursor and you can also have tracking events. TrackMouseEvent function (Windows)[^]
In vino veritas
-
If I launch a non modal dialog from a CFormView, how can I know if the mouse leave the surface of the CNonModalDlg ? Preferable I should know inside of CNonModalDialog ... I override
OnMouseMove(UINT nFlags, CPoint point)
void CNonMOdalDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call defaultCPoint pt(point); // to not mess up point CRect rectDialog; GetWindowRect(&rectDialog); ScreenToClient(&rectDialog); if(! rectDialog.PtInRect(pt)) TRACE("################################ooouttt\\n"); CDialog::OnMouseMove(nFlags, point);
}
but when I leave the dialog surface, the TRACE are not signal me ...
Flaviu2 wrote:
...the TRACE are not signal me ...
Does the
if()
condition evaluate to true?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Flaviu2 wrote:
...the TRACE are not signal me ...
Does the
if()
condition evaluate to true?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
As long I get out with mouse from CNonModalDlg surface, the handler are not fire at all anymore.
-
As long I get out with mouse from CNonModalDlg surface, the handler are not fire at all anymore.
You wont ever get the mouse move messages while the mouse is out of the client area unless you set the capture. Richard and I aren't joking there is nothing wrong. Read the detail it is very clear WM_MOUSEMOVE message (Windows)[^] WM_MOUSEMOVE message Posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse. You need to set capture on the mouse if you want the message outside the area. You can grab it when your dialog takes focus or sometimes it is when you select something like select a piece of text to draw. I can't mind read what you are trying to do but you need to set capture on the mouse to get that message outside the client area of the window. So perhaps start with the simple what starts the fact you want to track the mouse is there an event, a selection process? You want to track the mouse for some reason and whatever starts that process is where you set the capture. When it completes you release the capture. The set capture just needs your window handle and the release call requires no parameters it's a really simple thing and you just need to put the two lines of code in the right place. The only native window that behaves like that with default behaviour are menu boxes which start the capture when you left mouse click down. They release mouse capture on left mouse click up. That is how you can click an move along menu trees. Perhaps do the same on your dialog so you get the idea. On you dialog handler set capture to start on the left mouse click down and release capture on left mouse click up and you will suddenly see the track outside your window so long as you hold the left button mouse down just like on a menu.
In vino veritas
-
You wont ever get the mouse move messages while the mouse is out of the client area unless you set the capture. Richard and I aren't joking there is nothing wrong. Read the detail it is very clear WM_MOUSEMOVE message (Windows)[^] WM_MOUSEMOVE message Posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse. You need to set capture on the mouse if you want the message outside the area. You can grab it when your dialog takes focus or sometimes it is when you select something like select a piece of text to draw. I can't mind read what you are trying to do but you need to set capture on the mouse to get that message outside the client area of the window. So perhaps start with the simple what starts the fact you want to track the mouse is there an event, a selection process? You want to track the mouse for some reason and whatever starts that process is where you set the capture. When it completes you release the capture. The set capture just needs your window handle and the release call requires no parameters it's a really simple thing and you just need to put the two lines of code in the right place. The only native window that behaves like that with default behaviour are menu boxes which start the capture when you left mouse click down. They release mouse capture on left mouse click up. That is how you can click an move along menu trees. Perhaps do the same on your dialog so you get the idea. On you dialog handler set capture to start on the left mouse click down and release capture on left mouse click up and you will suddenly see the track outside your window so long as you hold the left button mouse down just like on a menu.
In vino veritas