Is there a way to stop TaskMessageDlg making sounds?

457 Views Asked by At

I want to display a TaskMessageDlg with Information icon but I don't want that beep. Is it possible ?

1

There are 1 best solutions below

2
Andreas Rejbrand On BEST ANSWER

I want to display a TaskMessageDlg with Information icon but I don't want that beep.

Actually, you probably don't. The great thing about the task dialogs introduced in Windows Vista is that they offer a familiar, consistent, and accessible UX on the platform -- if developers use them correctly.

A part of this UX is the use of standard system icons and their associated sounds, which can be configured by the end user.

For visually impaired users, the sound might actually be important. If one particular end user doesn't like these sounds, then (s)he can disable them in the operating system.

Is it possible?

TaskMessageDlg is only one way to display a task dialog in a VCL application, so let us broaden the question to task dialogs in general.

Yes, it is kind of possible. Instead of using the TD_INFORMATION_ICON standard icon, use a custom icon. For instance, you can use Print Screen and Microsoft Paint to create a BMP file with the icon shown on your desktop. Or, you can extract the system icon using LoadIcon, LoadIconWithScaleDown, or (horrors!) by digging into User32.dll manually.


Just as a proof of concept:

  with TTaskDialog.Create(nil) do
    try
      Title := 'Too many frogs have been created.';
      CommonButtons := [tcbOk];
      Flags := [tfUseHiconMain, tfAllowDialogCancellation];
      CustomMainIcon.Handle := LoadIcon(0, IDI_INFORMATION);
      Execute;
    finally
      Free;
    end;