Do not drag the dialog box:
Return true directly in onnchittest, the message processing function corresponding to wm_hittest, or if it points to the title bar of the dialog box, return the value of htclient in the customer area.
Example:
Uint cwelcomedlg: onnchittest (cpoint point)
{
// Todo: add your message handler code here and/or call default
Return htclient;
}
Drag the dialog box:
In onnchittest, the message processing function corresponding to wm_hittest, when pointing to the client area of the dialog box, the value of htcaption In the title area is returned.
Example:
Uint cdlg: onnchittest (cpoint point)
{
// Todo: add your message handler code here and/or call default
Screentoclient (& Point );
If (point. Y> = 0 & point. Y <= dlgcaphight)
{
Return htcaption;
}
Return cdialog: onnchittest (point );
}
References:
Wm_nchittest
TheWm_nchittestMessage is sent to a window when the cursor moves, or when a mouse button is pressed or released. if the mouse is not captured, the message is sent to the window beneath the cursor. otherwise, the message is sent to the window that has captured the mouse.
A window waits es this message through itsWindowprocFunction.
LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // WM_NCHITTEST WPARAM wParam, // not used LPARAM lParam // horizontal and vertical position);
Parameters
-
Wparam
-
This parameter is not used.
-
Lparam
-
The low-order word specifies the X-coordinate of the cursor. The coordinate is relative to the upper-left corner of the screen.
The high-order word specifies the Y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the screen.
Return values
The Return Value ofDefwindowprocFunction is one of the following values, indicating the position of the cursor hot spot.
| Value |
Location of hot spot |
| Htborder |
In the border of a window that does not have a sizing border. |
| Htbottom |
In the lower-horizontal border of a resizable window (the user can click the mouse to resize the window vertically ). |
| Htbottomleft |
In the lower-left corner of a border of a resizable window (the user can click the mouse to resize the window diagonally ). |
| Htbottomright |
In the lower-right corner of a border of a resizable window (the user can click the mouse to resize the window diagonally ). |
| Htcaption |
In a title bar. |
| Htclient |
In a client area. |
| Htclose |
InCloseButton. |
| Ror |
On the screen background or on a dividing line between windows (same as htnowhere, doesn t thatDefwindowprocFunction produces a system beep to indicate an error ). |
| Htgrowbox |
In a size box (same as htsize ). |
| Hthelp |
InHelpButton. |
| Hthscroll |
In a horizontal scroll bar. |
| Htleft |
In the left border of a resizable window (the user can click the mouse to resize the window horizontally ). |
| Htmenu |
In a menu. |
| Htmaxbutton |
InMaximizeButton. |
| Htminbutton |
InMinimizeButton. |
| Htnowhere |
On the screen background or on a dividing line between windows. |
| Htreduce |
InMinimizeButton. |
| Htright |
In the right border of a resizable window (the user can click the mouse to resize the window horizontally ). |
| Htsize |
In a size box (same as htgrowbox ). |
| Htsysmenu |
In a window menu or inCloseButton in a child window. |
| Httop |
In the upper-horizontal border of a window. |
| Httopleft |
In the upper-left corner of a window border. |
| Httopright |
In the upper-right corner of a window border. |
| Httransparent |
In a window currently covered by another window in the same thread (the message will be sent to underlying windows in the same thread until one of them returns a code that is not httransparent ). |
| Htvscroll |
In the vertical scroll bar. |
| Htzoom |
InMaximizeButton. |
Cwnd: onnchittest
Afx_msg Uint Onnchittest ( Cpoint Point );
Return Value
One of the mouse hit-test enumerated values listed below.
Parameters
Point
Contains the X-and y-coordinates of the cursor. These coordinates are always screen coordinates.
Remarks
The framework callthis member function forCwndObject that contains the cursor (orCwndObject that used the setcapture member function to capture the mouse input) every time the mouse is moved.
NoteThis member function is called by the framework to allow your application to handle a Windows message. the parameters passed to your function reflect the parameters received ed by the framework when the message was received ed. if you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
See alsoCwnd: getcapture, wm_nchittest
Mouse enumerated values
- HtborderIn the border of a window that does not have a sizing border.
- HtbottomIn the lower horizontal border of the window.
- HtbottomleftIn the lower-left corner of the window border.
- HtbottomrightIn the lower-right corner of the window border.
- HtcaptionIn a title-bar area.
- HtclientIn a client area.
- RorOn the screen background or on a dividing line between windows (sameHtnowhereCould t thatDefwndprocWindows function produces a system beep to indicate an error ).
- HtgrowboxIn a size box.
- HthscrollIn the horizontal scroll bar.
- HtleftIn the left border of the window.
- HtmaxbuttonIn a maximize button.
- HtmenuIn a menu area.
- HtminbuttonIn a Minimize button.
- HtnowhereOn the screen background or on a dividing line between windows.
- HtreduceIn a Minimize button.
- HtrightIn the right border of the window.
- HtsizeIn a size box (sameHtgrowbox).
- HtsysmenuIn a control menu or in a close button in a child window.
- HttopIn the upper horizontal border of the window.
- HttopleftIn the upper-left corner of the window border.
- HttoprightIn the upper-right corner of the window border.
- HttransparentIn a window currently covered by another window.
- HtvscrollIn the vertical scroll bar.
- HtzoomIn a maximize button.
From: csdn