Prev: WM_CLICK
Next: MMControl
From: Rencie on
I want to make a midi file play repeatedly, how do I achieve this in VB 6
using MMControl?
From: Martin Walke on
Hi Rencie,

Unless you want the user controls of the MMControl why not use the
sndPlaySound API

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_playsound.asp


HTH
Martin

"Rencie" <Rencie(a)discussions.microsoft.com> wrote in message
news:E0A3CA4C-E9BB-487B-8FA9-C31AAFAF2D63(a)microsoft.com...
>I want to make a midi file play repeatedly, how do I achieve this in VB 6
> using MMControl?


From: Rencie on
Thank you. Can you give an example on how to use that in Visual Basic?
because, I can't find an example in my MSDN Library Visual Basic
Documentation.
From: Martin Walke on
Hi Rencie

Declare the API call either in your form and use private

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

or in a module and make in public

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Add the constants
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_MEMORY = &H4
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

Then simply

ret = sndPlaySound("c:\windows NT\media\flourish.mid", SND_ASYNC or
SND_LOOP)

To stop the sound, specify the file but without the SND_LOOP flag set

ret = sndPlaySound("c:\windows NT\media\flourish.mid", SND_ASYNC)

There appears to be a problem with using sndPlaySound on XP although it
works for me :). If that is the case then use PlaySound (see previous link
for info) but basically the flags are the same and the definition is :

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

and specify 0 as the second parameter

ret = PlaySound("c:\windows NT\media\flourish.mid", 0, SND_ASYNC or
SND_LOOP)

HTH
Martin

"Rencie" <Rencie(a)discussions.microsoft.com> wrote in message
news:CA531598-C101-4828-ABF1-613BED20C7B7(a)microsoft.com...
> Thank you. Can you give an example on how to use that in Visual Basic?
> because, I can't find an example in my MSDN Library Visual Basic
> Documentation.


From: Rencie on
Thanks a lot, I'll try that and I'll let you know. ok? Thanks again.
 |  Next  |  Last
Pages: 1 2 3 4
Prev: WM_CLICK
Next: MMControl