Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1960 lines
47 KiB

  1. //==========================================================================;
  2. //
  3. // cpl.c
  4. //
  5. // Copyright (c) 1991-1998 Microsoft Corporation
  6. //
  7. // Description:
  8. //
  9. //
  10. // History:
  11. // 11/16/92 cjp [curtisp]
  12. //
  13. //==========================================================================;
  14. #include <windows.h>
  15. #include <windowsx.h>
  16. #include <mmsystem.h>
  17. #include <mmddk.h>
  18. #include <mmreg.h>
  19. #include <msacm.h>
  20. #include <msacmdrv.h>
  21. #if (WINVER >= 0x0400)
  22. #define NOSTATUSBAR
  23. #endif
  24. #include <cpl.h>
  25. #include <stdlib.h>
  26. #define WM_ACMMAP_ACM_NOTIFY (WM_USER + 100)
  27. #if (WINVER >= 0x0400)
  28. #pragma message("----when chicago fixes their header files, remove this stuff")
  29. #include <memory.h>
  30. #ifdef __cplusplus
  31. extern "C" // assume C declarations for C++
  32. {
  33. #endif // __cplusplus
  34. #pragma message("----Using Chicago Interface!")
  35. #define BEGIN_INTERFACE
  36. ////////#include <shellapi.h>
  37. #include <shell.h>
  38. #ifdef WIN32
  39. #include <shlobj.h>
  40. #else
  41. #include <ole2.h>
  42. #include <prsht.h>
  43. #endif
  44. #include <setupx.h>
  45. #ifdef __cplusplus
  46. } // end of extern "C" {
  47. #endif // __cplusplus */
  48. #include "msacmhlp.h"
  49. LRESULT PASCAL CPLSendNotify(HWND hDlg, int idFrom, int code);
  50. #endif
  51. #include "msacmmap.h"
  52. #include "debug.h"
  53. //
  54. //
  55. //
  56. //
  57. typedef struct tACMDRIVERSETTINGS
  58. {
  59. HACMDRIVERID hadid;
  60. DWORD fdwSupport;
  61. DWORD dwPriority;
  62. } ACMDRIVERSETTINGS, FAR *LPACMDRIVERSETTINGS;
  63. // A global structure for keeping out cancel variables.
  64. struct
  65. {
  66. BOOL fPreferredOnly;
  67. UINT uIdPreferredIn;
  68. UINT uIdPreferredOut;
  69. LPACMDRIVERSETTINGS pads;
  70. } CPLSettings;
  71. #if (WINVER >= 0x0400)
  72. TCHAR BCODE gszCPLHelp[] = TEXT("MAPPER.HLP");
  73. int BCODE ganKeywordIds[] =
  74. {
  75. IDD_CPL_LIST_DRIVERS, IDH_AUDIOCOMP_DRIVER,
  76. IDD_CPL_COMBO_PLAYBACK, IDH_AUDIOCOMP_PLAYBACK,
  77. IDD_CPL_COMBO_RECORD, IDH_AUDIOCOMP_RECORDING,
  78. IDD_CPL_CHECK_PREFERRED, IDH_AUDIOCOMP_PREFERRED,
  79. IDD_CPL_BTN_CONFIGURE, IDH_PRIORITY_CHANGE,
  80. IDD_CPL_BTN_PRIORITY, IDH_PRIORITY_DISABLE,
  81. 0, 0
  82. };
  83. TCHAR BCODE gszClass[] = TEXT("Media");
  84. TCHAR BCODE gszClassStr[] = TEXT("Class");
  85. TCHAR BCODE gszACMClass[] = TEXT("ACM");
  86. #else
  87. #if defined(WIN32) && !defined(WIN4)
  88. //
  89. // Daytona help. The number 5123 is taken from
  90. // \nt\private\windows\shell\control\main\cphelp.h. If you change this
  91. // value, you gotta change it here, there, and also in the appropriate
  92. // .hpj file (control.hpj?) in the Daytona help project.
  93. //
  94. #define USE_DAYTONA_HELP
  95. #define IDH_CHILD_MSACM 5123
  96. const TCHAR gszCPLHelp[] = TEXT("CONTROL.HLP");
  97. #else
  98. TCHAR BCODE gszCPLHelp[] = TEXT("MAP_WIN.HLP");
  99. #endif
  100. #endif
  101. TCHAR BCODE gszFormatDriverDesc[] = TEXT("%lu\t%s\t%s");
  102. TCHAR BCODE gszFormatNumber[] = TEXT("%lu");
  103. //
  104. // this string variable must be large enough to hold the IDS_TXT_DISABLED
  105. // resource string.. for USA, this is '(disabled)'--which is 11 bytes
  106. // including the NULL terminator.
  107. //
  108. TCHAR gszDisabled[32];
  109. HACMDRIVERID ghadidNotify;
  110. //
  111. //
  112. //
  113. #define CONTROL_MAX_ITEM_CHARS (10 + 1 + 32 + 1 + ACMDRIVERDETAILS_LONGNAME_CHARS)
  114. //==========================================================================;
  115. //
  116. //
  117. //
  118. //
  119. //==========================================================================;
  120. //--------------------------------------------------------------------------;
  121. //
  122. // void ControlApplySettings
  123. //
  124. // Description:
  125. //
  126. //
  127. // Arguments:
  128. // HWND hwnd:
  129. //
  130. // Return (void):
  131. //
  132. // History:
  133. // 09/08/93 cjp [curtisp]
  134. //
  135. //--------------------------------------------------------------------------;
  136. void FNLOCAL ControlApplySettings
  137. (
  138. HWND hwnd
  139. )
  140. {
  141. MMRESULT mmr;
  142. HWND hlb;
  143. HWND hcb;
  144. UINT cDrivers;
  145. LPACMDRIVERSETTINGS pads;
  146. UINT u;
  147. BOOL fDisabled;
  148. DWORD fdwPriority;
  149. //
  150. // Flush priority changes.
  151. //
  152. hlb = GetDlgItem(hwnd, IDD_CPL_LIST_DRIVERS);
  153. cDrivers = (UINT)ListBox_GetCount(hlb);
  154. if (LB_ERR == cDrivers)
  155. return;
  156. //
  157. //
  158. //
  159. mmr = acmDriverPriority(NULL, 0L, ACM_DRIVERPRIORITYF_BEGIN);
  160. if (MMSYSERR_NOERROR != mmr)
  161. {
  162. DPF(0, "!ControlApplySettings: acmDriverPriority(end) failed! mmr=%u", mmr);
  163. return;
  164. }
  165. for (u = 0; u < cDrivers; u++)
  166. {
  167. pads = (LPACMDRIVERSETTINGS)ListBox_GetItemData(hlb, u);
  168. if (NULL == pads)
  169. {
  170. DPF(0, "!ControlApplySettings: NULL item data for driver index=%u!", u);
  171. continue;
  172. }
  173. fDisabled = (0 != (ACMDRIVERDETAILS_SUPPORTF_DISABLED & pads->fdwSupport));
  174. fdwPriority = fDisabled ? ACM_DRIVERPRIORITYF_DISABLE : ACM_DRIVERPRIORITYF_ENABLE;
  175. mmr = acmDriverPriority(pads->hadid, pads->dwPriority, fdwPriority);
  176. if (MMSYSERR_NOERROR != mmr)
  177. {
  178. DPF(0, "!ControlApplySettings: acmDriverPriority(%.04Xh, %lu, %.08lXh) failed! mmr=%u",
  179. pads->hadid, pads->dwPriority, fdwPriority, mmr);
  180. }
  181. }
  182. mmr = acmDriverPriority(NULL, 0L, ACM_DRIVERPRIORITYF_END);
  183. if (MMSYSERR_NOERROR != mmr)
  184. {
  185. DPF(0, "!ControlApplySettings: acmDriverPriority(end) failed! mmr=%u", mmr);
  186. }
  187. //
  188. // update mapper preference changes
  189. //
  190. WAIT_FOR_MUTEX(gpag->hMutexSettings);
  191. gpag->pSettings->fPreferredOnly = CPLSettings.fPreferredOnly;
  192. gpag->pSettings->uIdPreferredIn = CPLSettings.uIdPreferredIn;
  193. gpag->pSettings->uIdPreferredOut = CPLSettings.uIdPreferredOut;
  194. hcb = GetDlgItem(hwnd, IDD_CPL_COMBO_RECORD);
  195. u = (UINT)ComboBox_GetCurSel(hcb);
  196. ComboBox_GetLBText(hcb, u, (LPARAM)(LPVOID)gpag->pSettings->szPreferredWaveIn);
  197. hcb = GetDlgItem(hwnd, IDD_CPL_COMBO_PLAYBACK);
  198. u = (UINT)ComboBox_GetCurSel(hcb);
  199. ComboBox_GetLBText(hcb, u, (LPARAM)(LPVOID)gpag->pSettings->szPreferredWaveOut);
  200. RELEASE_MUTEX(gpag->hMutexSettings);
  201. //
  202. //
  203. //
  204. mapSettingsSave();
  205. } // ControlApplySettings()
  206. //==========================================================================;
  207. //
  208. //
  209. //
  210. //
  211. //==========================================================================;
  212. //--------------------------------------------------------------------------;
  213. //
  214. // BOOL DlgProcACMRestart
  215. //
  216. // Description:
  217. //
  218. //
  219. // Arguments:
  220. //
  221. // Return (BOOL):
  222. //
  223. //
  224. // History:
  225. // 11/16/92 cjp [curtisp]
  226. //
  227. //--------------------------------------------------------------------------;
  228. BOOL FNCALLBACK DlgProcACMRestart
  229. (
  230. HWND hwnd,
  231. UINT uMsg,
  232. WPARAM wParam,
  233. LPARAM lParam
  234. )
  235. {
  236. UINT uCmdId;
  237. switch (uMsg)
  238. {
  239. case WM_INITDIALOG:
  240. return (TRUE);
  241. case WM_COMMAND:
  242. uCmdId = GET_WM_COMMAND_ID(wParam, lParam);
  243. if ((uCmdId == IDOK) || (uCmdId == IDCANCEL))
  244. EndDialog(hwnd, uCmdId == IDOK);
  245. return (TRUE);
  246. }
  247. return (FALSE);
  248. } // DlgProcACMRestart()
  249. //--------------------------------------------------------------------------;
  250. //
  251. // BOOL DlgProcACMAboutBox
  252. //
  253. // Description:
  254. //
  255. //
  256. // Arguments:
  257. //
  258. // Return (BOOL):
  259. //
  260. //
  261. // History:
  262. // 11/16/92 cjp [curtisp]
  263. //
  264. //--------------------------------------------------------------------------;
  265. BOOL FNCALLBACK DlgProcACMAboutBox
  266. (
  267. HWND hwnd,
  268. UINT uMsg,
  269. WPARAM wParam,
  270. LPARAM lParam
  271. )
  272. {
  273. TCHAR ach[80];
  274. TCHAR szFormat[80];
  275. LPACMDRIVERDETAILS padd;
  276. DWORD dw1;
  277. DWORD dw2;
  278. UINT uCmdId;
  279. HFONT hfont;
  280. HWND htxt;
  281. switch (uMsg)
  282. {
  283. case WM_INITDIALOG:
  284. padd = (LPACMDRIVERDETAILS)lParam;
  285. if (NULL == padd)
  286. {
  287. DPF(0, "!DlgProcACMAboutBox: NULL driver details passed!");
  288. return (TRUE);
  289. }
  290. #ifdef JAPAN
  291. hfont = GetStockFont(SYSTEM_FIXED_FONT);
  292. #else
  293. hfont = GetStockFont(ANSI_VAR_FONT);
  294. #endif
  295. //
  296. // fill in all the static text controls with the long info
  297. // returned from the driver
  298. //
  299. LoadString(gpag->hinst, IDS_ABOUT_TITLE, szFormat, SIZEOF(szFormat));
  300. wsprintf(ach, szFormat, (LPTSTR)padd->szShortName);
  301. SetWindowText(hwnd, ach);
  302. //
  303. // if the driver supplies an icon, then use it..
  304. //
  305. if (NULL != padd->hicon)
  306. {
  307. Static_SetIcon(GetDlgItem(hwnd, IDD_ABOUT_ICON_DRIVER), padd->hicon);
  308. }
  309. htxt = GetDlgItem(hwnd, IDD_ABOUT_TXT_DESCRIPTION);
  310. SetWindowFont(htxt, hfont, FALSE);
  311. SetWindowText(htxt, padd->szLongName);
  312. dw1 = padd->vdwACM;
  313. dw2 = padd->vdwDriver;
  314. LoadString(gpag->hinst, IDS_ABOUT_VERSION, szFormat, SIZEOF(szFormat));
  315. #ifdef DEBUG
  316. wsprintf(ach, szFormat, HIWORD(dw2) >> 8, (BYTE)HIWORD(dw2), LOWORD(dw2),
  317. HIWORD(dw1) >> 8, (BYTE)HIWORD(dw1), LOWORD(dw1));
  318. #else
  319. wsprintf(ach, szFormat, HIWORD(dw2) >> 8, (BYTE)HIWORD(dw2),
  320. HIWORD(dw1) >> 8, (BYTE)HIWORD(dw1));
  321. #endif
  322. htxt = GetDlgItem(hwnd, IDD_ABOUT_TXT_VERSION);
  323. SetWindowFont(htxt, hfont, FALSE);
  324. SetWindowText(htxt, ach);
  325. htxt = GetDlgItem(hwnd, IDD_ABOUT_TXT_COPYRIGHT);
  326. SetWindowFont(htxt, hfont, FALSE);
  327. SetWindowText(htxt, padd->szCopyright);
  328. htxt = GetDlgItem(hwnd, IDD_ABOUT_TXT_LICENSING);
  329. SetWindowFont(htxt, hfont, FALSE);
  330. SetWindowText(htxt, padd->szLicensing);
  331. htxt = GetDlgItem(hwnd, IDD_ABOUT_TXT_FEATURES);
  332. SetWindowFont(htxt, hfont, FALSE);
  333. SetWindowText(htxt, padd->szFeatures);
  334. return (TRUE);
  335. case WM_COMMAND:
  336. uCmdId = GET_WM_COMMAND_ID(wParam,lParam);
  337. if ((uCmdId == IDOK) || (uCmdId == IDCANCEL))
  338. EndDialog(hwnd, wParam == uCmdId);
  339. return (TRUE);
  340. }
  341. return (FALSE);
  342. } // DlgProcACMAboutBox()
  343. //--------------------------------------------------------------------------;
  344. //
  345. // void ControlAboutDriver
  346. //
  347. // Description:
  348. //
  349. //
  350. // Arguments:
  351. // HWND hwnd:
  352. //
  353. // LPACMDRIVERSETTINGS pads:
  354. //
  355. // Return (void):
  356. //
  357. // History:
  358. // 09/08/93 cjp [curtisp]
  359. //
  360. //--------------------------------------------------------------------------;
  361. void FNLOCAL ControlAboutDriver
  362. (
  363. HWND hwnd,
  364. LPACMDRIVERSETTINGS pads
  365. )
  366. {
  367. PACMDRIVERDETAILS padd;
  368. MMRESULT mmr;
  369. if (NULL == pads)
  370. return;
  371. //
  372. // if the driver returns MMSYSERR_NOTSUPPORTED, then we need to
  373. // display the info--otherwise, it supposedly displayed a dialog
  374. // (or had a critical error?)
  375. //
  376. mmr = (MMRESULT)acmDriverMessage((HACMDRIVER)pads->hadid,
  377. ACMDM_DRIVER_ABOUT,
  378. (LPARAM)(UINT)hwnd,
  379. 0L);
  380. if (MMSYSERR_NOTSUPPORTED != mmr)
  381. return;
  382. //
  383. // alloc some zero-init'd memory to hold the about box info
  384. //
  385. padd = (PACMDRIVERDETAILS)LocalAlloc(LPTR, sizeof(*padd));
  386. if (NULL == padd)
  387. return;
  388. //
  389. // get info and bring up a generic about box...
  390. //
  391. padd->cbStruct = sizeof(*padd);
  392. mmr = acmDriverDetails(pads->hadid, padd, 0L);
  393. if (MMSYSERR_NOERROR == mmr)
  394. {
  395. DialogBoxParam(gpag->hinst,
  396. DLG_ABOUT_MSACM,
  397. hwnd,
  398. DlgProcACMAboutBox,
  399. (LPARAM)(LPVOID)padd);
  400. }
  401. LocalFree((HLOCAL)padd);
  402. } // ControlAboutDriver()
  403. //--------------------------------------------------------------------------;
  404. //
  405. // BOOL ControlConfigureDriver
  406. //
  407. // Description:
  408. //
  409. //
  410. // Arguments:
  411. // HWND hwnd:
  412. //
  413. // LPACMDRIVERSETTINGS pads:
  414. //
  415. // Return (BOOL):
  416. //
  417. // History:
  418. // 06/15/93 cjp [curtisp]
  419. //
  420. //--------------------------------------------------------------------------;
  421. BOOL FNLOCAL ControlConfigureDriver
  422. (
  423. HWND hwnd,
  424. LPACMDRIVERSETTINGS pads
  425. )
  426. {
  427. int n;
  428. LRESULT lr;
  429. if (NULL == pads)
  430. return (FALSE);
  431. //
  432. //
  433. //
  434. lr = acmDriverMessage((HACMDRIVER)pads->hadid,
  435. DRV_CONFIGURE,
  436. (UINT)hwnd,
  437. 0L);
  438. if (DRVCNF_CANCEL == lr)
  439. return (FALSE);
  440. if (DRVCNF_RESTART != lr)
  441. return (FALSE);
  442. //
  443. //
  444. //
  445. n = DialogBox(gpag->hinst, DLG_RESTART_MSACM, hwnd, DlgProcACMRestart);
  446. if (IDOK == n)
  447. {
  448. ControlApplySettings(hwnd);
  449. ExitWindows(EW_RESTARTWINDOWS, 0);
  450. }
  451. //
  452. // something apparently changed with config..
  453. //
  454. return (TRUE);
  455. } // ControlConfigureDriver()
  456. //==========================================================================;
  457. //
  458. //
  459. //
  460. //
  461. //==========================================================================;
  462. //--------------------------------------------------------------------------;
  463. //
  464. // BOOL DlgProcPriority
  465. //
  466. // Description:
  467. //
  468. //
  469. // Arguments:
  470. //
  471. // Return (BOOL):
  472. //
  473. //
  474. // History:
  475. // 5/31/93 jyg
  476. //
  477. //--------------------------------------------------------------------------;
  478. typedef struct tPRIORITYDLGPARAM {
  479. int iPriority; // in/out priority
  480. int iPriorityMax; // maximum priority value
  481. BOOL fDisabled; // is disabled
  482. TCHAR ach[CONTROL_MAX_ITEM_CHARS]; // name of driver
  483. } PRIORITYDLGPARAM, *PPRIORITYDLGPARAM, FAR *LPPRIORITYDLGPARAM;
  484. BOOL FNCALLBACK DlgProcPriority
  485. (
  486. HWND hwnd,
  487. UINT uMsg,
  488. WPARAM wParam,
  489. LPARAM lParam
  490. )
  491. {
  492. TCHAR achFromTo[80];
  493. TCHAR ach[80];
  494. UINT u;
  495. LPPRIORITYDLGPARAM pdlgparam;
  496. UINT uCmdId;
  497. HWND hcb;
  498. HFONT hfont;
  499. HWND htxt;
  500. //
  501. //
  502. //
  503. switch (uMsg)
  504. {
  505. case WM_INITDIALOG:
  506. SetWindowLong(hwnd, DWL_USER, lParam);
  507. pdlgparam = (LPPRIORITYDLGPARAM)lParam;
  508. #ifdef JAPAN
  509. hfont = GetStockFont(SYSTEM_FIXED_FONT);
  510. #else
  511. hfont = GetStockFont(ANSI_VAR_FONT);
  512. #endif
  513. htxt = GetDlgItem(hwnd, IDD_PRIORITY_TXT_DRIVER);
  514. SetWindowFont(htxt, hfont, FALSE);
  515. SetWindowText(htxt, pdlgparam->ach);
  516. LoadString(gpag->hinst, IDS_PRIORITY_FROMTO, achFromTo, SIZEOF(achFromTo));
  517. wsprintf(ach, achFromTo, pdlgparam->iPriority);
  518. SetDlgItemText(hwnd, IDD_PRIORITY_TXT_FROMTO, ach);
  519. //
  520. // the priority selection is fixed in a dropdownlist box.
  521. //
  522. hcb = GetDlgItem(hwnd, IDD_PRIORITY_COMBO_PRIORITY);
  523. SetWindowFont(hcb, hfont, FALSE);
  524. for (u = 1; u <= (UINT)pdlgparam->iPriorityMax; u++)
  525. {
  526. wsprintf(ach, gszFormatNumber, (DWORD)u);
  527. ComboBox_AddString(hcb, ach);
  528. }
  529. ComboBox_SetCurSel(hcb, pdlgparam->iPriority - 1);
  530. CheckDlgButton(hwnd, IDD_PRIORITY_CHECK_DISABLE, pdlgparam->fDisabled);
  531. return (TRUE);
  532. case WM_COMMAND:
  533. uCmdId = GET_WM_COMMAND_ID(wParam,lParam);
  534. switch (uCmdId)
  535. {
  536. case IDOK:
  537. pdlgparam = (LPPRIORITYDLGPARAM)GetWindowLong(hwnd, DWL_USER);
  538. hcb = GetDlgItem(hwnd, IDD_PRIORITY_COMBO_PRIORITY);
  539. pdlgparam->iPriority = ComboBox_GetCurSel(hcb);
  540. pdlgparam->iPriority++;
  541. pdlgparam->fDisabled = IsDlgButtonChecked(hwnd, IDD_PRIORITY_CHECK_DISABLE);
  542. case IDCANCEL:
  543. EndDialog(hwnd, (TRUE == uCmdId));
  544. break;
  545. }
  546. return (TRUE);
  547. }
  548. return (FALSE);
  549. } // DlgProcPriority()
  550. //==========================================================================;
  551. //
  552. //
  553. //
  554. //
  555. //==========================================================================;
  556. //--------------------------------------------------------------------------;
  557. //
  558. // LPACMDRIVERSETTINGS ControlGetSelectedDriver
  559. //
  560. // Description:
  561. //
  562. //
  563. // Arguments:
  564. // HWND hwnd:
  565. //
  566. // Return (LPACMDRIVERSETTINGS):
  567. //
  568. // History:
  569. // 06/15/93 cjp [curtisp]
  570. //
  571. //--------------------------------------------------------------------------;
  572. LPACMDRIVERSETTINGS FNLOCAL ControlGetSelectedDriver
  573. (
  574. HWND hwnd
  575. )
  576. {
  577. HWND hlb;
  578. UINT u;
  579. LPACMDRIVERSETTINGS pads;
  580. hlb = GetDlgItem(hwnd, IDD_CPL_LIST_DRIVERS);
  581. u = (UINT)ListBox_GetCurSel(hlb);
  582. if (LB_ERR == u)
  583. {
  584. DPF(0, "!ControlGetSelectedDriver: apparently there is no selected driver?");
  585. return (NULL);
  586. }
  587. pads = (LPACMDRIVERSETTINGS)ListBox_GetItemData(hlb, u);
  588. if (NULL == pads)
  589. {
  590. DPF(0, "!ControlGetSelectedDriver: NULL item data for selected driver!!?");
  591. return (NULL);
  592. }
  593. return (pads);
  594. } // ControlGetSelectedDriver()
  595. //--------------------------------------------------------------------------;
  596. //
  597. // void ControlRefreshList
  598. //
  599. // Description:
  600. //
  601. //
  602. // Arguments:
  603. // HWND hwnd:
  604. //
  605. // Return (void):
  606. //
  607. // History:
  608. // 09/08/93 cjp [curtisp]
  609. //
  610. //--------------------------------------------------------------------------;
  611. void FNLOCAL ControlRefreshList
  612. (
  613. HWND hwnd,
  614. BOOL fNotify
  615. )
  616. {
  617. UINT cItems;
  618. UINT uSelection;
  619. ACMDRIVERDETAILS add;
  620. LPACMDRIVERSETTINGS pads;
  621. UINT u;
  622. HWND hlb;
  623. TCHAR ach[CONTROL_MAX_ITEM_CHARS];
  624. BOOL f;
  625. //
  626. //
  627. //
  628. hlb = GetDlgItem(hwnd, IDD_CPL_LIST_DRIVERS);
  629. SetWindowRedraw(hlb, FALSE);
  630. //
  631. //
  632. //
  633. cItems = ListBox_GetCount(hlb);
  634. uSelection = ListBox_GetCurSel(hlb);
  635. for (u = 0; u < cItems; u++)
  636. {
  637. pads = (LPACMDRIVERSETTINGS)ListBox_GetItemData(hlb, u);
  638. ListBox_DeleteString(hlb, u);
  639. add.cbStruct = sizeof(add);
  640. if (MMSYSERR_NOERROR != acmDriverDetails(pads->hadid, &add, 0L))
  641. {
  642. add.szLongName[0] = '\0';
  643. }
  644. f = (0 != (pads->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED));
  645. wsprintf(ach, gszFormatDriverDesc,
  646. pads->dwPriority,
  647. (f ? (LPTSTR)gszDisabled : (LPTSTR)gszNull),
  648. (LPTSTR)add.szLongName);
  649. ListBox_InsertString(hlb, u, ach);
  650. ListBox_SetItemData(hlb, u, (LPARAM)(LPVOID)pads);
  651. }
  652. ListBox_SetCurSel(hlb, uSelection);
  653. SetWindowRedraw(hlb, TRUE);
  654. } // ControlRefreshList()
  655. //--------------------------------------------------------------------------;
  656. //
  657. // void ControlChangePriority
  658. //
  659. // Description:
  660. //
  661. //
  662. // Arguments:
  663. // HWND hwnd:
  664. //
  665. // Return (void):
  666. //
  667. // History:
  668. // 09/08/93 cjp [curtisp]
  669. //
  670. //--------------------------------------------------------------------------;
  671. void FNLOCAL ControlChangePriority
  672. (
  673. HWND hwnd
  674. )
  675. {
  676. PRIORITYDLGPARAM dlgparam;
  677. ACMDRIVERDETAILS add;
  678. LPACMDRIVERSETTINGS pads;
  679. UINT u;
  680. int iPrevPriority; // previous priority
  681. BOOL fPrevDisabled; // previous disabled state
  682. HWND hlb;
  683. TCHAR ach[CONTROL_MAX_ITEM_CHARS];
  684. BOOL f;
  685. pads = ControlGetSelectedDriver(hwnd);
  686. if (NULL == pads)
  687. return;
  688. add.cbStruct = sizeof(add);
  689. if (MMSYSERR_NOERROR != acmDriverDetails(pads->hadid, &add, 0L))
  690. return;
  691. iPrevPriority = (int)pads->dwPriority;
  692. fPrevDisabled = (0 != (pads->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED));
  693. dlgparam.iPriority = iPrevPriority;
  694. dlgparam.fDisabled = fPrevDisabled;
  695. hlb = GetDlgItem(hwnd, IDD_CPL_LIST_DRIVERS);
  696. dlgparam.iPriorityMax = ListBox_GetCount(hlb);
  697. lstrcpy(dlgparam.ach, add.szLongName);
  698. f = (BOOL)DialogBoxParam(gpag->hinst,
  699. DLG_PRIORITY_SET,
  700. hwnd,
  701. DlgProcPriority,
  702. (LPARAM)(LPVOID)&dlgparam);
  703. if (!f)
  704. return;
  705. if ((dlgparam.fDisabled == fPrevDisabled) &&
  706. (dlgparam.iPriority == iPrevPriority))
  707. return;
  708. //
  709. //
  710. //
  711. SetWindowRedraw(hlb, FALSE);
  712. //
  713. // change the disabled state.
  714. //
  715. if (dlgparam.fDisabled != fPrevDisabled)
  716. {
  717. pads->fdwSupport ^= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
  718. }
  719. //
  720. // has there been a priority change?
  721. //
  722. if (dlgparam.iPriority != iPrevPriority)
  723. {
  724. //
  725. // remove old entry and add a placeholder
  726. //
  727. ListBox_DeleteString(hlb, iPrevPriority - 1);
  728. ListBox_InsertString(hlb, dlgparam.iPriority - 1, gszNull);
  729. ListBox_SetItemData(hlb, dlgparam.iPriority - 1, (LPARAM)(LPVOID)pads);
  730. }
  731. //
  732. //
  733. //
  734. for (u = 0; u < (UINT)dlgparam.iPriorityMax; u++)
  735. {
  736. pads = (LPACMDRIVERSETTINGS)ListBox_GetItemData(hlb, u);
  737. ListBox_DeleteString(hlb, u);
  738. add.cbStruct = sizeof(add);
  739. if (MMSYSERR_NOERROR != acmDriverDetails(pads->hadid, &add, 0L))
  740. continue;
  741. f = (0 != (pads->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED));
  742. pads->dwPriority = u + 1;
  743. wsprintf(ach, gszFormatDriverDesc,
  744. pads->dwPriority,
  745. (f ? (LPTSTR)gszDisabled : (LPTSTR)gszNull),
  746. (LPTSTR)add.szLongName);
  747. ListBox_InsertString(hlb, u, ach);
  748. ListBox_SetItemData(hlb, u, (LPARAM)(LPVOID)pads);
  749. }
  750. ListBox_SetCurSel(hlb, dlgparam.iPriority - 1);
  751. SetWindowRedraw(hlb, TRUE);
  752. } // ControlChangePriority()
  753. //--------------------------------------------------------------------------;
  754. //
  755. // void ControlNewDriverSelected
  756. //
  757. // Description:
  758. //
  759. //
  760. // Arguments:
  761. // HWND hwnd:
  762. //
  763. // Return (void):
  764. //
  765. // History:
  766. // 09/08/93 cjp [curtisp]
  767. //
  768. //--------------------------------------------------------------------------;
  769. void FNLOCAL ControlNewDriverSelected
  770. (
  771. HWND hwnd
  772. )
  773. {
  774. LRESULT lr;
  775. LPACMDRIVERSETTINGS pads;
  776. pads = ControlGetSelectedDriver(hwnd);
  777. if (NULL == pads)
  778. return;
  779. lr = acmDriverMessage((HACMDRIVER)pads->hadid,
  780. DRV_QUERYCONFIGURE,
  781. 0L,
  782. 0L);
  783. EnableWindow(GetDlgItem(hwnd, IDD_CPL_BTN_CONFIGURE), (0 != lr));
  784. } // ControlNewDriverSelected()
  785. //==========================================================================;
  786. //
  787. //
  788. //
  789. //
  790. //==========================================================================;
  791. //--------------------------------------------------------------------------;
  792. //
  793. // UINT ControlWaveDeviceChanged
  794. //
  795. // Description:
  796. //
  797. //
  798. // Arguments:
  799. // HWND hwnd:
  800. //
  801. // HWND hcb:
  802. //
  803. // UINT uId:
  804. //
  805. // Return (UINT):
  806. //
  807. // History:
  808. // 09/08/93 cjp [curtisp]
  809. //
  810. //--------------------------------------------------------------------------;
  811. UINT FNLOCAL ControlWaveDeviceChanged
  812. (
  813. HWND hwnd,
  814. HWND hcb,
  815. UINT uId
  816. )
  817. {
  818. UINT uDevId;
  819. UINT u;
  820. uDevId = (UINT)-1;
  821. u = (UINT)ComboBox_GetCurSel(hcb);
  822. if (LB_ERR != u)
  823. {
  824. uDevId = (UINT)ComboBox_GetItemData(hcb, u);
  825. switch (uId)
  826. {
  827. case IDD_CPL_COMBO_RECORD:
  828. CPLSettings.uIdPreferredIn = uDevId;
  829. break;
  830. case IDD_CPL_COMBO_PLAYBACK:
  831. CPLSettings.uIdPreferredOut = uDevId;
  832. break;
  833. }
  834. }
  835. return (uDevId);
  836. } // ControlWaveDeviceChanged()
  837. //==========================================================================;
  838. //
  839. //
  840. //
  841. //
  842. //==========================================================================;
  843. //--------------------------------------------------------------------------;
  844. //
  845. // void ControlCleanupDialog
  846. //
  847. // Description:
  848. //
  849. //
  850. // Arguments:
  851. // HWND hwnd:
  852. //
  853. // Return (void):
  854. //
  855. // History:
  856. // 09/08/93 cjp [curtisp]
  857. //
  858. //--------------------------------------------------------------------------;
  859. void FNLOCAL ControlCleanupDialog
  860. (
  861. HWND hwnd
  862. )
  863. {
  864. //
  865. //
  866. //
  867. if (NULL != ghadidNotify)
  868. {
  869. acmDriverRemove(ghadidNotify, 0L);
  870. ghadidNotify = NULL;
  871. }
  872. //
  873. //
  874. //
  875. if (NULL != CPLSettings.pads)
  876. {
  877. GlobalFreePtr(CPLSettings.pads);
  878. CPLSettings.pads = NULL;
  879. }
  880. } // ControlCleanupDialog()
  881. //--------------------------------------------------------------------------;
  882. //
  883. // BOOL ControlDriverEnumCallback
  884. //
  885. // Description:
  886. //
  887. //
  888. // Arguments:
  889. // HACMDRIVERID hadid:
  890. //
  891. // DWORD dwInstance:
  892. //
  893. // DWORD fdwSupport:
  894. //
  895. // Return (BOOL):
  896. //
  897. // History:
  898. // 09/18/93 cjp [curtisp]
  899. //
  900. //--------------------------------------------------------------------------;
  901. BOOL FNCALLBACK ControlDriverEnumCallback
  902. (
  903. HACMDRIVERID hadid,
  904. DWORD dwInstance,
  905. DWORD fdwSupport
  906. )
  907. {
  908. MMRESULT mmr;
  909. HWND hlb;
  910. ACMDRIVERDETAILS add;
  911. TCHAR ach[CONTROL_MAX_ITEM_CHARS];
  912. DWORD dwPriority;
  913. LPACMDRIVERSETTINGS pads;
  914. BOOL f;
  915. UINT u;
  916. add.cbStruct = sizeof(add);
  917. mmr = acmDriverDetails(hadid, &add, 0L);
  918. if (MMSYSERR_NOERROR != mmr)
  919. {
  920. DPF(0, "!ControlDriverEnumCallback: acmDriverDetails failed! hadid=%.04Xh, mmr=%u", hadid, mmr);
  921. return (TRUE);
  922. }
  923. mmr = acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_PRIORITY, &dwPriority);
  924. if (MMSYSERR_NOERROR != mmr)
  925. {
  926. DPF(0, "!ControlDriverEnumCallback: acmMetrics(priority) failed! hadid=%.04Xh, mmr=%u", hadid, mmr);
  927. return (TRUE);
  928. }
  929. f = (0 != (fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED));
  930. wsprintf(ach, gszFormatDriverDesc,
  931. dwPriority,
  932. (f ? (LPTSTR)gszDisabled : (LPTSTR)gszNull),
  933. (LPTSTR)add.szLongName);
  934. hlb = (HWND)(UINT)dwInstance;
  935. u = ListBox_GetCount(hlb);
  936. pads = &CPLSettings.pads[u];
  937. pads->hadid = hadid;
  938. pads->fdwSupport = fdwSupport;
  939. pads->dwPriority = dwPriority;
  940. u = ListBox_AddString(hlb, ach);
  941. ListBox_SetItemData(hlb, u, (LPARAM)(LPVOID)pads);
  942. return (TRUE);
  943. } // ControlDriverEnumCallback()
  944. //--------------------------------------------------------------------------;
  945. //
  946. // BOOL ControlInitDialog
  947. //
  948. // Description:
  949. //
  950. //
  951. // Arguments:
  952. // HWND hwnd:
  953. //
  954. // Return (BOOL):
  955. //
  956. // History:
  957. // 09/08/93 cjp [curtisp]
  958. //
  959. //--------------------------------------------------------------------------;
  960. BOOL FNLOCAL ControlInitDialog
  961. (
  962. HWND hwnd
  963. )
  964. {
  965. MMRESULT mmr;
  966. UINT u;
  967. UINT cInDevs;
  968. UINT cOutDevs;
  969. HWND hlb;
  970. HWND hcb;
  971. int aiTabs[2];
  972. RECT rc;
  973. RECT rcText;
  974. POINT ptUpperLeft;
  975. HDC hdc;
  976. LPACMDRIVERSETTINGS pads;
  977. DWORD cb;
  978. UINT cTotalInstalledDrivers;
  979. TCHAR ach[10];
  980. HFONT hfont;
  981. SIZE sSize;
  982. CPLSettings.pads = NULL;
  983. //
  984. // For the tabbed listbox, we are defining 3 columns
  985. // Priority, State, Name. To be flexible, we need to know
  986. // the max length of the text for the numeric, and the disabled strings
  987. //
  988. // ->| ->|
  989. // 1 (disabled) Long Name
  990. //
  991. // The aiTabs array contains the tabstops where:
  992. // aiTabs[0]
  993. //
  994. mmr = acmMetrics(NULL, ACM_METRIC_COUNT_DRIVERS, &cb);
  995. if (MMSYSERR_NOERROR != mmr)
  996. {
  997. DPF(0, "!ControlInitDialog: acmMetrics(count_drivers) failed! mmr=%u", mmr);
  998. cb = 0;
  999. }
  1000. cTotalInstalledDrivers = (UINT)cb;
  1001. mmr = acmMetrics(NULL, ACM_METRIC_COUNT_DISABLED, &cb);
  1002. if (MMSYSERR_NOERROR != mmr)
  1003. {
  1004. DPF(0, "!ControlInitDialog: acmMetrics(count_disabled) failed! mmr=%u", mmr);
  1005. cb = 0;
  1006. }
  1007. cTotalInstalledDrivers += (UINT)cb;
  1008. if (0 == cTotalInstalledDrivers)
  1009. {
  1010. // No drivers, MSACM was not initialized correctly.
  1011. EndDialog(hwnd, FALSE);
  1012. return (TRUE);
  1013. }
  1014. //
  1015. //
  1016. //
  1017. cb = sizeof(*pads) * cTotalInstalledDrivers;
  1018. pads = (LPACMDRIVERSETTINGS)GlobalAllocPtr(GHND, cb);
  1019. if (NULL == pads)
  1020. {
  1021. EndDialog(hwnd, FALSE);
  1022. return (TRUE);
  1023. }
  1024. CPLSettings.pads = pads;
  1025. //
  1026. //
  1027. //
  1028. LoadString(gpag->hinst, IDS_TXT_DISABLED, gszDisabled, SIZEOF(gszDisabled));
  1029. //
  1030. //
  1031. //
  1032. hlb = GetDlgItem(hwnd, IDD_CPL_LIST_DRIVERS);
  1033. #ifdef JAPAN
  1034. hfont = GetStockFont(SYSTEM_FIXED_FONT);
  1035. #else
  1036. hfont = GetStockFont(ANSI_VAR_FONT);
  1037. #endif
  1038. SetWindowFont(hlb, hfont, FALSE);
  1039. SetWindowRedraw(hlb, FALSE);
  1040. ListBox_ResetContent(hlb);
  1041. mmr = acmDriverEnum(ControlDriverEnumCallback,
  1042. (DWORD)(UINT)hlb,
  1043. ACM_DRIVERENUMF_NOLOCAL |
  1044. ACM_DRIVERENUMF_DISABLED);
  1045. if (MMSYSERR_NOERROR != mmr)
  1046. {
  1047. DPF(0, "!ControlInitDialog: acmDriverEnum failed! mmr=%u", mmr);
  1048. EndDialog(hwnd, FALSE);
  1049. return (TRUE);
  1050. }
  1051. //
  1052. //
  1053. //
  1054. mmr = acmDriverAdd(&ghadidNotify,
  1055. gpag->hinst,
  1056. (LPARAM)(UINT)hwnd,
  1057. WM_ACMMAP_ACM_NOTIFY,
  1058. ACM_DRIVERADDF_NOTIFYHWND);
  1059. if (MMSYSERR_NOERROR != mmr)
  1060. {
  1061. DPF(0, "!ControlInitDialog: acmDriverAdd failed to add notify window! mmr=%u", mmr);
  1062. }
  1063. //
  1064. //
  1065. //
  1066. hdc = GetDC(hlb);
  1067. u = ListBox_GetCount(hlb);
  1068. wsprintf(ach, gszFormatNumber, (DWORD)u);
  1069. GetTextExtentPoint(hdc, ach, lstrlen(ach), &sSize);
  1070. aiTabs[0] = sSize.cx;
  1071. #ifdef JAPAN
  1072. //fix kksuzuka: #2206
  1073. //Since the charcter number of Japanese localized Disabled string is less
  1074. // than localized priority string, sSize.cx is not enough to disp Priority
  1075. //string.
  1076. GetTextExtentPoint(hdc, TEXT("xxxxxxxxxx"), 10, &sSize);
  1077. #else
  1078. GetTextExtentPoint(hdc, gszDisabled, lstrlen(gszDisabled), &sSize);
  1079. #endif
  1080. aiTabs[1] = sSize.cx;
  1081. ReleaseDC(hlb, hdc);
  1082. //
  1083. // one dialog base cell
  1084. //
  1085. rc.left = 0;
  1086. rc.right = 4;
  1087. rc.top = 0;
  1088. rc.bottom = 8;
  1089. MapDialogRect(hwnd,&rc);
  1090. // rc.right now contains the width of dialog base unit in pixels
  1091. aiTabs[0] = (aiTabs[0] * 4) / rc.right;
  1092. aiTabs[1] = (aiTabs[1] * 4) / rc.right;
  1093. // Now add separation between columns.
  1094. aiTabs[0] += 4;
  1095. aiTabs[1] += aiTabs[0] + 4;
  1096. ListBox_SetTabStops(hlb, 2, (LPARAM)(LPVOID)aiTabs);
  1097. //
  1098. // Note: Translation back to logical units.
  1099. // Tabs[0] = (aiTabs[0] * rc.right) / 4;
  1100. // Tabs[1] = (aiTabs[1] * rc.right) / 4;
  1101. //
  1102. //
  1103. // Ok, what's going on in the next chunk of code is the column
  1104. // description "Driver" is being moved on top of it's tabbed
  1105. // column. Since we keep the dialog coordinates of the second
  1106. // tab around, we just convert back to logical coordinates and
  1107. // shift the static control over (relative to the origin where
  1108. // the static "Priority" control sits.
  1109. //
  1110. // Move window positions relative to the parent client area, so we
  1111. // need to translate to client coordinates after we've gotten the
  1112. // position of the control in screen coordinates.
  1113. //
  1114. //
  1115. // Use "Priority" as a reference, since it never moves and
  1116. // this function might be called more than once.
  1117. //
  1118. GetWindowRect(GetDlgItem(hwnd,IDD_CPL_STATIC_PRIORITY), &rcText);
  1119. ptUpperLeft.x = rcText.left;
  1120. ptUpperLeft.y = rcText.top;
  1121. ScreenToClient(hwnd, &ptUpperLeft);
  1122. rcText.right -= rcText.left;
  1123. rcText.bottom -= rcText.top;
  1124. rcText.left = ptUpperLeft.x;
  1125. rcText.top = ptUpperLeft.y;
  1126. //
  1127. // move relative 2 dialog tabs translated to logical units.
  1128. //
  1129. #if (WINVER < 0x0400)
  1130. rcText.left += (aiTabs[1] * (rc.right - 1)) / 4;
  1131. #else
  1132. rcText.left += (aiTabs[1] * rc.right) / 4;
  1133. #endif
  1134. MoveWindow(GetDlgItem(hwnd, IDD_CPL_STATIC_DRIVERS),
  1135. rcText.left,
  1136. rcText.top,
  1137. rcText.right,
  1138. rcText.bottom,
  1139. FALSE);
  1140. //
  1141. // set up the initial selection to be the first driver--i wonder
  1142. // what we should do if NO drivers are installed? but since we
  1143. // will ALWAYS have the PCM converter installed (regardless of whether
  1144. // it is enabled or disabled), i'm not going to worry about it...
  1145. //
  1146. ListBox_SetCurSel(hlb, 0);
  1147. ControlNewDriverSelected(hwnd);
  1148. SetWindowRedraw(hlb, TRUE);
  1149. InvalidateRect(hlb, NULL, FALSE);
  1150. //
  1151. // !!!
  1152. //
  1153. //
  1154. cInDevs = gpag->cWaveInDevs;
  1155. cOutDevs = gpag->cWaveOutDevs;
  1156. WAIT_FOR_MUTEX(gpag->hMutexSettings);
  1157. //
  1158. // fill the output devices combo box
  1159. //
  1160. hcb = GetDlgItem(hwnd, IDD_CPL_COMBO_PLAYBACK);
  1161. SetWindowFont(hcb, hfont, FALSE);
  1162. ComboBox_ResetContent(hcb);
  1163. if (0 == cOutDevs)
  1164. {
  1165. EnableWindow(hcb, FALSE);
  1166. }
  1167. else
  1168. {
  1169. for (u = 0; u < cOutDevs; u++)
  1170. {
  1171. WAVEOUTCAPS woc;
  1172. waveOutGetDevCaps(u, &woc, sizeof(woc));
  1173. woc.szPname[SIZEOF(woc.szPname) - 1] = '\0';
  1174. ComboBox_AddString(hcb, woc.szPname);
  1175. ComboBox_SetItemData(hcb, u + 1, (LPARAM)u);
  1176. }
  1177. u = (UINT)ComboBox_SelectString(hcb, 0, gpag->pSettings->szPreferredWaveOut);
  1178. if (CB_ERR == u)
  1179. {
  1180. ComboBox_SetCurSel(hcb, 0);
  1181. }
  1182. }
  1183. //
  1184. // fill the input devices combo box
  1185. //
  1186. hcb = GetDlgItem(hwnd, IDD_CPL_COMBO_RECORD);
  1187. SetWindowFont(hcb, hfont, FALSE);
  1188. ComboBox_ResetContent(hcb);
  1189. if (0 == cInDevs)
  1190. {
  1191. EnableWindow(hcb, FALSE);
  1192. }
  1193. else
  1194. {
  1195. for (u = 0; u < cInDevs; u++)
  1196. {
  1197. WAVEINCAPS wic;
  1198. waveInGetDevCaps(u, &wic, sizeof(wic));
  1199. wic.szPname[SIZEOF(wic.szPname) - 1] = '\0';
  1200. ComboBox_AddString(hcb, wic.szPname);
  1201. ComboBox_SetItemData(hcb, u + 1, (LPARAM)u);
  1202. }
  1203. u = (UINT)ComboBox_SelectString(hcb, 0, gpag->pSettings->szPreferredWaveIn);
  1204. if (CB_ERR == u)
  1205. {
  1206. ComboBox_SetCurSel(hcb, 0);
  1207. }
  1208. }
  1209. //
  1210. //
  1211. //
  1212. CPLSettings.fPreferredOnly = gpag->pSettings->fPreferredOnly;
  1213. CheckDlgButton(hwnd, IDD_CPL_CHECK_PREFERRED, gpag->pSettings->fPreferredOnly);
  1214. RELEASE_MUTEX(gpag->hMutexSettings);
  1215. #if (WINVER >= 0x0400)
  1216. EnableWindow(GetDlgItem(hwnd, IDD_CPL_BTN_INSTALL), TRUE); //VIJR: disable install
  1217. //CPLSendNotify(hwnd, LOWORD((DWORD)DLG_CPL_MSACM), PSN_CHANGED);
  1218. PropSheet_Changed(GetParent(hwnd),hwnd);
  1219. #endif
  1220. return (TRUE);
  1221. } // ControlInitDialog()
  1222. //==========================================================================;
  1223. //
  1224. //
  1225. //
  1226. //
  1227. //==========================================================================;
  1228. //--------------------------------------------------------------------------;
  1229. //
  1230. // void ControlCommand
  1231. //
  1232. // Description:
  1233. //
  1234. //
  1235. // Arguments:
  1236. // HWND hwnd:
  1237. //
  1238. // WPARAM wParam:
  1239. //
  1240. // LPARAM lParam:
  1241. //
  1242. // Return (void):
  1243. //
  1244. // History:
  1245. // 09/08/93 cjp [curtisp]
  1246. //
  1247. //--------------------------------------------------------------------------;
  1248. void FNLOCAL ControlCommand
  1249. (
  1250. HWND hwnd,
  1251. WPARAM wParam,
  1252. LPARAM lParam
  1253. )
  1254. {
  1255. UINT uCmdId;
  1256. UINT uCmd;
  1257. HWND hwndCmd;
  1258. LPACMDRIVERSETTINGS pads;
  1259. //
  1260. //
  1261. //
  1262. uCmdId = GET_WM_COMMAND_ID(wParam, lParam);
  1263. uCmd = GET_WM_COMMAND_CMD(wParam, lParam);
  1264. hwndCmd = GET_WM_COMMAND_HWND(wParam, lParam);
  1265. switch (uCmdId)
  1266. {
  1267. case IDD_CPL_BTN_APPLY:
  1268. ControlApplySettings(hwnd);
  1269. break;
  1270. case IDOK:
  1271. #if (WINVER < 0x0400)
  1272. ControlApplySettings(hwnd);
  1273. if (GetKeyState(VK_CONTROL) < 0)
  1274. break;
  1275. #endif
  1276. case IDCANCEL:
  1277. WinHelp(hwnd, gszCPLHelp, HELP_QUIT, 0L);
  1278. EndDialog(hwnd, (TRUE == uCmdId));
  1279. break;
  1280. case IDD_CPL_BTN_CONFIGURE:
  1281. pads = ControlGetSelectedDriver(hwnd);
  1282. ControlConfigureDriver(hwnd, pads);
  1283. break;
  1284. case IDD_CPL_BTN_ABOUT:
  1285. pads = ControlGetSelectedDriver(hwnd);
  1286. ControlAboutDriver(hwnd, pads);
  1287. break;
  1288. case IDD_CPL_BTN_PRIORITY:
  1289. ControlChangePriority(hwnd);
  1290. break;
  1291. case IDD_CPL_BTN_HELP:
  1292. #ifdef USE_DAYTONA_HELP
  1293. WinHelp(hwnd, gszCPLHelp, HELP_CONTEXT, IDH_CHILD_MSACM );
  1294. #else
  1295. WinHelp(hwnd, gszCPLHelp, HELP_CONTENTS, 0L);
  1296. #endif
  1297. break;
  1298. case IDD_CPL_BTN_BUMPTOTOP:
  1299. break;
  1300. case IDD_CPL_BTN_ABLE:
  1301. pads = ControlGetSelectedDriver(hwnd);
  1302. if (NULL != pads)
  1303. {
  1304. pads->fdwSupport ^= ACMDRIVERDETAILS_SUPPORTF_DISABLED;
  1305. ControlRefreshList(hwnd, FALSE);
  1306. }
  1307. break;
  1308. #if (WINVER >= 0x0400)
  1309. case IDD_CPL_BTN_INSTALL:
  1310. {
  1311. typedef RETERR (WINAPI pfnDICREATEDEVICEINFO)(LPLPDEVICE_INFO lplpdi, LPCSTR lpszDescription, DWORD hDevnode, HKEY hkey, LPCSTR lpszRegsubkey, LPCSTR lpszClassName, HWND hwndParent);
  1312. typedef RETERR (WINAPI pfnDIDESTROYDEVICEINFOLIST)(LPDEVICE_INFO lpdi);
  1313. typedef RETERR (WINAPI pfnDICALLCLASSINSTALLER)(DI_FUNCTION diFctn, LPDEVICE_INFO lpdi);
  1314. static TCHAR BCODE gszSetupX[] = TEXT("SETUPX.DLL");
  1315. static TCHAR BCODE gszDiCreateDeviceInfo[] = TEXT("DiCreateDeviceInfo");
  1316. static TCHAR BCODE gszDiDestroyDeviceInfoList[] = TEXT("DiDestroyDeviceInfoList");
  1317. static TCHAR BCODE gszDiCallClassInstaller[] = TEXT("DiCallClassInstaller");
  1318. pfnDICREATEDEVICEINFO FAR* pfnDiCreateDeviceInfo;
  1319. pfnDIDESTROYDEVICEINFOLIST FAR* pfnDiDestroyDeviceInfoList;
  1320. pfnDICALLCLASSINSTALLER FAR* pfnDiCallClassInstaller;
  1321. LPDEVICE_INFO lpdi;
  1322. HINSTANCE hiSetupX;
  1323. hiSetupX = LoadLibrary(gszSetupX);
  1324. if (hiSetupX <= HINSTANCE_ERROR)
  1325. break;
  1326. pfnDiCreateDeviceInfo = (pfnDICREATEDEVICEINFO FAR*)GetProcAddress(hiSetupX, gszDiCreateDeviceInfo);
  1327. pfnDiDestroyDeviceInfoList = (pfnDIDESTROYDEVICEINFOLIST FAR*)GetProcAddress(hiSetupX, gszDiDestroyDeviceInfoList);
  1328. pfnDiCallClassInstaller = (pfnDICALLCLASSINSTALLER FAR*)GetProcAddress(hiSetupX, gszDiCallClassInstaller);
  1329. pfnDiCreateDeviceInfo(&lpdi, NULL, NULL, NULL, NULL, "media",
  1330. GetParent(hwnd));
  1331. lpdi->Flags |= DI_SHOWOEM;
  1332. if (pfnDiCallClassInstaller(DIF_SELECTDEVICE, lpdi) == OK)
  1333. {
  1334. pfnDiCallClassInstaller(DIF_INSTALLDEVICE, lpdi);
  1335. }
  1336. pfnDiDestroyDeviceInfoList(lpdi);
  1337. FreeLibrary(hiSetupX);
  1338. break;
  1339. }
  1340. #endif
  1341. case IDD_CPL_CHECK_PREFERRED:
  1342. CPLSettings.fPreferredOnly = IsDlgButtonChecked(hwnd, IDD_CPL_CHECK_PREFERRED);
  1343. break;
  1344. case IDD_CPL_COMBO_RECORD:
  1345. case IDD_CPL_COMBO_PLAYBACK:
  1346. if (CBN_SELCHANGE == uCmd)
  1347. {
  1348. ControlWaveDeviceChanged(hwnd, hwndCmd, uCmdId);
  1349. }
  1350. break;
  1351. case IDD_CPL_LIST_DRIVERS:
  1352. switch (uCmd)
  1353. {
  1354. case LBN_SELCHANGE:
  1355. ControlNewDriverSelected(hwnd);
  1356. break;
  1357. case LBN_DBLCLK:
  1358. if (GetKeyState(VK_CONTROL) < 0)
  1359. {
  1360. uCmd = IDD_CPL_BTN_ABLE;
  1361. }
  1362. else if (GetKeyState(VK_SHIFT) < 0)
  1363. {
  1364. uCmd = IDD_CPL_BTN_BUMPTOTOP;
  1365. }
  1366. else
  1367. {
  1368. uCmd = IDD_CPL_BTN_ABOUT;
  1369. }
  1370. ControlCommand(hwnd, uCmd, 0L);
  1371. break;
  1372. }
  1373. break;
  1374. }
  1375. } // ControlCommand()
  1376. //==========================================================================;
  1377. //
  1378. //
  1379. //
  1380. //
  1381. //==========================================================================;
  1382. //--------------------------------------------------------------------------;
  1383. //
  1384. // BOOL ACMDlg
  1385. //
  1386. // Description:
  1387. //
  1388. //
  1389. // Arguments:
  1390. // HWND hwnd:
  1391. //
  1392. // UINT uMsg:
  1393. //
  1394. // WPARAM wParam:
  1395. //
  1396. // LPARAM lParam:
  1397. //
  1398. // Return (BOOL):
  1399. //
  1400. // History:
  1401. // 09/08/93 cjp [curtisp]
  1402. //
  1403. //--------------------------------------------------------------------------;
  1404. BOOL FNCALLBACK ACMDlg
  1405. (
  1406. HWND hwnd,
  1407. UINT uMsg,
  1408. WPARAM wParam,
  1409. LPARAM lParam
  1410. )
  1411. {
  1412. #if (WINVER >= 0x0400)
  1413. LPNMHDR pnm;
  1414. #endif
  1415. switch (uMsg)
  1416. {
  1417. case WM_INITDIALOG:
  1418. ControlInitDialog(hwnd);
  1419. return (TRUE);
  1420. case WM_COMMAND:
  1421. ControlCommand(hwnd, wParam, lParam);
  1422. return (TRUE);
  1423. case WM_DESTROY:
  1424. ControlCleanupDialog(hwnd);
  1425. return (TRUE);
  1426. case WM_ACMMAP_ACM_NOTIFY:
  1427. ControlRefreshList(hwnd, TRUE);
  1428. return (TRUE);
  1429. #if (WINVER >= 0x0400)
  1430. //
  1431. // right mouse click (and F1)
  1432. //
  1433. case WM_CONTEXTMENU:
  1434. WinHelp((HWND)wParam, gszCPLHelp, HELP_CONTEXTMENU, (DWORD)(LPSTR)ganKeywordIds);
  1435. break;
  1436. case WM_HELP:
  1437. WinHelp(((LPHELPINFO)lParam)->hItemHandle, gszCPLHelp, WM_HELP, (DWORD)(LPSTR)ganKeywordIds);
  1438. break;
  1439. case WM_NOTIFY:
  1440. pnm = (NMHDR FAR *)lParam;
  1441. switch(pnm->code)
  1442. {
  1443. case PSN_KILLACTIVE:
  1444. FORWARD_WM_COMMAND(hwnd, IDOK, 0, 0, SendMessage);
  1445. break;
  1446. case PSN_APPLY:
  1447. FORWARD_WM_COMMAND(hwnd, IDD_CPL_BTN_APPLY, 0, 0, SendMessage);
  1448. return TRUE;
  1449. case PSN_SETACTIVE:
  1450. // FORWARD_WM_COMMAND(hwnd, ID_INIT, 0, 0, SendMessage);
  1451. return TRUE;
  1452. case PSN_RESET:
  1453. FORWARD_WM_COMMAND(hwnd, IDCANCEL, 0, 0, SendMessage);
  1454. return TRUE;
  1455. }
  1456. break;
  1457. #endif
  1458. }
  1459. return (FALSE);
  1460. } // ACMDlg()
  1461. //==========================================================================;
  1462. //
  1463. //
  1464. //
  1465. //
  1466. //==========================================================================;
  1467. #if (WINVER < 0x0400)
  1468. //--------------------------------------------------------------------------;
  1469. //
  1470. // LRESULT CPLApplet
  1471. //
  1472. // Description:
  1473. //
  1474. //
  1475. // Arguments:
  1476. // HWND hwnd:
  1477. //
  1478. // UINT uMsg:
  1479. //
  1480. // LPARAM lParam1:
  1481. //
  1482. // LPARAM lParam2:
  1483. //
  1484. // Return (LRESULT):
  1485. //
  1486. // History:
  1487. // 09/08/93 cjp [curtisp]
  1488. //
  1489. //--------------------------------------------------------------------------;
  1490. EXTERN_C LRESULT FNEXPORT CPlApplet
  1491. (
  1492. HWND hwnd,
  1493. UINT uMsg,
  1494. LPARAM lParam1,
  1495. LPARAM lParam2
  1496. )
  1497. {
  1498. static BOOL fAppletEntered = FALSE;
  1499. LPNEWCPLINFO pcpli;
  1500. switch (uMsg)
  1501. {
  1502. case CPL_INIT:
  1503. #ifdef WIN32
  1504. //
  1505. // Is it a bug that we rely on ENABLE being called?
  1506. //
  1507. mapSettingsRestore();
  1508. #endif
  1509. //
  1510. // For snowball program managment. They don't want to document
  1511. // the CPL.
  1512. //
  1513. if (!gpag->fEnableControl)
  1514. return (FALSE);
  1515. return (TRUE);
  1516. case CPL_GETCOUNT:
  1517. return (1L);
  1518. case CPL_NEWINQUIRE:
  1519. pcpli = (LPNEWCPLINFO)lParam2;
  1520. pcpli->dwSize = sizeof(*pcpli);
  1521. pcpli->hIcon = LoadIcon(gpag->hinst, ICON_MSACM);
  1522. LoadString(gpag->hinst, IDS_CPL_NAME, pcpli->szName, SIZEOF(pcpli->szName));
  1523. LoadString(gpag->hinst, IDS_CPL_INFO, pcpli->szInfo, SIZEOF(pcpli->szInfo));
  1524. lstrcpy(pcpli->szHelpFile, gszCPLHelp);
  1525. pcpli->lData = 0;
  1526. pcpli->dwHelpContext = 0;
  1527. return (TRUE);
  1528. case CPL_DBLCLK:
  1529. if (!fAppletEntered)
  1530. {
  1531. fAppletEntered = TRUE;
  1532. DialogBox(gpag->hinst, DLG_CPL_MSACM, hwnd, ACMDlg);
  1533. fAppletEntered = FALSE;
  1534. }
  1535. break;
  1536. case CPL_SELECT:
  1537. case CPL_STOP:
  1538. case CPL_EXIT:
  1539. break;
  1540. }
  1541. return (0L);
  1542. } // CPLApplet()
  1543. #else // WINVER
  1544. //
  1545. // Function: ReleasePage, private
  1546. //
  1547. // Descriptions:
  1548. // This function performs any needed cleanup on the property sheet which
  1549. // was previously created.
  1550. //
  1551. // Arguments:
  1552. // ppsp -- the page which is being deleted.
  1553. //
  1554. // Returns:
  1555. // void
  1556. //
  1557. EXTERN_C void FNEXPORT ReleasePage
  1558. (
  1559. LPPROPSHEETPAGE ppsp
  1560. )
  1561. {
  1562. LocalFree((HLOCAL)ppsp->lParam);
  1563. }
  1564. //
  1565. // Function: AddAcmPages, private
  1566. //
  1567. // Descriptions:
  1568. // This function creates a property sheet object for the resource page
  1569. // which shows resource information.
  1570. //
  1571. // Arguments:
  1572. // lpszResource -- the class for which the page is to be added
  1573. // lpfnAddPage -- the callback function.
  1574. // lParam -- the lParam to be passed to the callback.
  1575. //
  1576. // Returns:
  1577. // TRUE, if no error FALSE, otherwise.
  1578. //
  1579. EXTERN_C BOOL FNEXPORT AddAcmPages
  1580. (
  1581. LPVOID pszTitle,
  1582. LPFNADDPROPSHEETPAGE lpfnAddPropSheetPage,
  1583. LPARAM lParam
  1584. )
  1585. {
  1586. PROPSHEETPAGE psp;
  1587. PSTR szTitle;
  1588. if (szTitle = (PSTR)LocalAlloc(LPTR, lstrlen(pszTitle) + 1)) {
  1589. HPROPSHEETPAGE hpsp;
  1590. lstrcpy(szTitle, pszTitle);
  1591. psp.dwSize = sizeof(PROPSHEETPAGE);
  1592. psp.dwFlags = PSP_USETITLE | PSP_USERELEASEFUNC;
  1593. psp.hInstance = gpag->hinst;
  1594. psp.pszTemplate = DLG_CPL_MSACM;
  1595. psp.pszIcon = NULL;
  1596. psp.pszTitle = szTitle;
  1597. psp.pfnDlgProc = ACMDlg;
  1598. psp.lParam = (LPARAM)(LPSTR)szTitle;
  1599. psp.pfnRelease = ReleasePage;
  1600. psp.pcRefParent = NULL;
  1601. if (hpsp = CreatePropertySheetPage(&psp)) {
  1602. if (lpfnAddPropSheetPage(hpsp, lParam))
  1603. return TRUE;
  1604. DestroyPropertySheetPage(hpsp);
  1605. } else
  1606. LocalFree((HLOCAL)szTitle);
  1607. }
  1608. return FALSE;
  1609. }
  1610. LRESULT PASCAL CPLSendNotify(HWND hwnd, int idFrom, int code)
  1611. {
  1612. LRESULT lr;
  1613. NMHDR nm;
  1614. nm.hwndFrom = hwnd;
  1615. nm.idFrom = idFrom;
  1616. nm.code = code;
  1617. lr = SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)(LPVOID)&nm);
  1618. return (lr);
  1619. }
  1620. #endif