void CPcLoginDlg::OnLButtonDown(WPARAM wParam, LPARAM lParam)
{
POINT pt = {0};
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
RECT rcClient = {0};
GetClientRect(m_hWnd, &rcClient);
if((pt.x >= 0) && (pt.x < rcClient.right - rcClient.left))
{
SendMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
{
POINT pt = {0};
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
RECT rcClient = {0};
GetClientRect(m_hWnd, &rcClient);
if((pt.x >= 0) && (pt.x < rcClient.right - rcClient.left))
{
SendMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
当鼠标左键点击到窗口区域的时候,可以实现窗口拖动。