Sign in Join
FPDoc Onlineexperiment

TControl.ScreenToClient function

Member of TControlpublicIn unit Controls

Converts absolute screen coordinates into client-relative coordinates.

Declaration

pascal
function ScreenToClient(const APoint: TPoint): TPoint; virtual

Arguments

APoint

TPoint instance with the screen coordinates converted in the method.

Function result

TPoint instance with the client-relative coordinates for the specified screen coordinates.

Description

The APoint argument contains the screen coordinates which are converted to client-relative coordinates in the method. The X member has the horizontal coordinate, and the Y member has the vertical coordinate.

The return value is a TPoint type which contains the coordinates from APoint with the X and Y members decremented by the corresponding values found in the ClientOrigin for the control.

Accessing the ClientOrigin property raises an EInvalidOperation exception if Parent has not been assigned for the control.

ScreenToClient is used in the implementation of methods like ClientToParent, ParentToClient, and GetMousePosFromMessage. It is also used to convert mouse coordinates during drag and drop, docking, and context menu operations.

Use ScreenToControl to convert absolute screen coordinate to control-relative values.

Use ClientToScreen to convert client-relative coordinates to absolute screen coordinates. Use ControlToScreen to convert the coordinates in the control to absolute screen coordinates.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.