1. 處理WM_LBUTTONDOWD 消息 發送消息: SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); 或 SendMessage(hWnd, WM_SYSCOMMAND, 0XF012, 0);
代碼:
a. 處理 WM_NCBUTTONDOWN 消息
{
switch (nMsg)
{
case WM_LBUTTONDOWN:
SendMessage(hWnd, WM_NCLBUTTON, HTCAPTION, lParam);
break;
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}
b. 處理 WM_SYSCOMMAND 消息
{
switch (nMsg)
{
case WM_LBUTTONDOWN:
SendMessage(hWnd, WM_SYSCOMMAND, 0XF012, 0);
break;
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}
2. 處理WM_NCHITEST消息 直接返回 HTCAPTION
{
switch (nMsg)
{
case WM_NCHITTEST:
return HTCAPTOIN
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}