开发者

What's the most efficient way to track the mouse cursor position on Windows?

开发者 https://www.devze.com 2022-12-21 15:35 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号