I want to display a TaskMessageDlg with Information icon but I don't want that beep. Is it possible ?
-
This isn't so much a Delphi question as a Windows question. That's because `TaskMessageDlg` is simply a wrapper around the system dialog. You could always use `CreateMessageDialog` to avoid the system dialog. But that won't be a properly themed dialog. Otherwise your question is actually a question about `TaskDialogIndirect`. I'm not aware of an easy way to suppress sounds for you app. Of course, it's easy for you to disable sounds at the system level, and that surely is the right thing to do. – David Heffernan Oct 13 '20 at 11:57
-
No, because in other parts of my application I want Messages with their beeps... – Marus Gradinaru Oct 13 '20 at 12:02
1 Answers
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;

- 105,602
- 8
- 282
- 384
-
I cannot disable them in the operating system because I want sounds with most of the dialogs, but I have one dialog that is used frequently and that sound is anoying... But the solution you gave me it's brilliant ! Thanks ! :) P.S: I do not write applications for commercial use, just for my needs. And I'am not visually impaired... – Marus Gradinaru Oct 13 '20 at 14:16
-