Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function converts the screen coordinates of a specified point on the screen to client coordinates.

Syntax

BOOL ScreenToClient( 
  HWND 
hWnd, 
  LPPOINT 
lpPoint
); 

Parameters

hWnd

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

lpPoint

Long pointer to a POINTstructure that contains the screen coordinates to be converted.

Return Value

Nonzero indicates success. Zero indicates failure.

To get extended error information, call GetLastError.

Remarks

The function uses the window identified by the hWndparameter and the screen coordinates given in the POINTstructure to compute client coordinates. It then replaces the screen coordinates with the client coordinates.

The ScreenToClientfunction assumes the specified point is in screen coordinates.

All coordinates are in device units.

Regardless of the screen's layout settings, ScreenToClientalways interprets coordinates as if the screen layout is left-to-right. Do not use this function if your screen has a right-to-left layout. Instead, use MapWindowPoints.

Requirements

Header winuser.h
Library coredll.lib, Winmgr.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also