When the window determines the mouse position, Windows sends a WM_NCHITTEST message to the window, allowing the message to be processed so that Windows considers the mouse to be on the title bar as soon as the mouse is inside the window. This requires the Onnchittest function that overloads the CWnd class to handle the WM_NCHITTEST message, calling the function of the parent class in the function, and if returning htclient, indicating that the mouse is in the window client area, so that the overloaded function returns Htcaption, Causes Windows to mistakenly assume that the mouse is on the title bar.
When the user presses the left mouse button in the window client area, causes Windows to think that the mouse is on the title bar, that is, to send a wparam parameter to htcaption in the processing function OnLButtonDown processing the WM_LBUTTONDOWN message, LPARAM The Wm_nclbuttondown message for the current coordinate.
1 void Ctmfcddlg::onlbuttondown (UINT nflags, CPoint point) 2 {3 // todo:add your message handler code here and/or call default 4 5 Cdialogex::onlbuttondown (nflags, point); 6 7 PostMessage (Wm_nclbuttondown, Htcaption, Makelparam (Point.x, Point.y)); 8 }
or SendMessage (wm_syscommand,0xf012,0);
MFC no Border dialog box moves