WM_NCHITTEST

2.x

WM_NCHITTEST
xPos = (int) LOWORD(lParam);    /* horizontal position of cursor */
yPos = (int) HIWORD(lParam);    /* vertical position of cursor   */

The WM_NCHITTEST message is sent to the window that contains the cursor or to the window that used the SetCapture function to capture the mouse input. It is sent every time the mouse is moved.

Parameters

xPos

Value of the low-order word of lParam. Specifies the x-coordinate of the cursor, in screen coordinates.

yPos

Value of the high-order word of lParam. Specifies the y-coordinate of the cursor, in screen coordinates.

Return Value

The return value of the DefWindowProc function is one of the following values indicating the position of the cursor:

Value Meaning

HTBORDER In the border of a window that does not have a sizing border
HTBOTTOM In the lower horizontal border of a window
HTBOTTOMLEFT In the lower-left corner of a window border
HTBOTTOMRIGHT In the lower-right corner of a window border
HTCAPTION In a title bar area
HTCLIENT In a client area
HTERROR 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 In a size box (same as HTSIZE)
HTHSCROLL In the horizontal scroll bar
HTLEFT In the left border of a window
HTMAXBUTTON In a Maximize button
HTMENU In a menu area
HTMINBUTTON In a Minimize button
HTNOWHERE On the screen background or on a dividing line between windows
HTREDUCE In a Minimize button
HTRIGHT In the right border of a window
HTSIZE In a size box (same as HTGROWBOX)
HTSYSMENU In a System menu (sometimes referred to as a Control menu) or in a close button 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
HTVSCROLL In the vertical scroll bar
HTZOOM In a Maximize button

Comments

The MAKEPOINT macro can be used to convert the lParam parameter to a POINT structure.

Example

This example shows a portion of a subclass procedure that detects mouse messages in a static window:

LONG lRetVal;

case WM_NCHITTEST:
    lRetVal = DefWindowProc(hwnd, msg, wParam, lParam);
    if (lRetVal == HTTRANSPARENT) {
        .
        . /* Process mouse events in static window. */
        .
    }
    break;

default:
    CallWindowProc(lpStaticProc, hwnd, msg, wParam, lParam);

See Also

DefWindowProc, GetCapture