将值传递给同时接受WPARAM和LPARAM参数的函数时,我传递给它的是哪个函数是否重要?有人告诉我,如果我使用Windows x64,我应该使用WPARAM; 这是真的?
Aar*_*otz 25
发送信息时,WPARAM和LPARAM参数具有取决于消息特定解释.您需要以您发送的消息希望它们传递的方式传递这些参数.如果您要定义自己的消息(可能通过一个由偏移WM_USER,WM_APP或RegisterWindowMessage),那么你显然有更多的余地.
在16位Windows的时代,a WPARAM是一个16位字,而是LPARAM一个32位长.这些区别在Win32中消失了; 他们都成了32位的价值观.
根据这个,LPARAM定义为LONG_PTR,在64位Windows中是一个有符号的64位值.WPARAM定义为UINT_PTR,在64位Windows中是无符号的64位值.如果要定义自己的消息,则可能需要相应地分配其参数.
Ian*_*oyd 12
| for handles | for pointers |
| and numbers | |
| OS | WPARAM | LPARAM |
|----------------|-----------------|---------------|
| 16-bit Windows | 16-bit unsigned | 32-bit signed |
| 32-bit Windows | 32-bit unsigned | 32-bit signed |
| 64-bit Windows | 64-bit unsigned | 64-bit signed |
Run Code Online (Sandbox Code Playgroud)
多年来,其定义的历史发生了变化.
WINDOWS.H(Windows 2.03 SDK,c.1988)
/* Message structure */
typedef struct tagMSG {
HWND hwnd;
WORD message;
WORD wParam;
LONG lParam;
DWORD time;
POINT pt;
} MSG;
Run Code Online (Sandbox Code Playgroud)
WinDefs.h(c.1999)
/* Types use for passing & returning polymorphic values */
typedef UINT WPARAM;
typedef LONG LPARAM;
typedef LONG LRESULT;
Run Code Online (Sandbox Code Playgroud)
WinDef.h(c.2005)
/* Types use for passing & returning polymorphic values */
typedef UINT_PTR WPARAM;
typedef LONG_PTR LPARAM;
typedef LONG_PTR LRESULT;
Run Code Online (Sandbox Code Playgroud)
W用于无符号16位WORD,L用于带符号的32位LONG)这是特定于消息的.您可以使用此系统定义的消息类别列表作为参考.选择一个组,然后从该组中选择一条消息,以查看该消息指定您应该作为WPARAM/LPARAM传递的内容.
雷蒙德陈解释了为什么我们有两个参数.
| 归档时间: |
|
| 查看次数: |
38830 次 |
| 最近记录: |