SendMessage WM_MOUSEMOVE 未按预期工作

发布于 2024-09-28 13:16:59 字数 250 浏览 3 评论 0原文

当将 WM_MOUSEMOVE 消息发送到应用程序(在本例中为 Open Office Writer)的客户区时,图像将闪烁,就好像鼠标位于指定坐标上一样,但不会停留在该状态。代码为:

PostMessage(hWndClient, WM_MOUSEMOVE, 0, MAKEWORD(x, y))

其中 x 和 y 相对于客户区。

循环发送它仍然不起作用,因为鼠标悬停事件突出显示的区域只会闪烁。

任何帮助将不胜感激。

When sending the WM_MOUSEMOVE message to the client area of an application (in this case Open Office Writer) the image will flicker as if the mouse is over the specified coordinates, but does not stay in that state. The code is:

PostMessage(hWndClient, WM_MOUSEMOVE, 0, MAKEWORD(x, y))

where x and y are relative to the client area.

Sending this in a loop still does not work as the area highlighted by the mouse over event will just flicker.

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

独自←快乐 2024-10-05 13:16:59

该应用程序可能会触发各种其他事件。也许它想看到 WM_MOUSEHOVER 等...已经有一段时间了,但我记得其中一些事件的实现方式确实很混乱 - 就像有一个单独的线程轮询鼠标并在鼠标移动时生成 WM_MOUSELEAVE 事件不再在窗户上方。你也可能被类似的东西咬伤。应用程序本身也可能在收到事件时轮询鼠标的真实位置。

根据您想要执行的操作,也许您可​​以通过编程方式移动鼠标,而不仅仅是尝试伪造事件。不幸的是,我不记得这个的API,但我确信这是可能的。

The app could be triggering on all sorts of other events. Maybe it wants to see WM_MOUSEHOVER etc... It's been long a while, but I remember there being something really klugy about how some of these events were implemented - like there was a separate thread that polled the mouse and generated WM_MOUSELEAVE events when the mouse was no longer over the window. You could be getting bitten by something like that too. It's also possible that the application itself is polling the mouse for its true position when it receives the event.

Depending on what you're trying to do, perhaps you could programmatically move the mouse instead of just trying to fake events. Unfortunately, I don't remember the API for this, but I'm sure it's possible.

寄离 2024-10-05 13:16:59

我在我的主窗口中使用了这样的东西,看起来有帮助......在 WM_MOUSEMOVE 中:

POINT Point;
GetCursorPos(&Point);
ScreenToClient(hHwnd, &Point);
int X = Point.x;
int Y = Point.y;

I used sth like this in my main window and looks that helps... in WM_MOUSEMOVE:

POINT Point;
GetCursorPos(&Point);
ScreenToClient(hHwnd, &Point);
int X = Point.x;
int Y = Point.y;
那些过往 2024-10-05 13:16:59

试试这个:PostMessage(hWndClient, WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(x, y)),由于postion是一个32位整数,低16位是x,高16位是y,也许你应该使用MAKELONG而不是MAKEWORD
检查WM_MOUSEMOVE

Try this: PostMessage(hWndClient, WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(x, y)), since postion is a 32-bit integer, the lower 16 bit is x, and the higher 16 bit is y, maybe you should use MAKELONG instead of MAKEWORD.
Check WM_MOUSEMOVE.

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