很简单地说,比如现在有一个IMAGE1控件,如何在点击它的同时实现调用一个声音文件,比如声音文件放在C:\SOUND.WMV。
形象地说,比如五子棋游戏吧,如何实现点击一下,响一下放棋的声音文件??
请不要写出语法的模板,请以 点击IMAGE1控件,实现播放声音文件 SOUND.WMV (该文件假设存在 C:\ 下),麻烦写出具体可以运行的代码,谢谢!
形象地说,比如五子棋游戏吧,如何实现点击一下,响一下放棋的声音文件??
请不要写出语法的模板,请以 点击IMAGE1控件,实现播放声音文件 SOUND.WMV (该文件假设存在 C:\ 下),麻烦写出具体可以运行的代码,谢谢!
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_ALIAS = &H10000 ' name is a WIN.INI [sounds] entry
Private Const SND_ALIAS_ID = &H110000 ' name is a WIN.INI [sounds] entry identifier
Private Const SND_ALIAS_START = 0 ' must be > 4096 to keep strings in same section of resource file
Private Const SND_APPLICATION = &H80 ' look for application specific association
Private Const SND_ASYNC = &H1 ' play asynchronously
Private Const SND_FILENAME = &H20000 ' name is a file name
Private Const SND_LOOP = &H8 ' loop the sound until next sndPlaySound
Private Const SND_MEMORY = &H4 ' lpszSoundName points to a memory file
Private Const SND_NODEFAULT = &H2 ' silence not default, if sound not found
Private Const SND_NOSTOP = &H10 ' don't stop any currently playing sound
Private Const SND_NOWAIT = &H2000 ' don't wait if the driver is busy
Private Const SND_PURGE = &H40 ' purge non-static events for task
Private Const SND_RESERVED = &HFF000000 ' In particular these flags are reserved
Private Const SND_RESOURCE = &H40004 ' name is a resource name or atom
Private Const SND_SYNC = &H0 ' play synchronously (default)
Private Const SND_TYPE_MASK = &H170007
Private Const SND_VALID = &H1F ' valid flags / ;Internal /
Private Const SND_VALIDFLAGS = &H17201F ' Set of valid flag bits. Anything outsidePrivate Sub Image1_Click()
'只能是 Wav的
PlaySound "C:\SOUND.WAV",ByVal 0&, SND_FILENAME Or SND_ASYNC
End Sub