WPARAM wparam,LPARAM lparam两个参数估计是Windows编程的最常见的两个万金油参数。但我也时常为此感到疑惑:由于它俩根据不同的消息或函数有不同的意义,那么假如给定消息或回调函数,你怎么搜索这两个参数的意义呢? 比如WM_LBUTTONDOWN消息中WPARAM wparam,LPARAM lparam的意义表示什么呢?说实话在MSDN中我不知道该搜索哪个关键字,因为我搜索WM_LBUTTONDOWN没有找到,搜索OnLButtonDown没有找到,那么我只能通过google或者百度搜索:"WM_LBUTTONDOWN消息中WPARAM wparam,LPARAM lparam的意义"来找。说实话,这样有时也很找到。 我很想知道:高手们是靠经验积累记住的,还是有专门的关键字来搜索这两个参数对于不同的消息和函数的意义?
The WM_LBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is in the client area of a window. If the mouse is not captured, the message is posted to the window beneath the cursor. Otherwise, the message is posted to the window that has captured the mouse.A window receives this message through its WindowProc function.
SyntaxWM_LBUTTONDOWN WPARAM wParam
LPARAM lParam;
ParameterswParam
Indicates whether various virtual keys are down. This parameter can be one or more of the following values.
MK_CONTROL
The CTRL key is down.
MK_LBUTTON
The left mouse button is down.
MK_MBUTTON
The middle mouse button is down.
MK_RBUTTON
The right mouse button is down.
MK_SHIFT
The SHIFT key is down.
MK_XBUTTON1
Windows 2000/XP: The first X button is down.
MK_XBUTTON2
Windows 2000/XP: The second X button is down.
lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area. The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
Return ValueIf an application processes this message, it should return zero.
ResUse the following code to obtain the horizontal and vertical position:xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam); You can also use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure. To detect that the ALT key was pressed, check whether GetKeyState(VK_MENU) < 0. Note, this must not be GetAsyncKeyState.
如:输入【WM_GETTEXT】,马上就可以看到关于它的详细说明。一般情况下,不会使用【搜索】。