?
Solved

Playing sound holding up application

Posted on 2003-02-24
3
Medium Priority
?
161 Views
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.

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
Comment
Question by:thurst
[X]
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
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
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
Private Const SND_USUAL = SND_ASYNC And SND_NODEFAULT

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

Accepted Solution

by:
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
0
 

Author Comment

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

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