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.

1366 lines
39 KiB

  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 - 1994 Microsoft Corporation. All Rights Reserved.
  9. //--------------------------------------------------------------------------;
  10. //
  11. // aadrvs.c
  12. //
  13. // Description:
  14. //
  15. //
  16. //
  17. //==========================================================================;
  18. #include <windows.h>
  19. #include <windowsx.h>
  20. #include <mmsystem.h>
  21. #include <mmreg.h>
  22. #include <msacm.h>
  23. #include <memory.h>
  24. #include "tlb.h"
  25. #include "appport.h"
  26. #include "acmapp.h"
  27. #include "debug.h"
  28. TCHAR gszFormatDriversTitle[] = TEXT("Id\t4!Name\t12!Priority\t6!Support\t6!Full Name");
  29. TCHAR gszFormatDriversList[] = TEXT("%.04Xh\t%s\t%lu%s\t%.08lXh\t%s");
  30. TCHAR gszFormatDriverFormatsTitle[] = TEXT("Id\t4!Index\t2!Tag\t2!Support\t5!cbwfx\t2!Format");
  31. TCHAR gszFormatDriverFormatsList[] = TEXT("%.04Xh\t%lu\t%lu\t%.08lXh\t%u\t%-s");
  32. static HACMDRIVERID ghadidSelected;
  33. static HACMDRIVER ghadSelected;
  34. //--------------------------------------------------------------------------;
  35. //
  36. // BOOL AcmAppDisplayDriverDetails
  37. //
  38. // Description:
  39. //
  40. //
  41. // Arguments:
  42. // HWND hedit:
  43. //
  44. // HACMDRIVER had:
  45. //
  46. // Return (BOOL):
  47. //
  48. //--------------------------------------------------------------------------;
  49. BOOL FNLOCAL AcmAppDisplayDriverDetails
  50. (
  51. HWND hedit,
  52. HACMDRIVERID hadid
  53. )
  54. {
  55. static TCHAR szDisplayTitle[] = TEXT("[Driver Details]\r\n");
  56. MMRESULT mmr;
  57. ACMDRIVERDETAILS add;
  58. //
  59. //
  60. //
  61. MEditPrintF(hedit, szDisplayTitle);
  62. MEditPrintF(hedit, TEXT("%25s: %.04Xh"), (LPTSTR)TEXT("Driver Identifier Handle"), hadid);
  63. //
  64. //
  65. //
  66. //
  67. add.cbStruct = sizeof(add);
  68. mmr = acmDriverDetails(hadid, &add, 0L);
  69. if (MMSYSERR_NOERROR != mmr)
  70. {
  71. //
  72. // this should never happen..
  73. //
  74. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("ERROR GETTING DRIVER DETAILS"), mmr);
  75. return (FALSE);
  76. }
  77. //
  78. //
  79. //
  80. //
  81. MEditPrintF(hedit, TEXT("%25s: %lu bytes (requested %lu)"),
  82. (LPTSTR)TEXT("Size of Driver Details"),
  83. add.cbStruct, (DWORD)sizeof(add));
  84. //
  85. // this would be bad
  86. //
  87. if (add.cbStruct < sizeof(add))
  88. return (0L);
  89. MEditPrintF(hedit, TEXT("%25s: %.08lXh (%s)"), (LPTSTR)TEXT("FCC Type"),
  90. add.fccType,
  91. (ACMDRIVERDETAILS_FCCTYPE_AUDIOCODEC == add.fccType) ?
  92. (LPTSTR)TEXT("'audc'") : (LPTSTR)TEXT("**INVALID**"));
  93. MEditPrintF(hedit, TEXT("%25s: %.08lXh (%s)"), (LPTSTR)TEXT("FCC Compressor"),
  94. add.fccComp,
  95. (ACMDRIVERDETAILS_FCCCOMP_UNDEFINED == add.fccComp) ?
  96. (LPTSTR)TEXT("correct") : (LPTSTR)TEXT("**INVALID**"));
  97. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Manufacturer Id"), add.wMid);
  98. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Product Id"), add.wPid);
  99. MEditPrintF(hedit, TEXT("%25s: %u.%.02u (Build %.03u)"), (LPTSTR)TEXT("ACM Version Required"),
  100. HIWORD(add.vdwACM) >> 8,
  101. HIWORD(add.vdwACM) & 0x00FF,
  102. LOWORD(add.vdwACM));
  103. MEditPrintF(hedit, TEXT("%25s: %u.%.02u (Build %.03u)"), (LPTSTR)TEXT("CODEC Version"),
  104. HIWORD(add.vdwDriver) >> 8,
  105. HIWORD(add.vdwDriver) & 0x00FF,
  106. LOWORD(add.vdwDriver));
  107. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("Standard Support"), add.fdwSupport);
  108. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Count Format Tags"), add.cFormatTags);
  109. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Count Filter Tags"), add.cFilterTags);
  110. MEditPrintF(hedit, TEXT("%25s: %.04Xh"), (LPTSTR)TEXT("Custom Icon Handle"), add.hicon);
  111. MEditPrintF(hedit, TEXT("%25s: '%s'"), (LPTSTR)TEXT("Short Name"), (LPTSTR)add.szShortName);
  112. MEditPrintF(hedit, TEXT("%25s: '%s'"), (LPTSTR)TEXT("Long Name"), (LPTSTR)add.szLongName);
  113. MEditPrintF(hedit, TEXT("%25s: '%s'"), (LPTSTR)TEXT("Copyright"), (LPTSTR)add.szCopyright);
  114. MEditPrintF(hedit, TEXT("%25s: '%s'"), (LPTSTR)TEXT("Licensing"), (LPTSTR)add.szLicensing);
  115. MEditPrintF(hedit, TEXT("%25s: '%s'\r\n"), (LPTSTR)TEXT("Features"), (LPTSTR)add.szFeatures);
  116. //
  117. //
  118. //
  119. if (0 != (ACMDRIVERDETAILS_SUPPORTF_HARDWARE & add.fdwSupport))
  120. {
  121. TCHAR ach[40];
  122. DWORD dw;
  123. mmr = acmMetrics((HACMOBJ)hadid, ACM_METRIC_HARDWARE_WAVE_INPUT, &dw);
  124. AcmAppGetErrorString(mmr, ach);
  125. MEditPrintF(hedit, TEXT("%25s: %ld (mmr = %s, [%u])"), (LPTSTR)TEXT("Wave Input Device"), dw, (LPTSTR)ach, mmr);
  126. mmr = acmMetrics((HACMOBJ)hadid, ACM_METRIC_HARDWARE_WAVE_OUTPUT, &dw);
  127. AcmAppGetErrorString(mmr, ach);
  128. MEditPrintF(hedit, TEXT("%25s: %ld (mmr = %s, [%u])"), (LPTSTR)TEXT("Wave Output Device"), dw, (LPTSTR)ach, mmr);
  129. }
  130. return (TRUE);
  131. } // AcmAppDisplayDriverDetails()
  132. //--------------------------------------------------------------------------;
  133. //
  134. // BOOL AcmAppDisplayFormats
  135. //
  136. // Description:
  137. //
  138. //
  139. // Arguments:
  140. // HWND hedit:
  141. //
  142. // HACMDRIVER had:
  143. //
  144. // ACMFORMATTAGDETAILS paftd:
  145. //
  146. // Return (BOOL):
  147. //
  148. //
  149. //--------------------------------------------------------------------------;
  150. BOOL FNLOCAL AcmAppDisplayFormats
  151. (
  152. HWND hedit,
  153. HACMDRIVER had,
  154. LPACMFORMATTAGDETAILS paftd
  155. )
  156. {
  157. MMRESULT mmr;
  158. UINT u;
  159. ACMFORMATDETAILS afd;
  160. PWAVEFORMATEX pwfx;
  161. if (0 == paftd->cStandardFormats)
  162. return (TRUE);
  163. pwfx = (PWAVEFORMATEX)LocalAlloc(LPTR, (UINT)paftd->cbFormatSize);
  164. if (NULL == pwfx)
  165. return (FALSE);
  166. //
  167. //
  168. //
  169. //
  170. for (u = 0; u < paftd->cStandardFormats; u++)
  171. {
  172. afd.cbStruct = sizeof(afd);
  173. afd.dwFormatIndex = u;
  174. afd.dwFormatTag = paftd->dwFormatTag;
  175. afd.fdwSupport = 0L;
  176. afd.pwfx = pwfx;
  177. afd.cbwfx = paftd->cbFormatSize;
  178. afd.szFormat[0] = '\0';
  179. mmr = acmFormatDetails(had, &afd, ACM_FORMATDETAILSF_INDEX);
  180. if (MMSYSERR_NOERROR != mmr)
  181. {
  182. //
  183. // this should never happen..
  184. //
  185. MEditPrintF(hedit, TEXT("%25s: err = %.04Xh"), (LPTSTR)TEXT("ERROR GETTING FORMAT DETAILS"), mmr);
  186. continue;
  187. }
  188. //
  189. // this would be bad
  190. //
  191. if (afd.cbStruct < sizeof(afd))
  192. {
  193. MEditPrintF(hedit, TEXT("%25s: %lu bytes (requested %lu)"), (LPTSTR)TEXT("Size of Format Details"),
  194. afd.cbStruct, (DWORD)sizeof(afd));
  195. continue;
  196. }
  197. MEditPrintF(hedit, TEXT("%15s %u: '%s'"), (LPTSTR)TEXT("Format"), u, (LPTSTR)afd.szFormat);
  198. }
  199. LocalFree((HLOCAL)pwfx);
  200. return (TRUE);
  201. } // AcmAppDisplayFormats()
  202. //--------------------------------------------------------------------------;
  203. //
  204. // BOOL AcmAppDisplayDriverTags
  205. //
  206. // Description:
  207. //
  208. //
  209. // Arguments:
  210. // HWND hedit:
  211. //
  212. // HACMDRIVER had:
  213. //
  214. // Return (BOOL):
  215. //
  216. //
  217. //--------------------------------------------------------------------------;
  218. BOOL FNLOCAL AcmAppDisplayDriverTags
  219. (
  220. HWND hedit,
  221. HACMDRIVER had
  222. )
  223. {
  224. static TCHAR szDisplayTitle[] = TEXT("[Driver Tags]\r\n");
  225. static TCHAR szDisplayFormatTags[] = TEXT("\r\n[Format Tags]");
  226. static TCHAR szDisplayFilterTags[] = TEXT("\r\n[Filter Tags]");
  227. TCHAR ach[APP_MAX_STRING_CHARS];
  228. ACMDRIVERDETAILS add;
  229. MMRESULT mmr;
  230. UINT u;
  231. HACMDRIVERID hadid;
  232. //
  233. //
  234. //
  235. MEditPrintF(hedit, szDisplayTitle);
  236. mmr = acmDriverID((HACMOBJ)had, &hadid, 0L);
  237. MEditPrintF(hedit, TEXT("%25s: %.04Xh"), (LPTSTR)TEXT("Driver Identifier Handle"), hadid);
  238. MEditPrintF(hedit, TEXT("%25s: %.04Xh"), (LPTSTR)TEXT("Driver Handle"), had);
  239. //
  240. //
  241. //
  242. //
  243. add.cbStruct = sizeof(add);
  244. mmr = acmDriverDetails(hadid, &add, 0L);
  245. if (MMSYSERR_NOERROR != mmr)
  246. {
  247. //
  248. // this should never happen..
  249. //
  250. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("ERROR GETTING INFO"), mmr);
  251. return (FALSE);
  252. }
  253. MEditPrintF(hedit, TEXT("%25s: '%s'"), (LPTSTR)TEXT("Name"), (LPTSTR)add.szShortName);
  254. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Count Format Tags"), add.cFormatTags);
  255. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Count Filter Tags"), add.cFilterTags);
  256. if (0 != add.cFormatTags)
  257. MEditPrintF(hedit, szDisplayFormatTags);
  258. for (u = 0; u < add.cFormatTags; u++)
  259. {
  260. ACMFORMATTAGDETAILS aftd;
  261. WAVEFORMATEX wfx;
  262. MEditPrintF(hedit, TEXT("\r\n%25s: %u"), (LPTSTR)TEXT("Format Tag Index"), u);
  263. _fmemset(&aftd, 0, sizeof(aftd));
  264. aftd.cbStruct = sizeof(aftd);
  265. aftd.dwFormatTagIndex = u;
  266. mmr = acmFormatTagDetails(had, &aftd, ACM_FORMATTAGDETAILSF_INDEX);
  267. if (MMSYSERR_NOERROR != mmr)
  268. {
  269. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("ERROR GETTING TAGS"), mmr);
  270. return (FALSE);
  271. }
  272. MEditPrintF(hedit, TEXT("%25s: %lu bytes (requested %lu)"),
  273. (LPTSTR)TEXT("Size of Tag Details"),
  274. aftd.cbStruct, (DWORD)sizeof(aftd));
  275. //
  276. // this would be bad
  277. //
  278. if (aftd.cbStruct < sizeof(aftd))
  279. continue;
  280. wfx.wFormatTag = LOWORD(aftd.dwFormatTag);
  281. AcmAppGetFormatDescription(&wfx, ach, NULL);
  282. MEditPrintF(hedit, TEXT("%25s: [%lu], %s"), (LPTSTR)TEXT("Format Tag"), aftd.dwFormatTag, (LPTSTR)ach);
  283. MEditPrintF(hedit, TEXT("%25s: %u bytes"), (LPTSTR)TEXT("Format Size (Max)"), aftd.cbFormatSize);
  284. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("Standard Support"), aftd.fdwSupport);
  285. MEditPrintF(hedit, TEXT("%25s: %lu"), (LPTSTR)TEXT("Standard Formats"), aftd.cStandardFormats);
  286. MEditPrintF(hedit, TEXT("%25s: '%s'"), (LPTSTR)TEXT("Format Tag Name"), (LPTSTR)aftd.szFormatTag);
  287. AcmAppDisplayFormats(hedit, had, &aftd);
  288. }
  289. if (0 != add.cFilterTags)
  290. MEditPrintF(hedit, szDisplayFilterTags);
  291. for (u = 0; u < add.cFilterTags; u++)
  292. {
  293. ACMFILTERTAGDETAILS aftd;
  294. WAVEFILTER wfltr;
  295. MEditPrintF(hedit, TEXT("%25s: %u"), (LPTSTR)TEXT("Filter Tag Index"), u);
  296. _fmemset(&aftd, 0, sizeof(aftd));
  297. aftd.cbStruct = sizeof(aftd);
  298. aftd.dwFilterTagIndex = u;
  299. mmr = acmFilterTagDetails(had, &aftd, ACM_FILTERTAGDETAILSF_INDEX);
  300. if (MMSYSERR_NOERROR != mmr)
  301. {
  302. //
  303. //
  304. //
  305. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("ERROR GETTING TAGS"), mmr);
  306. return (FALSE);
  307. }
  308. MEditPrintF(hedit, TEXT("%25s: %lu bytes (requested %lu)"),
  309. (LPTSTR)TEXT("Size of Tag Details"),
  310. aftd.cbStruct, (DWORD)sizeof(aftd));
  311. //
  312. // this would be bad
  313. //
  314. if (aftd.cbStruct < sizeof(aftd))
  315. continue;
  316. wfltr.dwFilterTag = aftd.dwFilterTag;
  317. AcmAppGetFilterDescription(&wfltr, ach, NULL);
  318. MEditPrintF(hedit, TEXT("%25s: [%lu], %s"), (LPTSTR)TEXT("Filter Tag"), aftd.dwFilterTag, (LPTSTR)ach);
  319. MEditPrintF(hedit, TEXT("%25s: %lu bytes"), (LPTSTR)TEXT("Format Size (Max)"), aftd.cbFilterSize);
  320. MEditPrintF(hedit, TEXT("%25s: %.08lXh"), (LPTSTR)TEXT("Standard Support"), aftd.fdwSupport);
  321. MEditPrintF(hedit, TEXT("%25s: %lu"), (LPTSTR)TEXT("Standard Filters"), aftd.cStandardFilters);
  322. MEditPrintF(hedit, TEXT("%25s: '%s'\r\n"), (LPTSTR)TEXT("Filter Tag Name"), (LPTSTR)aftd.szFilterTag);
  323. }
  324. return (TRUE);
  325. } // AcmAppDisplayDriverTags()
  326. //--------------------------------------------------------------------------;
  327. //
  328. // BOOL AcmAppDriverDetailsDlgProc
  329. //
  330. // Description:
  331. //
  332. //
  333. // Arguments:
  334. // HWND hwnd:
  335. //
  336. // UINT uMsg:
  337. //
  338. // WPARAM wParam:
  339. //
  340. // LPARAM lParam:
  341. //
  342. // Return (BOOL):
  343. //
  344. //
  345. //--------------------------------------------------------------------------;
  346. BOOL FNEXPORT AcmAppDriverDetailsDlgProc
  347. (
  348. HWND hwnd,
  349. UINT uMsg,
  350. WPARAM wParam,
  351. LPARAM lParam
  352. )
  353. {
  354. HACMDRIVERID hadid;
  355. HWND hedit;
  356. UINT uId;
  357. switch (uMsg)
  358. {
  359. case WM_INITDIALOG:
  360. hedit = GetDlgItem(hwnd, IDD_AADETAILS_EDIT_DETAILS);
  361. SetWindowFont(hedit, ghfontApp, FALSE);
  362. //
  363. // clear the display
  364. //
  365. AppHourGlass(TRUE);
  366. SetWindowRedraw(hedit, FALSE);
  367. MEditPrintF(hedit, NULL);
  368. hadid = (HACMDRIVERID)(UINT)lParam;
  369. if (NULL == hadid)
  370. {
  371. MEditPrintF(hedit, TEXT("\r\n\r\nhmm..."));
  372. }
  373. else
  374. {
  375. AcmAppDisplayDriverDetails(hedit, hadid);
  376. }
  377. Edit_SetSel(hedit, (WPARAM)0, (LPARAM)0);
  378. SetWindowRedraw(hedit, TRUE);
  379. AppHourGlass(FALSE);
  380. return (TRUE);
  381. case WM_COMMAND:
  382. uId = GET_WM_COMMAND_ID(wParam, lParam);
  383. if ((IDOK == uId) || (IDCANCEL == uId))
  384. {
  385. EndDialog(hwnd, (IDOK == uId));
  386. }
  387. break;
  388. }
  389. return (FALSE);
  390. } // AcmAppDriverDetailsDlgProc()
  391. //==========================================================================;
  392. //
  393. //
  394. //
  395. //
  396. //==========================================================================;
  397. //--------------------------------------------------------------------------;
  398. //
  399. // BOOL AcmAppDriverFormatDetailsDlgProc
  400. //
  401. // Description:
  402. //
  403. //
  404. // Arguments:
  405. // HWND hwnd:
  406. //
  407. // UINT uMsg:
  408. //
  409. // WPARAM wParam:
  410. //
  411. // LPARAM lParam:
  412. //
  413. // Return (BOOL):
  414. //
  415. //
  416. //--------------------------------------------------------------------------;
  417. BOOL FNEXPORT AcmAppDriverFormatDetailsDlgProc
  418. (
  419. HWND hwnd,
  420. UINT uMsg,
  421. WPARAM wParam,
  422. LPARAM lParam
  423. )
  424. {
  425. HACMDRIVERID hadid;
  426. HWND hlb;
  427. HWND hedit;
  428. int n;
  429. UINT uId;
  430. switch (uMsg)
  431. {
  432. case WM_INITDIALOG:
  433. hlb = GetDlgItem(GetParent(hwnd), IDD_AADRIVERFORMATS_LIST_FORMATS);
  434. n = ListBox_GetCurSel(hlb);
  435. if (LB_ERR == n)
  436. return (TRUE);
  437. hadid = (HACMDRIVERID)(UINT)ListBox_GetItemData(hlb, n);
  438. hedit = GetDlgItem(hwnd, IDD_AADETAILS_EDIT_DETAILS);
  439. SetWindowFont(hedit, ghfontApp, FALSE);
  440. //
  441. // clear the display
  442. //
  443. AppHourGlass(TRUE);
  444. SetWindowRedraw(hedit, FALSE);
  445. MEditPrintF(hedit, NULL);
  446. MEditPrintF(hedit, TEXT("\r\n\r\nFormat Details!"));
  447. Edit_SetSel(hedit, (WPARAM)0, (LPARAM)0);
  448. SetWindowRedraw(hedit, TRUE);
  449. AppHourGlass(FALSE);
  450. return (TRUE);
  451. case WM_COMMAND:
  452. uId = GET_WM_COMMAND_ID(wParam, lParam);
  453. if ((IDOK == uId) || (IDCANCEL == uId))
  454. {
  455. EndDialog(hwnd, (IDOK == uId));
  456. }
  457. break;
  458. }
  459. return (FALSE);
  460. } // AcmAppDriverFormatDetailsDlgProc()
  461. //--------------------------------------------------------------------------;
  462. //
  463. // BOOL AcmAppDriverFormatEnumCallback
  464. //
  465. // Description:
  466. //
  467. //
  468. // Arguments:
  469. // HACMDRIVERID hadid:
  470. //
  471. // DWORD dwInstance:
  472. //
  473. // DWORD fdwSupport:
  474. //
  475. // Return (BOOL):
  476. //
  477. //
  478. //--------------------------------------------------------------------------;
  479. BOOL FNEXPORT AcmAppDriverFormatEnumCallback
  480. (
  481. HACMDRIVERID hadid,
  482. LPACMFORMATDETAILS pafd,
  483. DWORD dwInstance,
  484. DWORD fdwSupport
  485. )
  486. {
  487. TCHAR ach[APP_MAX_STRING_CHARS];
  488. HWND hlb;
  489. int nIndex;
  490. LPARAM lParam;
  491. UINT cbwfx;
  492. //
  493. //
  494. //
  495. hlb = (HWND)(UINT)dwInstance;
  496. cbwfx = SIZEOF_WAVEFORMATEX(pafd->pwfx);
  497. wsprintf(ach, gszFormatDriverFormatsList,
  498. hadid,
  499. pafd->dwFormatIndex,
  500. pafd->dwFormatTag,
  501. pafd->fdwSupport,
  502. cbwfx,
  503. (LPTSTR)pafd->szFormat);
  504. AcmAppDebugLog(ach);
  505. AcmAppDebugLog(TEXT("\r\n"));
  506. nIndex = ListBox_AddString(hlb, ach);
  507. lParam = (LPARAM)(UINT)hadid;
  508. ListBox_SetItemData(hlb, nIndex, lParam);
  509. //
  510. // return TRUE to continue with enumeration
  511. //
  512. return (TRUE);
  513. } // AcmAppDriverFormatEnumCallback()
  514. //--------------------------------------------------------------------------;
  515. //
  516. // BOOL AcmAppDriverFormatsDlgProc
  517. //
  518. // Description:
  519. // This dialog procedure is used to display driver formats.
  520. //
  521. // Arguments:
  522. // HWND hwnd: Handle to window.
  523. //
  524. // UINT uMsg: Message being sent to the window.
  525. //
  526. // WPARAM wParam: Specific argument to message.
  527. //
  528. // LPARAM lParam: Specific argument to message.
  529. //
  530. // Return (BOOL):
  531. // The return value is specific to the message that was received. For
  532. // the most part, it is FALSE if this dialog procedure does not handle
  533. // a message.
  534. //
  535. //
  536. //--------------------------------------------------------------------------;
  537. BOOL FNEXPORT AcmAppDriverFormatsDlgProc
  538. (
  539. HWND hwnd,
  540. UINT uMsg,
  541. WPARAM wParam,
  542. LPARAM lParam
  543. )
  544. {
  545. static PTABBEDLISTBOX ptlb;
  546. HWND hwndStatic;
  547. MMRESULT mmr;
  548. RECT rc;
  549. PAINTSTRUCT ps;
  550. UINT uId;
  551. UINT uCode;
  552. HACMDRIVER had;
  553. ACMFORMATDETAILS afd;
  554. PWAVEFORMATEX pwfx;
  555. DWORD cbwfx;
  556. switch (uMsg)
  557. {
  558. case WM_INITDIALOG:
  559. hwndStatic = GetDlgItem(hwnd, IDD_AADRIVERFORMATS_STATIC_POSITION);
  560. GetWindowRect(hwndStatic, &rc);
  561. ScreenToClient(hwnd, (LPPOINT)&rc.left);
  562. ScreenToClient(hwnd, (LPPOINT)&rc.right);
  563. ShowWindow(hwndStatic, SW_HIDE);
  564. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERFORMATS_BTN_DETAILS), FALSE);
  565. ptlb = TlbCreate(hwnd, IDD_AADRIVERFORMATS_LIST_FORMATS, &rc);
  566. if (NULL == ptlb)
  567. return (TRUE);
  568. TlbSetFont(ptlb, GetStockFont(ANSI_VAR_FONT), FALSE);
  569. TlbSetTitleAndTabs(ptlb, gszFormatDriverFormatsTitle, FALSE);
  570. SetWindowPos(ptlb->hlb, GetDlgItem(hwnd, IDOK),
  571. 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  572. ListBox_ResetContent(ptlb->hlb);
  573. AcmAppDebugLog(NULL);
  574. had = (HACMDRIVER)(UINT)lParam;
  575. mmr = acmMetrics((HACMOBJ)had, ACM_METRIC_MAX_SIZE_FORMAT, &cbwfx);
  576. if (MMSYSERR_NOERROR != mmr)
  577. return (TRUE);
  578. pwfx = (PWAVEFORMATEX)LocalAlloc(LPTR, (UINT)cbwfx);
  579. if (NULL == pwfx)
  580. return (TRUE);
  581. _fmemset(&afd, 0, sizeof(afd));
  582. afd.cbStruct = sizeof(afd);
  583. afd.dwFormatTag = WAVE_FORMAT_UNKNOWN;
  584. afd.pwfx = pwfx;
  585. afd.cbwfx = cbwfx;
  586. //
  587. //
  588. //
  589. SetWindowRedraw(ptlb->hlb, FALSE);
  590. mmr = acmFormatEnum(had,
  591. &afd,
  592. AcmAppDriverFormatEnumCallback,
  593. (DWORD)(UINT)ptlb->hlb,
  594. 0L);
  595. if (MMSYSERR_NOERROR == mmr)
  596. {
  597. ListBox_SetCurSel(ptlb->hlb, 0);
  598. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERFORMATS_BTN_DETAILS), TRUE);
  599. }
  600. SetWindowRedraw(ptlb->hlb, TRUE);
  601. LocalFree((HLOCAL)pwfx);
  602. return (TRUE);
  603. case WM_PAINT:
  604. if (NULL != ptlb)
  605. {
  606. BeginPaint(hwnd, &ps);
  607. TlbPaint(ptlb, hwnd, ps.hdc);
  608. EndPaint(hwnd, &ps);
  609. }
  610. break;
  611. case WM_COMMAND:
  612. uId = GET_WM_COMMAND_ID(wParam, lParam);
  613. uCode = GET_WM_COMMAND_CMD(wParam, lParam);
  614. switch (uId)
  615. {
  616. case IDOK:
  617. case IDCANCEL:
  618. if (NULL != ptlb)
  619. {
  620. //
  621. // hadidk! don't destroy the listbox window, but
  622. // free all other memory for TLB. the listbox
  623. // window will be destroyed when the dialog is
  624. // destroyed.
  625. //
  626. ptlb->hlb = NULL;
  627. TlbDestroy(ptlb);
  628. ptlb = NULL;
  629. }
  630. EndDialog(hwnd, (IDOK == uId));
  631. break;
  632. case IDD_AADRIVERFORMATS_BTN_DETAILS:
  633. DialogBoxParam(ghinst,
  634. DLG_AADETAILS,
  635. hwnd,
  636. AcmAppDriverFormatDetailsDlgProc,
  637. uId);
  638. break;
  639. case IDD_AADRIVERFORMATS_LIST_FORMATS:
  640. switch (uCode)
  641. {
  642. case LBN_SELCHANGE:
  643. break;
  644. case LBN_DBLCLK:
  645. DialogBoxParam(ghinst,
  646. DLG_AADETAILS,
  647. hwnd,
  648. AcmAppDriverFormatDetailsDlgProc,
  649. IDD_AADRIVERFORMATS_BTN_DETAILS);
  650. break;
  651. }
  652. break;
  653. }
  654. break;
  655. }
  656. return (FALSE);
  657. } // AcmAppDriverFormatsDlgProc()
  658. //==========================================================================;
  659. //
  660. //
  661. //
  662. //
  663. //==========================================================================;
  664. //--------------------------------------------------------------------------;
  665. //
  666. // BOOL AcmAppDriverEnumCallback
  667. //
  668. // Description:
  669. //
  670. //
  671. // Arguments:
  672. // HACMDRIVERID hadid:
  673. //
  674. // DWORD dwInstance:
  675. //
  676. // DWORD fdwSupport:
  677. //
  678. // Return (BOOL):
  679. //
  680. //
  681. //--------------------------------------------------------------------------;
  682. BOOL FNEXPORT AcmAppDriverEnumCallback
  683. (
  684. HACMDRIVERID hadid,
  685. DWORD dwInstance,
  686. DWORD fdwSupport
  687. )
  688. {
  689. static TCHAR szBogus[] = TEXT("????");
  690. MMRESULT mmr;
  691. TCHAR ach[APP_MAX_STRING_CHARS];
  692. HWND hlb;
  693. int n;
  694. ACMDRIVERDETAILS add;
  695. BOOL fDisabled;
  696. DWORD dwPriority;
  697. //
  698. //
  699. //
  700. hlb = (HWND)(UINT)dwInstance;
  701. add.cbStruct = sizeof(add);
  702. mmr = acmDriverDetails(hadid, &add, 0L);
  703. if (MMSYSERR_NOERROR != mmr)
  704. {
  705. lstrcpy(add.szShortName, szBogus);
  706. lstrcpy(add.szLongName, szBogus);
  707. }
  708. dwPriority = (DWORD)-1L;
  709. acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_PRIORITY, &dwPriority);
  710. fDisabled = (0 != (ACMDRIVERDETAILS_SUPPORTF_DISABLED & fdwSupport));
  711. wsprintf(ach, gszFormatDriversList,
  712. hadid,
  713. (LPTSTR)add.szShortName,
  714. dwPriority,
  715. fDisabled ? (LPTSTR)TEXT(" (disabled)") : (LPTSTR)gszNull,
  716. fdwSupport,
  717. (LPTSTR)add.szLongName);
  718. AcmAppDebugLog(ach);
  719. AcmAppDebugLog(TEXT("\r\n"));
  720. n = ListBox_AddString(hlb, ach);
  721. ListBox_SetItemData(hlb, n, (LPARAM)(UINT)hadid);
  722. //
  723. // return TRUE to continue with enumeration (FALSE will stop the
  724. // enumerator)
  725. //
  726. return (TRUE);
  727. } // AcmAppDriverEnumCallback()
  728. //--------------------------------------------------------------------------;
  729. //
  730. // HACMDRIVERID AcmAppGetSelectedDriver
  731. //
  732. // Description:
  733. //
  734. //
  735. // Arguments:
  736. // HWND hwnd:
  737. //
  738. // Return (HACMDRIVERID):
  739. //
  740. //
  741. //--------------------------------------------------------------------------;
  742. HACMDRIVERID FNLOCAL AcmAppGetSelectedDriver
  743. (
  744. HWND hwnd
  745. )
  746. {
  747. HWND hlb;
  748. UINT u;
  749. HACMDRIVERID hadid;
  750. hlb = GetDlgItem(hwnd, IDD_AADRIVERS_LIST_DRIVERS);
  751. u = (UINT)ListBox_GetCurSel(hlb);
  752. if (LB_ERR == u)
  753. {
  754. DPF(0, "!AcmAppGetSelectedDriver: apparently there is no selected driver?");
  755. return (NULL);
  756. }
  757. hadid = (HACMDRIVERID)(UINT)ListBox_GetItemData(hlb, u);
  758. if (NULL == hadid)
  759. {
  760. DPF(0, "!AcmAppGetSelectedDriver: NULL item data for selected driver!!?");
  761. return (NULL);
  762. }
  763. return (hadid);
  764. } // AcmAppGetSelectedDriver()
  765. //--------------------------------------------------------------------------;
  766. //
  767. // BOOL AcmAppDriverSelected
  768. //
  769. // Description:
  770. //
  771. //
  772. // Arguments:
  773. // HWND hwnd:
  774. //
  775. // Return (BOOL):
  776. //
  777. //
  778. //--------------------------------------------------------------------------;
  779. HACMDRIVER FNLOCAL AcmAppDriverSelected
  780. (
  781. HWND hwnd
  782. )
  783. {
  784. LRESULT lr;
  785. MMRESULT mmr;
  786. BOOL f;
  787. HACMDRIVERID hadid;
  788. HACMDRIVER had;
  789. DWORD fdwSupport;
  790. f = FALSE;
  791. //
  792. //
  793. //
  794. if (NULL != ghadSelected)
  795. {
  796. mmr = acmDriverClose(ghadSelected, 0L);
  797. if (MMSYSERR_NOERROR != mmr)
  798. {
  799. DPF(0, "!AcmAppDriverSelected: driver %.04Xh failed to close! mmr=%u", ghadSelected, mmr);
  800. }
  801. ghadSelected = NULL;
  802. }
  803. had = NULL;
  804. //
  805. //
  806. //
  807. hadid = AcmAppGetSelectedDriver(hwnd);
  808. if (NULL != hadid)
  809. {
  810. mmr = acmMetrics((HACMOBJ)hadid, ACM_METRIC_DRIVER_SUPPORT, &fdwSupport);
  811. if (MMSYSERR_NOERROR != mmr)
  812. {
  813. fdwSupport = ACMDRIVERDETAILS_SUPPORTF_DISABLED;
  814. //
  815. // !!! this should NEVER EVER EVER HAPPEN !!!
  816. //
  817. DPF(0, "!AcmAppDriverSelected: driver id %.04Xh failed to give support! mmr=%u", hadid, mmr);
  818. }
  819. if (0 == (ACMDRIVERDETAILS_SUPPORTF_DISABLED & fdwSupport))
  820. {
  821. mmr = acmDriverOpen(&had, hadid, 0L);
  822. if (MMSYSERR_NOERROR != mmr)
  823. {
  824. DPF(0, "!AcmAppDriverSelected: driver id %.04Xh failed to open! mmr=%u", hadid, mmr);
  825. }
  826. }
  827. //
  828. //
  829. //
  830. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_DETAILS), TRUE);
  831. lr = acmDriverMessage((HACMDRIVER)hadid, ACMDM_DRIVER_ABOUT, -1L, 0L);
  832. f = (MMSYSERR_NOERROR == lr);
  833. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_ABOUT), f);
  834. lr = acmDriverMessage((HACMDRIVER)hadid, DRV_QUERYCONFIGURE, 0L, 0L);
  835. f = (0L != lr);
  836. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_CONFIG), f);
  837. }
  838. else
  839. {
  840. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_DETAILS), FALSE);
  841. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_ABOUT), FALSE);
  842. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_CONFIG), FALSE);
  843. }
  844. //
  845. //
  846. //
  847. if (NULL == had)
  848. {
  849. //
  850. //
  851. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_FORMATS), FALSE);
  852. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_FILTERS), FALSE);
  853. }
  854. else
  855. {
  856. f = (0 == (ACMDRIVERDETAILS_SUPPORTF_DISABLED & fdwSupport));
  857. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_FORMATS), f);
  858. f = (0 != (ACMDRIVERDETAILS_SUPPORTF_FILTER & fdwSupport));
  859. EnableWindow(GetDlgItem(hwnd, IDD_AADRIVERS_BTN_FILTERS), f);
  860. }
  861. //
  862. //
  863. //
  864. ghadidSelected = hadid;
  865. ghadSelected = had;
  866. return (had);
  867. } // AcmAppDriverSelected()
  868. //--------------------------------------------------------------------------;
  869. //
  870. // BOOL AcmAppDriversDlgProc
  871. //
  872. // Description:
  873. // This dialog procedure is used to display ACM driver capabilities.
  874. //
  875. // Arguments:
  876. // HWND hwnd: Handle to window.
  877. //
  878. // UINT uMsg: Message being sent to the window.
  879. //
  880. // WPARAM wParam: Specific argument to message.
  881. //
  882. // LPARAM lParam: Specific argument to message.
  883. //
  884. // Return (BOOL):
  885. // The return value is specific to the message that was received. For
  886. // the most part, it is FALSE if this dialog procedure does not handle
  887. // a message.
  888. //
  889. //--------------------------------------------------------------------------;
  890. BOOL FNEXPORT AcmAppDriversDlgProc
  891. (
  892. HWND hwnd,
  893. UINT uMsg,
  894. WPARAM wParam,
  895. LPARAM lParam
  896. )
  897. {
  898. PTABBEDLISTBOX ptlb;
  899. HWND hstat;
  900. MMRESULT mmr;
  901. LRESULT lr;
  902. RECT rc;
  903. PAINTSTRUCT ps;
  904. UINT uId;
  905. UINT uCode;
  906. UINT u;
  907. ptlb = (PTABBEDLISTBOX)(UINT)GetWindowLong(hwnd, DWL_USER);
  908. switch (uMsg)
  909. {
  910. case WM_INITDIALOG:
  911. hstat = GetDlgItem(hwnd, IDD_AADRIVERS_STATIC_POSITION);
  912. GetWindowRect(hstat, &rc);
  913. ScreenToClient(hwnd, (LPPOINT)&rc.left);
  914. ScreenToClient(hwnd, (LPPOINT)&rc.right);
  915. ShowWindow(hstat, SW_HIDE);
  916. ptlb = TlbCreate(hwnd, IDD_AADRIVERS_LIST_DRIVERS, &rc);
  917. SetWindowLong(hwnd, DWL_USER, (LONG)(UINT)ptlb);
  918. if (NULL == ptlb)
  919. {
  920. EndDialog(hwnd, FALSE);
  921. return (TRUE);
  922. }
  923. //
  924. //
  925. //
  926. TlbSetFont(ptlb, GetStockFont(ANSI_VAR_FONT), FALSE);
  927. TlbSetTitleAndTabs(ptlb, gszFormatDriversTitle, FALSE);
  928. SetWindowPos(ptlb->hlb, GetDlgItem(hwnd, IDOK),
  929. 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  930. SendMessage(hwnd, WM_ACMAPP_ACM_NOTIFY, 0, 0L);
  931. return (TRUE);
  932. case WM_PAINT:
  933. if (NULL != ptlb)
  934. {
  935. BeginPaint(hwnd, &ps);
  936. TlbPaint(ptlb, hwnd, ps.hdc);
  937. EndPaint(hwnd, &ps);
  938. }
  939. break;
  940. case WM_ACMAPP_ACM_NOTIFY:
  941. u = (UINT)ListBox_GetCurSel(ptlb->hlb);
  942. if (LB_ERR == u)
  943. {
  944. u = 0;
  945. }
  946. SetWindowRedraw(ptlb->hlb, FALSE);
  947. ListBox_ResetContent(ptlb->hlb);
  948. AcmAppDebugLog(NULL);
  949. //
  950. //
  951. //
  952. mmr = acmDriverEnum(AcmAppDriverEnumCallback,
  953. (DWORD)(UINT)ptlb->hlb,
  954. ACM_DRIVERENUMF_DISABLED);
  955. if (MMSYSERR_NOERROR != mmr)
  956. {
  957. //
  958. // this will let us know something is wrong!
  959. //
  960. EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
  961. }
  962. ListBox_SetCurSel(ptlb->hlb, u);
  963. SetWindowRedraw(ptlb->hlb, TRUE);
  964. AcmAppDriverSelected(hwnd);
  965. break;
  966. case WM_COMMAND:
  967. uId = GET_WM_COMMAND_ID(wParam, lParam);
  968. uCode = GET_WM_COMMAND_CMD(wParam, lParam);
  969. switch (uId)
  970. {
  971. case IDOK:
  972. case IDCANCEL:
  973. if (NULL != ptlb)
  974. {
  975. //
  976. // hadidk! don't destroy the listbox window, but
  977. // free all other memory for TLB. the listbox
  978. // window will be destroyed when the dialog is
  979. // destroyed.
  980. //
  981. ptlb->hlb = NULL;
  982. TlbDestroy(ptlb);
  983. ptlb = NULL;
  984. }
  985. if (NULL != ghadSelected)
  986. {
  987. acmDriverClose(ghadSelected, 0L);
  988. ghadSelected = NULL;
  989. }
  990. EndDialog(hwnd, (IDOK == uId));
  991. break;
  992. case IDD_AADRIVERS_BTN_DETAILS:
  993. DialogBoxParam(ghinst,
  994. DLG_AADETAILS,
  995. hwnd,
  996. AcmAppDriverDetailsDlgProc,
  997. (LPARAM)(UINT)ghadidSelected);
  998. break;
  999. case IDD_AADRIVERS_BTN_FORMATS:
  1000. if (NULL != ghadSelected)
  1001. {
  1002. DialogBoxParam(ghinst,
  1003. DLG_AADRIVERFORMATS,
  1004. hwnd,
  1005. AcmAppDriverFormatsDlgProc,
  1006. (LPARAM)(UINT)ghadSelected);
  1007. }
  1008. break;
  1009. case IDD_AADRIVERS_BTN_FILTERS:
  1010. #if 0
  1011. if (NULL != ghadSelected)
  1012. {
  1013. DialogBoxParam(ghinst,
  1014. DLG_AADRIVERFILTERS,
  1015. hwnd,
  1016. AcmAppDriverFiltersDlgProc,
  1017. (LPARAM)(UINT)ghadSelected);
  1018. }
  1019. #endif
  1020. break;
  1021. case IDD_AADRIVERS_BTN_CONFIG:
  1022. if (NULL == ghadidSelected)
  1023. break;
  1024. lr = acmDriverMessage((HACMDRIVER)ghadidSelected,
  1025. DRV_CONFIGURE,
  1026. (LPARAM)(UINT)hwnd,
  1027. 0L);
  1028. switch (lr)
  1029. {
  1030. case DRVCNF_CANCEL:
  1031. //
  1032. // user canceled the configuration (no
  1033. // configuration information was changed)
  1034. //
  1035. break;
  1036. case DRVCNF_OK:
  1037. //
  1038. // user changed AND accepted configuration
  1039. // changes--applications should refresh
  1040. // anything they have for this driver
  1041. //
  1042. break;
  1043. case DRVCNF_RESTART:
  1044. //
  1045. // user changed and accepted configuration
  1046. // changes--however, Windows must be
  1047. // restarted for the changes to take
  1048. // affect.
  1049. //
  1050. #pragma message("----AcmAppDriversDlgProc: must do DRVCNF_RESTART!")
  1051. break;
  1052. default:
  1053. DPF(0, "!configure: driver returned bogus value=%lu!", lr);
  1054. break;
  1055. }
  1056. break;
  1057. case IDD_AADRIVERS_BTN_ABOUT:
  1058. if (NULL != ghadidSelected)
  1059. {
  1060. //
  1061. // some driver actually provided
  1062. // a custom about box... i'm glad i don't have to
  1063. // port, maintain, and support this driver!
  1064. //
  1065. lr = acmDriverMessage((HACMDRIVER)ghadidSelected,
  1066. ACMDM_DRIVER_ABOUT,
  1067. (LPARAM)(UINT)hwnd,
  1068. 0L);
  1069. }
  1070. break;
  1071. case IDD_AADRIVERS_BTN_ABLE:
  1072. if (NULL != ghadidSelected)
  1073. {
  1074. DWORD fdwSupport;
  1075. DWORD fdwPriority;
  1076. mmr = acmMetrics((HACMOBJ)ghadidSelected,
  1077. ACM_METRIC_DRIVER_SUPPORT,
  1078. &fdwSupport);
  1079. if (MMSYSERR_NOERROR != mmr)
  1080. {
  1081. MessageBeep(0);
  1082. break;
  1083. }
  1084. if (0 == (ACMDRIVERDETAILS_SUPPORTF_DISABLED & fdwSupport))
  1085. {
  1086. fdwPriority = ACM_DRIVERPRIORITYF_DISABLE;
  1087. }
  1088. else
  1089. {
  1090. fdwPriority = ACM_DRIVERPRIORITYF_ENABLE;
  1091. }
  1092. mmr = acmDriverPriority(ghadidSelected,
  1093. 0L,
  1094. fdwPriority);
  1095. if (MMSYSERR_NOERROR != mmr)
  1096. {
  1097. MessageBeep(0);
  1098. break;
  1099. }
  1100. }
  1101. break;
  1102. case IDD_AADRIVERS_BTN_TOTOP:
  1103. if (NULL != ghadidSelected)
  1104. {
  1105. mmr = acmDriverPriority(ghadidSelected, 1, 0L);
  1106. if (MMSYSERR_NOERROR != mmr)
  1107. {
  1108. MessageBeep(0);
  1109. break;
  1110. }
  1111. }
  1112. break;
  1113. case IDD_AADRIVERS_LIST_DRIVERS:
  1114. switch (uCode)
  1115. {
  1116. case LBN_SELCHANGE:
  1117. AcmAppDriverSelected(hwnd);
  1118. break;
  1119. case LBN_DBLCLK:
  1120. if (GetKeyState(VK_CONTROL) < 0)
  1121. {
  1122. uId = IDD_AADRIVERS_BTN_ABLE;
  1123. }
  1124. else if (GetKeyState(VK_SHIFT) < 0)
  1125. {
  1126. uId = IDD_AADRIVERS_BTN_TOTOP;
  1127. }
  1128. else
  1129. {
  1130. uId = IDD_AADRIVERS_BTN_DETAILS;
  1131. }
  1132. FORWARD_WM_COMMAND(hwnd,
  1133. uId,
  1134. GetDlgItem(hwnd, uId),
  1135. 1,
  1136. SendMessage);
  1137. break;
  1138. }
  1139. break;
  1140. }
  1141. break;
  1142. }
  1143. return (FALSE);
  1144. } // AcmAppDriversDlgProc()