WM_NCHITTEST message
Sent to a window in order to determine what part of the window corresponds to a particular screen coordinate. This can happen, for example, when the cursor moves, when a mouse button is pressed or released, or in response to a call to a function such as WindowFromPoint. 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 receives this message through its WindowProc function.
#define WM_NCHITTEST 0x0084
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 value
The return value of the DefWindowProc function is one of the following values, indicating the position of the cursor hot spot.
Return code/value | Description |
---|---|
|
In the border of a window that does not have a sizing border. |
|
In the lower-horizontal border of a resizable window (the user can click the mouse to resize the window vertically). |
|
In the lower-left corner of a border of a resizable window (the user can click the mouse to resize the window diagonally). |
|
In the lower-right corner of a border of a resizable window (the user can click the mouse to resize the window diagonally). |
|
In a title bar. |
|
In a client area. |
|
In a Close button. |
|
On the screen background or on a dividing line between windows (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). |
|
In a size box (same as HTSIZE). |
|
In a Help button. |
|
In a horizontal scroll bar. |
|
In the left border of a resizable window (the user can click the mouse to resize the window horizontally). |
|
In a menu. |
|
In a Maximize button. |
|
In a Minimize button. |
|
On the screen background or on a dividing line between windows. |
|
In a Minimize button. |
|
In the right border of a resizable window (the user can click the mouse to resize the window horizontally). |
|
In a size box (same as HTGROWBOX). |
|
In a window menu or in a Close button in a child window. |
|
In the upper-horizontal border of a window. |
|
In the upper-left corner of a window border. |
|
In the upper-right corner of a window border. |
|
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). |
|
In the vertical scroll bar. |
|
In a Maximize button. |
Remarks
Use the following code to obtain the horizontal and vertical position:
xPos = GET_X_LPARAM(lParam);
yPos = GET_Y_LPARAM(lParam);
As noted above, the x-coordinate is in the low-order short of the return value; the y-coordinate is in the high-order short (both represent signed values because they can take negative values on systems with multiple monitors). If the return value is assigned to a variable, you can use the MAKEPOINTS macro to obtain a POINTS structure from the return value. You can also use the GET_X_LPARAM or GET_Y_LPARAM macro to extract the x- or y-coordinate.
Important
Do not use the LOWORD or HIWORD macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitors can have negative x- and y- coordinates, and LOWORD and HIWORD treat the coordinates as unsigned quantities.
Windows Vista: When creating custom frames that include the standard caption buttons, this message should first be passed to the DwmDefWindowProc function. This enables the Desktop Window Manager (DWM) to provide hit-testing for the captions buttons. If DwmDefWindowProc does not handle the message, further processing of WM_NCHITTEST may be needed.
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
Minimum supported server |
Windows 2000 Server [desktop apps only] |
Header |
|
See also
-
Reference
-
Conceptual
-
Other Resources