[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# TApplication.GetControlAtPos

Gets the control which contains the specified position, and optionally updates the internal tracking members for mouse capture when needed.

## Declaration

Source position: forms.pp line 1601

`public function TApplication.GetControlAtPos(`
`P: TPoint`
`):TControl;`

## Arguments

`P` |  | TPoint instance with the horizontal and vertical screen coordinates for a control to locate in the method.

## Function result

Control with bounds which include the specified position.

## Description

GetControlAtPos is a TControl function used to get the control which contains the point specified in P. The X and Y members in P are screen coordinates.

GetControlAtPos compares the coordinates in P to existing tracking members used for the last active mouse control in the application. If the control is valid and uses the coordinates in P, it is used as the return value for the method. Otherwise, FindControlAtPos is called to locate the control at the position in P.

The return value is Nil if a control is not found for the specified position, or when called at design-time. When the return value is assigned, the internal tracking members are updated with the last active control and its position.

GetControlAtPos is used in the implementation of the GetControlAtMouse method, and in private TControl methods.

## Version info

Added in LCL version 4.0.

## See also

TApplication.GetControlAtMouse |  | Gets the control under the mouse pointer.