Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
User Input
Mouse Input
Notifications
 WM_NCHITTEST Notification
WM_NCHITTEST Notification

The WM_NCHITTEST message 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 receives this message through its WindowProc function.

Syntax

WM_NCHITTEST

    WPARAM wParam
    LPARAM lParam;
    

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.

ValueLocation of hot spot
HTBORDERIn the border of a window that does not have a sizing border.
HTBOTTOMIn the lower-horizontal border of a resizable window (the user can click the mouse to resize the window vertically).
HTBOTTOMLEFTIn the lower-left corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).
HTBOTTOMRIGHTIn the lower-right corner of a border of a resizable window (the user can click the mouse to resize the window diagonally).
HTCAPTIONIn a title bar.
HTCLIENTIn a client area.
HTCLOSEIn a Close button.
HTERROROn 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).
HTGROWBOXIn a size box (same as HTSIZE).
HTHELPIn a Help button.
HTHSCROLLIn a horizontal scroll bar.
HTLEFTIn the left border of a resizable window (the user can click the mouse to resize the window horizontally).
HTMENUIn a menu.
HTMAXBUTTONIn a Maximize button.
HTMINBUTTONIn a Minimize button.
HTNOWHEREOn the screen background or on a dividing line between windows.
HTREDUCEIn a Minimize button.
HTRIGHTIn the right border of a resizable window (the user can click the mouse to resize the window horizontally).
HTSIZEIn a size box (same as HTGROWBOX).
HTSYSMENUIn a window menu or in a Close button in a child window.
HTTOPIn the upper-horizontal border of a window.
HTTOPLEFTIn the upper-left corner of a window border.
HTTOPRIGHTIn the upper-right corner of a window border.
HTTRANSPARENTIn 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).
HTVSCROLLIn the vertical scroll bar.
HTZOOMIn 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);
You can also use the MAKEPOINTS macro to convert the lParam parameter to a POINTS structure.

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.

Notification Requirements

Minimum DLL Version None
HeaderDeclared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 3.1

See Also

Mouse Input Overview, DefWindowProc, GET_X_LPARAM, GET_Y_LPARAM, MAKEPOINTS, POINTS
Community Content   What is Community Content?
Add new content RSS  Annotations
Value      Đonny   |   Edit   |  
WM_NCHITTEST = &H84
Public Enum WM_NCHITTEST
HTBORDER = 18
HTBOTTOM = 15
HTBOTTOMLEFT = 16
HTBOTTOMRIGHT = 17
HTCAPTION = 2
HTCLIENT = 1
HTCLOSE = 20
HTERROR = -2
HTGROWBOX = 4
HTHELP = 21
HTHSCROLL = 6
HTLEFT = 10
HTMENU = 5
HTMAXBUTTON = 9
HTMINBUTTON = 8
HTNOWHERE = 0
HTREDUCE = HTMINBUTTON
HTRIGHT = 11
HTSIZE = HTGROWBOX
HTSYSMENU = 3
HTTOP = 12
HTTOPLEFT = 13
HTTOPRIGHT = 14
HTTRANSPARENT = -1
HTVSCROLL = 7
HTZOOM = HTMAXBUTTON
End Enum
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker