无边框模式对话框,设置鼠标拖动
1. 对话框中创建成员变量
long _icur;
2. 响应对话框类消息 WM_NCHITTEST
ScreenToClient(&point);
RECT rtWindow;
GetClientRect(&rtWindow);
long wndHeight = rtWindow.bottom - rtWindow.top;
long wndWidth = rtWindow.right - rtWindow.left;
_icur = 0;
RECT rcW = {0,0,wndWidth,100};
if(::PtInRect(&rcW,point))
{
return HTCAPTION; // 在拖动范围内
}
return CWnd::OnNcHitTest(point);
3. 响应对话框类消息 WM_SETCURSOR
if(_icur==0)
{
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
return TRUE;
}
return CDialog::OnSetCursor(pWnd, nHitTest, message);
参考
- (在VC++中实现无标题栏对话框的拖动) [http://blog.csdn.net/pjl1119/article/details/6775378]