• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

Playing sound holding up application

I have a problem with my about screen.  I have rigged it so it currently plays a sound when it loads....Which is fine except that you have to wait until the sound finishes before accessing any of the buttons on that screen.

I want it to work as a normal about screen would...where it plays the sound but you can still access the screen functionality while its playing.

Suggestions?


-----

Private Sub Form_Load()

Dim Sound As Long

frmAbout.Show
Me.Caption = "About " & App.Title
lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
lblTitle.Caption = App.Title

DoEvents ' Passing time back to CPU..

'Plays a tune when the about screen is opened
Sound = sndPlaySound("The Microsoft Sound.wav", SND_SYNC Or SND_NODEFAULT)

End Sub
0
thurst
Asked:
thurst
1 Solution
 
DhaestCommented:
Try it with a api-call

Private Declare Function dcPlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_SYNC = &H0
Private Const SND_ASYNC = &H1
Private Const SND_NODEFAULT = &H2
Private Const SND_LOOP = &H8
Private Const SND_NOSTOP = &H10
Private Const SND_USUAL = SND_ASYNC And SND_NODEFAULT

'Sample call
Call dcPlaySound("C:\windows\media\The Microsoft Sound.wav", 0, SND_USUAL)
0
 
floppermanCommented:
I believe that the two functions ends up in the same code eventually.

The trick is the flags to the sndPlaySound function. When you are using SND_SYNC the call does not return until the sound is finished. But if you use SND_ASYNC (asynchronous) the function returns immediatly.

So your flags should be: SND_ASYNC Or SND_NODEFAULT
0
 
thurstAuthor Commented:
Cheers.  You don't know how much that use to BUG me. (no pun intended).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now