Mega Code Archive

 
Categories / Delphi / Multimedia
 

MessageDlg with Sound

Title: MessageDlg with Sound Question: In Windows message dialogs appear with a characteristic sound, configurable by the user. The dialogs created with VCLs MessageDlg didn''t sound. But with al little help, they can do it. Answer: Taking the parameter atype, MsgDlg selects the sound and plays it with MessageBeep. Then it calls MessageDlg as usual. function MsgDlg (const msg: string; atype: TMsgDlgType; abuttons: TMsgDlgButtons; helpctx: Longint): Word; var mb: CARDINAL; begin case AType of mtWarning: mb:= MB_ICONEXCLAMATION; mtError: mb:= MB_ICONHAND; mtInformation: mb:= MB_ICONASTERISK; mtConfirmation: mb:= MB_ICONQUESTION; else mb:= $0FFFFFFFF; end; MessageBeep (mb); MsgDlg:= MessageDlg (msg, atype, abuttons, helpctx); end (*MsgDlg*);