home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / audio / acmapp / aawavdev.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  21KB  |  765 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (C) 1992 - 1997 Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. //  aawavdev.c
  13. //
  14. //  Description:
  15. //      Get and display information on the wave devices installed in the
  16. //      system.
  17. //
  18. //
  19. //==========================================================================;
  20.  
  21. #include <windows.h>
  22. #include <windowsx.h>
  23. #include <mmsystem.h>
  24. #include <memory.h>
  25.  
  26. #include <mmreg.h>
  27. #include <msacm.h>
  28.  
  29. #include "appport.h"
  30. #include "acmapp.h"
  31.  
  32. #include "debug.h"
  33.  
  34.  
  35. //
  36. //  WAVE[IN|OUT]CAPS
  37. //
  38. //
  39. //
  40. PTSTR gaszWaveInOutCapsFormats[32] =
  41. {
  42.     TEXT("8M11"),           // Bit 0    WAVE_FORMAT_1M08
  43.     TEXT("8S11"),           // Bit 1    WAVE_FORMAT_1S08
  44.     TEXT("16M11"),          // Bit 2    WAVE_FORMAT_1M16
  45.     TEXT("16S11"),          // Bit 3    WAVE_FORMAT_1S16
  46.     TEXT("8M22"),           // Bit 4    WAVE_FORMAT_2M08
  47.     TEXT("8S22"),           // Bit 5    WAVE_FORMAT_2S08
  48.     TEXT("16M22"),          // Bit 6    WAVE_FORMAT_2M16
  49.     TEXT("16S22"),          // Bit 7    WAVE_FORMAT_2S16
  50.     TEXT("8M44"),           // Bit 8    WAVE_FORMAT_4M08
  51.     TEXT("8S44"),           // Bit 9    WAVE_FORMAT_4S08
  52.     TEXT("16M44"),          // Bit 10   WAVE_FORMAT_4M16
  53.     TEXT("16S44"),          // Bit 11   WAVE_FORMAT_4S16
  54.     NULL,                   // Bit 12
  55.     NULL,                   // Bit 13
  56.     NULL,                   // Bit 14
  57.     NULL,                   // Bit 15
  58.     NULL,                   // Bit 16
  59.     NULL,                   // Bit 17
  60.     NULL,                   // Bit 18
  61.     NULL,                   // Bit 19
  62.     NULL,                   // Bit 20
  63.     NULL,                   // Bit 21
  64.     NULL,                   // Bit 22
  65.     NULL,                   // Bit 23
  66.     NULL,                   // Bit 24
  67.     NULL,                   // Bit 25
  68.     NULL,                   // Bit 26
  69.     NULL,                   // Bit 27
  70.     NULL,                   // Bit 28
  71.     NULL,                   // Bit 29
  72.     NULL,                   // Bit 30
  73.     NULL                    // Bit 31
  74. };
  75.  
  76. PTSTR gaszWaveOutCapsSupport[32] =
  77. {
  78.     TEXT("Pitch"),          // Bit 0    WAVECAPS_PITCH
  79.     TEXT("Playback Rate"),  // Bit 1    WAVECAPS_PLAYBACKRATE
  80.     TEXT("Volume"),         // Bit 2    WAVECAPS_VOLUME
  81.     TEXT("L/R Volume"),     // Bit 3    WAVECAPS_LRVOLUME
  82.     TEXT("Sync"),           // Bit 4    WAVECAPS_SYNC
  83.     NULL,                   // Bit 5
  84.     NULL,                   // Bit 6
  85.     NULL,                   // Bit 7
  86.     NULL,                   // Bit 8
  87.     NULL,                   // Bit 9
  88.     NULL,                   // Bit 10
  89.     NULL,                   // Bit 11
  90.     NULL,                   // Bit 12
  91.     NULL,                   // Bit 13
  92.     NULL,                   // Bit 14
  93.     NULL,                   // Bit 15
  94.     NULL,                   // Bit 16
  95.     NULL,                   // Bit 17
  96.     NULL,                   // Bit 18
  97.     NULL,                   // Bit 19
  98.     NULL,                   // Bit 20
  99.     NULL,                   // Bit 21
  100.     NULL,                   // Bit 22
  101.     NULL,                   // Bit 23
  102.     NULL,                   // Bit 24
  103.     NULL,                   // Bit 25
  104.     NULL,                   // Bit 26
  105.     NULL,                   // Bit 27
  106.     NULL,                   // Bit 28
  107.     NULL,                   // Bit 29
  108.     NULL,                   // Bit 30
  109.     NULL                    // Bit 31
  110. };
  111.  
  112.  
  113.  
  114.  
  115. //==========================================================================;
  116. //
  117. //
  118. //
  119. //
  120. //==========================================================================;
  121.  
  122. //--------------------------------------------------------------------------;
  123. //  
  124. //  MMRESULT AcmAppWaveInGetDevCaps
  125. //  
  126. //  Description:
  127. //  
  128. //  
  129. //  Arguments:
  130. //      UINT uDevId:
  131. //  
  132. //      LPWAVEINCAPS pwic:
  133. //  
  134. //  Return (MMRESULT):
  135. //  
  136. //  
  137. //--------------------------------------------------------------------------;
  138.  
  139. MMRESULT FNLOCAL AcmAppWaveInGetDevCaps
  140. (
  141.     UINT                    uDevId,
  142.     LPWAVEINCAPS            pwic
  143. )
  144. {
  145.     MMRESULT            mmr;
  146.  
  147.     //
  148.     //
  149.     //
  150.     mmr = waveInGetDevCaps(uDevId, pwic, sizeof(*pwic));
  151.     if (MMSYSERR_NOERROR == mmr)
  152.     {
  153.         //
  154.         //  because some people shipped drivers without testing.
  155.         //
  156.         pwic->szPname[SIZEOF(pwic->szPname) - 1] = '\0';
  157.     }
  158.     else
  159.     {
  160.         _fmemset(pwic, 0, sizeof(*pwic));
  161.  
  162.         if (MMSYSERR_BADDEVICEID == mmr)
  163.         {
  164.             return (mmr);
  165.         }
  166.  
  167.         if (WAVE_MAPPER == uDevId)
  168.         {
  169.             lstrcpy(pwic->szPname, TEXT("Default Wave Input Mapper"));
  170.         }
  171.         else
  172.         {
  173.             wsprintf(pwic->szPname, TEXT("Bad Wave Input Device %u"), uDevId);
  174.         }
  175.     }
  176.  
  177.     return (MMSYSERR_NOERROR);
  178. } // AcmAppWaveInGetDevCaps()
  179.  
  180.  
  181. //--------------------------------------------------------------------------;
  182. //  
  183. //  MMRESULT AcmAppWaveOutGetDevCaps
  184. //  
  185. //  Description:
  186. //  
  187. //  
  188. //  Arguments:
  189. //      UINT uDevId:
  190. //  
  191. //      LPWAVEOUTCAPS pwoc:
  192. //  
  193. //  Return (MMRESULT):
  194. //  
  195. //  
  196. //--------------------------------------------------------------------------;
  197.  
  198. MMRESULT FNLOCAL AcmAppWaveOutGetDevCaps
  199. (
  200.     UINT                    uDevId,
  201.     LPWAVEOUTCAPS           pwoc
  202. )
  203. {
  204.     MMRESULT            mmr;
  205.  
  206.     //
  207.     //
  208.     //
  209.     mmr = waveOutGetDevCaps(uDevId, pwoc, sizeof(*pwoc));
  210.     if (MMSYSERR_NOERROR == mmr)
  211.     {
  212.         //
  213.         //  because some people shipped drivers without testing.
  214.         //
  215.         pwoc->szPname[SIZEOF(pwoc->szPname) - 1] = '\0';
  216.     }
  217.     else
  218.     {
  219.         _fmemset(pwoc, 0, sizeof(*pwoc));
  220.  
  221.         if (MMSYSERR_BADDEVICEID == mmr)
  222.         {
  223.             return (mmr);
  224.         }
  225.  
  226.         if (WAVE_MAPPER == uDevId)
  227.         {
  228.             lstrcpy(pwoc->szPname, TEXT("Default Wave Output Mapper"));
  229.         }
  230.         else
  231.         {
  232.             wsprintf(pwoc->szPname, TEXT("Bad Wave Output Device %u"), uDevId);
  233.         }
  234.     }
  235.  
  236.     return (MMSYSERR_NOERROR);
  237. } // AcmAppWaveOutGetDevCaps()
  238.  
  239.  
  240. //--------------------------------------------------------------------------;
  241. //  
  242. //  BOOL AcmAppDisplayWaveInDevCaps
  243. //  
  244. //  Description:
  245. //  
  246. //  
  247. //  Arguments:
  248. //      HWND hedit:
  249. //  
  250. //      UINT uDevId:
  251. //  
  252. //      LPWAVEINCAPS pwic:
  253. //  
  254. //  Return (BOOL):
  255. //  
  256. //  
  257. //--------------------------------------------------------------------------;
  258.  
  259. BOOL FNLOCAL AcmAppDisplayWaveInDevCaps
  260. (
  261.     HWND                    hedit,
  262.     UINT                    uDevId,
  263.     LPWAVEINCAPS            pwic,
  264.     LPWAVEFORMATEX          pwfx
  265. )
  266. {
  267.     static TCHAR        szDisplayTitle[]    = TEXT("[Wave Input Device Capabilities]\r\n");
  268.     TCHAR               ach[40];
  269.     PTSTR               psz;
  270.     UINT                u;
  271.     UINT                v;
  272.     DWORD               dw;
  273.  
  274.     SetWindowRedraw(hedit, FALSE);
  275.  
  276.     MEditPrintF(hedit, NULL);
  277.     MEditPrintF(hedit, szDisplayTitle);
  278.  
  279.     //
  280.     //
  281.     //
  282.     if (NULL != pwfx)
  283.     {
  284.         TCHAR           szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
  285.         TCHAR           szFormat[ACMFORMATDETAILS_FORMAT_CHARS];
  286.         MMRESULT        mmr;
  287.         HWAVEIN         hwi;
  288.  
  289.         //
  290.         //
  291.         //
  292.         AcmAppGetFormatDescription(pwfx, szFormatTag, szFormat);
  293.         MEditPrintF(hedit, TEXT("%17s: %s"), (LPTSTR)TEXT("Format"), (LPTSTR)szFormatTag);
  294.         MEditPrintF(hedit, TEXT("%17s: %s"), (LPTSTR)TEXT("Attributes"), (LPTSTR)szFormat);
  295.  
  296.  
  297.         //
  298.         //
  299.         //
  300.         MEditPrintF(hedit, TEXT("~%17s: "), (LPTSTR)TEXT("Recordable"));
  301.         mmr = waveInOpen(&hwi, uDevId,
  302. #if (WINVER < 0x0400)
  303.                          (LPWAVEFORMAT)pwfx,
  304. #else
  305.                          pwfx,
  306. #endif
  307.                          0L, 0L, 0L);
  308.  
  309.         if (MMSYSERR_NOERROR == mmr)
  310.         {
  311.             MEditPrintF(hedit, gszYes);
  312.             waveInClose(hwi);
  313.             hwi = NULL;
  314.         }
  315.         else
  316.         {
  317.             AcmAppGetErrorString(mmr, ach);
  318.             MEditPrintF(hedit, TEXT("%s, %s (%u)"), (LPTSTR)gszNo, (LPSTR)ach, mmr);
  319.         }
  320.  
  321.  
  322.         //
  323.         //
  324.         //
  325.         MEditPrintF(hedit, TEXT("~%17s: "), (LPTSTR)TEXT("(Query)"));
  326.         mmr = waveInOpen(NULL, uDevId,
  327. #if (WINVER < 0x0400)
  328.                          (LPWAVEFORMAT)pwfx,
  329. #else
  330.                          pwfx,
  331. #endif
  332.                          0L, 0L, WAVE_FORMAT_QUERY);
  333.  
  334.         if (MMSYSERR_NOERROR == mmr)
  335.         {
  336.             MEditPrintF(hedit, gszYes);
  337.         }
  338.         else
  339.         {
  340.             AcmAppGetErrorString(mmr, ach);
  341.             MEditPrintF(hedit, TEXT("%s, %s (%u)"), (LPTSTR)gszNo, (LPSTR)ach, mmr);
  342.         }
  343.  
  344.  
  345.         MEditPrintF(hedit, gszNull);
  346.     }
  347.  
  348.     //
  349.     //
  350.     //
  351.     MEditPrintF(hedit, TEXT("%17s: %d"), (LPTSTR)TEXT("Device Id"), uDevId);
  352.  
  353.     MEditPrintF(hedit, TEXT("%17s: %u"), (LPTSTR)TEXT("Manufacturer Id"), pwic->wMid);
  354.     MEditPrintF(hedit, TEXT("%17s: %u"), (LPTSTR)TEXT("Product Id"), pwic->wPid);
  355.     MEditPrintF(hedit, TEXT("%17s: %u.%.02u"), (LPTSTR)TEXT("Driver Version"),
  356.                 (pwic->vDriverVersion >> 8),
  357.                 (pwic->vDriverVersion & 0x00FF));
  358.     MEditPrintF(hedit, TEXT("%17s: '%s'"), (LPTSTR)TEXT("Device Name"), (LPTSTR)pwic->szPname);
  359.     MEditPrintF(hedit, TEXT("%17s: %u"), (LPTSTR)TEXT("Channels"), pwic->wChannels);
  360.  
  361.  
  362.     //
  363.     //
  364.     //
  365.     //
  366.     MEditPrintF(hedit, TEXT("%17s: %.08lXh"), (LPTSTR)TEXT("Standard Formats"), pwic->dwFormats);
  367.     for (v = u = 0, dw = pwic->dwFormats; (0L != dw); u++)
  368.     {
  369.         if ((BYTE)dw & (BYTE)1)
  370.         {
  371.             psz = gaszWaveInOutCapsFormats[u];
  372.             if (NULL == psz)
  373.             {
  374.                 wsprintf(ach, TEXT("Unknown%u"), u);
  375.                 psz = ach;
  376.             }
  377.  
  378.             if (0 == (v % 4))
  379.             {
  380.                 if (v != 0)
  381.                 {
  382.                     MEditPrintF(hedit, gszNull);
  383.                 }
  384.                 MEditPrintF(hedit, TEXT("~%19s%s"), (LPTSTR)gszNull, (LPTSTR)psz);
  385.             }
  386.             else
  387.             {
  388.                 MEditPrintF(hedit, TEXT("~, %s"), (LPTSTR)psz);
  389.             }
  390.  
  391.             v++;
  392.         }
  393.  
  394.         dw >>= 1;
  395.     }
  396.     MEditPrintF(hedit, gszNull);
  397.  
  398.     SetWindowRedraw(hedit, TRUE);
  399.  
  400.     return (TRUE);
  401. } // AcmAppDisplayWaveInDevCaps()
  402.  
  403.  
  404. //--------------------------------------------------------------------------;
  405. //  
  406. //  BOOL AcmAppDisplayWaveOutDevCaps
  407. //  
  408. //  Description:
  409. //  
  410. //  
  411. //  Arguments:
  412. //      HWND hedit:
  413. //  
  414. //      UINT uDevId:
  415. //  
  416. //      LPWAVEOUTCAPS pwoc:
  417. //  
  418. //  Return (BOOL):
  419. //  
  420. //  
  421. //--------------------------------------------------------------------------;
  422.  
  423. BOOL FNLOCAL AcmAppDisplayWaveOutDevCaps
  424. (
  425.     HWND                    hedit,
  426.     UINT                    uDevId,
  427.     LPWAVEOUTCAPS           pwoc,
  428.     LPWAVEFORMATEX          pwfx
  429. )
  430. {
  431.     static TCHAR    szDisplayTitle[]    = TEXT("[Wave Output Device Capabilities]\r\n");
  432.     TCHAR           ach[40];
  433.     PTSTR           psz;
  434.     UINT            u;
  435.     UINT            v;
  436.     DWORD           dw;
  437.  
  438.     SetWindowRedraw(hedit, FALSE);
  439.  
  440.     //
  441.     //
  442.     //
  443.     MEditPrintF(hedit, NULL);
  444.     MEditPrintF(hedit, szDisplayTitle);
  445.  
  446.  
  447.  
  448.     //
  449.     //
  450.     //
  451.     if (NULL != pwfx)
  452.     {
  453.         TCHAR           szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
  454.         TCHAR           szFormat[ACMFORMATDETAILS_FORMAT_CHARS];
  455.         MMRESULT        mmr;
  456.         HWAVEOUT        hwo;
  457.         DWORD           fdwOpen;
  458.  
  459.         fdwOpen = (0 != (WAVECAPS_SYNC & pwoc->dwSupport)) ? 0L : WAVE_ALLOWSYNC;
  460.  
  461.         //
  462.         //
  463.         //
  464.         AcmAppGetFormatDescription(pwfx, szFormatTag, szFormat);
  465.         MEditPrintF(hedit, TEXT("%17s: %s"), (LPTSTR)TEXT("Format"), (LPTSTR)szFormatTag);
  466.         MEditPrintF(hedit, TEXT("%17s: %s"), (LPTSTR)TEXT("Attributes"), (LPTSTR)szFormat);
  467.  
  468.  
  469.         //
  470.         //
  471.         //
  472.         MEditPrintF(hedit, TEXT("~%17s: "), (LPTSTR)TEXT("Playable"));
  473.         mmr = waveOutOpen(&hwo, uDevId,
  474. #if (WINVER < 0x0400)
  475.                           (LPWAVEFORMAT)pwfx,
  476. #else
  477.                           pwfx,
  478. #endif
  479.                           0L, 0L, fdwOpen);
  480.  
  481.         if (MMSYSERR_NOERROR == mmr)
  482.         {
  483.             MEditPrintF(hedit, gszYes);
  484.             waveOutClose(hwo);
  485.             hwo = NULL;
  486.         }
  487.         else
  488.         {
  489.             AcmAppGetErrorString(mmr, ach);
  490.             MEditPrintF(hedit, TEXT("%s, %s (%u)"), (LPTSTR)gszNo, (LPSTR)ach, mmr);
  491.         }
  492.  
  493.         //
  494.         //
  495.         //
  496.         MEditPrintF(hedit, TEXT("~%17s: "), (LPTSTR)TEXT("(Query)"));
  497.         mmr = waveOutOpen(NULL, uDevId,
  498. #if (WINVER < 0x0400)
  499.                           (LPWAVEFORMAT)pwfx,
  500. #else
  501.                           pwfx,
  502. #endif
  503.                           0L, 0L, fdwOpen | WAVE_FORMAT_QUERY);
  504.  
  505.         if (MMSYSERR_NOERROR == mmr)
  506.         {
  507.             MEditPrintF(hedit, gszYes);
  508.         }
  509.         else
  510.         {
  511.             AcmAppGetErrorString(mmr, ach);
  512.             MEditPrintF(hedit, TEXT("%s, %s (%u)"), (LPTSTR)gszNo, (LPSTR)ach, mmr);
  513.         }
  514.  
  515.         MEditPrintF(hedit, gszNull);
  516.     }
  517.  
  518.  
  519.  
  520.     MEditPrintF(hedit, TEXT("%17s: %d"), (LPTSTR)TEXT("Device Id"), uDevId);
  521.  
  522.     MEditPrintF(hedit, TEXT("%17s: %u"), (LPTSTR)TEXT("Manufacturer Id"), pwoc->wMid);
  523.     MEditPrintF(hedit, TEXT("%17s: %u"), (LPTSTR)TEXT("Product Id"), pwoc->wPid);
  524.     MEditPrintF(hedit, TEXT("%17s: %u.%.02u"), (LPTSTR)TEXT("Driver Version"),
  525.                 (pwoc->vDriverVersion >> 8),
  526.                 (pwoc->vDriverVersion & 0x00FF));
  527.     MEditPrintF(hedit, TEXT("%17s: '%s'"), (LPTSTR)TEXT("Device Name"), (LPTSTR)pwoc->szPname);
  528.     MEditPrintF(hedit, TEXT("%17s: %u"), (LPTSTR)TEXT("Channels"), pwoc->wChannels);
  529.  
  530.  
  531.  
  532.     //
  533.     //
  534.     //
  535.     //
  536.     MEditPrintF(hedit, TEXT("%17s: %.08lXh"), (LPTSTR)TEXT("Standard Formats"), pwoc->dwFormats);
  537.     for (v = u = 0, dw = pwoc->dwFormats; (0L != dw); u++)
  538.     {
  539.         if ((BYTE)dw & (BYTE)1)
  540.         {
  541.             psz = gaszWaveInOutCapsFormats[u];
  542.             if (NULL == psz)
  543.             {
  544.                 wsprintf(ach, TEXT("Unknown%u"), u);
  545.                 psz = ach;
  546.             }
  547.  
  548.             if (0 == (v % 4))
  549.             {
  550.                 if (v != 0)
  551.                 {
  552.                     MEditPrintF(hedit, gszNull);
  553.                 }
  554.                 MEditPrintF(hedit, TEXT("~%19s%s"), (LPTSTR)gszNull, (LPTSTR)psz);
  555.             }
  556.             else
  557.             {
  558.                 MEditPrintF(hedit, TEXT("~, %s"), (LPTSTR)psz);
  559.             }
  560.  
  561.             v++;
  562.         }
  563.  
  564.         dw >>= 1;
  565.     }
  566.     MEditPrintF(hedit, gszNull);
  567.  
  568.     //
  569.     //
  570.     //
  571.     //
  572.     MEditPrintF(hedit, TEXT("%17s: %.08lXh"), (LPTSTR)TEXT("Standard Support"), pwoc->dwSupport);
  573.     for (v = u = 0, dw = pwoc->dwSupport; dw; u++)
  574.     {
  575.         if ((BYTE)dw & (BYTE)1)
  576.         {
  577.             psz = gaszWaveOutCapsSupport[u];
  578.             if (NULL == psz)
  579.             {
  580.                 wsprintf(ach, TEXT("Unknown%u"), u);
  581.                 psz = ach;
  582.             }
  583.  
  584.             if (0 == (v % 4))
  585.             {
  586.                 if (v != 0)
  587.                 {
  588.                     MEditPrintF(hedit, gszNull);
  589.                 }
  590.                 MEditPrintF(hedit, TEXT("~%19s%s"), (LPTSTR)gszNull, (LPTSTR)psz);
  591.             }
  592.             else
  593.             {
  594.                 MEditPrintF(hedit, TEXT("~, %s"), (LPTSTR)psz);
  595.             }
  596.  
  597.             v++;
  598.         }
  599.  
  600.         dw >>= 1;
  601.     }
  602.     MEditPrintF(hedit, gszNull);
  603.  
  604.     SetWindowRedraw(hedit, TRUE);
  605.  
  606.     return (TRUE);
  607. } // AcmAppDisplayWaveOutDevCaps()
  608.  
  609.  
  610. //--------------------------------------------------------------------------;
  611. //  
  612. //  BOOL AcmAppWaveDeviceDlgProc
  613. //  
  614. //  Description:
  615. //  
  616. //  
  617. //  Arguments:
  618. //      HWND hwnd:
  619. //  
  620. //      UINT uMsg:
  621. //  
  622. //      WPARAM wParam:
  623. //  
  624. //      LPARAM lParam:
  625. //  
  626. //  Return (BOOL):
  627. //  
  628. //  
  629. //--------------------------------------------------------------------------;
  630.  
  631. BOOL FNEXPORT AcmAppWaveDeviceDlgProc
  632. (
  633.     HWND                    hwnd,
  634.     UINT                    uMsg,
  635.     WPARAM                  wParam,
  636.     LPARAM                  lParam
  637. )
  638. {
  639.     LONG                lDevice;
  640.     BOOL                fInput;
  641.     UINT                uDevId;
  642.  
  643.     UINT                cWaveDevs;
  644.     UINT                u;
  645.     UINT                uId;
  646.     UINT                uCmd;
  647.     HWND                hcb;
  648.     HWND                hedit;
  649.     HFONT               hfont;
  650.  
  651.     WAVEINCAPS          wic;
  652.     WAVEOUTCAPS         woc;
  653.  
  654.     lDevice = GetWindowLong(hwnd, DWL_USER);
  655.     uDevId  = (UINT)(int)(short)LOWORD(lDevice);
  656.     fInput  = (BOOL)HIWORD(lDevice);
  657.  
  658.     //
  659.     //
  660.     //
  661.     switch (uMsg)
  662.     {
  663.         case WM_INITDIALOG:
  664. //          hfont = GetStockFont(ANSI_FIXED_FONT);
  665.             hfont = ghfontApp;
  666.             hedit = GetDlgItem(hwnd, IDD_AAWAVEDEVICE_EDIT_CAPABILITIES);
  667.             SetWindowFont(hedit, hfont, FALSE);
  668.  
  669.             uDevId = (UINT)(int)(short)LOWORD(lParam);
  670.             fInput = (BOOL)HIWORD(lParam);
  671.             SetWindowLong(hwnd, DWL_USER, lParam);
  672.  
  673.  
  674.             //
  675.             //
  676.             //
  677.             hcb = GetDlgItem(hwnd, IDD_AAWAVEDEVICE_COMBO_DEVICE);
  678.             SetWindowFont(hcb, hfont, FALSE);
  679.  
  680.             if (fInput)
  681.                 cWaveDevs = waveInGetNumDevs() + 1;
  682.             else
  683.                 cWaveDevs = waveOutGetNumDevs() + 1;
  684.  
  685.             for (u = (UINT)WAVE_MAPPER; (0 != cWaveDevs); u++, cWaveDevs--)
  686.             {
  687.                 if (fInput)
  688.                 {
  689.                     AcmAppWaveInGetDevCaps(u, &wic);
  690.                     ComboBox_AddString(hcb, wic.szPname);
  691.                 }
  692.                 else
  693.                 {
  694.                     AcmAppWaveOutGetDevCaps(u, &woc);
  695.                     ComboBox_AddString(hcb, woc.szPname);
  696.                 }
  697.  
  698.                 if (uDevId == u)
  699.                 {
  700.                     hedit = GetDlgItem(hwnd, IDD_AAWAVEDEVICE_EDIT_CAPABILITIES);
  701.  
  702.                     if (fInput)
  703.                         AcmAppDisplayWaveInDevCaps(hedit, uDevId, &wic, gaafd.pwfx);
  704.                     else
  705.                         AcmAppDisplayWaveOutDevCaps(hedit, uDevId, &woc, gaafd.pwfx);
  706.                 }
  707.             }
  708.  
  709.             ComboBox_SetCurSel(hcb, uDevId + 1);
  710.             return (TRUE);
  711.  
  712.  
  713.         case WM_COMMAND:
  714.             uId = GET_WM_COMMAND_ID(wParam, lParam);
  715.  
  716.             switch (uId)
  717.             {
  718.                 case IDOK:
  719.                     hcb    = GetDlgItem(hwnd, IDD_AAWAVEDEVICE_COMBO_DEVICE);
  720.                     uDevId = ComboBox_GetCurSel(hcb);
  721.                     if (CB_ERR != uDevId)
  722.                     {
  723.                         EndDialog(hwnd, uDevId - 1);
  724.                         break;
  725.                     }
  726.  
  727.                     // -- fall through -- //
  728.                     
  729.                 case IDCANCEL:
  730.                     EndDialog(hwnd, uDevId);
  731.                     break;
  732.                     
  733.  
  734.                 case IDD_AAWAVEDEVICE_COMBO_DEVICE:
  735.                     uCmd = GET_WM_COMMAND_CMD(wParam, lParam);
  736.                     hcb  = GET_WM_COMMAND_HWND(wParam, lParam);
  737.                     switch (uCmd)
  738.                     {
  739.                         case CBN_SELCHANGE:
  740.                             uDevId = ComboBox_GetCurSel(hcb);
  741.                             if (CB_ERR == uDevId)
  742.                                 break;
  743.  
  744.                             uDevId--;
  745.  
  746.                             hedit = GetDlgItem(hwnd, IDD_AAWAVEDEVICE_EDIT_CAPABILITIES);
  747.                             if (fInput)
  748.                             {
  749.                                 AcmAppWaveInGetDevCaps(uDevId, &wic);
  750.                                 AcmAppDisplayWaveInDevCaps(hedit, uDevId, &wic, gaafd.pwfx);
  751.                             }
  752.                             else
  753.                             {
  754.                                 AcmAppWaveOutGetDevCaps(uDevId, &woc);
  755.                                 AcmAppDisplayWaveOutDevCaps(hedit, uDevId, &woc, gaafd.pwfx);
  756.                             }
  757.                             break;
  758.                     }
  759.             }
  760.             return (TRUE);
  761.     }
  762.  
  763.     return (FALSE);
  764. } // AcmAppWaveDeviceDlgProc()
  765.