case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_MOUSEMOVE:
{
if (wParam & MK_LBUTTON || wParam & MK_RBUTTON)
{
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(WHITE_PEN));
DrawBezier(hdc, apt); if (wParam & MK_LBUTTON)
{
apt[1].x = LOWORD(lParam);
apt[1].y = HIWORD(lParam);
}
if (wParam & MK_RBUTTON)
{
apt[2].x = LOWORD(lParam);
apt[2].y = HIWORD(lParam);
} SelectObject(hdc, GetStockObject(BLACK_PEN));
DrawBezier(hdc, apt);
ReleaseDC(hwnd, hdc);
}
return 0;
}
上面是画BEZIER曲线的核心代码 我想知道的是里面的wParam 和 HIWORD(lParam) LOWORD(lParam) 具体是指的什么东西
是窗口的坐标吗?貌似能随时变化?
case WM_RBUTTONDOWN:
case WM_MOUSEMOVE:
{
if (wParam & MK_LBUTTON || wParam & MK_RBUTTON)
{
hdc = GetDC(hwnd);
SelectObject(hdc, GetStockObject(WHITE_PEN));
DrawBezier(hdc, apt); if (wParam & MK_LBUTTON)
{
apt[1].x = LOWORD(lParam);
apt[1].y = HIWORD(lParam);
}
if (wParam & MK_RBUTTON)
{
apt[2].x = LOWORD(lParam);
apt[2].y = HIWORD(lParam);
} SelectObject(hdc, GetStockObject(BLACK_PEN));
DrawBezier(hdc, apt);
ReleaseDC(hwnd, hdc);
}
return 0;
}
上面是画BEZIER曲线的核心代码 我想知道的是里面的wParam 和 HIWORD(lParam) LOWORD(lParam) 具体是指的什么东西
是窗口的坐标吗?貌似能随时变化?
WM_MOUSEMOVE
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
同理:
WM_LBUTTONDOWN
fwKeys = wParam; // key flags
xPos = LOWORD(lParam); // horizontal position of cursor
yPos = HIWORD(lParam); // vertical position of cursor
是关键标志?什么意思。
在MSDN上搜了下wParam是这样解释的:The value of this field depends on the message. Use the wParam field to get information that is important to handling the message. This field is typically used to store small information such as flags.按他是说明 是不是wParam 是跟着消息走的 当程序接受到一个消息时 wParam 就存储相应的数据以便于处理消息,最后一句to store small information such as flags.不太明白,什么是small information?
flags 具体是什么东西?
fwKeys = wParam; // key flags (虚拟键标记)
//
fwKeys
Value of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: Value Description
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.