Sign in Join
Wiki copytemporary

TTaskDialog

English · Français · Suomi · Русский · 中文(中国)

TTaskDialog is a non-visual component, which shows full-featured dialogs at runtime, dialogs with rich features like Windows TaskDialog API has. It is available on the Dialogs tab of the Component Palette. It is available since Lazarus 1.8.

Dialog is shown with the Execute() method, and if this returns True, property ModalResult has ModalResult of the pressed button:

Execute returns True if the dialog was opened successfully. On Windows Vista and up, a native dialog is show, which may fail (because of inconsistent parameters), in which case an emulated taskdialog is shown. On all other platforms the emulated dialog is shown. So, in effect the result value of Execute will always be True.

Property MainIcon can be set to values for standard icons: none, warning, error, information, shield.

Property RadioButton has the radio-button object, which was clicked.

Example

This example shows how to create dialog in runtime, and to add custom buttons in runtime:

pascal
  with TTaskDialog.Create(self) do
    try
      Title := 'Confirm removal';
      Caption := 'Confirm';
      Text := 'Remove selected item?';
      CommonButtons := [];
      with TTaskDialogButtonItem(Buttons.Add) do
      begin
        Caption := 'Remove';
        ModalResult := mrYes;
      end;
      with TTaskDialogButtonItem(Buttons.Add) do
      begin
        Caption := 'Keep';
        ModalResult := mrNo;
      end;
      MainIcon := tdiQuestion;
      if Execute then
        if ModalResult = mrYes then
          ShowMessage('Item removed');
    finally
      Free;
    end

See also


From the Free Pascal wiki, page "TTaskDialog", as it stood on 2023-11-11 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.