Επεξεργασία

Κοινή χρήση μέσω


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
HTBORDER
18
In the border of a window that does not have a sizing border.
HTBOTTOM
15
In the lower-horizontal border of a resizable window (the user can click the mouse to resize the window vertically).
HTBOTTOMLEFT
16
In the lower-left corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).
HTBOTTOMRIGHT
17
In the lower-right corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).
HTCAPTION
2
In a title bar.
HTCLIENT
1
In a client area.
HTCLOSE
20
In a Close button.
HTERROR
-2
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).
HTGROWBOX
4
In a size box (same as HTSIZE).
HTHELP
21
In a Help button.
HTHSCROLL
6
In a horizontal scroll bar.
HTLEFT
10
In the left border of a resizable window (the user can click the mouse to resize the window horizontally).
HTMENU
5
In a menu.
HTMAXBUTTON
9
In a Maximize button.
HTMINBUTTON
8
In a Minimize button.
HTNOWHERE
0
On the screen background or on a dividing line between windows.
HTREDUCE
8
In a Minimize button.
HTRIGHT
11
In the right border of a resizable window (the user can click the mouse to resize the window horizontally).
HTSIZE
4
In a size box (same as HTGROWBOX).
HTSYSMENU
3
In a window menu or in a Close button in a child window.
HTTOP
12
In the upper-horizontal border of a window.
HTTOPLEFT
13
In the upper-left corner of a window border.
HTTOPRIGHT
14
In the upper-right corner of a window border.
HTTRANSPARENT
-1
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
7
In the vertical scroll bar.
HTZOOM
9
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
Winuser.h (include Windowsx.h)

See also

Reference

DefWindowProc

GET_X_LPARAM

GET_Y_LPARAM

Conceptual

Mouse Input

Other Resources

MAKEPOINTS

POINTS