Track mouse coordinates off frame? 
Author Message
 Track mouse coordinates off frame?

I was wondering what method I would use to track the mouse coordinates
(presumably from a WM_MOUSEMOVE message) when the mouse is off the frame of
the application.  I've played with SetCapture(), but even with the capture
set, I stop receiving WM_MOUSEMOVE messages when off the frame of the
application.  It will track mouse clicks but not mouse move.  Any help
appreciated.

Paul



Mon, 25 Apr 2005 22:30:45 GMT  
 Track mouse coordinates off frame?
See if you can use the TrackMouseEvent() API.

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------


Quote:

> I was wondering what method I would use to track the mouse coordinates
> (presumably from a WM_MOUSEMOVE message) when the mouse is off the frame
of
> the application.  I've played with SetCapture(), but even with the capture
> set, I stop receiving WM_MOUSEMOVE messages when off the frame of the
> application.  It will track mouse clicks but not mouse move.  Any help
> appreciated.

> Paul



Mon, 25 Apr 2005 23:18:43 GMT  
 Track mouse coordinates off frame?
SetCapture should work even when mouse leaves your window. If you move
quickly outside, you may miss some WM_MOUSEMOVE etc.

--
Ajay Kalra [MVP - VC++]


Quote:

> I was wondering what method I would use to track the mouse coordinates
> (presumably from a WM_MOUSEMOVE message) when the mouse is off the frame
of
> the application.  I've played with SetCapture(), but even with the capture
> set, I stop receiving WM_MOUSEMOVE messages when off the frame of the
> application.  It will track mouse clicks but not mouse move.  Any help
> appreciated.

> Paul



Mon, 25 Apr 2005 23:37:28 GMT  
 Track mouse coordinates off frame?


Quote:
> SetCapture should work even when mouse leaves your window. If you move
> quickly outside, you may miss some WM_MOUSEMOVE etc.

According to the SetCapture docs,

<quote>
If the mouse cursor is over a window created by another thread, the system
will direct mouse input to the specified window only if a mouse button is
down.
</quote>

So, you'll only get mouse messages outside your window if the user has a
mouse button pressed (which means tracking the state of buttons while
pressing, dragging, etc. works as expected).

Jay



Mon, 25 Apr 2005 23:41:34 GMT  
 Track mouse coordinates off frame?
Thats not really true anymore. The docs I think are outdated. This is from a
MSJ article(Dec 1998, MSJ, Q&A):

<Quote>
Mouse capture is also affected by the Windows 95 and Windows NT localized
input queues.... If the mouse is captured while the mouse button is up, the
window receives mouse input only as long as the mouse is over that window or
another window created by the same thread.

Well, contrary to what the documentation states, even if the user moves the
mouse completely outside your window, your program will still get
WM_MOUSEMOVE messages if you've captured the mouse. This is true in both
Windows 9x and Windows NT.
</Quote>

-----
Ajay Kalra [MVP - VC++]


Quote:



> > SetCapture should work even when mouse leaves your window. If you move
> > quickly outside, you may miss some WM_MOUSEMOVE etc.

> According to the SetCapture docs,

> <quote>
> If the mouse cursor is over a window created by another thread, the system
> will direct mouse input to the specified window only if a mouse button is
> down.
> </quote>

> So, you'll only get mouse messages outside your window if the user has a
> mouse button pressed (which means tracking the state of buttons while
> pressing, dragging, etc. works as expected).

> Jay



Tue, 26 Apr 2005 00:33:32 GMT  
 Track mouse coordinates off frame?


Quote:
> Thats not really true anymore. The docs I think are outdated. This is from
a
> MSJ article(Dec 1998, MSJ, Q&A):

> <Quote>
> Mouse capture is also affected by the Windows 95 and Windows NT localized
> input queues.... If the mouse is captured while the mouse button is up,
the
> window receives mouse input only as long as the mouse is over that window
or
> another window created by the same thread.

> Well, contrary to what the documentation states, even if the user moves
the
> mouse completely outside your window, your program will still get
> WM_MOUSEMOVE messages if you've captured the mouse. This is true in both
> Windows 9x and Windows NT.
> </Quote>

Interesting. Life is never simple (or maybe it's just "Windows programming
is never simple" or perhaps both).

A quick perusal of web sites discussing this topic shed no absolute light on
the topic. My take: perhaps there's an ambiguity between the docs use of
"will direct mouse input" vs. receiving a WM_MOUSEMOVE. What I would guess
is that Windows doesn't want you to steal mouse input destined for another
window, but it will tell you about it. When you have the button down during
a SetCapture, all mouse input is "directed" to you. No one else gets the
message. When the mouse is up, you still get the WM_MOUSEMOVE, but so does
the target window it's meant for. And mouse clicks are yet another story...

So perhaps they're both "right". Just a guess. If I cared enough and had the
time, I would write some code to test it. But the second half of that "and"
is definitely not true, so I'll have to pass for now.

Reading down a bit in the article you mentioned, the author mentions that
SetCapture isn't good for tracking the mouse anyway (which the OP wanted)
since it prevents keyboard input. Yet another little fact I vaguely remember
running into long ago and forgetting.

Thanks for the info!

Jay



Tue, 26 Apr 2005 01:18:51 GMT  
 Track mouse coordinates off frame?
Sounds like you messed up the use of SetCapture. The use of mouse capture to track the
mouse when it is not over the app (assuming it actually is during a drag operation, for
example) is common and works. OTOH, if you want to simply track the mouse, see my essay on
hook functions on my MVP Tips site.
                                        joe

Quote:

>I was wondering what method I would use to track the mouse coordinates
>(presumably from a WM_MOUSEMOVE message) when the mouse is off the frame of
>the application.  I've played with SetCapture(), but even with the capture
>set, I stop receiving WM_MOUSEMOVE messages when off the frame of the
>application.  It will track mouse clicks but not mouse move.  Any help
>appreciated.

>Paul

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Tue, 26 Apr 2005 07:24:36 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Mouse Position, coordinates of where mouse is on screen

2. Drawing text near mouse during mouse tracking?

3. track track track to Afxwin.h

4. Turning off or tracking specific optimizations

5. tracking build time - how to turn off?

6. Track frame movement

7. Mouse click coordinates in ActiveX

8. Capture mouse coordinates on the desktop screen

9. x and y coordinates when i click right mouse button

10. How to get the absolute client mouse coordinates?

11. GetItemRect and GetClientRect coordinates not the same as mouse

12. mouse cursor coordinates

 

 
Powered by phpBB® Forum Software