NTK and The NTK Project
are properties of Jn Dechereux
Home | Documentation | FAQ.

Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorLucas
    • CommentTimeSep 11th 2013
     
    Hi all, I want to play a WAV sound stored in a resource of my EXE. Having browsed all the contrib dirs, I've only found 'dGridview' an example that uses the NTKPlaySound()function to play WAV files from the disk. But, didn't find any hints on how to play sound from a resource. Can someone point me a tutorial or send a code snippet?

    TIA, Lucas
    •  
      CommentAuthorxbasefan
    • CommentTimeSep 12th 2013
     
    try the Playsound() api:
    PlaySound(IDS_ALERT, NULL, SND_RESOURCE+SND_ASYNC) // from res
    PlaySound("alert.wav", NULL, SND_FILENAME+SND_ASYNC+SND_LOOP) // from disk


    here is the call:
    _DLL FUNCTION PlaySound( pszSound as lpcstr, hMod as handle, fdwSound as dword ) AS bool PASCAL:WINMM.PlaySoundA

    works great use it for years now.
    wilson
    •  
      CommentAuthorLucas
    • CommentTimeSep 13th 2013
     
    Wilson, big thanks for this nice piece of code. It's all very clear to me now.

    Lucas
    •  
      CommentAuthorLucas
    • CommentTimeSep 13th 2013
     
    For those interested in this function, below are some useful #def found on the web.

    #define SND_SYNC 0 // play asynchronously
    #define SND_ASYNC 1 // play synchronously
    #define SND_NODEFAULT 2
    #define SND_MEMORY 4
    #define SND_LOOP 8 // loop the sound
    #define SND_NOSTOP 16 // don't stop any currently playing sound
    #define SND_NOWAIT 0x2000
    #define SND_ALIAS 0x10000
    #define SND_ALIAS_ID 0x110000
    #define SND_FILENAME 0x20000 // name is file name
    #define SND_RESOURCE 0x40004 // name is resource name or atom
    #define SND_PURGE 0x40
    #define SND_APPLICATION 0x80
    #define SND_ALIAS_START 0

    HTH
    Lucas