1

I am using Delphi 10.4. This is a Windows VCL Application.

I wanted to convert all my ShowMessage, MessageDlg and MessageBox calls to TaskDialogs in my program. When I tried to do that, I couldn't get TaskDialog to display anything.

So what I did was create a new minimal VCL application, simply added a button and a TaskDialog to it:

enter image description here

This was my code:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    TaskDialog1: TTaskDialog;
    procedure MyMessageBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;                                                 

var
  Form1: TForm1;

implementation

procedure TForm1.MyMessageBox;
begin
  Form1.TaskDialog1.Caption := 'My Application';
  Form1.TaskDialog1.Title := 'Hello World!';
  Form1.TaskDialog1.Text := 'I am a TTaskDialog, that is, a wrapper for the Task Dialog introduced ' +
              'in the Microsoft Windows Vista operating system. Am I not adorable?';
  Form1.TaskDialog1.CommonButtons := [tcbClose];
  Form1.TaskDialog1.Execute;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyMessageBox;
end;

{$R *.dfm}

begin

Application.Run;

end.

That worked fine. When running it and pressing Button1, I get:

enter image description here

So now I go to my application. I add a button to my main form, and set the MyMessageBox procedure to this:

procedure TLogoAppForm.MyMessageBox;
begin
  ShowMessage('ShowMessage ......................................');
  Application.MessageBox('Application.MessageBox ...........................', 'Error', 0);
  MessageDlg('MessageDlg ................................', mtWarning, [mbOk], 0);

  LogoAppForm.TaskDialog1.Caption := 'My Application';
  LogoAppForm.TaskDialog1.Title := 'Hello World!';
  LogoAppForm.TaskDialog1.Text := 'I am a TTaskDialog, that is, a wrapper for the Task Dialog introduced ' +
              'in the Microsoft Windows Vista operating system. Am I not adorable?';
  LogoAppForm.TaskDialog1.CommonButtons := [tcbClose];
  LogoAppForm.TaskDialog1.Execute;
end;

Pressing the button in my application correctly brings up each of the ShowMessage, MessageBox and MessageDlg windows in sequence, but after closing the MessageDlg window, nothing at all appears for the TaskDialog.

Does anyone know what might be causing TaskDialog to not work in my application and how I might fix this?

0

1 Answer 1

6

You must enable runtime themes for the VCL TTaskDialog to work. Go to Project/Options/Application/Manifest to do so.

Sign up to request clarification or add additional context in comments.

1 Comment

Do you have the same problem if you call the Win32 API TaskDialog() or TaskDialogIndirect() function directly? If so, that will give you an HRESULT error code saying why it is failing. If the functions do not fail, but the TTaskDialog component does, then it has to be a bug in TTaskDialog in 10.4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.