Sign in Join
FPDoc Onlineexperiment

TCustomTaskDialog.Execute function

Member of TCustomTaskDialogpublicIn unit Dialogs

Displays the task dialog and captures the modal result value.

Declaration

pascal
function Execute: Boolean; dynamic; overload
function Execute(ParentWnd: HWND): Boolean; dynamic; overload

Description

Execute is an overloaded Boolean function used to display the dialog and capture the value for the ModalResult property. The parameterless variant is normally called to display and execute the dialog form. It gets the handle for the active form which is used as the parent for the task dialog form from the Screen singleton. If a TCustomForm has not been assigned in Screen, the unassigned handle value (0) is used. The overloaded variant is called using the handle value as an argument.

Execute calls the DoExecute method to perform actions needed to initialize and display the dialog form. It also processes return values used in properties like ModalResult, QueryResult, QueryItemIndex, Button, and RadioButton.

The return value is True if the dialog was successfully displayed and a valid button identifier was clicked to close the dialog - including when Esc, Alt+F4 or the Cancel button is used.

This behavior is different than other LCL dialogs where a ModalResult of mrCancel would cause Execute / DoExecute to return False. This is consistent with the task dialog behavior in the Delphi VCL; the Delphi documentation states otherwise but it is incorrect.

See also

An experiment, built from Lazarus main 2dfa93c66e of 10-22-2026. Not the official Lazarus documentation.