Playing sound holding up application

Posted on 2003-02-24
Medium Priority
Last Modified: 2010-05-03
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.



Private Sub Form_Load()

Dim Sound As Long

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
Question by:thurst
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 53

Expert Comment

ID: 8014759
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

'Sample call
Call dcPlaySound("C:\windows\media\The Microsoft Sound.wav", 0, SND_USUAL)

Accepted Solution

flopperman earned 820 total points
ID: 8017829
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

Author Comment

ID: 8021688
Cheers.  You don't know how much that use to BUG me. (no pun intended).

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question