ScreenToClient function (winuser.h)

The ScreenToClient function converts the screen coordinates of a specified point on the screen to client-area coordinates.

Syntax

BOOL ScreenToClient(
  [in] HWND    hWnd,
       LPPOINT lpPoint
);

Parameters

[in] hWnd

A handle to the window whose client area will be used for the conversion.

lpPoint

A pointer to a POINT structure that specifies the screen coordinates to be converted.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Remarks

The function uses the window identified by the hWnd parameter and the screen coordinates given in the POINT structure to compute client coordinates. It then replaces the screen coordinates with the client coordinates. The new coordinates are relative to the upper-left corner of the specified window's client area.

The ScreenToClient function assumes the specified point is in screen coordinates.

All coordinates are in device units.

Do not use ScreenToClient when in a mirroring situation, that is, when changing from left-to-right layout to right-to-left layout. Instead, use MapWindowPoints. For more information, see "Window Layout and Mirroring" in Window Features.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-window-l1-1-2 (introduced in Windows 10, version 10.0.10240)

See also

ClientToScreen

Coordinate Space and Transformation Functions

Coordinate Spaces and Transformations Overview

MapWindowPoints

POINT