wparam和lparam的思考

首先看看定义:

typedef unsigned int        UINT;
typedef UINT WPARAM;//就是无符号整形
typedef long LONG;
typedef LONG LPARAM;//就是长整形

这就是所谓的wparam和lparam,从定义我们可以看出lparam比wparam要长,所以习惯上都用wparam来存储消息类型,而用lparam来存储要传递的参数,当然它的类型随着消息的不同而变化:如发送一个WM_LBUTTONDOWN消息,

SendMessage针对鼠标消息中wParam和lParam参数
SendMessage(Hwnd, WM_LBUTTONDOWN, wparam, lparam);
SendMessage(Hwnd, WM_LBUTTONUP, wparam, lparam);  
   
wParam	//消息类型  
MK_CONTROL   Set if the ctrl key is down.    
MK_LBUTTON   Set if the left mouse button is down.    
MK_MBUTTON   Set if the middle mouse button is down.    
MK_RBUTTON   Set if the right mouse button is down.    
MK_SHIFT     Set if the shift key is down.    
   
lParam	//传递参数
xPos = LOWORD(lParam);     //horizontal position of cursor    
yPos = HIWORD(lParam);     //vertical position of cursor
posted @ 2011-04-27 00:29  MagiCube  阅读(1286)  评论(0编辑  收藏  举报