开发者

SendMessage WM_MOUSEMOVE not working as expected

开发者 https://www.devze.com 2023-01-21 16:00 出处:网络
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

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.


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.


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;


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.

0

精彩评论

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