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

# TaskDlg

Provides a wrapper function used to configure and execute a TTaskDialog instance.

## Declaration

Source position: dialogs.pp line 949

`function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`ADefaultButton: TMsgDlgBtn;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`const ARadioButtons: array of string;`
`out RadioIndex: Integer;`
`ADefaultRadio: Integer = - 1;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`ADefaultButton: TMsgDlgBtn;`
`const ARadioButtons: array of string;`
`out RadioIndex: Integer;`
`ADefaultRadio: Integer = - 1;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`const ACheckBoxText: string;`
`out Checked: Boolean;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`ADefaultButton: TMsgDlgBtn;`
`const ACheckBoxText: string;`
`out Checked: Boolean;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`const ACheckBoxText: string;`
`out Checked: Boolean;`
`const ARadioButtons: array of string;`
`out RadioIndex: Integer;`
`ADefaultRadio: Integer = - 1;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`ADefaultButton: TMsgDlgBtn;`
`const ACheckBoxText: string;`
`out Checked: Boolean;`
`const ARadioButtons: array of string;`
`out RadioIndex: Integer;`
`ADefaultRadio: Integer = - 1;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload; function TaskDlg(`
`const aCaption: string;`
`const aMsg: string;`
`const aInfo: string;`
`DlgIcon: TTaskDialogIcon;`
`AButtons: TMsgDlgButtons;`
`const ACustomButtons: array of string;`
`ADefaultButton: Integer;`
`const ACheckBoxText: string;`
`out Checked: Boolean;`
`const ARadioButtons: array of string;`
`out RadioIndex: Integer;`
`ADefaultRadio: Integer = - 1;`
`const aFooter: string = '';`
`const aDetails: string = '';`
`const aShowDetails: string = '';`
`const aHideDetails: string = '';`
`AFlags: TTaskDialogFlags = [tfAllowDialogCancellation]`
`):TModalResult; overload;`

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Function result

TModalResult value returned when the task dialog is executed. The default value is mrCancel.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ADefaultButton` |  | Indicates the default button on the task dialog. Button identifiers start at 500 for the task dialog.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ARadioButtons` |  | Array of string values used as the captions for radio buttons displayed on the task dialog.
`RadioIndex` |  | Output parameter used to return the ordinal position for the radio button selected on the task dialog during execution.
`ADefaultRadio` |  | Ordinal position for the default radio button selected when the task dialog is executed. The default value is -1 and indicates that a default radio button has not been specified. The task dialog will default at run-time to the first radio button unless tfNoDefaultRadioButton has been included in Flags.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ADefaultButton` |  | Indicates the default button on the task dialog. Button identifiers start at 500 for the task dialog.
`ARadioButtons` |  | Array of string values used as the captions for radio buttons displayed on the task dialog.
`RadioIndex` |  | Output parameter used to return the ordinal position for the radio button selected on the task dialog during execution.
`ADefaultRadio` |  | Ordinal position for the default radio button selected when the task dialog is executed. The default value is -1 and indicates that a default radio button has not been specified. The task dialog will default at run-time to the first radio button unless tfNoDefaultRadioButton has been included in Flags.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ACheckBoxText` |  | Text displayed as the verification text on the task dialog.
`Checked` |  | Output parameter used to return the checked state for the verification check box on the task dialog.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ADefaultButton` |  | Indicates the default button on the task dialog. Button identifiers start at 500 for the task dialog.
`ACheckBoxText` |  | Text displayed as the verification text on the task dialog.
`Checked` |  | Output parameter used to return the checked state for the verification check box on the task dialog.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ACheckBoxText` |  | Text displayed as the verification text on the task dialog.
`Checked` |  | Output parameter used to return the checked state for the verification check box on the task dialog.
`ARadioButtons` |  | Array of string values used as the captions for radio buttons displayed on the task dialog.
`RadioIndex` |  | Output parameter used to return the ordinal position for the radio button selected on the task dialog during execution.
`ADefaultRadio` |  | Ordinal position for the default radio button selected when the task dialog is executed. The default value is -1 and indicates that a default radio button has not been specified. The task dialog will default at run-time to the first radio button unless tfNoDefaultRadioButton has been included in Flags.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ADefaultButton` |  | Indicates the default button on the task dialog. Button identifiers start at 500 for the task dialog.
`ACheckBoxText` |  | Text displayed as the verification text on the task dialog.
`Checked` |  | Output parameter used to return the checked state for the verification check box on the task dialog.
`ARadioButtons` |  | Array of string values used as the captions for radio buttons displayed on the task dialog.
`RadioIndex` |  | Output parameter used to return the ordinal position for the radio button selected on the task dialog during execution.
`ADefaultRadio` |  | Ordinal position for the default radio button selected when the task dialog is executed. The default value is -1 and indicates that a default radio button has not been specified. The task dialog will default at run-time to the first radio button unless tfNoDefaultRadioButton has been included in Flags.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Arguments

`aCaption` |  | Text displayed as the title bar caption on the task dialog form.
`aMsg` |  | Text displayed as the header-like text in the body of the task dialog.
`aInfo` |  | Text displayed in the main content area on the task dialog immediately after the header text in aMsg.
`DlgIcon` |  | Indicates the icon displayed on the task dialog.
`AButtons` |  | Set with the common buttons displayed on the task dialog. These buttons have a modal result value associated with the button, and can include values like mbOK, mbCancel, mbYes, mbNo, mbRetry, and mbClose.
`ACustomButtons` |  | Array of string values with the captions for custom buttons displayed on the task dialog.
`ADefaultButton` |  | Indicates the default button on the task dialog. Button identifiers start at 500 for the task dialog.
`ACheckBoxText` |  | Text displayed as the verification text on the task dialog.
`Checked` |  | Output parameter used to return the checked state for the verification check box on the task dialog.
`ARadioButtons` |  | Array of string values used as the captions for radio buttons displayed on the task dialog.
`RadioIndex` |  | Output parameter used to return the ordinal position for the radio button selected on the task dialog during execution.
`ADefaultRadio` |  | Ordinal position for the default radio button selected when the task dialog is executed. The default value is -1 and indicates that a default radio button has not been specified. The task dialog will default at run-time to the first radio button unless tfNoDefaultRadioButton has been included in Flags.
`aFooter` |  | Text displayed as the caption in the footer area on the task dialog.
`aDetails` |  | Text displayed in an expandable text area on the task dialog. Include tfExpandedByDefault in Flags to automatically expand the text area in the main body of the task dialog. Include tfExpandFooterArea in Flags to place the detail text in the expandable footer area.
`aShowDetails` |  | Text displayed as the caption for the expand/collapse button when the text area is enabled and collapsed.
`aHideDetails` |  | Text displayed as the caption for the expand/collapse button when the text area is enabled and expanded.
`AFlags` |  | Set of features or behaviors enabled in task dialog. The default value is [tfAllowDialogCancellation] and allows the task dialog to be cancelled.

## Description

TaskDlg is an overloaded function which implements a wrapper used to execute a TTaskDialog with the specified parameter values. TaskDlg is a convenience routine that allows a task dialog to be used in a manner similar to the MessageDlg routine. The overloaded variants allow different features / behaviors to be enabled when the task dialog is executed.

The parameter values are copied to the corresponding properties in the TTaskDialog instance created (and freed after execution) in the routine. The Execute method in the dialog is called to display the dialog form and to capture the result.

The return value is the TModalResult enumeration value returned in the ModalResult property for the TTaskdialog instance. The default value is mrCancel.

Use the Flags argument to indicate whether specific features are enabled (or disabled) when the task dialog is executed. See TTaskDialogFlag for the values allows in the Flags argument and their usage.

See TTaskDialog for more information about the features and behaviors supported in the dialog type.

For example:

    var
      IsChecked: boolean;
      RadioResult: integer;
    begin
      TaskDlg('I am the caption', 'I am the message',
        'Some text as information. Lorem ipsum foo bar.',
        tdiInformation, [mbOk, mbCancel], ['Custom', 'Button', 'first'], 500,
        'Checkbox text', IsChecked, ['radio 1', 'radio 2', 'radio default'],
        RadioResult, 2 {0-based}, 'Example footer text',
        { Can be in body or footer }
        'If there is need for more DETAILS, then the can be added here. ' +
        'And can be controlled by tfExpandedByDefault, tfExpandFooterArea',
        { These have default text, rarely need to be changed }
        'Click to see details', 'Click to hide details',
        [tfAllowDialogCancellation {, tfExpandedByDefault, tfExpandFooterArea}]
        );
    end;

Please note that the TaskDlg wrapper does not provide access to all of the features / behaviors available in TTaskDialog. You must use a TTaskDialog instance to configure and enable those features when parameters are not provided in TaskDlg.

## Version info

Added in LCL version 4.0.

## See also

TTaskDialog |  | Implements a configurable modal task dialog.
TTaskDialogIcon |  | Identifier for an icon displayed on a Task dialog.
TMsgDlgButtons |  | Set type used to store the buttons on a message dialog.
TMsgDlgBtn |  | Identifies dialog button types.
TTaskDialogFlags |  | Set type used to store values from the TTaskDialogFlag enumeration.
TTaskDialogFlag |  | Represents options that can be enabled for TTaskDialog.
MessageDlg |  | Shows a message to the user and gets the response.
TModalResult |  | Dummy type for the values that can be returned as a modal result.