Using both Delphi 1 and Delphi 2, I want to associate a sound to a click on a button.  I am stuck on my code, and since I never used sound before I am unfamiliar with that area.

Here is the scenario:
Sound file is called click.wav and is stored in directory f:/dmtb (the program directory)

I want to either use the wav file as part of my resources or have it load from file from the program directory.  THe sound would be played when certain buttons in the program are played.

My current code is in error.  What happens is the sound I have in the background will not clear so the wav file can be played.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

duke_nConnect With a Mentor Commented:
sndplaysound('click.wav',snd_nodefault);//windows will wait the //sound to end and then give the "turn" back to your program
sndplaysound('click.wav',snd_async);//if you want to do //something while windows plays the sound
What do you mean "the sound I have in background"??? Of course you have to pause it. You could mix them, but that's hard.
DMM1956Author Commented:
If I have a sound like a Midi playing, the sound I associate with a button will not play.

Note:  the command I am looking for needs to be 16bit code (Delphi 1) as the client side of my DLL must be 16 bit.

Also trying to figure out how to include a wav file as part of the resources so I don't have to distribute the file with the program.

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Midi shouldn't interfear. Another wav would though. How are you playing it?

See this:
" Wav files or system sound when clicked"
-See sndPlaySound in Win32s.HLP

c u
DMM1956Author Commented:
Ooops...slipped accepting the last.  Here is the problem.  SndPlaySnd I believe is 32 BIT.  I need 16bit code to play sound when I click a button within a program.  WIN32 code will not work with what I have in mind.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.