home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / SSNDMSG.ZIP / SSNDMSG.C
Text File  |  1993-04-23  |  4KB  |  128 lines

  1.  
  2. /*****************************************************************************\
  3. *  
  4. *  BocaSoft System Sounds interface code - 04/27/93  
  5. *
  6. *  Shareware - No License Fee  
  7. *  
  8. *  BocaSoft Incorporated  
  9. *  117 NW 43rd St. 
  10. *  Boca Raton, FL 
  11. *  33431 
  12. *  (407)392-7743  
  13. *  
  14. *  
  15. *  These two routines demonstrate a simple way for an OS/2 PM application 
  16. *  to trigger sounds within the BocaSoft System Sounds product.  By using
  17. *  our product in conjunction with MMPM/2 a developer can take advantage 
  18. *  of high performance audio playback with minimal code.
  19. *  
  20. *  The first routine, "FindSystemSounds", returns a window handle which in
  21. *  turn is used by the second routine, "PlaySound", to post a window message
  22. *  with the appropriate audio index.  The audio index must be associated with
  23. *  an enabled audio file within the BocaSoft product.  We suggest using
  24. *  obscure key combinations such as CTRL-SHIFT-ALT to avoid conflicts 
  25. *  with main system events.  See below listing for appropriate index values.
  26. *
  27. *  To order a copy of BocaSoft System Sounds please call (407)392-7743.  We
  28. *  accept VISA and Mastercard.  American Express will be available in May.
  29. *
  30. *  Introductory beta offer with free upgrade:  $ 49.00
  31. *  
  32. *  
  33. *  Event Index Values     -> 0 to 41
  34. *  
  35. *  Key Index Values:
  36. *  ----------------
  37. *  
  38. *  No control keys     -> index = 42 + scan code
  39. *  SHIFT        -> index = 42 + scan code + (256 * 1)
  40. *  ALT            -> index = 42 + scan code + (256 * 2)
  41. *  CTRL             -> index = 42 + scan code + (256 * 3)
  42. *  SHIFT | ALT        -> index = 42 + scan code + (256 * 4)
  43. *  SHIFT | CTRL        -> index = 42 + scan code + (256 * 5)
  44. *  ALT | CTRL        -> index = 42 + scan code + (256 * 6)
  45. *  SHIFT | ALT | CTRL    -> index = 42 + scan code + (256 * 7)
  46. *  
  47. \*****************************************************************************/
  48.  
  49.  
  50. #define    SSND_PROG_NAME    "System Sounds for OS/2"
  51. #define    SSND_WM_PLAY    0x5000
  52.  
  53. ULONG    PlaySound (HWND, ULONG);
  54. HWND    FindSystemSounds (VOID);
  55.  
  56.  
  57. /*****************************************************************************\
  58. *
  59. *  Subroutine Name:  FindSystemSounds
  60. *
  61. *  Function:  Get the window handle for BocaSoft System Sounds.
  62. *
  63. \*****************************************************************************/
  64.  
  65. HWND    FindSystemSounds (VOID)
  66. {
  67.      HWND      hwndParent;     /* whose child windows are enumed */ 
  68.     HWND      hwndNext;    /* current enumeration handle     */
  69.      HENUM      henum;         /* enumeration handle          */
  70.     CHAR    szWinName[50];  /* window text */
  71.     BOOL    bFound = FALSE;
  72.  
  73.     /* Enumerate all desktop windows and search for 
  74.     BocaSoft System Sounds */
  75.  
  76.     hwndParent = HWND_DESKTOP;
  77.  
  78.     henum = WinBeginEnumWindows (hwndParent);
  79.  
  80.     while ((hwndNext = WinGetNextWindow (henum)) != NULLHANDLE)
  81.     {
  82.         WinQueryWindowText (hwndNext, sizeof(szWinName), szWinName);
  83.  
  84.         if (!(strcmp(szWinName, SSND_PROG_NAME)))
  85.         {
  86.             bFound = TRUE;
  87.             break;
  88.         }
  89.     }
  90.     WinEndEnumWindows (henum);
  91.  
  92.     if (!bFound)
  93.         hwndNext = 0;
  94.  
  95.     return (hwndNext);
  96. }
  97.  
  98.  
  99.  
  100.  
  101. /*****************************************************************************\
  102. *
  103. *  Subroutine Name:  PlaySound
  104. *
  105. *  Function:  Post a window message to BocaSoft System Sounds with
  106. *             a sound index.
  107. *
  108. \*****************************************************************************/
  109.  
  110. ULONG    PlaySound (HWND hwnd,
  111.     ULONG ulIndex)
  112. {
  113.     ULONG    ulRc = 0;
  114.  
  115.     /* Send a message to System Sounds */
  116.  
  117.     ulRc = WinPostMsg (hwnd,
  118.         SSND_WM_PLAY,
  119.         0,
  120.         (MPARAM)ulIndex);
  121.  
  122.     return (ulRc);
  123. }
  124.  
  125.  
  126.  
  127.  
  128.