在 Windows 上跟踪鼠标光标位置的最有效方法是什么?
在 Mac OS X 的 Cocoa 框架中,有 Tracking Rects,它可以有效地允许您注册视图区域并在鼠标进入或离开时获取回调消息。
Windows下有类似的API吗?我想避免使用计时器每隔 x 间隔调用 GetCursorPos() 。
可能它们的名字完全不同,而且很微不足道,但到目前为止我还没有找到任何东西。
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 enters 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
TrackMouseEvent,这将向您发送一个
WM_MOUSELEAVE 消息,如果鼠标有一段时间没有移动,还会出现悬停通知。
如果你想要一个小于你的窗口的跟踪矩形,那么你必须自己做。
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.
在窗口中捕获 WM_MOUSEMOVE。
Catch WM_MOUSEMOVE in your window.
您可以安装鼠标钩子来捕获鼠标事件。
You can install a mouse hook to capture mouse events.