Moving a window
-
You can use of MoveWindow.
-
do you mean you want to move your window by dragging it by clicking on anywhere on the dialog?
-
Handle WM_NCHITTEST and always return HTCAPTION.
-
Handle WM_NCHITTEST and always return HTCAPTION.
Just a little aside note. "Moving your window by dragging it by clicking on anywhere on the dialog" is OK in one particular case: it has no menu, no system menu, no maximize/minimize/close button, no scrollbars and is not resizeable. Returning always HTCAPTION from WM_NCHITTEST message handler leads in the impossibility of using menus,... and all enumerated above. A little bit better approach is to apply the trick only for the client area. Here is an example:
UINT CMyDialog::OnNcHitTest(CPoint point) { UINT nRet = CDialog::OnNcHitTest(point); if(HTCLIENT == nRet) { nRet = HTCAPTION; } return nRet; }
Ovidiu Cucu Microsoft MVP - Visual C++
-
Add the following line of code in your LButton Down handler.
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
-
Just a little aside note. "Moving your window by dragging it by clicking on anywhere on the dialog" is OK in one particular case: it has no menu, no system menu, no maximize/minimize/close button, no scrollbars and is not resizeable. Returning always HTCAPTION from WM_NCHITTEST message handler leads in the impossibility of using menus,... and all enumerated above. A little bit better approach is to apply the trick only for the client area. Here is an example:
UINT CMyDialog::OnNcHitTest(CPoint point) { UINT nRet = CDialog::OnNcHitTest(point); if(HTCLIENT == nRet) { nRet = HTCAPTION; } return nRet; }
Ovidiu Cucu Microsoft MVP - Visual C++