Thread View: borland.public.cppbuilder.multimedia
2 messages
2 total messages
Started by Elisabeth
Thu, 12 May 2005 09:36
alarm
Author: Elisabeth
Date: Thu, 12 May 2005 09:36
Date: Thu, 12 May 2005 09:36
4 lines
958 bytes
958 bytes
Hello, How could I implement a sound (alarm) when an event occurs during execution of my Form Application? (I have not any file with such sound.) Elisabeth
Re: alarm
Author: Mark Jacobs
Date: Thu, 12 May 2005 11:11
Date: Thu, 12 May 2005 11:11
33 lines
2113 bytes
2113 bytes
Elisabeth wrote:
> How could I implement a sound (alarm) when an event occurs during execution
> of my Form Application? (I have not any file with such sound.)
Have a look at the PlaySound Windows API function. Here are a couple of
examples :-
1) Play the system exclamation sound as configured under Windows Control Panel
Sounds
PlaySound("SystemExclamation",HInstance,SND_ALIAS | SND_ASYNC);
2) Play a sound linked into your app using a resource file
PlaySound("emnotify",HInstance,SND_RESOURCE | SND_ASYNC);
The resource file (myproject.rc) in this example is the single line :-
emnotify WAVE "emnotify.wav"
Use a text editor to enter this line into a text file and save it as
myproject.rc, then add that file to your project. The sound then becomes
linked in to your app, so that a separate sound file is no longer necessary -
it is embedded in the executable.
3) Play a sound in a file specified by AnsiString filnam over and over again
until electricity runs out :-
PlaySound(filnam.c_str(),HInstance,SND_FILENAME | SND_ASYNC | SND_LOOP);
4) Stop all sounds playing so far :-
PlaySound(NULL,HInstance,SND_PURGE);
HTH
--
Mark Jacobs
http://www.dkcomputing.co.uk
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads