How to Invoke MessageBeep API to Play System Alert .WAV SoundsLast reviewed: February 18, 1996Article ID: Q110103 |
The information in this article applies to:
SUMMARYThis article describes how to invoke the MessageBeep API function to play the waveform sound associated with a given Windows system alert level. This is useful for playing a sound such as when you display a message box with the MsgBox statement.
MORE INFORMATIONThe sound for each Windows alert level is identified by an entry in the [sounds] section of the WIN.INI initialization file. You can use the Windows Control Panel to change this [sounds] section. The MessageBeep API function returns control to Visual Basic immediately after queuing a sound. The Visual Basic program executes subsequent code while the MessageBeep sound plays asynchronously. The MessageBeep API function accepts one parameter, which can have one of the following values:
Parameter Value Meaning -1 Produces a standard beep sound by using the computer speaker. MB_ICONASTERISK Plays the sound identified by the SystemAsterisk entry in the [sounds] section of WIN.INI. MB_ICONEXCLAMATION Plays the sound identified by the SystemExclamation entry in the [sounds] section of WIN.INI. MB_ICONHAND Plays the sound identified by the SystemHand entry in the [sounds] section of WIN.INI. MB_ICONQUESTION Plays the sound identified by the SystemQuestion entry in the [sounds] section of WIN.INI. MB_OK Plays the sound identified by the SystemDefault entry in the [sounds] section of WIN.INI. Example: How to Invoke MessageBeep API Function
Windows Sound Events Are Not StandardizedWindows version 3.1 allows you to assign waveform audio sounds to certain events through the Control Panel. These events are:
Default Beep Exclamation Windows Start Windows Exit Critical Stop Question AsteriskSystem sounds are dependent upon the application in which they occur. To produce a sound, an application needs to notify Windows that a sound is to occur, and then tell Windows which system sound to play. The application will specify one of the seven default system sounds or any sound event that it has added to this list. This means that you cannot add sound events to the default list and have an application play that sound, unless the application has been specifically written to call that sound event. Additionally, applications for Windows have not standardized on when these sound events should occur. Therefore, one application may play the Default Beep sound when an error occurs while another application might play the Critical Stop sound.
Parameters for MsgBox Statement
Const MB_ICONSTOP = 16 ' Critical message; displays STOP icon. Const MB_ICONQUESTION = 32 ' Warning query; displays ? icon. Const MB_ICONEXCLAMATION = 48 ' Warning message; displays ! icon. Const MB_ICONINFORMATION = 64 ' Information message; displays i icon. Const MB_OK = 0 ' OK button only Const MB_OKCANCEL = 1 ' OK and Cancel buttons Const MB_ABORTRETRYIGNORE = 2 ' Abort, Retry, and Ignore buttons Const MB_YESNOCANCEL = 3 ' Yes, No, and Cancel buttons Const MB_YESNO = 4 ' Yes and No buttons Const MB_RETRYCANCEL = 5 ' Retry and Cancel buttons Const MB_APPLMODAL = 0 ' Application Modal Message Box Const MB_DEFBUTTON1 = 0 ' First button is default Const MB_DEFBUTTON2 = 256 ' Second button is default Const MB_DEFBUTTON3 = 512 ' Third button is default Const MB_SYSTEMMODAL = 4096 'System ModalThe above parameters for the MsgBox statement can also be found in any of the following sources:
|
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |