Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
How to have MessageDlg() play the corresponding sound
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Application.MessageBox() and the Windows API function MessageBox() each play the system sound associated with the type of the message, but the VCL function MessageDlg does not. You have to call the API function MessageBeep() before you call MessageBox().
Replace your calls to MessageDlg() with MessageDlgSound() from the example below.  | |  | | function MessageDlgSound(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; | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|