方法一:
处理窗口的WM_NCHITTEST消息,重载其响应函数CWnd::OnNcHitTest,使当点击窗口的 任意位置时能移动窗口: UINT OnNcHitTest(CPoint point){ UINT nHitTest CDialog::OnNcHitTest(point); return (nHitTest==HTCLIENT)?HTCAPTION:nHitTest; } 方法二: 当用户在窗口客户区按下鼠标左键时,使windows认为鼠标是在标题栏上,即在处理 WM_LBUTTONDOWN消息的处理函数OnLButtonDown中发送一个wParam参数为HTCAPTION, lParam为当前坐标的WM_NCLBUTTONDOWN消息: PostMessage(WM_NCLBUTTONDOWN,HTCAPTION,MAKELPARAM(x,y)); |