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

# TCustomForm

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

The base type for TForm classes.

## Declaration

Source position: forms.pp line 513

`type TCustomForm = class(TCustomDesignControl)`
`protected`
`procedure WMActivate(); message;` |  | Handles the LM_ACTIVATE message which activates or deactivates the form.
`procedure WMCloseQuery(); message;` |  | Handles the LM_CLOSEQUERY message used to close the window.
`procedure WMHelp(); message;` |  | Handles the LM_HELP window message for the form.
`procedure WMShowWindow(); message;` |  | Handles the LM_SHOWWINDOW window message for the form.
`procedure WMSize(); message;` |  | Handles the LM_SIZE window message for the form.
`procedure WMWindowPosChanging(); message;` |  | Notifies the magnetic window manager when the position for a form is being updated.
`procedure WMWindowPosChanged(); message;` |  | Handles the LM_WINDOWPOSCHANGED window message for the form.
`procedure CMBiDiModeChanged(); message;` |  | Handles the CM_BIDIMODECHANGED control message for the form.
`procedure CMParentBiDiModeChanged(); message;` |  | Handles the CM_PARENTBIDIMODECHANGED control message for the form.
`procedure CMAppShowBtnGlyphChanged(); message;` |  | Handles the CM_APPSHOWBTNGLYPHCHANGED control message for the form.
`procedure CMAppShowMenuGlyphChanged(); message;` |  | Handles the CM_APPSHOWMENUGLYPHCHANGED control message for the form.
`procedure CMIconChanged(); message;` |  | Handles the CM_ICONCHANGED control message for the form.
`procedure CMRelease(); message;` |  | Handles the CM_RELEASE control message for the form.
`procedure CMActivate(); message;` |  | Handles the CM_ACTIVATE control message for the form.
`procedure CMDeactivate(); message;` |  | Handles the CM_DEACTIVATE control message for the form.
`procedure CMShowingChanged(); message;` |  | Handles the CM_SHOWINGCHANGED control message for the form.
`procedure WMDPIChanged(); message;` |  | Handles the LM_DPICHANGED window message for the form.
`FActionLists: TList;` |  | Member used to store the action lists associated with the form.
`FFormBorderStyle: TFormBorderStyle;` |  | The border style affects the title bar, border, icon(s), and resize behavior for the form.
`FFormState: TFormState;` |  | State flags for the form.
`class procedure WSRegisterClass; override;` |  | Registers this component class with the current WidgetSet.
`procedure DoShowWindow; virtual;` |  | Chooses the active control when the form becomes visible at run-time.
`procedure Activate; virtual;` |  | Signals the OnActivate event handler when a form is focused in an application.
`procedure ActiveChanged; virtual;` |  | An empty implementation in TCustomForm.
`procedure AdjustClientRect(); override;` |  | Excludes borders from the given rectangle.
`procedure BeginFormUpdate;` |  | Increments the form update counter, and disables auto-sizing on the initial update lock.
`function ColorIsStored; override;` |  | Implements the storage specifier for the Color property.
`procedure CreateParams(); override;` |  | Initializes parameters used to create the handle for the form instance.
`procedure CreateWnd; override;` |  | Creates the handle for the widgetset class and updates it Menu and Icons.
`procedure Deactivate; virtual;` |  | Performs actions when the form loses focus.
`procedure DoClose(); virtual;` |  | Notifies handlers of the close action for the form.
`procedure DoCreate; virtual;` |  | Notifies the create handlers for the form instance.
`procedure DoDestroy; virtual;` |  | Signals the OnDestroy event handler for the form instance.
`procedure DoHide; virtual;` |  | Signals the OnHide event handler for the form instance.
`procedure DoShow; virtual;` |  | Signals the OnShow event handler when needed.
`procedure EndFormUpdate;` |  | Decrements the form update counter, and re-enables auto-sizing on the form.
`function HandleCreateException; virtual;` |  | Indicates if an exception in the OnCreate event handler is handled by the application.
`function HandleDestroyException; virtual;` |  | Placeholder for exception handlers in derived classes.
`function HandleShowHideException; virtual;` |  | Placeholder for exception handlers in derived classes.
`procedure InitializeWnd; override;` |  | Initializes the widget, also for AlphaBlend and AllowDropFiles.
`procedure Loaded; override;` |  | Performs actions when the component has been loaded using the LCL streaming mechanism.
`procedure ChildHandlesCreated; override;` |  | Called when handles for child control are created in the form instance.
`procedure Notification(); override;` |  | Handles the notification when a component is added to or removed from the form.
`procedure PaintWindow(); override;` |  | Calls the Paint method using the specified device context in the control Canvas.
`procedure RequestAlign; override;` |  | Calls the user Alignment handler (AlignControls). Here: NOP for a top-level form.
`procedure Resizing(); override;` |  | Performs actions needed when the form processes the WMSize message.
`procedure CalculatePreferredSize(); override;` |  | Calculates the clipping width and height for a top-level form on the monitor WorkArea.
`procedure DoOnResize; override;` |  | Performs a delayed resize action using the DelayedEvent for the control.
`procedure DoOnChangeBounds; override;` |  | Performs a delayed bounds change using the DelayedEvent for the control.
`procedure SetZOrder(); override;` |  | Moves a top-level form in front of or behind all other forms.
`procedure SetParent(); override;` |  | Sets the value for the Parent property.
`procedure MoveToDefaultPosition; virtual;` |  | Moves the form to the location specified in the Position property.
`procedure UpdateShowing; override;` |  | Configures and position the form when its visibility has been changed.
`procedure SetVisible(); override;` |  | Sets the value for the Visible property.
`procedure AllAutoSized; override;` |  | If the form is about to show, calculate its metrics.
`procedure DoFirstShow; virtual;` |  | Executes handlers using the FirstShow handler type.
`procedure UpdateWindowState;` |  | UpdateWindowState is an empty implementation in TCustomForm.
`procedure VisibleChanging; override;` |  | Notifies all VisibleChanging handlers.
`procedure VisibleChanged; override;` |  | Notifies all handlers when the visibility for the form has been changed.
`procedure WndProc(); override;` |  | The general message handler for this control.
`function VisibleIsStored;` |  | Implements the storage specifier for the Visible property.
`procedure DoAutoSize; override;` |  | For internal use only; call AdjustSize instead.
`procedure SetAutoSize(); override;` |  | Sets the value for the AutoSize property.
`procedure SetAutoScroll(); override;` |  | Sets the value for the AutoScroll property.
`procedure SetScaled(); override;` |  | Sets the value for the Scaled property.
`procedure DoAddActionList();` |  | Adds the specified list of actions to the ActionList for the form.
`procedure DoRemoveActionList();` |  | Removes the specified list of actions from the internal list.
`procedure ProcessResource; virtual;` |  | Loads resources needed for the form.
`procedure BeginAutoDrag; override;` |  | Re-implements the auto-drag behavior for forms.
`procedure DoDock(); override;` |  | Docks or undocks the form in the specified dock site.
`function GetFloating; override;` |  | Gets the value for the Floating properties.
`function GetDefaultDockCaption; override;` |  | Default caption displayed when the form is docked.
`procedure CMActionExecute(); message;` |  | Handles the CM_ACTIONEXECUTE control message.
`procedure CMActionUpdate(); message;` |  | Handles the CM_ACTIONUPDATE control message.
`function DoExecuteAction();` |  | Asks all applicable components to execute an action.
`function DoUpdateAction();` |  | Tries all applicable components to update an action.
`procedure UpdateActions; virtual;` |  | Asks all components on the form to update their actions.
`property ClientHandle: HWND; [r]` |  | The Handle of the MDIForm client (container for MDI children).
`public`
`constructor Create(); override;` |  | Constructor for the class instance.
`constructor CreateNew(); virtual;` |  | Creates a form instance without a resource (.lfm) file.
`destructor Destroy; override;` |  | Destructor for the class instance.
`procedure AfterConstruction; override;` |  | Performs actions when the form has been created and loaded from its resource file.
`procedure BeforeDestruction; override;` |  | Performs actions before the form instance is physically freed.
`class function GetControlClassDefaultSize; override;` |  | Returns the default dimensions for new instances of the class.
`function BigIconHandle;` |  | Returns the handle for the large icon on the form or in the application.
`procedure Close;` |  | Closes the form.
`function CloseQuery; virtual;` |  | Asks the OnCloseQuery handler whether the form can be closed.
`procedure DefocusControl();` |  | Updates ActiveControl if it is to be de-focused.
`procedure DestroyWnd; override;` |  | Destroys the interface object (widget).
`procedure EnsureVisible();` |  | Ensures that the form is fully visible, and optionally brings it in front of all other forms.
`procedure FocusControl();` |  | Gives focus to the specified control.
`function FormIsUpdating; override;` |  | Indicates if the BeginFormUpdate method has been called without a corresponding EndFormUpdate method call.
`procedure GetFormImage();` |  | Gets the display content for the form as an image.
`function GetRolesForControl();` |  | Gets the role(s) for the control in a modal form (default or cancel button).
`function GetRealPopupParent;` |  | Gets the form that is the effective parent for the pop-up, dialog, or splash screen.
`procedure Hide;` |  | Hides the control by setting the Visible property to False.
`procedure IntfDropFiles();` |  | Invokes the OnDropFiles handler of the form. This function is called by the LCL interface.
`procedure IntfHelp();` |  | Shows help for a control or menu item. This function is called by the LCL interface.
`function IsShortcut(); virtual;` |  | Determines whether the specified message contains a shortcut or accelerator key.
`procedure MakeFullyVisible();` |  | Resizes the form for the specified monitor.
`function AutoSizeDelayedHandle; override;` |  | Returns True if an auto-size action should be skipped when a form handle is not available.
`procedure GetPreferredSize(); override;` |  | Returns default/preferred height and width, for use in auto-sizing.
`procedure Release;` |  | Marks the form for destruction.
`function CanFocus; override;` |  | True when the form can receive focus.
`procedure SetFocus; override;` |  | Ensures that the control or window handle has focus.
`function SetFocusedControl(); virtual;` |  | Handles a focus change for a control (enter/exit messages).
`procedure SetRestoredBounds();` |  | Sets the bounds for the restored control.
`procedure Show;` |  | Displays the form instance with support for High DPI scaling.
`function ShowModal; virtual;` |  | Displays the form as a modal dialog.
`procedure ShowOnTop;` |  | Displays the form in front of all other forms.
`function SmallIconHandle;` |  | Returns (and optionally creates) the Handle for the small Icon used for the form.
`procedure GetChildren(); override;` |  | Executes the specified callback for all child Controls, and Components with no Parent.
`function WantChildKey(); virtual;` |  | Indicates if key messages in a child control are handled in the message processing loop for the form.
`procedure RemoveAllHandlersOfObject(); override;` |  | Override this method to remove all references to notification handlers in AnObject.
`procedure AddHandlerFirstShow();` |  | Adds a handler routine called the first time the form is shown.
`procedure RemoveHandlerFirstShow();` |  | Removes the handler called the first time the form executes its Show method.
`procedure AddHandlerClose();` |  | Adds a handler for a form close event.
`procedure RemoveHandlerClose();` |  | Removes a form close handler added to the form instance.
`procedure AddHandlerCreate();` |  | Adds a handler for a form create event.
`procedure RemoveHandlerCreate();` |  | Removes a form create handler added to the form instance.
`function ActiveMDIChild; virtual;` |  | Returns the currently active MDI child form.
`function GetMDIChildren(); virtual;` |  | Provides indexed access to MDI child forms when used as a MDI form.
`function MDIChildCount; virtual;` |  | Provides indexed access to MDI child forms when used as a MDI form.
`procedure AutoScale;` |  | Sets scaled to True and calls AutoAdjustLayout with the current PPI for the monitor.
`procedure Dock(); override;` |  | Docks the form to the specified dock site.
`procedure UpdateDockCaption(); override;` |  | Gets the combined Caption for DockClients on the form.
`property Active: Boolean; [r]` |  | Indicates if the form is enabled, visible, and has focus.
`property ActiveControl: TWinControl; [rw]` |  | Gets or sets the active control on the form.
`property ActiveDefaultControl: TControl; [rw]` |  | Specifies the active default control on the form.
`property AllowDropFiles: Boolean; [rw]` |  | Specifies whether files can be dropped onto this form.
`property AlphaBlend: Boolean; [rw]` |  | Allows the form to be drawn with translucency.
`property AlphaBlendValue: Byte; [rw]` |  | The translucence level for the form (0=transparent, 255=opaque).
`property AutoScroll: Boolean; [s]` |  | Indicates if the form can automatically show or hide scroll bars.
`property BorderIcons: TBorderIcons; [rw]` |  | Specifies the icons which appear in the title bar for the form.
`property BorderStyle: TFormBorderStyle; [rw]` |  | The border style affects the title bar, border, icon(s), and resize behavior for the form.
`property CancelControl: TControl; [rw]` |  | The control associated with the Cancel action.
`property Caption: TCaption; [s]` |  | The text displayed in the title bar for the form.
`property Color: TColor;` |  | The background color for the form.
`property DefaultControl: TControl; [rw]` |  | The control associated with the default action for this form.
`property DefaultMonitor: TDefaultMonitor; [rw]` |  | The monitor on which the form is displayed.
`property Designer: TIDesigner; [rw]` |  | The designer object when the form is in design mode.
`property EffectiveShowInTaskBar: TShowInTaskbar; [r]` |  | Value for the ShowInTaskBar property when resolved using the Application settings.
`property FormState: TFormState; [r]` |  | State flags for the form.
`property FormStyle: TFormStyle; [rw]` |  | Indicates the style for the form.
`property HelpFile: string; [rw]` |  | The name of the help file for the form.
`property Icon: TIcon; [rws]` |  | The Icon associated with this Form (in minimized state).
`property KeyPreview: Boolean; [rw]` |  | Allows the form to intercept keystrokes in child controls.
`property MDIChildren []: TCustomForm; [r]` |  | Provides indexed access to MDI child forms when used as a MDI form.
`property Menu: TMainMenu; [rw]` |  | The main menu for the form instance.
`property ModalResult: TModalResult; [rw]` |  | Specifies the return value for a form (or dialog) displayed modally.
`property Monitor: TMonitor; [r]` |  | Contains the Monitor where the form is shown.
`property LastActiveControl: TWinControl; [r]` |  | Tracks focus changes for the active form or the last active control on the current form.
`property PopupMode: TPopupMode; [rw]` |  | Defines where pop-up menus are shown.
`property PopupParent: TCustomForm; [rw]` |  | Parent form which owns the current form instance when displayed as a pop-up window.
`property SnapOptions: TWindowMagnetOptions; [rw]` |  | Contains the form and screen snapping options for the form instance.
`property ScreenSnap: Boolean; [rws]` |  | Indicates whether the form instance can be snapped to an edge on the monitor.
`property SnapBuffer: Integer; [rws]` |  | Distance from (or proximity to) an edge on a snap target where the snapping behavior is automatically engaged.
`property OnActivate: TNotifyEvent; [rw]` |  | Handler signalled when the form instance receives focus.
`property OnClose: TCloseEvent; [rws]` |  | Handler called when the form is closed. It determines what happens to the form (destroy, hide, etc.).
`property OnCloseQuery: TCloseQueryEvent; [rws]` |  | Event handler signalled when trying to close a form.
`property OnCreate: TNotifyEvent; [rw]` |  | Handler called when the form has been created.
`property OnDeactivate: TNotifyEvent; [rw]` |  | Handler signalled when the form is deactivated (loses focus).
`property OnDestroy: TNotifyEvent; [rw]` |  | Handler called when the form is destroyed.
`property OnDropFiles: TDropFilesEvent; [rw]` |  | Handler called when files have been dropped.
`property OnHelp: THelpEvent; [rw]` |  | Handler called when Help is requested.
`property OnHide: TNotifyEvent; [rw]` |  | Handler called when the form is being hidden.
`property OnResize: TNotifyEvent; [s]` |  | Event handler signalled when the size for the form is changed.
`property OnShortcut: TShortCutEvent; [rw]` |  | Event handler signalled when a key is pressed, before further handling of the key.
`property OnShow: TNotifyEvent; [rw]` |  | Handler called when the form becomes visible.
`property OnShowModalFinished: TModalDialogFinished; [rw]` |  | Event handler signalled when modal display of the form has been completed.
`property OnWindowStateChange: TNotifyEvent; [rw]` |  | Handler called when the form is minimized, maximized or restored.
`property ParentFont: Boolean;` |  | Uses the font from the Parent when enabled.
`property Position: TPosition; [rw]` |  | The initial placement for the form.
`property RestoredLeft: Integer; [r]` |  | The Left coordinate for the form when it is restored (i.e. changes from minimized or maximized).
`property RestoredTop: Integer; [r]` |  | The Top coordinate for the form when it is restored (i.e. changes from minimized or maximized).
`property RestoredWidth: Integer; [r]` |  | The width of the form when it is resized.
`property RestoredHeight: Integer; [r]` |  | The height of the form when it is resized.
`property ShowInTaskBar: TShowInTaskbar; [rw]` |  | Indicates if the form should be displayed on the system Task Bar.
`property Visible: Boolean; [s]` |  | Indicates if the control is visible on its parent.
`property WindowState: TWindowState; [rw]` |  | Indicates whether the form is displayed in a minimized, maximized, full-screen or normal state.
`end;`

## Inheritance

`TCustomForm` |  | The base type for TForm classes.
`TCustomDesignControl` |  | Provides a designer surface for scaling and layout of its child controls.
`TScrollingWinControl` |  | Implements a windowed control with scroll bars.
`TCustomControl` |  | The base class for windowed controls which paint themselves.
`TWinControl` |  | Implements a windowed control which can contain other child controls.
`TControl` |  | The base class for visible controls.
`TLCLComponent` |  | The base class for LCL components which have an associated widget.
`TComponent`
?
`TObject`

## Description

TCustomForm is a TCustomDesignControl descendant that implements the base type for TForm classes.

Forms represent a window or a dialog used as the user interface for a GUI application. It is a container where visual components (such as buttons, labels, edit fields, images, etc.) can be placed. It is also a designer surface which provides design-time support for configuration and layout of the content placed on the form.

TCustomForm acts an abstraction layer which masks implementation-specific routines required for the various widgetsets supported in the Lazarus Component Library (LCL). Methods and properties are provided which interact with the underlying Operating System or platform, and provide a common API for form-related operations.

## See also

TForm |  | Implements a form used in an LCL application.
TCustomDesignControl |  | Provides a designer surface for scaling and layout of its child controls.