🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #128

Re: alarm

#128
From: Mark Jacobs
Date: Thu, 12 May 2005 11:11
33 lines
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
Technical Details
Message-ID: <428339c0@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <42832320@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,568e5d9b80215d0f
X-Google-Attributes: gid10d0fc,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 12 May 2005 12:11:37 +0100
From: Mark Jacobs <http://www.jacobsm.com/mjmsg.htm?mj@critical>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.multimedia
Subject: Re: alarm
References: <42832320@newsgroups.borland.com>
In-Reply-To: <42832320@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.144.157.8
Message-ID: <428339c0@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1115896256 81.144.157.8 (12 May 2005 04:10:56 -0700)
Lines: 33
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail