我不懂,我没分,但我好学:谁帮我解答这个问题啊?
如何实现点击一个按钮的时候发出一个声音,如电话拨号时,发出拨号声一样?
谢谢了
问题点数:0、回复次数:5Top
1 楼hmhhawkman(千两狂死狼)回复于 2004-12-03 15:54:46 得分 0
beep
让蜂鸣器发声Top
2 楼space6212()回复于 2004-12-03 16:11:06 得分 0
但我不想要哪知声音效果,我要调用一个声音文件,如何实现Top
3 楼wwqna(york)回复于 2004-12-03 16:12:49 得分 0
自己弄个音乐来播放一下就可以了Top
4 楼wwqna(york)回复于 2004-12-03 16:15:06 得分 0
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As LongTop
5 楼wwqna(york)回复于 2004-12-03 16:16:19 得分 0
Private Declare Function auxGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long
Private Declare Function mciGetDeviceID Lib "winmm.dll" Alias "mciGetDeviceIDA" (ByVal lpstrName As String) As Long
Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByVal dwParam2 As Long) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function midiOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long
Private Declare Function midiOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function waveOutGetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, lpdwVolume As Long) As Long
Private Declare Function waveOutSetVolume Lib "winmm.dll" (ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Type lVolType
v As Long
End Type
Private Type VolType
lv As Integer
rv As Integer
End Type
Const SM_CXBORDER = 5
Const SM_CYBORDER = 6
Const VK_SNAPSHOT As Byte = &H2C
Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Const MCI_SET = &H80D
Const MCI_SET_DOOR_OPEN = &H100&
Private Sub Command1_Click() ' PLAY WAV
Command5_Click
Dim i As Long, RS As String, cb As Long, W$
RS = Space$(128)
W$ = "c:\windows\media\robot~17.wav"
i = mciSendString("open waveaudio!" & W$ & " alias sound", RS, 128, cb)
If i Then MsgBox "Error! Probably file not found. Modify the code to point to a .WAV file on your system."
i = mciSendString("play sound", RS, 128, cb)
End Sub
Private Sub Command16_Click() ' Prev CD Track
Dim i As Long, RS As String, cb As Long, W$, s As Long
RS = Space$(128)
i = mciSendString("status cdaudio current track", RS, 128, cb)
If Val(RS) Then
s = Val(RS) - 1
i = mciSendString("status cdaudio position track " & s, RS, 128, cb)
s = Val(RS)
If s Then
i = mciSendString("play cdaudio from " & s, RS, 128, cb)
ProgressBar4.Line (0, 0)-(ProgressBar4.Width, ProgressBar4.Height), ProgressBar4.BackColor, BF
End If
End If
End Sub
Private Sub Command17_Click() ' Next CD Track
Dim i As Long, RS As String, cb As Long, W$, s As Long
RS = Space$(128)
i = mciSendString("status cdaudio current track", RS, 128, cb)
If Val(RS) Then
s = Val(RS) + 1
i = mciSendString("status cdaudio position track " & s, RS, 128, cb)
s = Val(RS)
If s Then
i = mciSendString("play cdaudio from " & s, RS, 128, cb)
End If
End If
End Sub
Private Sub Command18_Click() ' EJECT CD
Command8_Click
Dim i As Long, RS As String, cb As Long, id As Long
RS = Space$(128)
i = mciSendString("open cdaudio", RS, 128, cb)
id = mciGetDeviceID("cdaudio")
i = mciSendCommand(id, MCI_SET, MCI_SET_DOOR_OPEN, 0)
Command8_Click
End Sub
Private Sub Command5_Click() ' STOP WAV
Dim i As Long, RS As String, cb As Long
RS = Space$(128)
i = mciSendString("stop sound", RS, 128, cb)
i = mciSendString("close sound", RS, 128, cb)
End Sub
Private Sub Command3_Click() ' PLAY AVI
Command7_Click
Dim i As Long, RS As String, cb As Long, A$, x As Long, y As Long
RS = Space$(128)
A$ = "d:\winvideo\matts\ktkd.avi"
i = mciSendString("open AVIvideo!" & A$ & " alias movie parent " & Frame1.hWnd & " style child", RS, 128, cb)
' i = mciSendString("put movie window client at 200 0 0 0", RS, 128, cb)
If i Then MsgBox "Error! Probably file not found. Modify the code to point to an .AVI file on your system."
i = mciSendString("play movie", RS, 128, cb)
End Sub
Private Sub Command7_Click() ' STOP AVI
Dim i As Long, RS As String, cb As Long
RS = Space$(128)
i = mciSendString("stop movie", RS, 128, cb)
i = mciSendString("close movie", RS, 128, cb)
End Sub
Private Sub Command15_Click() ' COPY AVI IMAGE
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
Picture1.Move 0, 0, Width, Height
Picture2.Move 0, 0, Frame1.Width, Frame1.Height
DoEvents
Picture1.Picture = Clipboard.GetData
' The positions must be adjusted for Form caption height and border width for exact frame match!
' Also, the Frame size should be adjusted to match the AVI !
Picture2.PaintPicture Picture1.Picture, 0, 0, Frame1.Width, Frame1.Height, Frame1.Left, Frame1.Top, Frame1.Width, Frame1.Height
Clipboard.Clear
Clipboard.SetData Picture2.Image
MsgBox "Image copied to the clipboard."
End Sub
Private Sub Command10_Click() ' PLAY RECORDED WAV
Dim i As Long
i = sndPlaySound("c:\cdtest.wav", 0)
If i = 0 Then MsgBox "Error! Probably file not found. Modify the code to record and play a .WAV file on your system."
End Sub
Private Sub Command11_Click() ' INCREASE WAV VOLUME
Dim id As Long, v As Long, i As Long, lVol As lVolType, Vol As VolType, lv As Double, rv As Double
id = -1 ' the ALL DEVICE id - this will change the master WAVE volume!
i = waveOutGetVolume(id, v)
lVol.v = v
LSet Vol = lVol
lv = Vol.lv: rv = Vol.rv
lv = lv + &HFFF
rv = rv + &HFFF
If lv > 32767 Then lv = lv - 65536
If rv > 32767 Then rv = rv - 65536
Vol.lv = lv
Vol.rv = rv
LSet lVol = Vol
v = lVol.v
i = waveOutSetVolume(id, v)
End Sub
Private Sub Command12_Click() ' DECREASE WAV VOLUME
Dim id As Long, v As Long, i As Long, lVol As lVolType, Vol As VolType, lv As Double, rv As Double
id = -1 ' the ALL DEVICE id - this will change the master WAVE volume!
i = waveOutGetVolume(id, v)
lVol.v = v
LSet Vol = lVol
lv = Vol.lv: rv = Vol.rv
lv = lv - &HFFF
rv = rv - &HFFF
If lv < -32768 Then lv = 65535 + lv
If rv < -32768 Then rv = 65535 + rv
Vol.lv = lv
Vol.rv = rv
LSet lVol = Vol
v = lVol.v
i = waveOutSetVolume(id, v)
End Sub
Top




