TStyledTaskDialog - Technical Reference
Overview
TStyledTaskDialog is an advanced task dialog component that replaces MessageDlg and TaskDialog with fully customizable dialogs featuring styled buttons and optional animations.
Class Hierarchy
TComponent
└─ TCustomTaskDialog
└─ TStyledTaskDialogUnit
pascal
Vcl.StyledTaskDialogDescription
TStyledTaskDialog provides a modern, fully customizable alternative to standard Windows dialogs. It supports styled buttons, custom icons, animations (via Skia4Delphi), progress bars, command links, radio buttons, verification checkboxes, and much more.
Key Features
- Styled buttons: Full StyleFamily/Class/Appearance support
- Custom icons: ImageList or animated icons (Lottie files via Skia4Delphi)
- Progress bar: Determinate or marquee progress indicators
- Command links: Large clickable areas with descriptions
- Radio buttons: Multiple-choice options
- Verification checkbox: "Don't show this again" option
- Expandable content: Collapsible additional information
- Footer: Optional footer area with text and icon
- Auto-click: Automatic button click after delay
- Full customization: Complete control over appearance
Main Properties
Dialog Content
| Property | Type | Description |
|---|---|---|
Title | String | Dialog title/caption |
Text | String | Main message text |
ExpandedText | String | Additional expandable information |
ExpandButtonCaption | String | Caption for expand button |
FooterText | String | Footer text |
VerificationText | String | Verification checkbox text |
Icons
| Property | Type | Description |
|---|---|---|
MainIcon | TTaskDialogIcon | Main icon (tdiNone, tdiWarning, tdiError, tdiInformation, tdiShield, tdiQuestion) |
CustomMainIcon | TIcon | Custom icon instead of standard |
FooterIcon | TTaskDialogIcon | Footer icon |
MainIconSize | Integer | Size of main icon |
Buttons
| Property | Type | Description |
|---|---|---|
CommonButtons | TTaskDialogCommonButtons | Standard buttons ([tcbOk, tcbYes, tcbNo, tcbCancel, tcbRetry, tcbClose]) |
CustomButtons | TTaskDialogButtons | Custom button collection |
DefaultButton | TTaskDialogCommonButton | Which button is default |
DialogButtonsFamily | TStyledButtonFamily | Style family for buttons |
Style Properties
| Property | Type | Description |
|---|---|---|
UseTitleInMessageDlg | Boolean | Show title in simple message dialogs |
UseCommandLinks | Boolean | Use command link style for buttons |
AlphaBlendValue | Byte | Dialog transparency (0-255) |
Progress Bar
| Property | Type | Description |
|---|---|---|
ProgressBar.Min | Integer | Minimum progress value |
ProgressBar.Max | Integer | Maximum progress value |
ProgressBar.Position | Integer | Current progress position |
ProgressBar.State | TProgressBarState | State (pbsNormal, pbsError, pbsPaused) |
ProgressBar.Style | TProgressBarStyle | Style (pbstNormal, pbstMarquee) |
Radio Buttons
| Property | Type | Description |
|---|---|---|
RadioButtons | TTaskDialogButtons | Radio button options |
DefaultRadioButton | Integer | Default selected radio button |
Animations (Skia4Delphi)
| Property | Type | Description |
|---|---|---|
UseAnimations | Boolean | Enable Lottie animations for icons |
UseAnimationLoop | Boolean | Loop animation continuously |
UseAnimationInverse | Boolean | Play animation in reverse |
Auto-Click
| Property | Type | Description |
|---|---|---|
AutoClick | Boolean | Automatically click button after delay |
AutoClickDelay | Integer | Delay before auto-click (milliseconds) |
Behavior
| Property | Type | Description |
|---|---|---|
Flags | TTaskDialogFlags | Dialog behavior flags |
Position | TPoint | Custom dialog position |
HideSystemCloseButton | Boolean | Hide X button in title bar |
Events
| Event | Description |
|---|---|
OnDialogCreated | Dialog form created (before shown) |
OnDialogShow | Dialog is being shown |
OnDialogConstructed | Dialog constructed (after shown) |
OnDialogDestroyed | Dialog closed and destroyed |
OnButtonClicked | Button clicked (can cancel) |
OnHyperlinkClicked | Hyperlink in text clicked |
OnRadioButtonClicked | Radio button selected |
OnVerificationClicked | Verification checkbox clicked |
OnExpanded | Expandable content shown/hidden |
Usage Examples
Simple Message Dialog
pascal
uses
Vcl.StyledTaskDialog;
begin
StyledMessageDlg('File saved successfully!', mtInformation, [mbOK], 0);
end;Confirmation Dialog
pascal
var
Dlg: TStyledTaskDialog;
begin
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Confirm Delete';
Dlg.Text := 'Are you sure you want to delete this file?';
Dlg.MainIcon := tdiWarning;
Dlg.CommonButtons := [tcbYes, tcbNo];
Dlg.DefaultButton := tcbNo;
Dlg.DialogButtonsFamily := BOOTSTRAP_FAMILY;
if Dlg.Execute then
if Dlg.ModalResult = mrYes then
DeleteFile(FileName);
finally
Dlg.Free;
end;
end;Dialog with Custom Buttons
pascal
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Choose Action';
Dlg.Text := 'What would you like to do?';
Dlg.MainIcon := tdiInformation;
with Dlg.CustomButtons.Add do
begin
Caption := 'Save and Continue';
ModalResult := 100;
end;
with Dlg.CustomButtons.Add do
begin
Caption := 'Discard Changes';
ModalResult := 101;
end;
Dlg.DialogButtonsFamily := BOOTSTRAP_FAMILY;
if Dlg.Execute then
case Dlg.ModalResult of
100: SaveAndContinue;
101: DiscardChanges;
end;
finally
Dlg.Free;
end;Dialog with Progress Bar
pascal
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Processing';
Dlg.Text := 'Please wait while files are being processed...';
Dlg.MainIcon := tdiInformation;
Dlg.CommonButtons := [tcbCancel];
Dlg.ProgressBar.Style := pbstMarquee; // Indeterminate progress
Dlg.Execute;
finally
Dlg.Free;
end;Dialog with Radio Buttons
pascal
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Choose Format';
Dlg.Text := 'Select export format:';
Dlg.MainIcon := tdiQuestion;
Dlg.CommonButtons := [tcbOk, tcbCancel];
Dlg.RadioButtons.Add.Caption := 'PDF Document';
Dlg.RadioButtons.Add.Caption := 'Excel Spreadsheet';
Dlg.RadioButtons.Add.Caption := 'Word Document';
Dlg.DefaultRadioButton := 0;
if Dlg.Execute and (Dlg.ModalResult = mrOk) then
case Dlg.RadioButton.ID of
0: ExportToPDF;
1: ExportToExcel;
2: ExportToWord;
end;
finally
Dlg.Free;
end;Dialog with Verification Checkbox
pascal
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Important Information';
Dlg.Text := 'This is an important message.';
Dlg.MainIcon := tdiInformation;
Dlg.CommonButtons := [tcbOk];
Dlg.VerificationText := 'Don''t show this message again';
Dlg.Execute;
if tfVerificationFlagChecked in Dlg.Flags then
// Save preference not to show again
SaveSetting('ShowImportantMessage', False);
finally
Dlg.Free;
end;Dialog with Expandable Content
pascal
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Error Occurred';
Dlg.Text := 'An error occurred while processing your request.';
Dlg.ExpandedText := 'Technical details:' + #13#10 + ExceptionMessage;
Dlg.ExpandButtonCaption := 'Show Details';
Dlg.MainIcon := tdiError;
Dlg.CommonButtons := [tcbOk];
Dlg.Execute;
finally
Dlg.Free;
end;Auto-Close Dialog
pascal
Dlg := TStyledTaskDialog.Create(Self);
try
Dlg.Title := 'Operation Complete';
Dlg.Text := 'This dialog will close automatically in 5 seconds.';
Dlg.MainIcon := tdiInformation;
Dlg.CommonButtons := [tcbOk];
Dlg.AutoClick := True;
Dlg.AutoClickDelay := 5000;
Dlg.Execute;
finally
Dlg.Free;
end;Global Dialog Configuration
pascal
// In project DPR file
uses
Vcl.StyledButton, Vcl.ButtonStylesAttributes, Vcl.StyledTaskDialog;
begin
Application.Initialize;
// Set default button style
TStyledButton.RegisterDefaultRenderingStyle(
btRounded,
BOOTSTRAP_FAMILY,
btn_primary,
BOOTSTRAP_NORMAL
);
// Initialize styled dialogs with font and button family
InitializeStyledTaskDialogs(
True, // Use styled dialogs
Screen.MessageFont, // Dialog font
BOOTSTRAP_FAMILY // Button family
);
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.Helper Functions
StyledMessageDlg
Replacement for MessageDlg:
pascal
function StyledMessageDlg(const Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;StyledTaskMessageDlg
Alternative task dialog function:
pascal
function StyledTaskMessageDlg(const Title, Msg: string; DlgType: TMsgDlgType;
Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;InitializeStyledTaskDialogs
Configure global dialog settings:
pascal
procedure InitializeStyledTaskDialogs(
AUseStyledDialogs: Boolean;
ADialogFont: TFont;
ADialogButtonsFamily: TStyledButtonFamily);Important Notes
- Replaces MessageDlg: Use StyledMessageDlg instead of MessageDlg
- Animations: Require Skia4Delphi for Lottie animation support
- Custom Forms: Can use custom dialog forms via TStyledTaskDialogForm
- DPI Aware: Automatically scales with DPI changes
- Modal Result: Returns standard modal results (mrOk, mrCancel, etc.) or custom values
See Also
- TStyledButton - Styled button used in dialogs
- AutoClick Guide - Auto-click feature documentation
