Yes, it is possible - pulled this code from a project of mine a few years
ago - I also have some advanced code which makes it possible to embed these
sounds (and other things) inside the MBX as well - the API should still be
valid - have fun!
Ralph
include "mapbasic.def"
Declare Sub Main
Declare Sub ButtonAction
Declare Function WAVEcaller(byval sWaveFile as string,byval lWait as
logical) as logical
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal
lpszSoundName As String, ByVal uFlags As Integer) As Logical
'sndPlaySound Def
define SND_ASYNC &H1
'The sound is played asynchronously, and the function returns
'immediately after beginning the sound. To terminate an
'asynchronously played sound, call SndPlaySound with the
'lpszSoundName parameter set to NULL.
define SND_LOOP &H8
'The sound continues to play repeatedly until sndPlaySound
'is called again with the lpszSoundName parameter set to NULL.
'You must also specify the SND_ASYNC flag to loop sounds.
define SND_MEMORY &H4
'The parameter specified by lpszSoundName points to an
'in-memory image of a waveform sound.
define SND_NODEFAULT &H2
'If the sound cannot be found, the function returns
'silently without playing the default sound.
define SND_NOSTOP &H10
'If a sound is currently playing, the function
'immediately returns FALSE without playing the requested sound.
define SND_SYNC &H0
'The sound is played synchronously, and the function
'does not return until the sound ends.
dim iFileLength as integer
Sub Main
dialog title "Seasons Greetings!"
control button title "Tada" ID 1 Calling ButtonAction
control button title "Ding" ID 2 Calling ButtonAction
control button title "Chord" ID 3 Calling ButtonAction
End Sub
Sub ButtonAction
dim a as smallint,runstring as string
a=triggercontrol()
do case a
Case 1
runString="c:\windows\media\tada.wav"
Case 2
runString="c:\windows\media\ding.wav"
Case 3
runString="c:\windows\media\chord.wav"
end case
if not WAVEcaller(runstring,true) then
Note "Sorry"
end if
end sub
Function WAVEcaller(byval sWaveFile as String,byval lWait as logical) as
logical
'platform test
if systeminfo(SYS_INFO_MIPLATFORM)<>MIPLATFORM_WIN32 then beep exit sub end
if
if not lWait then
WAVEcaller= sndPlaySound(sWaveFile, SND_ASYNC + SND_NODEFAULT )
else
WAVEcaller=sndPlaySound(sWaveFile, SND_SYNC+ SND_NODEFAULT)
end if
End Function
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Keith Campbell
Sent: Tuesday, May 30, 2000 8:17 AM
To: Simon W Fox
Cc: [EMAIL PROTECTED]
Subject: Re: MI MB Sound possible???
Simon,
One option is to use the 'Run Program' statement to start another
Windows application that will play a sound clip. You provide the file
name of the clip as part of the argument to the statement.
Keith
> From: Simon W Fox <[EMAIL PROTECTED]>
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: MI MB Sound possible???
> Date: Tue, 30 May 2000 10:57:17 +0100
> Good morning,
>
> I've looked through the archives for any information regarding playing
sound
> through a Mapbasic script. I found several messages asking similar
> questions, but found no answers. From this I take it that, either it's not
> possible or no one out there knows how to do it.
>
> My question is: If I can't do it in Mapbasic, is it possible to do it in
VB?
> and if so, how?
>
> Thanks
>
> Simon
>
>
> ----------------------------------------------------------------------
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
>
Keith Campbell
GIS Consultant
W S Atkins Consultants Ltd
UK
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]