对话框客户区实现拖动

参考文章:http://tech.sina.com.cn/s/2006-07-25/09051053460.shtml


响应WM_NCHITTEST消息


函数实现如下:


//////////////////
// Non-client hit-test handler to move window by its client area.
// If the user clicks anywhere on the client area, pretend it's the
// caption. Windows does the rest!
UINT CMyDialog::OnNcHitTest(CPoint pt)
{
 CRect rc;
 GetClientRect(&rc);
 ClientToScreen(&rc);
 return rc.PtInRect(pt) ? HTCAPTION : CDialog::OnNcHitTest(pt);
}

你可能感兴趣的:(对话框)