在 Windows 上跟踪鼠标光标位置的最有效方法是什么?

发布于 2024-08-23 09:35:47 字数 187 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

穿越时光隧道 2024-08-30 09:35:47

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.

野味少女 2024-08-30 09:35:47

在窗口中捕获 WM_MOUSEMOVE

Catch WM_MOUSEMOVE in your window.

ぇ气 2024-08-30 09:35:47

您可以安装鼠标钩子来捕获鼠标事件。

You can install a mouse hook to capture mouse events.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文