But, what is the code to stop music through a clicking a button in the same form i.e.
Thank you
There is another API function (i dont remember exactly, but maybe the SendMessage() function) can play wave sound file also, and it can stop the playing progess, pause the progess, as well as get the current possition of playing progess. Let me find again and tell you latter.
But if you want stop playing sound file only by sndPlaySound() Function when one button was clicked, do it manually by your-selft with no need one more functions. First, create one Wave Sound File called : "nothing.wav". This is simply the wave sound file with very short play-lenght almost silent (ex: lenght <= 1second). When you want stop playing the background sound, simply call sndPlaySound() to play "nothing.wav" without SND_LOOP parametter. The sound-card will play "nothing.wav" (instead of background music) to the end of file and automatically stop playing.
Each time you load the form, the sound-card will play the background music for loop, and each time you press the Stop button, the sound card will play the "nothing.wav" and then stop playing. Maybe, this is not the best way to stop playing, but at least it resolve your problem.