Where is the mouse??
-
I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc. My views usually track the mouse using the mouse events like the
CWnd::OnMouseMove
messages (which I have properly mapped etc). Reading the OnMouseMove help says that: 'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.' I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?). I 'd like to write code likeMyClass::OnMouseMove(....) { DoMyInitialAction(); _//an application action_ if( MouseInputStillOnMe() ) DoSomeOtherAction(....); _//another application action_ }
If myDoMyInitialAction
creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that theDoMyInitialAction
does that (It's a black box. I do not know what will do). Thus is it possible to write aMouseInputStillOnMe()
query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message? I assume that I can use theCWnd *CWnd::GetCapture( )
to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is? Thanks a lot for any help.... Dimitris...more you ask, more you learn -
I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc. My views usually track the mouse using the mouse events like the
CWnd::OnMouseMove
messages (which I have properly mapped etc). Reading the OnMouseMove help says that: 'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.' I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?). I 'd like to write code likeMyClass::OnMouseMove(....) { DoMyInitialAction(); _//an application action_ if( MouseInputStillOnMe() ) DoSomeOtherAction(....); _//another application action_ }
If myDoMyInitialAction
creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that theDoMyInitialAction
does that (It's a black box. I do not know what will do). Thus is it possible to write aMouseInputStillOnMe()
query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message? I assume that I can use theCWnd *CWnd::GetCapture( )
to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is? Thanks a lot for any help.... Dimitris...more you ask, more you learnI think you should look into using TrackMouseEvent The TrackMouseEvent function posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. I've seen better runs in my shorts! - Patches O'Houlihan
-
I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc. My views usually track the mouse using the mouse events like the
CWnd::OnMouseMove
messages (which I have properly mapped etc). Reading the OnMouseMove help says that: 'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.' I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?). I 'd like to write code likeMyClass::OnMouseMove(....) { DoMyInitialAction(); _//an application action_ if( MouseInputStillOnMe() ) DoSomeOtherAction(....); _//another application action_ }
If myDoMyInitialAction
creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that theDoMyInitialAction
does that (It's a black box. I do not know what will do). Thus is it possible to write aMouseInputStillOnMe()
query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message? I assume that I can use theCWnd *CWnd::GetCapture( )
to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is? Thanks a lot for any help.... Dimitris...more you ask, more you learnOr you could make use of the GetCursorPos() function and then indowFromPoint() to find out if the mouse is still over your window or not. If you vote me down, my score will only get lower