Help & Manual authoring tool
MessageDlg doesn't play the sound corresponding to the dialog type like Application.MessageBox does, but without much coding we can have our own version of MessageDlg playing those sounds

Making MessageDlg play the corresponding sound

Copyright © 2000 Ernesto De Spirito

SMImport - Native VCL components for importing data

The method MessageBox of the Application object plays the system sound associated with the type of the message, but the function MessageDlg doesn't. If you want sounds with MessageDlg then you either have to call the API MessageBeep (declared in the Windows unit) every time you call MessageDlg or use this wrapper for MessageDlg:

interface

uses dialogs, windows;

function MessageDlgS(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons = [mbOk]; HelpCtx: Longint = 0): Word;

implementation

function MessageDlgS(const Msg: string; DlgType: TMsgDlgType;
  Buttons: TMsgDlgButtons; HelpCtx: Longint): Word;
const
  Sounds: array [TMsgDlgType] of integer = (
    MB_ICONEXCLAMATION, MB_ICONHAND, MB_OK,
    MB_ICONQUESTION, MB_ICONASTERISK);
begin
  MessageBeep(Sounds[DlgType]);
  Result := MessageDlg(Msg,DlgType,Buttons,HelpCtx);
end;
JfControls Library - for Delphi and C++ Builder
Copyright © 2000/2006 Ernesto De Spirito.   All rights reserved.