I have the code below :
IF MessageDlg('Delete?',mtConfirmation,[mbYes,mbNo],0) = MrYes THEN
Begin
///Do Something;
End
Else
Begin
///Do Something;
End;
When the Style
is Windows
the MessageDlg
function play the sound , but if I change the Style
to Windows 10
for exemple, then the sound does not work.
Why the sound does not exist when I select a Style
?
How can I fix that ?
Note : I'm working on Delphi 10 Seattle.
Update:
I try MessageBeep(MB_ICONQUESTION);
as David Heffernan suggest in his Answer, but that also does not emit a sound.
To complement the David answer, depending of your Windows version, the current active style and others checks the MessageDlg function is implemented using a Custom TForm or using the TTaskDialog class (this is a wrapper for the Windows Task Dialog). So as workaround you can use the TTaskDialog class directly and add the Vcl.Styles.Hooks unit to your project to style that kind of dialog.
uses
Vcl.Styles.Hooks;
procedure TForm56.Button1Click(Sender: TObject);
var
LTaskDialog : TTaskDialog;
begin
LTaskDialog := TTaskDialog.Create(Self);
try
LTaskDialog.Caption := 'Confirm';
LTaskDialog.Text := 'Delete ?';
LTaskDialog.CommonButtons := [tcbYes, tcbNo];
LTaskDialog.MainIcon := tdiInformation;
if LTaskDialog.Execute then
if LTaskDialog.ModalResult = mrYes then
begin
end;
finally
LTaskDialog.Free;
end;