Using Win32 functions in Visual FoxPro Image Gallery
Windows Multimedia
..msdn
AVIFileExit
AVIFileGetStream
AVIFileInfo
AVIFileInit
AVIFileOpen
AVIFileRelease
AVIFileWriteData
AVIStreamGetFrame
AVIStreamGetFrameClose
AVIStreamGetFrameOpen
AVIStreamInfo
AVIStreamLength
AVIStreamReadFormat
AVIStreamRelease
AVIStreamStart
AVIStreamTimeToSample
capCreateCaptureWindow
capGetDriverDescription
DrawDibClose
DrawDibDraw
DrawDibOpen
mciGetDeviceID
mciGetErrorString
mciSendCommand
mciSendString
midiOutClose
midiOutGetDevCaps
midiOutGetNumDevs
midiOutOpen
midiOutReset
midiOutShortMsg
mixerClose
mixerGetControlDetails
mixerGetDevCaps
mixerGetID
mixerGetLineControls
mixerGetLineInfo
mixerGetNumDevs
mixerOpen
mixerSetControlDetails
mmioAscend
mmioClose
mmioCreateChunk
mmioDescend
mmioFlush
mmioOpen
mmioRead
mmioSeek
mmioWrite
PlaySound
sndPlaySound
timeGetDevCaps
waveInAddBuffer
waveInClose
waveInGetDevCaps
waveInGetErrorText
waveInGetNumDevs
waveInGetPosition
waveInOpen
waveInPrepareHeader
waveInReset
waveInStart
waveInStop
waveInUnprepareHeader
waveOutClose
waveOutGetDevCaps
waveOutGetErrorText
waveOutGetNumDevs
waveOutGetPosition
waveOutGetVolume
waveOutOpen
waveOutPrepareHeader
waveOutReset
waveOutSetVolume
waveOutUnprepareHeader
waveOutWrite
Code examples:
Playing WAV files on InteractiveChange
Playing WAV files on InteractiveChange

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
This code sample shows how to play a WAV sound on InteractiveChange event of ListBox control.

The sound is played asynchronously, which does not slow the UI. Separate sounds are played for odd and even list items.

See also:
  • Controlling master audio volume
  • Playing WAV sounds simultaneously
  • How to play MIDI notes
  • WAV file player

  • oForm = CREATEOBJECT("TForm")
    oForm.Visible = .T.
    READ EVENTS
    * end of main
    
    DEFINE CLASS TForm as Form
        Caption="Interactive PlaySound"
        Width=250
        Height=350
        Autocenter=.T.
    
        ADD OBJECT List1 as TList WITH;
        Left=5, Top=5, Width=240, Height=320
    
    PROCEDURE Init
        THIS.List1.PopulateList
    
    PROCEDURE Destroy
        CLEAR EVENTS
    
    PROCEDURE KeyPress
    LPARAMETERS nKeyCode, nShiftAltCtrl
        IF nKeyCode = 27
            THIS.Release
        ENDIF
    
    ENDDEFINE
    
    DEFINE CLASS TList as ListBox
    #DEFINE SND_FILENAME 0x20000
    #DEFINE SND_ASYNC 1
    
    PROCEDURE Init
        THIS.declare
    
    PROCEDURE PopulateList
        LOCAL nIndex
        FOR nIndex=1 TO 100
            THIS.AddItem("Item " +;
                TRANSFORM(nIndex))
        NEXT
        THIS.ListIndex = 1
    
    PROCEDURE InteractiveChange
        THIS.PlayEventSound
    
    PROCEDURE PlayEventSound
    * download these sound files or use your own
    * http://www.soundjay.com/button/button-20.wav
    * http://www.soundjay.com/button/button-33.wav
    
        * plays separate sounds 
        * for odd and even list items
        PlaySound(;
            IIF(MOD(THIS.ListIndex, 2)=0,;
            "sounds\button-20.wav",;
            "sounds\button-33.wav"),;
            0, SND_FILENAME + SND_ASYNC)
    
    PROCEDURE declare
        DECLARE INTEGER PlaySound IN winmm;
            STRING pszSound, INTEGER hmod,;
            LONG fdwSound
    
    ENDDEFINE
    

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    1265 bytes  
    Created: 2013-11-21 09:23:21  
    Modified: 2013-11-21 09:39:15  
    Visits in 7 days: 112  
    Listed functions:
    PlaySound
    Printer friendly API declarations
    My comment:
    As long as UI sounds stay equally informative and unobtrusive, they certainly can improve end-user experience. For example, your UI may deliver a sound not for every item in a list but for a few chosen ones.
    Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.82.78.213)
    10 sec.
    22 sec.Function: 'SetPriorityClass'
    32 sec.Example: 'Using WM_COPYDATA for interprocess communication (VFP9)'
    43 sec.Function: 'CreateFileTransacted'
    Function group: 'File Management'
    55 sec.Function: 'GdipBitmapSetPixel'
    Function group: 'GDI+ Bitmap'
    1.07 min.Function: 'GetCurrentProcess'
    Function group: 'Process and Thread'
    1.25 min.Function: 'SHAddToRecentDocs'
    Function group: 'Shell Functions'
    1.45 min.Function: 'AVIStreamTimeToSample'
    Function group: 'Windows Multimedia'
    1.6 min.
    Function group: 'GDI+'
    1.78 min.Function: 'SHFileOperation'
    Function group: 'Shell Functions'
    Google
    Advertise here!