Skip to content

TStyledTaskDialog Demo

Overview

This comprehensive demo showcases the TStyledTaskDialog component, demonstrating how to create modern, styled message dialogs and task dialogs with custom buttons, hyperlinks, command links, and auto-click features.

Styled TaskDialog Demo

What You'll Learn

  • Using TStyledTaskDialog vs. standard TTaskDialog
  • Creating styled message dialogs
  • Adding custom buttons and command links
  • Implementing hyperlinks in messages
  • Using auto-click (countdown) dialogs
  • Verification checkboxes
  • Expanded text sections
  • Footer text
  • Custom button widths and alpha blending

Dialog Types

The demo includes multiple ways to show dialogs:

1. Native Dialogs (Standard VCL)

  • Native MessageDlg: Delphi's standard message dialog
  • Native TaskDialog: Delphi's task dialog (Windows Vista+)
  • Native ShowMessage: Simple message box

2. Styled Dialogs

  • StyledMessageDlg: Styled replacement for MessageDlg
  • StyledTaskDialog: Full-featured styled task dialog
  • StyledShowMessage: Simple styled message

Message Dialog Functions

Simple Messages

pascal
// Standard
ShowMessage('Hello World');

// Styled
StyledShowMessage('Hello World');

Message Dialogs with Buttons

pascal
// Standard MessageDlg
if MessageDlg('Delete this item?', mtConfirmation,
  [mbYes, mbNo], 0) = mrYes then
  DeleteItem;

// Styled MessageDlg
if StyledMessageDlg('Delete this item?', mtConfirmation,
  [mbYes, mbNo], 0) = mrYes then
  DeleteItem;

Task Dialogs with Title

pascal
// Standard TaskDialog
TaskMessageDlg('Confirm Delete',
  'Are you sure you want to delete this item?',
  mtConfirmation, [mbYes, mbNo], 0);

// Styled TaskDialog
StyledTaskMessageDlg('Confirm Delete',
  'Are you sure you want to delete this item?',
  mtConfirmation, [mbYes, mbNo], 0);

Dialog Types (TMsgDlgType)

The demo shows all message types:

TypeIconUse Case
mtWarningWarningCaution messages
mtErrorErrorError notifications
mtInformationInfoInformational messages
mtConfirmationQuestionConfirmation questions
mtCustomNoneCustom dialogs

Standard Buttons

Available button combinations:

pascal
// Single button
[mbOK]

// Yes/No
[mbYes, mbNo]

// Yes/No/Cancel
[mbYes, mbNo, mbCancel]

// OK/Cancel
[mbOK, mbCancel]

// Abort/Retry/Ignore
[mbAbort, mbRetry, mbIgnore]

// All buttons
[mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mbHelp]

Default Button

Specify which button is default (Enter key):

pascal
StyledMessageDlg('Save changes?', mtConfirmation,
  [mbYes, mbNo, mbCancel], 0, mbYes);  // Yes is default

Add clickable links to dialog messages:

pascal
LMessage :=
  'The file was created: ' +
  StringToHRef('C:\Windows\System32\license.rtf', 'license.rtf') + sLineBreak +
  'You can run: ' +
  StringToHRef('C:\Windows\System32\Notepad.exe', 'Notepad Editor') + sLineBreak +
  'You can open folder: ' +
  StringToHRef('C:\Windows\System32\') + sLineBreak +
  'You can visit site: ' +
  StringToHRef('http://www.ethea.it', 'www.Ethea.it');

StyledTaskMessageDlg('File Operations', LMessage,
  mtInformation, [mbOK], 0);
  • File paths: Opens the file
  • Executables: Runs the program
  • Folders: Opens in Explorer
  • URLs: Opens in default browser

Using TStyledTaskDialog Component

For advanced features, use the component directly:

pascal
var
  Dialog: TStyledTaskDialog;
begin
  Dialog := TStyledTaskDialog.Create(Self);
  try
    Dialog.Caption := 'Application';
    Dialog.Title := 'Confirm Action';
    Dialog.Text := 'Do you want to proceed?';
    Dialog.CommonButtons := [tcbYes, tcbNo];
    Dialog.DefaultButton := tcbYes;

    // Execute dialog
    if Dialog.Execute then
    begin
      if Dialog.ModalResult = mrYes then
        PerformAction;
    end;
  finally
    Dialog.Free;
  end;
end;

Custom Buttons

Add custom buttons with command links:

pascal
Dialog.CommonButtons := []; // Clear common buttons

// Add custom button with command link
with Dialog.Buttons.Add as TTaskDialogButtonItem do
begin
  Caption := 'Retry';
  CommandLinkHint := 'Retry the operation...';
  ModalResult := mrRetry;
  Default := True;
end;

with Dialog.Buttons.Add as TTaskDialogButtonItem do
begin
  Caption := 'Cancel';
  CommandLinkHint := 'Cancel and return...';
  ModalResult := mrCancel;
end;

// Enable command links
Dialog.Flags := Dialog.Flags + [tfUseCommandLinks];

Auto-Click Feature

Dialogs can auto-close after a delay:

pascal
// Auto-click after 5 seconds
StyledTaskDialog.AutoClickDelay := 5000;
StyledTaskDialog.AutoClick := True;

// Or use the function parameter
StyledTaskMessageDlg('Auto-closing dialog',
  'This will close in 5 seconds',
  mtInformation, [mbOK], 0, mbOK,
  5000);  // 5000ms = 5 seconds

The button background color is drawn progressively for each second of AutoClickDelay duration.

Expanded Text

Add collapsible detail text:

pascal
Dialog.ExpandedText :=
  'Technical Details:' + sLineBreak +
  'Error Code: 0x80004005' + sLineBreak +
  'Module: DataAccess.dll' + sLineBreak +
  'Function: Connect';
Dialog.ExpandButtonCaption := 'Show Details';

Add footer information:

pascal
Dialog.FooterText := 'For more information, visit www.example.com';
Dialog.FooterIcon := tdiInformation;

Verification Checkbox

Add a "Don't show again" option:

pascal
Dialog.VerificationText := 'Don''t show this message again';
Dialog.Flags := Dialog.Flags + [tfVerificationFlagChecked];

// Check if user checked it
if Dialog.Execute then
begin
  if tfVerificationFlagChecked in Dialog.Flags then
    SaveSetting('DontShowAgain', True);
end;

Custom Button Width

Adjust button width:

pascal
StyledTaskDialog.ButtonsWidth := 120;  // 120 pixels

Alpha Blending

Set dialog transparency:

pascal
StyledTaskDialog.AlphaBlend := True;
StyledTaskDialog.AlphaBlendValue := 240;  // 0-255 (255 = opaque)

Style Families

Choose button style family for the dialog:

pascal
InitializeStyledTaskDialogs('Bootstrap');
// Now all styled dialogs use Bootstrap buttons

InitializeStyledTaskDialogs('Angular-Light');
// Now all styled dialogs use Angular buttons

Initialization

Initialize dialog defaults in your application startup:

pascal
begin
  Application.Initialize;

  // Initialize StyledTaskDialogs with Bootstrap buttons
  InitializeStyledTaskDialogs(
    True,                    // Use title in MessageDlg
    Screen.MessageFont,      // Font to use
    False,                   // Use command links
    'Bootstrap',             // Button family
    255,                     // Alpha blend (255 = opaque)
    120,                     // Button width
    32,                      // Button height
    -1);                     // Auto-click delay (-1 = disabled)

  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
end;

Error Handling

Show errors with styled dialogs:

pascal
procedure TForm.ShowError(Sender: TObject; E: Exception);
var
  LTitle: string;
begin
  LTitle := GetErrorClassNameDesc(E.ClassName,
    E is EAccessViolation);

  StyledTaskMessageDlg(LTitle, E.Message,
    mtError, [mbOK], E.HelpContext);
end;

// In FormCreate:
Application.OnException := ShowError;

Demo Features

The demo form includes:

Controls

  • Dialog Type: Choose message type
  • Buttons: Select which buttons to show
  • Default Button: Choose default button
  • Title: Set dialog title
  • Message: Set dialog message text
  • Caption: Set dialog window caption
  • Expanded Text: Collapsible details
  • Footer Text: Footer information
  • Verification Text: Checkbox text
  • Main Icon: Dialog icon type

Options

  • Use Command Links: Enable command link buttons
  • Use Title in MessageDlg: Show title in simple dialogs
  • Auto Click: Enable countdown auto-close
  • Auto Click Delay: Countdown duration

Test Buttons

  • Native ShowMessage: Standard Windows message
  • Styled ShowMessage: Styled message
  • Native MessageDlg: Standard message dialog
  • Styled MessageDlg: Styled message dialog
  • Native TaskDialog: Standard task dialog
  • Styled TaskDialog: Styled task dialog
  • Use DialogComp (Native): Standard TTaskDialog component
  • Use DialogComp (Styled): TStyledTaskDialog component

Advanced Examples

Progress Dialog

pascal
Dialog.Title := 'Processing...';
Dialog.Text := 'Please wait while processing';
Dialog.CommonButtons := [tcbCancel];
Dialog.Flags := Dialog.Flags + [tfShowProgressBar];
Dialog.Execute;

Radio Button Dialog

pascal
with Dialog.RadioButtons.Add do
begin
  Caption := 'Option 1';
  Enabled := True;
end;

with Dialog.RadioButtons.Add do
begin
  Caption := 'Option 2';
  Enabled := True;
end;

if Dialog.Execute then
  ShowMessage('Selected: ' + Dialog.RadioButton.Caption);

Animated Dialogs (with Skia4Delphi)

AnimatedStyledDialog.gif

If Skia4Delphi is installed:

pascal
{$IFDEF SKIA}
StyledTaskDialog.UseAnimations := True;
{$ENDIF}

This enables Lottie animations in dialogs.

Technical Details

Source Location

Demos/source/StyledDialogDemoForm.pas

Dialog Units

  • Vcl.StyledTaskDialog.pas - Main dialog component
  • Vcl.StyledTaskDialogFormUnit.pas - Dialog form base
  • Skia.Vcl.StyledTaskDialogAnimatedUnit.pas - Animated version (optional)

Supported Versions

All Delphi versions (XE6+)

Key Functions

FunctionDescription
StyledShowMessage()Simple message
StyledMessageDlg()Message with buttons
StyledTaskMessageDlg()Task dialog with title
InitializeStyledTaskDialogs()Set default options

See Also

Released under Apache License, Version 2.0.