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

# TWinControl.Handle

A reference handle to the widgetset class instance associated with this control.

## Declaration

Source position: controls.pp line 2338

`public property TWinControl.Handle : HWND read GetHandle write SetHandle;`

## Description

Handle is a HWND property which represents the handle to the widgetset class instance for the control. It provides a bi-directional communication mechanism between an LCL component and the native control on a given platform or widgetset. Handle has a non-zero value when it has been allocated for the widget.

Read access to the property value calls the HandleNeeded method to create the handle if it does not already exist in the control (and its Parent controls). When the property value is changed, the InvalidatePreferredSize method is called to update control flags and clear the cached size for the control.

Use HandleAllocated to check Handle for a non-zero value. Use HandleNeeded when the LCL component needs to ensure that the control and Parent controls have an assigned Handle. Or call CreateHandle.

Use WindowHandle to access the unique identifier for a device context used in drawing operations for the widgetset class.

## See also

TWinControl.HandleAllocated |  | Checks whether a handle for the widget has been allocated for the control.
TWinControl.HandleNeeded |  | Call this method when your code requires a valid Handle for this control.
TWinControl.CreateHandle |  | Creates the Handle for the widget, if not already created.
TWinControl.CreateWnd |  | Creates the interface object (widget) and assigns the value in Handle.
TWinControl.WindowHandle |  | For internal use; allows direct access to the Handle for the control, bypassing any getter/setter methods.
TWinControl.ParentHandlesAllocated |  | Returns True if all Parents have handles allocated, and are not being destroyed.