GetCursorPos Function

Retrieves the current position of the mouse cursor in screen coordinates.

Syntax

BOOL GetCursorPos(
        LPPOINT lpPoint
        );

Parameters

Parameter Description
lpPoint A pointer to a POINT structure that receives the screen coordinates of the mouse cursor. The coordinates are in device-independent units.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The coordinates returned by GetCursorPos are always in screen coordinates, regardless of which window is currently active.

Note: For applications that need to track mouse input for a specific window, consider using mouse input functions such as WM_MOUSEMOVE messages, which provide coordinates relative to the client area of the window.

Requirements

Component Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Header winuser.h (include windows.h)

See Also