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

# TApplication.MainFormHandle

Window handle for the MainForm in the application.

## Declaration

Source position: forms.pp line 1739

`public property TApplication.MainFormHandle : HWND read GetMainFormHandle;`

## Description

MainFormHandle is a read-only HWND property which contains the handle for the form instance used as the main form in the application.

The value for the property is derived using the OnGetMainFormHandle event handler (when assigned) or a TGetHandleEvent handler assigned in the application. When neither of these mechanisms provides a value other than zero (0), the window handle assigned in the MainForm property is used.

MainFormHandle is used in the implementation of methods in WidgetSet classes, primarily for the Windows platform, and in custom-drawn controls.

## See also

TApplication.MainForm |  | Contains the main form for the application.
TApplication.OnGetMainFormHandle |  | Event handler used to provide a value for the MainFormHandle property.
TApplicationHandlerType |  | Types of Application notification handlers.