sound

Pages: 12
I need to know how to use a sound with the windows program.
Sutch as when you push a button it will play a sound.
Without useing the Beep(,); command.

do you have eny idea?

I LOVE REPLIES!
If you just want to play .wav files, the easiest way is with PlaySound:

http://msdn.microsoft.com/en-us/library/ms712879(v=vs.85).aspx

Samples included on that page.
The Microsoft web page did not help. Do you have eny more ideas?
That web page he gave you tells you everything you need to know to play a simple windows sound in a Window program. You can set to play when a button is pushed or when some other action is performed. What exactly is it that you don't understand?
The Microsoft web page did not help.


There are examples at the bottom of the page.

You should be able to copy/paste and sub in your information.

If that isn't good enough for you I don't know what else we could do.
I tride to compile and run but it dose not use a sound!
can you give me an exampol?
Do you have a .wav file that you want to play? If yes, you can use this example:

PlaySound(TEXT("recycle.wav"), NULL, SND_FILENAME);

Do you want to play one of the built-in system sounds? If yes, you can use this example:

PlaySound((LPCTSTR)SND_ALIAS_SYSTEMSTART, NULL, SND_ALIAS_ID);

Note that both of these examples are just copy/pasted from that page I linked.
When i compiled it said

[Linker error] undefined reference to `PlaySoundA@12'
You'll have to link to winmm.lib

How you do that depends on what IDE you're using. Is this VC++?
C++
How do you link winmm.lib?
C++ is a language, not an IDE.

When you open your C++ program to write code, what is that program called? Is it Microsoft Visual C++?
dev-cpp
I'm afraid I'm not familiar with how to use that particular IDE.

However a google search of "Dev C++ how to link libraries" turned up this page:

http://www.bloodshed.net/faq.html#9

Do that, but try linking to -lwinmm instead of -lopengl32 like it is saying.
ty98, DevC++ is not an advisable IDE to use: http://www.cplusplus.com/forum/articles/36896/
Disch wrote:
How you do that depends on what IDE you're using. Is this VC++?
ty98 wrote:
C++
Disch wrote:
C++ is a language, not an IDE.


I rofl'd.

If you're having difficulty, I'd recommend dropping bloodshed... I'd pick up code::blocks, or heck even VC++express.

INSTRUCTIONS for bloodshed:
Select the project file in the File view, select Project => Settings , and then select the Link tab.

Add winmm.lib to the Object/library modules entry. To do this in Dev-C++, right-click on your project and select Project options. The Project options window opens.

In the Linker Options/Optional Libs or Object files field, enter -lwinmm

heck even VC++express

Awww :( VC++ Express is awesome. IMO the Code Prediction & documentation popups beats Code::Blocks anyday. And more of C++0x seemed to work as well.
Oh, and also SFML will do what you want. http://sfml-dev.org/

You can load and play a sound with it in three lines I think. And handling input isn't many more.
I would definitely switch to VC++ express if you are having problems here. IMO, only people who know what they are doing should be using other compilers/linkers, as there is far more support for MS VS.
What is VC++?!?!?!
Pages: 12