Linedawg
May 9th, 2007, 13:53 PM
Hello guys, I have a stupid question. I was programming a GUI menu screen after I got every thing working I decided to place a wave file to run in the back ground to add more depth to my application. But I realized I have no clue on how to trigger a sound file. Dose any one knows how to write a function, class or even a header file to allow for sounds? Also can I use C++ to active and search for the default soundcard on any windows system or do I have to use direct X?
I try to add this to my main with in the code:
Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Public Const SND_MEMORY = &H4 'play stream
Public Const SND_NOSTOP = &H10 ' no stop
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_PURGE = &H100 ' purge non-static event for task
Public Const SND_LOOP = &H8 ' loop
Public Const SND_NODEFAULT = &H2 ' silence if no file
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
Public Sub PlaySoundStream(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_MEMORY Or SND_ASYNC Or SND_LOOP)
End Sub
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC Or SND_LOOP)
End Sub
Public Sub StopSound()
' Plays a sound from filename.
PlaySound(Nothing, Nothing, SND_NODEFAULT Or SND_FILENAME)
End Sub
End Class
But I had no luck with it, I feel as if I’m missing some thing. So dose any one out there knows of a simple way to trigger a .WAV file to run in the back ground of my menu screen? Also dose any one know how to trigger a sound when you move a mouse curser over a button?
This has been driving my crazy for the past few days. I cant believe I have never tried this before lol but I’m stuck.
I try to add this to my main with in the code:
Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Public Const SND_MEMORY = &H4 'play stream
Public Const SND_NOSTOP = &H10 ' no stop
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_PURGE = &H100 ' purge non-static event for task
Public Const SND_LOOP = &H8 ' loop
Public Const SND_NODEFAULT = &H2 ' silence if no file
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
Public Sub PlaySoundStream(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_MEMORY Or SND_ASYNC Or SND_LOOP)
End Sub
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC Or SND_LOOP)
End Sub
Public Sub StopSound()
' Plays a sound from filename.
PlaySound(Nothing, Nothing, SND_NODEFAULT Or SND_FILENAME)
End Sub
End Class
But I had no luck with it, I feel as if I’m missing some thing. So dose any one out there knows of a simple way to trigger a .WAV file to run in the back ground of my menu screen? Also dose any one know how to trigger a sound when you move a mouse curser over a button?
This has been driving my crazy for the past few days. I cant believe I have never tried this before lol but I’m stuck.
