WM_MOUSEMOVE - 打包x和y位置 [英] WM_MOUSEMOVE - packing x and y positions

查看:268
本文介绍了WM_MOUSEMOVE - 打包x和y位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一个粗糙系统通过直接发送WM_MOUSEMOVE事件从C ++ / win32程序控制Flash电影。



它适用于一个轴:

  SendMessage(m_targetWindowHWND,WM_MOUSEMOVE,0,xpos); 

但我现在想同时发送x和y值。我知道这些被打包成WM_MOUSEMOVEs lparam。在C ++中,这可以用MAKEPOINTS或GET_X_LPARAM / GET_Y_LPARAM解包。



但是如何打包x和y,基本上做上面的宏的相反。 >

我的猜测:

  DWORD packed = y< 8 + x; 

感谢

解决方案

您要查找的宏是 MAKELPARAM



http://msdn.microsoft.com/en-us/library /windows/desktop/ms632661(v=vs.85).aspx

  LPARAM WINAPI MAKELPARAM(
WORD wLow,
WORD wHigh
);

我相信它等同于 MAKELONG 但返回一个 DWORD ),但是再次...也许有一个平台,其中LPARAM和DWORD定义不同。 : - /






EDIT :显然LPARAM(和WPARAM!敞篷是你的平台上的指针的大小。 L(长)和W(字)是历史的:什么是LPARAM和WPARAM定义为


I am using a crude system to control a Flash movie from a C++/win32 program by sending WM_MOUSEMOVE events directly to the Flash window.

It works well for one axis:

SendMessage( m_targetWindowHWND, WM_MOUSEMOVE, 0, xpos);

However I'd like to now send both x and y values. I know these are packed into a WM_MOUSEMOVEs lparam. In C++ this could be unpacked with MAKEPOINTS or GET_X_LPARAM/GET_Y_LPARAM.

But how do I pack the x and y, basically doing the reverse of the macros above.

My guess:

DWORD packed = y << 8 + x;

Thanks

解决方案

The macro you're looking for is MAKELPARAM:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632661(v=vs.85).aspx

LPARAM WINAPI MAKELPARAM(
    WORD wLow,
    WORD wHigh
);

I believe it's equivalent to MAKELONG (same thing but returns a DWORD), but then again...maybe there's a platform out there where a LPARAM and a DWORD are defined differently. :-/


EDIT: Apparently LPARAM (and WPARAM!) are nowadays both defined under the hood to be the size of pointers on your platform. The "L" (long) and "W" (word) are historical: what are LPARAM and WPARAM defined as

这篇关于WM_MOUSEMOVE - 打包x和y位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆