Results 1 to 6 of 6

Thread: [RESOLVED] msgbox sound question

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [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?

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: msgbox sound question

    Try this:

    VB Code:
    1. Option Explicit
    2.     Dim a As Long, i As Long, tmp As String, original As Long, vol As String
    3.    
    4. Private Declare Function waveOutSetVolume Lib "Winmm" _
    5. (ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer
    6.  
    7. Private Declare Function waveOutGetVolume Lib "Winmm" _
    8. (ByVal wDeviceID As Integer, dwVolume As Long) As Integer
    9.  
    10. Private Sub Command1_Click()
    11.     a = waveOutGetVolume(0, i)
    12.     tmp = "&h" & Right(Hex$(i), 4)
    13.     original = CLng(tmp)
    14.         vol = 0
    15.         tmp = Right((Hex$(vol + 65536)), 4)
    16.         vol = CLng("&H" & tmp & tmp)
    17.         a = waveOutSetVolume(0, vol)
    18.        
    19.             MsgBox "No sound...", vbExclamation
    20.            
    21.         vol = original
    22.         tmp = Right((Hex$(vol + 65536)), 4)
    23.         vol = CLng("&H" & tmp & tmp)
    24.         a = waveOutSetVolume(0, vol)
    25.        
    26.             MsgBox "Original sound volume!", vbExclamation
    27. End Sub

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    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?
    Quote Originally Posted by gavio
    Try this:

    VB Code:
    1. Option Explicit
    2.     Dim a As Long, i As Long, tmp As String, original As Long, vol As String
    3.    
    4. Private Declare Function waveOutSetVolume Lib "Winmm" _
    5. (ByVal wDeviceID As Integer, ByVal dwVolume As Long) As Integer
    6.  
    7. Private Declare Function waveOutGetVolume Lib "Winmm" _
    8. (ByVal wDeviceID As Integer, dwVolume As Long) As Integer
    9.  
    10. Private Sub Command1_Click()
    11.     a = waveOutGetVolume(0, i)
    12.     tmp = "&h" & Right(Hex$(i), 4)
    13.     original = CLng(tmp)
    14.         vol = 0
    15.         tmp = Right((Hex$(vol + 65536)), 4)
    16.         vol = CLng("&H" & tmp & tmp)
    17.         a = waveOutSetVolume(0, vol)
    18.        
    19.             MsgBox "No sound...", vbExclamation
    20.            
    21.         vol = original
    22.         tmp = Right((Hex$(vol + 65536)), 4)
    23.         vol = CLng("&H" & tmp & tmp)
    24.         a = waveOutSetVolume(0, vol)
    25.        
    26.             MsgBox "Original sound volume!", vbExclamation
    27. End Sub

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: msgbox sound question

    create your own message box from a form - it gives you much more flexibility

  5. #5
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: msgbox sound question

    Quote 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

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    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
  •  



Click Here to Expand Forum to Full Width