delphidelphi-12-athensttaskdialog

How to show a custom icon in Delphi's TTaskDialog?


In a Delphi 12.1 VCL Application in Windows 11, I am trying to set up a TTaskDialog at design-time:

object TaskDialog2: TTaskDialog
  Buttons = <>
  Caption = 'Choose an Action'
  RadioButtons = <
    item
      Caption = 'Create a shortcut to this folder'
    end
    item
      Caption = 'Copy the folder and all its contents'
    end>
  Text = 'How do you want to insert the Folder?'
  Left = 676
  Top = 396
end

But there is no question mark choice for the MainIcon property.

I can load my own question mark ICO in CustomMainIcon at design-time. But how to show that CustomMainIcon?

The loaded CustomMainIcon is neither shown at design-time (with 'Test Dialog') nor at run-time (with TaskDialog2.Execute).


Solution

  • Per Delphi's documentation:

    https://docwiki.embarcadero.com/Libraries/en/Vcl.Dialogs.TCustomTaskDialog.CustomMainIcon

    Indicates the custom main icon, if any, for the Task Dialog.

    CustomMainIcon points to the custom main icon for this Task Dialog, if tfUseHiconMain is set in Flags.

    The tfUseHiconMain flag is disabled by default. Your setup needs to enable it.