分类:
- <strong>方法一:直接在OnNcHitTest中虚拟发送HTCAPTION消息</strong>
方法二:直接在OnLButtonDown中虚拟发送WM_NCLBUTTONDOWN,HTCAPTION消息
- void CaaaDlg::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- CDialog::OnLButtonDown(nFlags, point);
- }
方法三:通过在OnMouseMove中手动进行处理
- void CaaaDlg::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- static CPoint PrePoint = CPoint(0, 0);
- if(MK_LBUTTON == nFlags)
- {
- if(point != PrePoint)
- {
- CPoint ptTemp = point - PrePoint;
- CRect rcWindow;
- GetWindowRect(&rcWindow);
- rcWindow.OffsetRect(ptTemp.x, ptTemp.y);
- MoveWindow(&rcWindow);
- return ;
- }
- }
- PrePoint = point;
- CDialog::OnMouseMove(nFlags, point);
- }
控件拖动:
控件拖动只能采用上述的第三种方法
转载自: