|
-
Jan 29th, 2000, 02:20 AM
#1
Thread Starter
New Member
Hi,
I wish to draw a click event control on the form and when pressed will play a wave file.
Can anyone help me with the code behind the button -- or whatever.
For information I am using VB5 (Professioonal) Edition is that helps !!!
Regards
Bernie
-
Jan 29th, 2000, 03:55 AM
#2
PowerPoster
Hey Bernie
You mean a command button...? 
Use API. Try this:
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 Sub StopSound_Click()
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 StartSound_Click()
StopSound_Click
Dim i As Long, RS As String, cb As Long, W$
RS = Space$(128)
W$ = "c:\windows\media\done.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
Good luck
Regards,
------------------
- Chris
[email protected]
If it ain't broke - don't fix it 
-
Jan 29th, 2000, 03:57 AM
#3
Hyperactive Member
In the module, or the general declarations:
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
(if you put it in the general declarations, only that form can use it, and you have to put the word Private in front of Declare)
In the form_click event, put this:
Call sndPlaySound("file name", SND_ASYNC AND SND_NODEFAULT)
This will play the sound with no default ding or anything if it doesn't find the file, and it will suspend execution until the file is done. To let the program keep running, delete the SND_ASYNC part.
good luck,
bob
P.S. My way's easier.
[This message has been edited by Bob Baddeley (edited 01-29-2000).]
-
Feb 4th, 2000, 06:40 AM
#4
New Member
hehe, now we know that is an ad.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|