What's the most efficient way to track the mouse cursor position on Windows?
In Mac OS X's Cocoa Framework, there are Tracking Rects, which effectively allows you to register an area of your view and get callback messages when the mouse ente开发者_如何学Crs or leaves.
Is there a similar API in Windows? I'd like to avoid using a timer to call GetCursorPos() every x interval.
It could be that they're named something totally different and it's quite trivial, but I've failed to find anything so far.
TrackMouseEvent, this will send you a WM_MOUSELEAVE
message when the mouse leaves your window, and also hover notifications if the mouse doesn't move for a while.
If you want a tracking rect smaller than your window, than you have to do that yourself.
Catch WM_MOUSEMOVE in your window.
You can install a mouse hook to capture mouse events.
精彩评论