|
-
Sep 1st, 2006, 12:06 AM
#1
Thread Starter
PowerPoster
[RESOLVED] msgbox sound question
when a messagebox comes up on the screen, you hear the default sound, is there anyway whereby that sound can be removed and then a custom sound can be used instead?
-
Sep 1st, 2006, 12:38 AM
#2
Re: msgbox sound question
Try this:
VB Code:
Option Explicit
Dim a As Long, i As Long, tmp As String, original As Long, vol As String
Private Declare Function waveOutSetVolume Lib "Winmm" _
(ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer
Private Declare Function waveOutGetVolume Lib "Winmm" _
(ByVal wDeviceID As Integer, dwVolume As Long) As Integer
Private Sub Command1_Click()
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
original = CLng(tmp)
vol = 0
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
MsgBox "No sound...", vbExclamation
vol = original
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
MsgBox "Original sound volume!", vbExclamation
End Sub
-
Sep 1st, 2006, 03:23 AM
#3
Thread Starter
PowerPoster
Re: msgbox sound question
i am not as advanced in vb as you are but it looks like the code turns sound on and off?
 Originally Posted by gavio
Try this:
VB Code:
Option Explicit
Dim a As Long, i As Long, tmp As String, original As Long, vol As String
Private Declare Function waveOutSetVolume Lib "Winmm" _
(ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer
Private Declare Function waveOutGetVolume Lib "Winmm" _
(ByVal wDeviceID As Integer, dwVolume As Long) As Integer
Private Sub Command1_Click()
a = waveOutGetVolume(0, i)
tmp = "&h" & Right(Hex$(i), 4)
original = CLng(tmp)
vol = 0
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
MsgBox "No sound...", vbExclamation
vol = original
tmp = Right((Hex$(vol + 65536)), 4)
vol = CLng("&H" & tmp & tmp)
a = waveOutSetVolume(0, vol)
MsgBox "Original sound volume!", vbExclamation
End Sub
-
Sep 1st, 2006, 03:42 AM
#4
Re: msgbox sound question
create your own message box from a form - it gives you much more flexibility
-
Sep 1st, 2006, 04:10 AM
#5
Re: msgbox sound question
 Originally Posted by BrailleSchool
i am not as advanced in vb as you are  but it looks like the code turns sound on and off?
Isn't that what you wanted? It sets the volume back to what it was. I don't think there is any other way to do it, unless you create your own message box as Bush proposed
-
Sep 1st, 2006, 12:51 PM
#6
Thread Starter
PowerPoster
Re: msgbox sound question
that might be the way to go... create own msgbox
ill do that once ive completed my app. have a lot done but still a lot more to go thanks guys.
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
|