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

# TCustomForm.Release

Marks the form for destruction.

## Declaration

Source position: forms.pp line 727

`public procedure TCustomForm.Release;`

## Description

Release is a procedure used to request destruction of the current form instance.

Release is called from the ShowModal method when a value other than mrNone is returned in the ModalResult property - including when the Application has been terminated while the dialog is active. While the method is public (just like in Delphi), it is not meant to be called from application code; ShowModal handles freeing the form instance in its processing loop. Calling Release when the form instance has already been freed in ShowModal raises an Access Violation (AV). You can use Close / OnClose to set the form close action to caFree to force the dialog to be closed and freed.

Release checks for a TApplication instance in the Application singleton. If it is assigned (contains a value other than Nil), its ReleaseComponent method is called to free the form instance by posting an asynchronous application message. When Application is not assigned, the Free method is called to destroy the form instance.

## See also

TCustomForm.ShowModal |  | Displays the form as a modal dialog.
TCustomForm.ModalResult |  | Specifies the return value for a form (or dialog) displayed modally.
TCustomForm.Close |  | Closes the form.
TCustomForm.OnClose |  | Handler called when the form is closed. It determines what happens to the form (destroy, hide, etc.).
TCustomForm.Destroy |  | Destructor for the class instance.
TApplication.ReleaseComponent |  | Safely destroys a component used in the application.
Application |  | The TApplication singleton.
TCloseAction |  | Represents actions that can occur when a form is closed.
TCustomApplication.Terminated