WM_SETCURSOR
hwndCursor = (HWND) wParam; /* handle of window with cursor */
nHittest = LOWORD(lParam); /* hit-test code */
wMouseMsg = HIWORD(lParam); /* mouse-message number */
The WM_SETCURSOR message is sent to a window if mouse input is not captured and the mouse causes cursor movement within the window.
hwndCursor
Value of wParam. Specifies a handle to the window that contains the cursor.
nHittest
Value of the low-order word of lParam. Specifies the hit-test area code.
wMouseMsg
Value of the high-order word of lParam. Specifies the number of the mouse message.
An application should return TRUE to halt further processing or FALSE to continue.
If the nHittest parameter is HTERROR and the wMouseMsg parameter is a mouse button–down message, the MessageBeep function is called.
The DefWindowProc function passes the WM_SETCURSOR message to a parent window before processing. If the parent window returns TRUE, further processing is halted. Passing the message to a window's parent window gives the parent window control over the cursor's setting in a child window. The DefWindowProc function also uses this message to set the cursor to a pointer if it is not in the client area or to the registered-class cursor if it is in the client area.
For a standard dialog box to set the cursor for one of its child window controls, it must force the DefDlgProc function to return TRUE in response to the WM_SETCURSOR message. (DefDlgProc provides default processing for the standard dialog box class.) When DefDlgProc returns TRUE, the dialog box procedure retains control over the cursor. When the dialog box procedure processes WM_SETCURSOR, it can return TRUE by using the SetWindowLong function and the DWL_MSGRESULT offset, as shown in the following example:
SetWindowLong
(hwndDlg, DWL_MSGRESULT, MAKELONG(TRUE, 0));