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.

2500 lines
65 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. //
  12. // aachoose.c
  13. //
  14. // Description:
  15. //
  16. //
  17. //
  18. //==========================================================================;
  19. #include <windows.h>
  20. #include <windowsx.h>
  21. #include <mmsystem.h>
  22. #include <memory.h>
  23. #include <stdlib.h>
  24. #include <mmreg.h>
  25. #include <msacm.h>
  26. #include "muldiv32.h"
  27. #include "appport.h"
  28. #include "waveio.h"
  29. #include "acmapp.h"
  30. #include "debug.h"
  31. TCHAR gszBogus[] = TEXT("????");
  32. TCHAR BCODE gszAcmAppHelpFormat[] = TEXT("choo_win.hlp");
  33. TCHAR BCODE gszAcmAppHelpFilter[] = TEXT("fil_win.hlp");
  34. LPTSTR gpszAcmAppHelp;
  35. UINT guMsgHelp;
  36. //==========================================================================;
  37. //
  38. //
  39. //
  40. //
  41. //==========================================================================;
  42. //--------------------------------------------------------------------------;
  43. //
  44. // BOOL AcmAppDlgProcFormatStyle
  45. //
  46. // Description:
  47. //
  48. //
  49. // Arguments:
  50. // HWND hwnd: Handle to window.
  51. //
  52. // UINT uMsg: Message being sent to the window.
  53. //
  54. // WPARAM wParam: Specific argument to message.
  55. //
  56. // LPARAM lParam: Specific argument to message.
  57. //
  58. // Return (BOOL):
  59. // The return value is specific to the message that was received. For
  60. // the most part, it is FALSE if this dialog procedure does not handle
  61. // a message.
  62. //
  63. //--------------------------------------------------------------------------;
  64. BOOL FNEXPORT AcmAppDlgProcFormatStyle
  65. (
  66. HWND hwnd,
  67. UINT uMsg,
  68. WPARAM wParam,
  69. LPARAM lParam
  70. )
  71. {
  72. PACMFORMATCHOOSE pafc;
  73. HFONT hfont;
  74. UINT uId;
  75. BOOL f;
  76. DWORD fdwStyle;
  77. pafc = (PACMFORMATCHOOSE)(UINT)GetWindowLong(hwnd, DWL_USER);
  78. switch (uMsg)
  79. {
  80. case WM_INITDIALOG:
  81. pafc = (PACMFORMATCHOOSE)(UINT)lParam;
  82. SetWindowLong(hwnd, DWL_USER, lParam);
  83. hfont = ghfontApp;
  84. //
  85. //
  86. //
  87. fdwStyle = pafc->fdwStyle;
  88. f = (0 != (ACMFORMATCHOOSE_STYLEF_SHOWHELP & fdwStyle));
  89. CheckDlgButton(hwnd, IDD_AAFORMATSTYLE_CHECK_SHOWHELP, f);
  90. f = (0 != (ACMFORMATCHOOSE_STYLEF_ENABLEHOOK & fdwStyle));
  91. CheckDlgButton(hwnd, IDD_AAFORMATSTYLE_CHECK_ENABLEHOOK, f);
  92. f = (0 != (ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE & fdwStyle));
  93. CheckDlgButton(hwnd, IDD_AAFORMATSTYLE_CHECK_ENABLETEMPLATE, f);
  94. f = (0 != (ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE & fdwStyle));
  95. CheckDlgButton(hwnd, IDD_AAFORMATSTYLE_CHECK_ENABLETEMPLATEHANDLE, f);
  96. f = (0 != (ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT & fdwStyle));
  97. CheckDlgButton(hwnd, IDD_AAFORMATSTYLE_CHECK_INITTOWFXSTRUCT, f);
  98. return (TRUE);
  99. case WM_COMMAND:
  100. uId = GET_WM_COMMAND_ID(wParam, lParam);
  101. switch (uId)
  102. {
  103. case IDOK:
  104. fdwStyle = 0L;
  105. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATSTYLE_CHECK_SHOWHELP);
  106. if (f) fdwStyle |= ACMFORMATCHOOSE_STYLEF_SHOWHELP;
  107. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATSTYLE_CHECK_ENABLEHOOK);
  108. if (f) fdwStyle |= ACMFORMATCHOOSE_STYLEF_ENABLEHOOK;
  109. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATSTYLE_CHECK_ENABLETEMPLATE);
  110. if (f) fdwStyle |= ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE;
  111. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATSTYLE_CHECK_ENABLETEMPLATEHANDLE);
  112. if (f) fdwStyle |= ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE;
  113. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATSTYLE_CHECK_INITTOWFXSTRUCT);
  114. if (f) fdwStyle |= ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
  115. pafc->fdwStyle = fdwStyle;
  116. // -- fall through -- //
  117. case IDCANCEL:
  118. EndDialog(hwnd, (IDOK == uId));
  119. break;
  120. }
  121. break;
  122. }
  123. return (FALSE);
  124. } // AcmAppDlgProcFormatStyle()
  125. //--------------------------------------------------------------------------;
  126. //
  127. // BOOL AcmAppDlgProcFilterStyle
  128. //
  129. // Description:
  130. //
  131. //
  132. // Arguments:
  133. // HWND hwnd: Handle to window.
  134. //
  135. // UINT uMsg: Message being sent to the window.
  136. //
  137. // WPARAM wParam: Specific argument to message.
  138. //
  139. // LPARAM lParam: Specific argument to message.
  140. //
  141. // Return (BOOL):
  142. // The return value is specific to the message that was received. For
  143. // the most part, it is FALSE if this dialog procedure does not handle
  144. // a message.
  145. //
  146. //--------------------------------------------------------------------------;
  147. BOOL FNEXPORT AcmAppDlgProcFilterStyle
  148. (
  149. HWND hwnd,
  150. UINT uMsg,
  151. WPARAM wParam,
  152. LPARAM lParam
  153. )
  154. {
  155. PACMFILTERCHOOSE pafc;
  156. HFONT hfont;
  157. UINT uId;
  158. BOOL f;
  159. DWORD fdwStyle;
  160. pafc = (PACMFILTERCHOOSE)(UINT)GetWindowLong(hwnd, DWL_USER);
  161. switch (uMsg)
  162. {
  163. case WM_INITDIALOG:
  164. pafc = (PACMFILTERCHOOSE)(UINT)lParam;
  165. SetWindowLong(hwnd, DWL_USER, lParam);
  166. hfont = ghfontApp;
  167. //
  168. //
  169. //
  170. fdwStyle = pafc->fdwStyle;
  171. f = (0 != (ACMFILTERCHOOSE_STYLEF_SHOWHELP & fdwStyle));
  172. CheckDlgButton(hwnd, IDD_AAFILTERSTYLE_CHECK_SHOWHELP, f);
  173. f = (0 != (ACMFILTERCHOOSE_STYLEF_ENABLEHOOK & fdwStyle));
  174. CheckDlgButton(hwnd, IDD_AAFILTERSTYLE_CHECK_ENABLEHOOK, f);
  175. f = (0 != (ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE & fdwStyle));
  176. CheckDlgButton(hwnd, IDD_AAFILTERSTYLE_CHECK_ENABLETEMPLATE, f);
  177. f = (0 != (ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE & fdwStyle));
  178. CheckDlgButton(hwnd, IDD_AAFILTERSTYLE_CHECK_ENABLETEMPLATEHANDLE, f);
  179. f = (0 != (ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT & fdwStyle));
  180. CheckDlgButton(hwnd, IDD_AAFILTERSTYLE_CHECK_INITTOFILTERSTRUCT, f);
  181. return (TRUE);
  182. case WM_COMMAND:
  183. uId = GET_WM_COMMAND_ID(wParam, lParam);
  184. switch (uId)
  185. {
  186. case IDOK:
  187. fdwStyle = 0L;
  188. f = IsDlgButtonChecked(hwnd, IDD_AAFILTERSTYLE_CHECK_SHOWHELP);
  189. if (f) fdwStyle |= ACMFILTERCHOOSE_STYLEF_SHOWHELP;
  190. f = IsDlgButtonChecked(hwnd, IDD_AAFILTERSTYLE_CHECK_ENABLEHOOK);
  191. if (f) fdwStyle |= ACMFILTERCHOOSE_STYLEF_ENABLEHOOK;
  192. f = IsDlgButtonChecked(hwnd, IDD_AAFILTERSTYLE_CHECK_ENABLETEMPLATE);
  193. if (f) fdwStyle |= ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE;
  194. f = IsDlgButtonChecked(hwnd, IDD_AAFILTERSTYLE_CHECK_ENABLETEMPLATEHANDLE);
  195. if (f) fdwStyle |= ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE;
  196. f = IsDlgButtonChecked(hwnd, IDD_AAFILTERSTYLE_CHECK_INITTOFILTERSTRUCT);
  197. if (f) fdwStyle |= ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT;
  198. pafc->fdwStyle = fdwStyle;
  199. // -- fall through -- //
  200. case IDCANCEL:
  201. EndDialog(hwnd, (IDOK == uId));
  202. break;
  203. }
  204. break;
  205. }
  206. return (FALSE);
  207. } // AcmAppDlgProcFilterStyle()
  208. //--------------------------------------------------------------------------;
  209. //
  210. // BOOL AcmAppDlgProcFilterEnum
  211. //
  212. // Description:
  213. //
  214. //
  215. // Arguments:
  216. // HWND hwnd: Handle to window.
  217. //
  218. // UINT uMsg: Message being sent to the window.
  219. //
  220. // WPARAM wParam: Specific argument to message.
  221. //
  222. // LPARAM lParam: Specific argument to message.
  223. //
  224. // Return (BOOL):
  225. // The return value is specific to the message that was received. For
  226. // the most part, it is FALSE if this dialog procedure does not handle
  227. // a message.
  228. //
  229. //--------------------------------------------------------------------------;
  230. BOOL FNEXPORT AcmAppDlgProcFilterEnum
  231. (
  232. HWND hwnd,
  233. UINT uMsg,
  234. WPARAM wParam,
  235. LPARAM lParam
  236. )
  237. {
  238. TCHAR ach[14];
  239. PWAVEFILTER pwfltr;
  240. HWND hedit;
  241. HFONT hfont;
  242. UINT uId;
  243. BOOL f;
  244. DWORD fdwEnum;
  245. pwfltr = (PWAVEFILTER)(UINT)GetWindowLong(hwnd, DWL_USER);
  246. switch (uMsg)
  247. {
  248. case WM_INITDIALOG:
  249. pwfltr = (PWAVEFILTER)(UINT)lParam;
  250. SetWindowLong(hwnd, DWL_USER, lParam);
  251. hfont = ghfontApp;
  252. //
  253. // the initial fdwEnum flags are passed in fdwFilter
  254. // because i'm too lazy to make another structure..
  255. //
  256. fdwEnum = pwfltr->fdwFilter;
  257. f = (0 != (ACM_FILTERENUMF_DWFILTERTAG & fdwEnum));
  258. CheckDlgButton(hwnd, IDD_AAFILTERENUM_CHECK_DWFILTERTAG, f);
  259. hedit = GetDlgItem(hwnd, IDD_AAFILTERENUM_EDIT_DWFILTERTAG);
  260. SetWindowFont(hedit, hfont, FALSE);
  261. AppSetWindowText(hedit, TEXT("%u"), pwfltr->dwFilterTag);
  262. return (TRUE);
  263. case WM_COMMAND:
  264. uId = GET_WM_COMMAND_ID(wParam, lParam);
  265. switch (uId)
  266. {
  267. case IDOK:
  268. fdwEnum = 0L;
  269. f = IsDlgButtonChecked(hwnd, IDD_AAFILTERENUM_CHECK_DWFILTERTAG);
  270. if (f) fdwEnum |= ACM_FILTERENUMF_DWFILTERTAG;
  271. hedit = GetDlgItem(hwnd, IDD_AAFILTERENUM_EDIT_DWFILTERTAG);
  272. Edit_GetText(hedit, ach, SIZEOF(ach));
  273. pwfltr->dwFilterTag = _tcstoul(ach, NULL, 10);
  274. pwfltr->fdwFilter = fdwEnum;
  275. // -- fall through -- //
  276. case IDCANCEL:
  277. EndDialog(hwnd, (IDOK == uId));
  278. break;
  279. }
  280. break;
  281. }
  282. return (FALSE);
  283. } // AcmAppDlgProcFilterEnum()
  284. //--------------------------------------------------------------------------;
  285. //
  286. // BOOL AcmAppDlgProcFormatEnum
  287. //
  288. // Description:
  289. //
  290. //
  291. // Arguments:
  292. // HWND hwnd: Handle to window.
  293. //
  294. // UINT uMsg: Message being sent to the window.
  295. //
  296. // WPARAM wParam: Specific argument to message.
  297. //
  298. // LPARAM lParam: Specific argument to message.
  299. //
  300. // Return (BOOL):
  301. // The return value is specific to the message that was received. For
  302. // the most part, it is FALSE if this dialog procedure does not handle
  303. // a message.
  304. //
  305. //--------------------------------------------------------------------------;
  306. BOOL FNEXPORT AcmAppDlgProcFormatEnum
  307. (
  308. HWND hwnd,
  309. UINT uMsg,
  310. WPARAM wParam,
  311. LPARAM lParam
  312. )
  313. {
  314. TCHAR ach[14];
  315. PWAVEFORMATEX pwfx;
  316. HWND hedit;
  317. HFONT hfont;
  318. UINT uId;
  319. BOOL f;
  320. DWORD fdwEnum;
  321. pwfx = (PWAVEFORMATEX)(UINT)GetWindowLong(hwnd, DWL_USER);
  322. switch (uMsg)
  323. {
  324. case WM_INITDIALOG:
  325. pwfx = (PWAVEFORMATEX)(UINT)lParam;
  326. SetWindowLong(hwnd, DWL_USER, lParam);
  327. hfont = ghfontApp;
  328. //
  329. // the initial fdwEnum flags are passed in nAvgBytesPerSec
  330. // because i'm too lazy to make another structure..
  331. //
  332. fdwEnum = pwfx->nAvgBytesPerSec;
  333. f = (0 != (ACM_FORMATENUMF_WFORMATTAG & fdwEnum));
  334. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_WFORMATTAG, f);
  335. f = (0 != (ACM_FORMATENUMF_NCHANNELS & fdwEnum));
  336. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_NCHANNELS, f);
  337. f = (0 != (ACM_FORMATENUMF_NSAMPLESPERSEC & fdwEnum));
  338. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_NSAMPLESPERSEC, f);
  339. f = (0 != (ACM_FORMATENUMF_WBITSPERSAMPLE & fdwEnum));
  340. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_WBITSPERSAMPLE, f);
  341. f = (0 != (ACM_FORMATENUMF_CONVERT & fdwEnum));
  342. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_CONVERT, f);
  343. f = (0 != (ACM_FORMATENUMF_SUGGEST & fdwEnum));
  344. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_SUGGEST, f);
  345. f = (0 != (ACM_FORMATENUMF_HARDWARE & fdwEnum));
  346. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_HARDWARE, f);
  347. f = (0 != (ACM_FORMATENUMF_INPUT & fdwEnum));
  348. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_INPUT, f);
  349. f = (0 != (ACM_FORMATENUMF_OUTPUT & fdwEnum));
  350. CheckDlgButton(hwnd, IDD_AAFORMATENUM_CHECK_OUTPUT, f);
  351. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_WFORMATTAG);
  352. SetWindowFont(hedit, hfont, FALSE);
  353. AppSetWindowText(hedit, TEXT("%u"), pwfx->wFormatTag);
  354. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_NCHANNELS);
  355. SetWindowFont(hedit, hfont, FALSE);
  356. AppSetWindowText(hedit, TEXT("%u"), pwfx->nChannels);
  357. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_NSAMPLESPERSEC);
  358. SetWindowFont(hedit, hfont, FALSE);
  359. AppSetWindowText(hedit, TEXT("%lu"), pwfx->nSamplesPerSec);
  360. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_WBITSPERSAMPLE);
  361. SetWindowFont(hedit, hfont, FALSE);
  362. AppSetWindowText(hedit, TEXT("%u"), pwfx->wBitsPerSample);
  363. return (TRUE);
  364. case WM_COMMAND:
  365. uId = GET_WM_COMMAND_ID(wParam, lParam);
  366. switch (uId)
  367. {
  368. case IDOK:
  369. fdwEnum = 0L;
  370. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_WFORMATTAG);
  371. if (f) fdwEnum |= ACM_FORMATENUMF_WFORMATTAG;
  372. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_NCHANNELS);
  373. if (f) fdwEnum |= ACM_FORMATENUMF_NCHANNELS;
  374. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_NSAMPLESPERSEC);
  375. if (f) fdwEnum |= ACM_FORMATENUMF_NSAMPLESPERSEC;
  376. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_WBITSPERSAMPLE);
  377. if (f) fdwEnum |= ACM_FORMATENUMF_WBITSPERSAMPLE;
  378. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_CONVERT);
  379. if (f) fdwEnum |= ACM_FORMATENUMF_CONVERT;
  380. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_SUGGEST);
  381. if (f) fdwEnum |= ACM_FORMATENUMF_SUGGEST;
  382. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_HARDWARE);
  383. if (f) fdwEnum |= ACM_FORMATENUMF_HARDWARE;
  384. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_INPUT);
  385. if (f) fdwEnum |= ACM_FORMATENUMF_INPUT;
  386. f = IsDlgButtonChecked(hwnd, IDD_AAFORMATENUM_CHECK_OUTPUT);
  387. if (f) fdwEnum |= ACM_FORMATENUMF_OUTPUT;
  388. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_WFORMATTAG);
  389. Edit_GetText(hedit, ach, SIZEOF(ach));
  390. pwfx->wFormatTag = (WORD)_tcstoul(ach, NULL, 10);
  391. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_NCHANNELS);
  392. Edit_GetText(hedit, ach, SIZEOF(ach));
  393. pwfx->nChannels = (WORD)_tcstoul(ach, NULL, 10);
  394. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_NSAMPLESPERSEC);
  395. Edit_GetText(hedit, ach, SIZEOF(ach));
  396. pwfx->nSamplesPerSec = _tcstoul(ach, NULL, 10);
  397. hedit = GetDlgItem(hwnd, IDD_AAFORMATENUM_EDIT_WBITSPERSAMPLE);
  398. Edit_GetText(hedit, ach, SIZEOF(ach));
  399. pwfx->wBitsPerSample = (WORD)_tcstoul(ach, NULL, 10);
  400. pwfx->nAvgBytesPerSec = fdwEnum;
  401. // -- fall through -- //
  402. case IDCANCEL:
  403. EndDialog(hwnd, (IDOK == uId));
  404. break;
  405. }
  406. break;
  407. }
  408. return (FALSE);
  409. } // AcmAppDlgProcFormatEnum()
  410. //--------------------------------------------------------------------------;
  411. //
  412. // BOOL AcmAppDlgProcProperties
  413. //
  414. // Description:
  415. //
  416. //
  417. // Arguments:
  418. // HWND hwnd: Handle to window.
  419. //
  420. // UINT uMsg: Message being sent to the window.
  421. //
  422. // WPARAM wParam: Specific argument to message.
  423. //
  424. // LPARAM lParam: Specific argument to message.
  425. //
  426. // Return (BOOL):
  427. // The return value is specific to the message that was received. For
  428. // the most part, it is FALSE if this dialog procedure does not handle
  429. // a message.
  430. //
  431. //--------------------------------------------------------------------------;
  432. BOOL FNEXPORT AcmAppDlgProcProperties
  433. (
  434. HWND hwnd,
  435. UINT uMsg,
  436. WPARAM wParam,
  437. LPARAM lParam
  438. )
  439. {
  440. MMRESULT mmr;
  441. TCHAR ach[14];
  442. PAACONVERTDESC paacd;
  443. HWND hcb;
  444. HFONT hfont;
  445. UINT uId;
  446. DWORD cb;
  447. paacd = (PAACONVERTDESC)(UINT)GetWindowLong(hwnd, DWL_USER);
  448. switch (uMsg)
  449. {
  450. case WM_INITDIALOG:
  451. paacd = (PAACONVERTDESC)(UINT)lParam;
  452. SetWindowLong(hwnd, DWL_USER, lParam);
  453. hfont = ghfontApp;
  454. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_SOURCE);
  455. SetWindowFont(hcb, hfont, FALSE);
  456. wsprintf(ach, TEXT("%lu"), paacd->cbSrcReadSize);
  457. ComboBox_AddString(hcb, ach);
  458. wsprintf(ach, TEXT("%lu"), paacd->cbSrcData);
  459. ComboBox_AddString(hcb, ach);
  460. wsprintf(ach, TEXT("%u"), paacd->pwfxSrc->nBlockAlign);
  461. ComboBox_AddString(hcb, ach);
  462. ComboBox_AddString(hcb, TEXT("1"));
  463. ComboBox_AddString(hcb, TEXT("2147483648"));
  464. ComboBox_AddString(hcb, TEXT("4294967295"));
  465. ComboBox_SetCurSel(hcb, 0);
  466. mmr = acmStreamSize(paacd->has,
  467. paacd->cbSrcReadSize,
  468. &paacd->cbDstBufSize,
  469. ACM_STREAMSIZEF_SOURCE);
  470. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_DESTINATION);
  471. SetWindowFont(hcb, hfont, FALSE);
  472. wsprintf(ach, TEXT("%lu"), paacd->cbDstBufSize);
  473. ComboBox_AddString(hcb, ach);
  474. wsprintf(ach, TEXT("%u"), paacd->pwfxDst->nBlockAlign);
  475. ComboBox_AddString(hcb, ach);
  476. ComboBox_AddString(hcb, TEXT("1"));
  477. ComboBox_AddString(hcb, TEXT("2147483648"));
  478. ComboBox_AddString(hcb, TEXT("4294967295"));
  479. ComboBox_SetCurSel(hcb, 0);
  480. return (TRUE);
  481. case WM_COMMAND:
  482. uId = GET_WM_COMMAND_ID(wParam, lParam);
  483. switch (uId)
  484. {
  485. case IDD_AAPROPERTIES_BTN_SOURCE:
  486. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_SOURCE);
  487. Edit_GetText(hcb, ach, SIZEOF(ach));
  488. cb = _tcstoul(ach, NULL, 10);
  489. mmr = acmStreamSize(paacd->has, cb, &cb, ACM_STREAMSIZEF_SOURCE);
  490. wsprintf(ach, TEXT("%lu"), cb);
  491. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_DESTINATION);
  492. Edit_SetText(hcb, ach);
  493. break;
  494. case IDD_AAPROPERTIES_BTN_DESTINATION:
  495. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_DESTINATION);
  496. Edit_GetText(hcb, ach, SIZEOF(ach));
  497. cb = _tcstoul(ach, NULL, 10);
  498. mmr = acmStreamSize(paacd->has, cb, &cb, ACM_STREAMSIZEF_DESTINATION);
  499. wsprintf(ach, TEXT("%lu"), cb);
  500. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_SOURCE);
  501. Edit_SetText(hcb, ach);
  502. break;
  503. case IDOK:
  504. hcb = GetDlgItem(hwnd, IDD_AAPROPERTIES_COMBO_SOURCE);
  505. Edit_GetText(hcb, ach, SIZEOF(ach));
  506. paacd->cbSrcReadSize = _tcstoul(ach, NULL, 10);
  507. // -- fall through -- //
  508. case IDCANCEL:
  509. EndDialog(hwnd, (IDOK == uId));
  510. break;
  511. }
  512. break;
  513. }
  514. return (FALSE);
  515. } // AcmAppDlgProcProperties()
  516. //==========================================================================;
  517. //
  518. //
  519. //
  520. //
  521. //==========================================================================;
  522. //--------------------------------------------------------------------------;
  523. //
  524. // BOOL AcmAppChooserFormatSuggest
  525. //
  526. // Description:
  527. //
  528. //
  529. // Arguments:
  530. // HWND hwnd:
  531. //
  532. // PAACONVERTDESC paacd:
  533. //
  534. // Return (BOOL):
  535. //
  536. //
  537. //--------------------------------------------------------------------------;
  538. BOOL FNLOCAL AcmAppChooserFormatSuggest
  539. (
  540. HWND hwnd,
  541. PAACONVERTDESC paacd
  542. )
  543. {
  544. MMRESULT mmr;
  545. LPWAVEFORMATEX pwfx;
  546. DWORD cbwfx;
  547. DWORD cbwfxSrc;
  548. //
  549. // this should never fail
  550. //
  551. mmr = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &cbwfx);
  552. if (MMSYSERR_NOERROR != mmr)
  553. {
  554. DPF(0, "!AcmAppChooserFormatSuggest() acmMetrics failed mmr=%u!", mmr);
  555. return (FALSE);
  556. }
  557. //
  558. // just in case no ACM driver is installed for the source format and
  559. // the source has a larger format size than the largest enabled ACM
  560. // driver...
  561. //
  562. cbwfxSrc = SIZEOF_WAVEFORMATEX(paacd->pwfxSrc);
  563. cbwfx = max(cbwfx, cbwfxSrc);
  564. pwfx = (LPWAVEFORMATEX)GlobalAllocPtr(GHND, cbwfx);
  565. if (NULL == pwfx)
  566. {
  567. DPF(0, "!AcmAppChooserFormatSuggest() GlobalAllocPtr(%lu) failed!", cbwfx);
  568. return (FALSE);
  569. }
  570. //
  571. // 'suggest anything'
  572. //
  573. mmr = acmFormatSuggest(NULL, paacd->pwfxSrc, pwfx, cbwfx, 0L);
  574. if (MMSYSERR_NOERROR != mmr)
  575. {
  576. AppMsgBox(hwnd, MB_OK | MB_ICONEXCLAMATION,
  577. TEXT("AcmAppChooserFormatSuggest() there is no suggested destination format. Defaulting to source format."));
  578. _fmemcpy(pwfx, paacd->pwfxSrc, (UINT)cbwfxSrc);
  579. }
  580. //
  581. //
  582. //
  583. if (NULL != paacd->pwfxDst)
  584. {
  585. GlobalFreePtr(paacd->pwfxDst);
  586. }
  587. paacd->pwfxDst = pwfx;
  588. AcmAppGetFormatDescription(pwfx, paacd->szDstFormatTag, paacd->szDstFormat);
  589. return (TRUE);
  590. } // AcmAppChooserFormatSuggest()
  591. //--------------------------------------------------------------------------;
  592. //
  593. // BOOL AcmAppChooserSaveFile
  594. //
  595. // Description:
  596. //
  597. //
  598. // Arguments:
  599. // HWND hwnd:
  600. //
  601. // PAACONVERTDESC paacd:
  602. //
  603. // Return (BOOL):
  604. //
  605. //
  606. //--------------------------------------------------------------------------;
  607. BOOL FNLOCAL AcmAppChooserSaveFile
  608. (
  609. HWND hwnd,
  610. PAACONVERTDESC paacd
  611. )
  612. {
  613. TCHAR szFilePath[APP_MAX_FILE_PATH_CHARS];
  614. TCHAR szFileTitle[APP_MAX_FILE_TITLE_CHARS];
  615. HWND hedit;
  616. BOOL f;
  617. hedit = GetDlgItem(hwnd, IDD_AACHOOSER_EDIT_FILE_OUTPUT);
  618. Edit_GetText(hedit, paacd->szFilePathDst, SIZEOF(paacd->szFilePathDst));
  619. lstrcpy(szFilePath, paacd->szFilePathDst);
  620. f = AppGetFileName(hwnd, szFilePath, szFileTitle, APP_GETFILENAMEF_SAVE);
  621. if (f)
  622. {
  623. lstrcpy(paacd->szFilePathDst, szFilePath);
  624. Edit_SetText(hedit, paacd->szFilePathDst);
  625. }
  626. return (f);
  627. } // AcmAppChooserSaveFile()
  628. //--------------------------------------------------------------------------;
  629. //
  630. // BOOL AcmAppChooserProperties
  631. //
  632. // Description:
  633. //
  634. //
  635. // Arguments:
  636. // HWND hwnd:
  637. //
  638. // PAACONVERTDESC paacd:
  639. //
  640. // Return (BOOL):
  641. //
  642. //
  643. //--------------------------------------------------------------------------;
  644. BOOL FNLOCAL AcmAppChooserProperties
  645. (
  646. HWND hwnd,
  647. PAACONVERTDESC paacd
  648. )
  649. {
  650. MMRESULT mmr;
  651. BOOL f;
  652. //
  653. //
  654. //
  655. if (NULL != paacd->hadid)
  656. {
  657. mmr = acmDriverOpen(&paacd->had, paacd->hadid, 0L);
  658. if (MMSYSERR_NOERROR != mmr)
  659. {
  660. return (FALSE);
  661. }
  662. }
  663. mmr = acmStreamOpen(&paacd->has,
  664. paacd->had,
  665. paacd->pwfxSrc,
  666. paacd->pwfxDst,
  667. paacd->fApplyFilter ? paacd->pwfltr : (LPWAVEFILTER)NULL,
  668. 0L,
  669. 0L,
  670. paacd->fdwOpen);
  671. if (MMSYSERR_NOERROR == mmr)
  672. {
  673. f = DialogBoxParam(ghinst,
  674. DLG_AAPROPERTIES,
  675. hwnd,
  676. AcmAppDlgProcProperties,
  677. (LPARAM)(UINT)paacd);
  678. acmStreamClose(paacd->has, 0L);
  679. paacd->has = NULL;
  680. }
  681. if (NULL != paacd->had)
  682. {
  683. acmDriverClose(paacd->had, 0L);
  684. paacd->had = NULL;
  685. }
  686. return (f);
  687. } // AcmAppChooserProperties()
  688. //--------------------------------------------------------------------------;
  689. //
  690. // UINT AcmAppChooserFormatHook
  691. //
  692. // Description:
  693. //
  694. //
  695. // Arguments:
  696. // HWND hwnd:
  697. //
  698. // UINT uMsg:
  699. //
  700. // WPARAM wParam:
  701. //
  702. // LPARAM lParam:
  703. //
  704. // Return (UINT):
  705. //
  706. //
  707. //--------------------------------------------------------------------------;
  708. UINT FNWCALLBACK AcmAppChooserFormatHook
  709. (
  710. HWND hwnd,
  711. UINT uMsg,
  712. WPARAM wParam,
  713. LPARAM lParam
  714. )
  715. {
  716. static BOOL fVerify;
  717. LPWAVEFORMATEX pwfx;
  718. WAVEFORMATEX wfx;
  719. TCHAR szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
  720. TCHAR szFormat[ACMFORMATDETAILS_FORMAT_CHARS];
  721. PAACONVERTDESC paacd;
  722. UINT uId;
  723. int n;
  724. BOOL f;
  725. paacd = (PAACONVERTDESC)(UINT)GetWindowLong(hwnd, DWL_USER);
  726. switch (uMsg)
  727. {
  728. case WM_INITDIALOG:
  729. paacd = (PAACONVERTDESC)(UINT)lParam;
  730. SetWindowLong(hwnd, DWL_USER, lParam);
  731. DPF(1, "AcmAppChooserFormatHook(%.04Xh, WM_INITDIALOG, %u, %lu): %.04Xh",
  732. hwnd, wParam, lParam, paacd);
  733. fVerify = TRUE;
  734. return (TRUE);
  735. case MM_ACM_FORMATCHOOSE:
  736. switch (wParam)
  737. {
  738. case FORMATCHOOSE_FORMATTAG_VERIFY:
  739. if (!fVerify)
  740. break;
  741. wfx.wFormatTag = LOWORD(lParam);
  742. AcmAppGetFormatDescription(&wfx, szFormatTag, NULL);
  743. n = AppMsgBox(hwnd, MB_YESNOCANCEL | MB_ICONQUESTION,
  744. TEXT("Add format tag [%lu], '%s'?"),
  745. lParam, (LPTSTR)szFormatTag);
  746. fVerify = (IDCANCEL != n);
  747. if (!fVerify)
  748. break;
  749. f = (IDYES == n);
  750. SetWindowLong(hwnd, DWL_MSGRESULT, f);
  751. return (TRUE);
  752. case FORMATCHOOSE_FORMAT_VERIFY:
  753. if (!fVerify)
  754. break;
  755. pwfx = (LPWAVEFORMATEX)lParam;
  756. AcmAppGetFormatDescription(pwfx, szFormatTag, szFormat);
  757. n = AppMsgBox(hwnd, MB_YESNOCANCEL | MB_ICONQUESTION,
  758. TEXT("Add format '%s' for format tag [%u], '%s'?"),
  759. (LPTSTR)szFormat,
  760. pwfx->wFormatTag,
  761. (LPTSTR)szFormatTag);
  762. fVerify = (IDCANCEL != n);
  763. if (!fVerify)
  764. break;
  765. f = (IDYES == n);
  766. SetWindowLong(hwnd, DWL_MSGRESULT, f);
  767. return (TRUE);
  768. case FORMATCHOOSE_CUSTOM_VERIFY:
  769. if (!fVerify)
  770. break;
  771. pwfx = (LPWAVEFORMATEX)lParam;
  772. AcmAppGetFormatDescription(pwfx, szFormatTag, szFormat);
  773. n = AppMsgBox(hwnd, MB_YESNOCANCEL | MB_ICONQUESTION,
  774. TEXT("Add CUSTOM format '%s' for format tag [%u], '%s'?"),
  775. (LPTSTR)szFormat,
  776. pwfx->wFormatTag,
  777. (LPTSTR)szFormatTag);
  778. fVerify = (IDCANCEL != n);
  779. if (!fVerify)
  780. break;
  781. f = (IDYES == n);
  782. SetWindowLong(hwnd, DWL_MSGRESULT, f);
  783. return (TRUE);
  784. }
  785. break;
  786. case WM_COMMAND:
  787. uId = GET_WM_COMMAND_ID(wParam, lParam);
  788. switch (uId)
  789. {
  790. case IDOK:
  791. case IDCANCEL:
  792. break;
  793. }
  794. break;
  795. }
  796. return (FALSE);
  797. } // AcmAppChooserFormatHook()
  798. //--------------------------------------------------------------------------;
  799. //
  800. // UINT AcmAppChooserFilterHook
  801. //
  802. // Description:
  803. //
  804. //
  805. // Arguments:
  806. // HWND hwnd:
  807. //
  808. // UINT uMsg:
  809. //
  810. // WPARAM wParam:
  811. //
  812. // LPARAM lParam:
  813. //
  814. // Return (UINT):
  815. //
  816. //
  817. //--------------------------------------------------------------------------;
  818. UINT FNWCALLBACK AcmAppChooserFilterHook
  819. (
  820. HWND hwnd,
  821. UINT uMsg,
  822. WPARAM wParam,
  823. LPARAM lParam
  824. )
  825. {
  826. static BOOL fVerify;
  827. WAVEFILTER wfltr;
  828. LPWAVEFILTER pwfltr;
  829. TCHAR szFilterTag[ACMFILTERTAGDETAILS_FILTERTAG_CHARS];
  830. TCHAR szFilter[ACMFILTERDETAILS_FILTER_CHARS];
  831. PAACONVERTDESC paacd;
  832. UINT uId;
  833. int n;
  834. BOOL f;
  835. paacd = (PAACONVERTDESC)(UINT)GetWindowLong(hwnd, DWL_USER);
  836. switch (uMsg)
  837. {
  838. case WM_INITDIALOG:
  839. paacd = (PAACONVERTDESC)(UINT)lParam;
  840. SetWindowLong(hwnd, DWL_USER, lParam);
  841. DPF(1, "AcmAppChooserFilterHook(%.04Xh, WM_INITDIALOG, %u, %lu): %.04Xh",
  842. hwnd, wParam, lParam, paacd);
  843. fVerify = TRUE;
  844. return (TRUE);
  845. case MM_ACM_FILTERCHOOSE:
  846. switch (wParam)
  847. {
  848. case FILTERCHOOSE_FILTERTAG_VERIFY:
  849. if (!fVerify)
  850. break;
  851. wfltr.dwFilterTag = lParam;
  852. AcmAppGetFilterDescription(&wfltr, szFilterTag, NULL);
  853. n = AppMsgBox(hwnd, MB_YESNOCANCEL | MB_ICONQUESTION,
  854. TEXT("Add filter tag [%lu], '%s'?"),
  855. lParam, (LPTSTR)szFilterTag);
  856. fVerify = (IDCANCEL != n);
  857. if (!fVerify)
  858. break;
  859. f = (IDYES == n);
  860. SetWindowLong(hwnd, DWL_MSGRESULT, f);
  861. return (TRUE);
  862. case FILTERCHOOSE_FILTER_VERIFY:
  863. if (!fVerify)
  864. break;
  865. pwfltr = (LPWAVEFILTER)lParam;
  866. AcmAppGetFilterDescription(pwfltr, szFilterTag, szFilter);
  867. n = AppMsgBox(hwnd, MB_YESNOCANCEL | MB_ICONQUESTION,
  868. TEXT("Add filter '%s' for filter tag [%lu], '%s'?"),
  869. (LPTSTR)szFilter,
  870. pwfltr->dwFilterTag,
  871. (LPTSTR)szFilterTag);
  872. fVerify = (IDCANCEL != n);
  873. if (!fVerify)
  874. break;
  875. f = (IDYES == n);
  876. SetWindowLong(hwnd, DWL_MSGRESULT, f);
  877. return (TRUE);
  878. case FILTERCHOOSE_CUSTOM_VERIFY:
  879. if (!fVerify)
  880. break;
  881. pwfltr = (LPWAVEFILTER)lParam;
  882. AcmAppGetFilterDescription(pwfltr, szFilterTag, szFilter);
  883. n = AppMsgBox(hwnd, MB_YESNOCANCEL | MB_ICONQUESTION,
  884. TEXT("Add CUSTOM filter '%s' for filter tag [%lu], '%s'?"),
  885. (LPTSTR)szFilter,
  886. pwfltr->dwFilterTag,
  887. (LPTSTR)szFilterTag);
  888. fVerify = (IDCANCEL != n);
  889. if (!fVerify)
  890. break;
  891. f = (IDYES == n);
  892. SetWindowLong(hwnd, DWL_MSGRESULT, f);
  893. return (TRUE);
  894. }
  895. break;
  896. case WM_COMMAND:
  897. uId = GET_WM_COMMAND_ID(wParam, lParam);
  898. switch (uId)
  899. {
  900. case IDOK:
  901. case IDCANCEL:
  902. break;
  903. }
  904. break;
  905. }
  906. return (FALSE);
  907. } // AcmAppChooserFilterHook()
  908. //--------------------------------------------------------------------------;
  909. //
  910. // BOOL AcmAppChooserFormat
  911. //
  912. // Description:
  913. //
  914. //
  915. // Arguments:
  916. // HWND hwnd:
  917. //
  918. // PAACONVERTDESC paacd:
  919. //
  920. // BOOL fOptions:
  921. //
  922. // Return (BOOL):
  923. //
  924. //
  925. //--------------------------------------------------------------------------;
  926. BOOL FNLOCAL AcmAppChooserFormat
  927. (
  928. HWND hwnd,
  929. PAACONVERTDESC paacd,
  930. BOOL fOptions
  931. )
  932. {
  933. ACMFORMATCHOOSE afc;
  934. MMRESULT mmr;
  935. LPWAVEFORMATEX pwfx;
  936. DWORD cbwfx;
  937. DWORD cbwfxSrc;
  938. DWORD fdwSuggest;
  939. DWORD fdwStyle;
  940. DWORD fdwEnum;
  941. WAVEFORMATEX wfxEnum;
  942. BOOL f;
  943. HRSRC hrsrc;
  944. //
  945. //
  946. //
  947. fdwSuggest = 0L;
  948. fdwStyle = 0L;
  949. fdwEnum = 0L;
  950. if (fOptions)
  951. {
  952. wfxEnum.wFormatTag = paacd->pwfxSrc->wFormatTag;
  953. wfxEnum.nChannels = paacd->pwfxSrc->nChannels;
  954. wfxEnum.nSamplesPerSec = paacd->pwfxSrc->nSamplesPerSec;
  955. wfxEnum.wBitsPerSample = paacd->pwfxSrc->wBitsPerSample;
  956. wfxEnum.nBlockAlign = 0;
  957. wfxEnum.nAvgBytesPerSec = fdwEnum;
  958. wfxEnum.cbSize = 0;
  959. f = DialogBoxParam(ghinst,
  960. DLG_AAFORMATENUM,
  961. hwnd,
  962. AcmAppDlgProcFormatEnum,
  963. (LPARAM)(UINT)&wfxEnum);
  964. if (!f)
  965. {
  966. return (FALSE);
  967. }
  968. fdwEnum = wfxEnum.nAvgBytesPerSec;
  969. wfxEnum.nAvgBytesPerSec = 0L;
  970. }
  971. if (fOptions)
  972. {
  973. afc.fdwStyle = fdwStyle;
  974. f = DialogBoxParam(ghinst,
  975. DLG_AAFORMATSTYLE,
  976. hwnd,
  977. AcmAppDlgProcFormatStyle,
  978. (LPARAM)(UINT)&afc);
  979. if (!f)
  980. {
  981. return (FALSE);
  982. }
  983. fdwStyle = afc.fdwStyle;
  984. }
  985. //
  986. // this should never fail
  987. //
  988. mmr = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FORMAT, &cbwfx);
  989. if (MMSYSERR_NOERROR != mmr)
  990. {
  991. DPF(0, "!AcmAppChooserFormat() acmMetrics failed mmr=%u!", mmr);
  992. return (FALSE);
  993. }
  994. //
  995. // just in case no ACM driver is installed for the source format and
  996. // the source has a larger format size than the largest enabled ACM
  997. // driver...
  998. //
  999. cbwfxSrc = SIZEOF_WAVEFORMATEX(paacd->pwfxSrc);
  1000. cbwfx = max(cbwfx, cbwfxSrc);
  1001. pwfx = (LPWAVEFORMATEX)GlobalAllocPtr(GHND, cbwfx);
  1002. if (NULL == pwfx)
  1003. {
  1004. DPF(0, "!AcmAppChooserFormat() GlobalAllocPtr(%lu) failed!", cbwfx);
  1005. return (FALSE);
  1006. }
  1007. //
  1008. //
  1009. //
  1010. //
  1011. if (0 != (fdwStyle & ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT))
  1012. {
  1013. if (NULL != paacd->pwfxDst)
  1014. {
  1015. _fmemcpy(pwfx, paacd->pwfxDst, SIZEOF_WAVEFORMATEX(paacd->pwfxDst));
  1016. }
  1017. else
  1018. {
  1019. _fmemcpy(pwfx, paacd->pwfxSrc, (UINT)cbwfxSrc);
  1020. }
  1021. }
  1022. //
  1023. //
  1024. //
  1025. //
  1026. if (0 == (ACMFORMATCHOOSE_STYLEF_SHOWHELP & fdwStyle))
  1027. {
  1028. guMsgHelp = 0;
  1029. }
  1030. else
  1031. {
  1032. guMsgHelp = RegisterWindowMessage(ACMHELPMSGSTRING);
  1033. if (0 == guMsgHelp)
  1034. {
  1035. fdwStyle &= ~ACMFORMATCHOOSE_STYLEF_SHOWHELP;
  1036. }
  1037. else
  1038. {
  1039. gpszAcmAppHelp = gszAcmAppHelpFormat;
  1040. }
  1041. }
  1042. //
  1043. // initialize the ACMFORMATCHOOSE members
  1044. //
  1045. memset(&afc, 0, sizeof(afc));
  1046. afc.cbStruct = sizeof(afc);
  1047. afc.fdwStyle = fdwStyle;
  1048. afc.hwndOwner = hwnd;
  1049. afc.pwfx = pwfx;
  1050. afc.cbwfx = cbwfx;
  1051. afc.pszTitle = TEXT("Destination Format Choice");
  1052. afc.szFormatTag[0] = '\0';
  1053. afc.szFormat[0] = '\0';
  1054. afc.pszName = NULL;
  1055. afc.cchName = 0;
  1056. afc.fdwEnum = fdwEnum;
  1057. if (0L == (afc.fdwEnum & (ACM_FORMATENUMF_WFORMATTAG |
  1058. ACM_FORMATENUMF_NCHANNELS |
  1059. ACM_FORMATENUMF_NSAMPLESPERSEC |
  1060. ACM_FORMATENUMF_WBITSPERSAMPLE |
  1061. ACM_FORMATENUMF_CONVERT |
  1062. ACM_FORMATENUMF_SUGGEST)))
  1063. {
  1064. afc.pwfxEnum = NULL;
  1065. }
  1066. else
  1067. {
  1068. if (0 == (afc.fdwEnum & (ACM_FORMATENUMF_CONVERT |
  1069. ACM_FORMATENUMF_SUGGEST)))
  1070. {
  1071. //
  1072. // if _CONVERT and _SUGGEST are not specified, then we only
  1073. // need to pass in a format structure large enough to describe
  1074. // everything up to (but not including) the cbSize--it's fine
  1075. // to pass more, but it is not necessary. in other words, a
  1076. // PCMWAVEFORMAT would do nicely...
  1077. //
  1078. afc.pwfxEnum = &wfxEnum;
  1079. }
  1080. else
  1081. {
  1082. //
  1083. // for the _CONVERT and _SUGGEST flags, we must pass a valid
  1084. // format--and since we're looking for destinations that apply
  1085. // to our source format, we simply reference it..
  1086. //
  1087. afc.pwfxEnum = paacd->pwfxSrc;
  1088. }
  1089. }
  1090. //
  1091. //
  1092. //
  1093. hrsrc = NULL;
  1094. if (0L == (afc.fdwStyle & (ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE |
  1095. ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE)))
  1096. {
  1097. afc.hInstance = NULL;
  1098. afc.pszTemplateName = NULL;
  1099. }
  1100. else
  1101. {
  1102. if (0L != (afc.fdwStyle & ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE))
  1103. {
  1104. //
  1105. // ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE
  1106. //
  1107. hrsrc = FindResource(ghinst, DLG_AAFORMATCHOOSE_TEMPLATE, RT_DIALOG);
  1108. afc.hInstance = (HINSTANCE)LoadResource(ghinst, hrsrc);
  1109. afc.pszTemplateName = NULL;
  1110. }
  1111. else
  1112. {
  1113. afc.hInstance = ghinst;
  1114. afc.pszTemplateName = DLG_AAFORMATCHOOSE_TEMPLATE;
  1115. }
  1116. }
  1117. if (0L == (afc.fdwStyle & ACMFORMATCHOOSE_STYLEF_ENABLEHOOK))
  1118. {
  1119. afc.lCustData = 0L;
  1120. afc.pfnHook = NULL;
  1121. }
  1122. else
  1123. {
  1124. afc.lCustData = (LPARAM)(UINT)paacd;
  1125. afc.pfnHook = AcmAppChooserFormatHook;
  1126. }
  1127. //
  1128. //
  1129. //
  1130. mmr = acmFormatChoose(&afc);
  1131. if (NULL != hrsrc)
  1132. {
  1133. FreeResource((HGLOBAL)afc.hInstance);
  1134. }
  1135. //
  1136. //
  1137. //
  1138. if (0 != guMsgHelp)
  1139. {
  1140. WinHelp(hwnd, gszAcmAppHelpFormat, HELP_QUIT, 0L);
  1141. guMsgHelp = 0;
  1142. }
  1143. if (MMSYSERR_NOERROR != mmr)
  1144. {
  1145. if (ACMERR_CANCELED != mmr)
  1146. {
  1147. TCHAR ach[40];
  1148. AcmAppGetErrorString(mmr, ach);
  1149. AppMsgBox(hwnd, MB_OK | MB_ICONEXCLAMATION,
  1150. TEXT("acmFormatChoose() failed with error %s, [%u]."),
  1151. (LPTSTR)ach, mmr);
  1152. }
  1153. GlobalFreePtr(pwfx);
  1154. return (FALSE);
  1155. }
  1156. //
  1157. //
  1158. //
  1159. if (NULL != paacd->pwfxDst)
  1160. {
  1161. GlobalFreePtr(paacd->pwfxDst);
  1162. }
  1163. paacd->pwfxDst = pwfx;
  1164. lstrcpy(paacd->szDstFormatTag, afc.szFormatTag);
  1165. lstrcpy(paacd->szDstFormat, afc.szFormat);
  1166. return (TRUE);
  1167. } // AcmAppChooserFormat()
  1168. //--------------------------------------------------------------------------;
  1169. //
  1170. // BOOL AcmAppChooserFilter
  1171. //
  1172. // Description:
  1173. //
  1174. //
  1175. // Arguments:
  1176. // HWND hwnd:
  1177. //
  1178. // PAACONVERTDESC paacd:
  1179. //
  1180. // BOOL fOptions:
  1181. //
  1182. // Return (BOOL):
  1183. //
  1184. //
  1185. //--------------------------------------------------------------------------;
  1186. BOOL FNLOCAL AcmAppChooserFilter
  1187. (
  1188. HWND hwnd,
  1189. PAACONVERTDESC paacd,
  1190. BOOL fOptions
  1191. )
  1192. {
  1193. ACMFILTERCHOOSE afc;
  1194. MMRESULT mmr;
  1195. LPWAVEFILTER pwfltr;
  1196. DWORD cbwfltr;
  1197. DWORD fdwStyle;
  1198. DWORD fdwEnum;
  1199. WAVEFILTER wfltrEnum;
  1200. BOOL f;
  1201. HRSRC hrsrc;
  1202. //
  1203. //
  1204. //
  1205. fdwStyle = 0L;
  1206. fdwEnum = 0L;
  1207. if (fOptions)
  1208. {
  1209. _fmemset(&wfltrEnum, 0, sizeof(wfltrEnum));
  1210. wfltrEnum.cbStruct = sizeof(wfltrEnum);
  1211. wfltrEnum.dwFilterTag = paacd->pwfxSrc->wFormatTag;
  1212. wfltrEnum.fdwFilter = fdwEnum;
  1213. f = DialogBoxParam(ghinst,
  1214. DLG_AAFILTERENUM,
  1215. hwnd,
  1216. AcmAppDlgProcFilterEnum,
  1217. (LPARAM)(UINT)&wfltrEnum);
  1218. if (!f)
  1219. {
  1220. return (FALSE);
  1221. }
  1222. fdwEnum = wfltrEnum.fdwFilter;
  1223. wfltrEnum.fdwFilter = 0L;
  1224. }
  1225. if (fOptions)
  1226. {
  1227. afc.fdwStyle = fdwStyle;
  1228. f = DialogBoxParam(ghinst,
  1229. DLG_AAFILTERSTYLE,
  1230. hwnd,
  1231. AcmAppDlgProcFilterStyle,
  1232. (LPARAM)(UINT)&afc);
  1233. if (!f)
  1234. {
  1235. return (FALSE);
  1236. }
  1237. fdwStyle = afc.fdwStyle;
  1238. }
  1239. //
  1240. // this should never fail
  1241. //
  1242. mmr = acmMetrics(NULL, ACM_METRIC_MAX_SIZE_FILTER, &cbwfltr);
  1243. if (MMSYSERR_NOERROR != mmr)
  1244. {
  1245. DPF(0, "!AcmAppChooserFilter() acmMetrics failed mmr=%u!", mmr);
  1246. return (FALSE);
  1247. }
  1248. //
  1249. //
  1250. //
  1251. cbwfltr = max(cbwfltr, sizeof(WAVEFILTER));
  1252. pwfltr = (LPWAVEFILTER)GlobalAllocPtr(GHND, cbwfltr);
  1253. if (NULL == pwfltr)
  1254. {
  1255. DPF(0, "!AcmAppChooserFilter() GlobalAllocPtr(%lu) failed!", cbwfltr);
  1256. return (FALSE);
  1257. }
  1258. //
  1259. //
  1260. //
  1261. if ((NULL != paacd->pwfltr) && (0L == fdwEnum))
  1262. {
  1263. fdwStyle |= ACMFILTERCHOOSE_STYLEF_INITTOFILTERSTRUCT;
  1264. _fmemcpy(pwfltr, paacd->pwfltr, (UINT)paacd->pwfltr->cbStruct);
  1265. }
  1266. //
  1267. //
  1268. //
  1269. //
  1270. if (0 == (ACMFILTERCHOOSE_STYLEF_SHOWHELP & fdwStyle))
  1271. {
  1272. guMsgHelp = 0;
  1273. }
  1274. else
  1275. {
  1276. guMsgHelp = RegisterWindowMessage(ACMHELPMSGSTRING);
  1277. if (0 == guMsgHelp)
  1278. {
  1279. fdwStyle &= ~ACMFILTERCHOOSE_STYLEF_SHOWHELP;
  1280. }
  1281. else
  1282. {
  1283. gpszAcmAppHelp = gszAcmAppHelpFilter;
  1284. }
  1285. }
  1286. //
  1287. // initialize the ACMFILTERCHOOSE members
  1288. //
  1289. memset(&afc, 0, sizeof(afc));
  1290. afc.cbStruct = sizeof(afc);
  1291. afc.fdwStyle = fdwStyle;
  1292. afc.hwndOwner = hwnd;
  1293. afc.pwfltr = pwfltr;
  1294. afc.cbwfltr = cbwfltr;
  1295. afc.pszTitle = TEXT("Apply Filter Choice");
  1296. afc.szFilterTag[0] = '\0';
  1297. afc.szFilter[0] = '\0';
  1298. afc.pszName = NULL;
  1299. afc.cchName = 0;
  1300. afc.fdwEnum = fdwEnum;
  1301. if (0L == (afc.fdwEnum & ACM_FILTERENUMF_DWFILTERTAG))
  1302. {
  1303. afc.pwfltrEnum = NULL;
  1304. }
  1305. else
  1306. {
  1307. afc.pwfltrEnum = &wfltrEnum;
  1308. }
  1309. if (0L == (afc.fdwStyle & (ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATE |
  1310. ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE)))
  1311. {
  1312. afc.hInstance = NULL;
  1313. afc.pszTemplateName = NULL;
  1314. }
  1315. else
  1316. {
  1317. if (0L != (afc.fdwStyle & ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE))
  1318. {
  1319. //
  1320. // ACMFILTERCHOOSE_STYLEF_ENABLETEMPLATEHANDLE
  1321. //
  1322. hrsrc = FindResource(ghinst, DLG_AAFILTERCHOOSE_TEMPLATE, RT_DIALOG);
  1323. afc.hInstance = (HINSTANCE)LoadResource(ghinst, hrsrc);
  1324. afc.pszTemplateName = NULL;
  1325. }
  1326. else
  1327. {
  1328. afc.hInstance = ghinst;
  1329. afc.pszTemplateName = DLG_AAFILTERCHOOSE_TEMPLATE;
  1330. }
  1331. }
  1332. if (0L == (afc.fdwStyle & ACMFILTERCHOOSE_STYLEF_ENABLEHOOK))
  1333. {
  1334. afc.lCustData = 0L;
  1335. afc.pfnHook = NULL;
  1336. }
  1337. else
  1338. {
  1339. afc.lCustData = (LPARAM)(UINT)paacd;
  1340. afc.pfnHook = AcmAppChooserFilterHook;
  1341. }
  1342. //
  1343. //
  1344. //
  1345. mmr = acmFilterChoose(&afc);
  1346. if (NULL != hrsrc)
  1347. {
  1348. FreeResource((HGLOBAL)afc.hInstance);
  1349. }
  1350. //
  1351. //
  1352. //
  1353. if (0 != guMsgHelp)
  1354. {
  1355. WinHelp(hwnd, gszAcmAppHelpFilter, HELP_QUIT, 0L);
  1356. guMsgHelp = 0;
  1357. }
  1358. if (MMSYSERR_NOERROR != mmr)
  1359. {
  1360. if (ACMERR_CANCELED != mmr)
  1361. {
  1362. AppMsgBox(hwnd, MB_OK | MB_ICONEXCLAMATION,
  1363. TEXT("acmFilterChoose() failed with error = %u!"), mmr);
  1364. }
  1365. GlobalFreePtr(pwfltr);
  1366. return (FALSE);
  1367. }
  1368. //
  1369. //
  1370. //
  1371. if (NULL != paacd->pwfltr)
  1372. {
  1373. GlobalFreePtr(paacd->pwfltr);
  1374. }
  1375. paacd->pwfltr = pwfltr;
  1376. lstrcpy(paacd->szFilterTag, afc.szFilterTag);
  1377. lstrcpy(paacd->szFilter, afc.szFilter);
  1378. return (TRUE);
  1379. } // AcmAppChooserFilter()
  1380. //--------------------------------------------------------------------------;
  1381. //
  1382. // BOOL AcmAppChooserDriverEnumCallback
  1383. //
  1384. // Description:
  1385. //
  1386. //
  1387. // Arguments:
  1388. // HACMDRIVERID hadid:
  1389. //
  1390. // DWORD dwInstance:
  1391. //
  1392. // DWORD fdwSupport:
  1393. //
  1394. // Return (BOOL):
  1395. //
  1396. //
  1397. //--------------------------------------------------------------------------;
  1398. BOOL FNEXPORT AcmAppChooserDriverEnumCallback
  1399. (
  1400. HACMDRIVERID hadid,
  1401. DWORD dwInstance,
  1402. DWORD fdwSupport
  1403. )
  1404. {
  1405. MMRESULT mmr;
  1406. HWND hcb;
  1407. int n;
  1408. ACMDRIVERDETAILS add;
  1409. //
  1410. // skip anything that does not support what we're after (for example,
  1411. // this will skip _HARDWARE only drivers that do not support stream
  1412. // functionality).
  1413. //
  1414. if (0 == (fdwSupport & (ACMDRIVERDETAILS_SUPPORTF_CODEC |
  1415. ACMDRIVERDETAILS_SUPPORTF_CONVERTER |
  1416. ACMDRIVERDETAILS_SUPPORTF_FILTER)))
  1417. {
  1418. return (TRUE);
  1419. }
  1420. //
  1421. //
  1422. //
  1423. hcb = (HWND)(UINT)dwInstance;
  1424. add.cbStruct = sizeof(add);
  1425. mmr = acmDriverDetails(hadid, &add, 0L);
  1426. if (MMSYSERR_NOERROR != mmr)
  1427. {
  1428. lstrcpy(add.szLongName, gszBogus);
  1429. }
  1430. AcmAppDebugLog(add.szLongName);
  1431. AcmAppDebugLog(TEXT("\r\n"));
  1432. n = ComboBox_AddString(hcb, add.szLongName);
  1433. ComboBox_SetItemData(hcb, n, (LPARAM)(UINT)hadid);
  1434. //
  1435. // return TRUE to continue with enumeration (FALSE will stop the
  1436. // enumerator)
  1437. //
  1438. return (TRUE);
  1439. } // AcmAppChooserDriverEnumCallback()
  1440. //--------------------------------------------------------------------------;
  1441. //
  1442. // BOOL AcmAppChooserUpdateDisplay
  1443. //
  1444. // Description:
  1445. //
  1446. //
  1447. // Arguments:
  1448. // HWND hwnd:
  1449. //
  1450. // PAACONVERTDESC paacd:
  1451. //
  1452. // Return (BOOL):
  1453. //
  1454. //
  1455. //--------------------------------------------------------------------------;
  1456. BOOL FNLOCAL AcmAppChooserUpdateDisplay
  1457. (
  1458. HWND hwnd,
  1459. PAACONVERTDESC paacd
  1460. )
  1461. {
  1462. HWND hedit;
  1463. HWND htxt;
  1464. HWND hcb;
  1465. HWND hsb;
  1466. int n;
  1467. MMRESULT mmr;
  1468. ACMDRIVERDETAILS add;
  1469. TCHAR ach[40];
  1470. LPWAVEFILTER pwfltr;
  1471. HACMDRIVERID hadid;
  1472. BOOL f;
  1473. DWORD fdwOpen;
  1474. int nValue;
  1475. int nMinPos;
  1476. int nMaxPos;
  1477. DWORD cbSrc;
  1478. DWORD cbDst;
  1479. //
  1480. //
  1481. //
  1482. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FILE_INPUT);
  1483. SetWindowText(htxt, paacd->szFilePathSrc);
  1484. AcmAppGetFormatDescription(paacd->pwfxSrc, paacd->szSrcFormatTag, paacd->szSrcFormat);
  1485. AppFormatBigNumber(ach, paacd->cbSrcData);
  1486. AppFormatBigNumber(&ach[20], paacd->cbSrcData / paacd->pwfxSrc->nBlockAlign);
  1487. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FORMAT_INPUT);
  1488. AppSetWindowText(htxt, TEXT("%s: %s\r\nAlignment=%u, Data=%s bytes, %s blocks"),
  1489. (LPTSTR)paacd->szSrcFormatTag,
  1490. (LPTSTR)paacd->szSrcFormat,
  1491. paacd->pwfxSrc->nBlockAlign,
  1492. (LPTSTR)ach, (LPTSTR)&ach[20]);
  1493. hedit = GetDlgItem(hwnd, IDD_AACHOOSER_EDIT_FILE_OUTPUT);
  1494. Edit_GetText(hedit, paacd->szFilePathDst, SIZEOF(paacd->szFilePathDst));
  1495. //
  1496. //
  1497. //
  1498. nValue = (int)paacd->uBufferTimePerConvert;
  1499. hsb = GetDlgItem(hwnd, IDD_AACHOOSER_SCROLL_TIME);
  1500. GetScrollRange(hsb, SB_CTL, &nMinPos, &nMaxPos);
  1501. if (nValue != GetScrollPos(hsb, SB_CTL))
  1502. {
  1503. SetScrollPos(hsb, SB_CTL, nValue, TRUE);
  1504. if (nValue == nMaxPos)
  1505. {
  1506. lstrcpy(ach, TEXT("(ALL)"));
  1507. }
  1508. else if (nValue == nMinPos)
  1509. {
  1510. lstrcpy(ach, TEXT("(Auto)"));
  1511. }
  1512. else
  1513. {
  1514. wsprintf(ach, TEXT("%u.%.03u"), nValue / 1000, nValue % 1000);
  1515. }
  1516. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_TIME);
  1517. SetWindowText(htxt, ach);
  1518. }
  1519. //
  1520. //
  1521. //
  1522. if (nValue == nMaxPos)
  1523. {
  1524. cbSrc = paacd->cbSrcData;
  1525. }
  1526. else if (nValue == nMinPos)
  1527. {
  1528. //
  1529. // could do something real here--for now, just do '1/8th of
  1530. // a second'..
  1531. //
  1532. cbSrc = paacd->pwfxSrc->nAvgBytesPerSec;
  1533. cbSrc = MulDivRN(cbSrc, 175, 1000);
  1534. }
  1535. else
  1536. {
  1537. cbSrc = paacd->pwfxSrc->nAvgBytesPerSec;
  1538. cbSrc = MulDivRN(cbSrc, (UINT)nValue, 1000);
  1539. }
  1540. paacd->cbSrcReadSize = cbSrc;
  1541. //
  1542. //
  1543. //
  1544. paacd->hadid = NULL;
  1545. hcb = GetDlgItem(hwnd, IDD_AACHOOSER_COMBO_DRIVER);
  1546. n = ComboBox_GetCurSel(hcb);
  1547. if (LB_ERR != n)
  1548. {
  1549. paacd->hadid = (HACMDRIVERID)(UINT)ComboBox_GetItemData(hcb, n);
  1550. }
  1551. //
  1552. //
  1553. //
  1554. //
  1555. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FORMAT);
  1556. if (NULL == paacd->pwfxDst)
  1557. {
  1558. SetWindowText(htxt, TEXT("(no format selected)"));
  1559. }
  1560. else
  1561. {
  1562. AppSetWindowText(htxt, TEXT("%s: %s\r\nAlignment=%u"),
  1563. (LPTSTR)paacd->szDstFormatTag,
  1564. (LPTSTR)paacd->szDstFormat,
  1565. paacd->pwfxDst->nBlockAlign);
  1566. }
  1567. //
  1568. //
  1569. //
  1570. //
  1571. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FILTER);
  1572. if (NULL == paacd->pwfltr)
  1573. {
  1574. SetWindowText(htxt, TEXT("(no filter selected)"));
  1575. }
  1576. else
  1577. {
  1578. AppSetWindowText(htxt, TEXT("%s: %s"),
  1579. (LPTSTR)paacd->szFilterTag,
  1580. (LPTSTR)paacd->szFilter);
  1581. }
  1582. hedit = GetDlgItem(hwnd, IDD_AACHOOSER_EDIT_DETAILS);
  1583. MEditPrintF(hedit, NULL);
  1584. if (NULL == paacd->pwfxDst)
  1585. {
  1586. MEditPrintF(hedit, TEXT("hadid=%.04Xh\r\npwfxDst=%.08lXh\r\npwfltr=%.08lXh"),
  1587. paacd->hadid,
  1588. paacd->pwfxDst,
  1589. paacd->pwfltr);
  1590. return (FALSE);
  1591. }
  1592. //
  1593. //
  1594. //
  1595. if (NULL != paacd->hadid)
  1596. {
  1597. mmr = acmDriverOpen(&paacd->had, paacd->hadid, 0L);
  1598. if (MMSYSERR_NOERROR != mmr)
  1599. {
  1600. AcmAppGetErrorString(mmr, ach);
  1601. MEditPrintF(hedit, TEXT("The selected driver (hadid=%.04Xh) cannot be opened. %s (%u)"),
  1602. paacd->hadid, (LPSTR)ach, mmr);
  1603. return (FALSE);
  1604. }
  1605. }
  1606. SetWindowRedraw(hedit, FALSE);
  1607. //
  1608. //
  1609. //
  1610. f = IsDlgButtonChecked(hwnd, IDD_AACHOOSER_CHECK_FILTER);
  1611. pwfltr = (f ? paacd->pwfltr : (LPWAVEFILTER)NULL);
  1612. paacd->fApplyFilter = f;
  1613. fdwOpen = 0L;
  1614. f = IsDlgButtonChecked(hwnd, IDD_AACHOOSER_CHECK_NONREALTIME);
  1615. if (f)
  1616. {
  1617. fdwOpen |= ACM_STREAMOPENF_NONREALTIME;
  1618. }
  1619. f = IsDlgButtonChecked(hwnd, IDD_AACHOOSER_CHECK_ASYNC);
  1620. if (f)
  1621. {
  1622. fdwOpen |= ACM_STREAMOPENF_ASYNC;
  1623. }
  1624. paacd->fdwOpen = fdwOpen;
  1625. //
  1626. //
  1627. //
  1628. MEditPrintF(hedit, TEXT("~%12s: "), (LPTSTR)TEXT("Stream Open"));
  1629. mmr = acmStreamOpen(&paacd->has,
  1630. paacd->had,
  1631. paacd->pwfxSrc,
  1632. paacd->pwfxDst,
  1633. pwfltr,
  1634. 0L,
  1635. 0L,
  1636. fdwOpen);
  1637. if (MMSYSERR_NOERROR == mmr)
  1638. {
  1639. TCHAR szSrc[20];
  1640. BOOL fSrcAligned;
  1641. BOOL fDstAligned;
  1642. acmDriverID((HACMOBJ)paacd->has, &hadid, 0L);
  1643. add.cbStruct = sizeof(add);
  1644. mmr = acmDriverDetails(hadid, &add, 0L);
  1645. if (MMSYSERR_NOERROR != mmr)
  1646. {
  1647. lstrcpy(add.szLongName, gszBogus);
  1648. }
  1649. MEditPrintF(hedit, TEXT("%s, %s"), (LPTSTR)gszYes, (LPTSTR)add.szLongName);
  1650. fSrcAligned = (0 == (cbSrc % paacd->pwfxSrc->nBlockAlign));
  1651. AppFormatBigNumber(szSrc, cbSrc);
  1652. mmr = acmStreamSize(paacd->has, cbSrc, &cbDst, ACM_STREAMSIZEF_SOURCE);
  1653. if (MMSYSERR_NOERROR == mmr)
  1654. {
  1655. TCHAR szDst[20];
  1656. fDstAligned = (0 == (cbDst % paacd->pwfxDst->nBlockAlign));
  1657. AppFormatBigNumber(szDst, cbDst);
  1658. if (cbSrc < cbDst)
  1659. {
  1660. cbDst = MulDivRN(cbDst, 10, cbSrc);
  1661. cbSrc = 10;
  1662. }
  1663. else
  1664. {
  1665. cbSrc = MulDivRN(cbSrc, 10, cbDst);
  1666. cbDst = 10;
  1667. }
  1668. MEditPrintF(hedit, TEXT("%12s: Src=%c%10s, Dst=%c%10s (%lu.%lu:%lu.%lu)"),
  1669. (LPTSTR)TEXT("Buffer Size"),
  1670. fSrcAligned ? '*' : ' ',
  1671. (LPTSTR)szSrc,
  1672. fDstAligned ? '*' : ' ',
  1673. (LPTSTR)szDst,
  1674. cbSrc / 10, cbSrc % 10,
  1675. cbDst / 10, cbDst % 10);
  1676. }
  1677. else
  1678. {
  1679. AcmAppGetErrorString(mmr, ach);
  1680. MEditPrintF(hedit, TEXT("%12s: Src=%c%10s, %s (%u)"), (LPTSTR)TEXT("Buffer Size"),
  1681. fSrcAligned ? '*' : ' ',
  1682. (LPTSTR)szSrc, (LPTSTR)ach, mmr);
  1683. }
  1684. acmStreamClose(paacd->has, 0L);
  1685. paacd->has = NULL;
  1686. }
  1687. else
  1688. {
  1689. AcmAppGetErrorString(mmr, ach);
  1690. MEditPrintF(hedit, TEXT("%s, %s (%u)"), (LPTSTR)gszNo, (LPSTR)ach, mmr);
  1691. }
  1692. //
  1693. //
  1694. //
  1695. MEditPrintF(hedit, TEXT("~%12s: "), (LPTSTR)TEXT("(Query)"));
  1696. mmr = acmStreamOpen(NULL,
  1697. paacd->had,
  1698. paacd->pwfxSrc,
  1699. paacd->pwfxDst,
  1700. pwfltr,
  1701. 0L,
  1702. 0L,
  1703. fdwOpen | ACM_STREAMOPENF_QUERY);
  1704. if (MMSYSERR_NOERROR == mmr)
  1705. {
  1706. MEditPrintF(hedit, gszYes);
  1707. }
  1708. else
  1709. {
  1710. AcmAppGetErrorString(mmr, ach);
  1711. MEditPrintF(hedit, TEXT("%s, %s (%u)"), (LPTSTR)gszNo, (LPSTR)ach, mmr);
  1712. }
  1713. if (NULL != paacd->had)
  1714. {
  1715. acmDriverClose(paacd->had, 0L);
  1716. paacd->had = NULL;
  1717. }
  1718. SetWindowRedraw(hedit, TRUE);
  1719. return (MMSYSERR_NOERROR == mmr);
  1720. } // AcmAppChooserUpdateDisplay()
  1721. //--------------------------------------------------------------------------;
  1722. //
  1723. // BOOL AcmAppChooserScrollConvertTime
  1724. //
  1725. // Description:
  1726. //
  1727. //
  1728. // Arguments:
  1729. // HWND hwnd:
  1730. //
  1731. // HWND hsb:
  1732. //
  1733. // UINT uCode:
  1734. //
  1735. // int nPos:
  1736. //
  1737. // Return (BOOL):
  1738. //
  1739. //
  1740. //--------------------------------------------------------------------------;
  1741. BOOL FNLOCAL AcmAppChooserScrollConvertTime
  1742. (
  1743. HWND hwnd,
  1744. HWND hsb,
  1745. UINT uCode,
  1746. int nPos
  1747. )
  1748. {
  1749. PAACONVERTDESC paacd;
  1750. int nMinPos;
  1751. int nMaxPos;
  1752. HWND htxt;
  1753. TCHAR ach[40];
  1754. GetScrollRange(hsb, SB_CTL, &nMinPos, &nMaxPos);
  1755. if ((SB_THUMBPOSITION != uCode) && (SB_THUMBTRACK != uCode))
  1756. {
  1757. nPos = GetScrollPos(hsb, SB_CTL);
  1758. }
  1759. //
  1760. //
  1761. //
  1762. switch (uCode)
  1763. {
  1764. case SB_PAGEDOWN:
  1765. if (GetKeyState(VK_CONTROL) < 0)
  1766. nPos = min(nMaxPos, nPos + 100);
  1767. else
  1768. nPos = min(nMaxPos, nPos + 500);
  1769. break;
  1770. case SB_LINEDOWN:
  1771. if (GetKeyState(VK_CONTROL) < 0)
  1772. nPos = min(nMaxPos, nPos + 1);
  1773. else
  1774. nPos = min(nMaxPos, nPos + 10);
  1775. break;
  1776. case SB_PAGEUP:
  1777. if (GetKeyState(VK_CONTROL) < 0)
  1778. nPos = max(nMinPos, nPos - 100);
  1779. else
  1780. nPos = max(nMinPos, nPos - 500);
  1781. break;
  1782. case SB_LINEUP:
  1783. if (GetKeyState(VK_CONTROL) < 0)
  1784. nPos = max(nMinPos, nPos - 1);
  1785. else
  1786. nPos = max(nMinPos, nPos - 10);
  1787. break;
  1788. case SB_TOP:
  1789. if (GetKeyState(VK_CONTROL) < 0)
  1790. nPos = nMinPos;
  1791. else
  1792. nPos = 1000;
  1793. break;
  1794. case SB_BOTTOM:
  1795. nPos = nMaxPos;
  1796. break;
  1797. case SB_THUMBPOSITION:
  1798. case SB_THUMBTRACK:
  1799. break;
  1800. default:
  1801. return (FALSE);
  1802. }
  1803. //
  1804. //
  1805. //
  1806. paacd = (PAACONVERTDESC)(UINT)GetWindowLong(hwnd, DWL_USER);
  1807. paacd->uBufferTimePerConvert = (UINT)nPos;
  1808. SetScrollPos(hsb, SB_CTL, nPos, TRUE);
  1809. if (nPos == nMaxPos)
  1810. {
  1811. lstrcpy(ach, TEXT("(ALL)"));
  1812. }
  1813. else if (nPos == nMinPos)
  1814. {
  1815. lstrcpy(ach, TEXT("(Auto)"));
  1816. }
  1817. else
  1818. {
  1819. wsprintf(ach, TEXT("%u.%.03u"), nPos / 1000, nPos % 1000);
  1820. }
  1821. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_TIME);
  1822. SetWindowText(htxt, ach);
  1823. //
  1824. //
  1825. //
  1826. return (TRUE);
  1827. } // AcmAppChooserScrollConvertTime()
  1828. //--------------------------------------------------------------------------;
  1829. //
  1830. // BOOL AcmAppDlgProcChooser
  1831. //
  1832. // Description:
  1833. //
  1834. //
  1835. // Arguments:
  1836. // HWND hwnd: Handle to window.
  1837. //
  1838. // UINT uMsg: Message being sent to the window.
  1839. //
  1840. // WPARAM wParam: Specific argument to message.
  1841. //
  1842. // LPARAM lParam: Specific argument to message.
  1843. //
  1844. // Return (BOOL):
  1845. // The return value is specific to the message that was received. For
  1846. // the most part, it is FALSE if this dialog procedure does not handle
  1847. // a message.
  1848. //
  1849. //--------------------------------------------------------------------------;
  1850. BOOL FNEXPORT AcmAppDlgProcChooser
  1851. (
  1852. HWND hwnd,
  1853. UINT uMsg,
  1854. WPARAM wParam,
  1855. LPARAM lParam
  1856. )
  1857. {
  1858. PAACONVERTDESC paacd;
  1859. HWND hedit;
  1860. HWND htxt;
  1861. HWND hcb;
  1862. HWND hsb;
  1863. HFONT hfont;
  1864. UINT uId;
  1865. UINT uCmd;
  1866. BOOL f;
  1867. //
  1868. //
  1869. //
  1870. if ((0 != guMsgHelp) && (uMsg == guMsgHelp))
  1871. {
  1872. WinHelp(hwnd, gpszAcmAppHelp, HELP_CONTENTS, 0L);
  1873. return (TRUE);
  1874. }
  1875. paacd = (PAACONVERTDESC)(UINT)GetWindowLong(hwnd, DWL_USER);
  1876. //
  1877. //
  1878. //
  1879. switch (uMsg)
  1880. {
  1881. case WM_INITDIALOG:
  1882. paacd = (PAACONVERTDESC)(UINT)lParam;
  1883. SetWindowLong(hwnd, DWL_USER, lParam);
  1884. if (NULL == paacd->pwfxSrc)
  1885. {
  1886. AppMsgBox(hwnd, MB_OK | MB_ICONEXCLAMATION,
  1887. TEXT("You must select a source file to convert."));
  1888. EndDialog(hwnd, FALSE);
  1889. return (TRUE);
  1890. }
  1891. if (NULL == paacd->pwfxDst)
  1892. {
  1893. AcmAppChooserFormatSuggest(hwnd, paacd);
  1894. }
  1895. hfont = GetStockFont(ANSI_VAR_FONT);
  1896. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FILE_INPUT);
  1897. SetWindowFont(htxt, hfont, FALSE);
  1898. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FORMAT_INPUT);
  1899. SetWindowFont(htxt, hfont, FALSE);
  1900. hedit = GetDlgItem(hwnd, IDD_AACHOOSER_EDIT_FILE_OUTPUT);
  1901. SetWindowFont(hedit, hfont, FALSE);
  1902. Edit_SetText(hedit, paacd->szFilePathDst);
  1903. hcb = GetDlgItem(hwnd, IDD_AACHOOSER_COMBO_DRIVER);
  1904. SetWindowFont(hcb, hfont, FALSE);
  1905. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FORMAT);
  1906. SetWindowFont(htxt, hfont, FALSE);
  1907. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_FILTER);
  1908. SetWindowFont(htxt, hfont, FALSE);
  1909. hfont = ghfontApp;
  1910. htxt = GetDlgItem(hwnd, IDD_AACHOOSER_TXT_TIME);
  1911. SetWindowFont(htxt, hfont, FALSE);
  1912. hedit = GetDlgItem(hwnd, IDD_AACHOOSER_EDIT_DETAILS);
  1913. SetWindowFont(hedit, hfont, FALSE);
  1914. hsb = GetDlgItem(hwnd, IDD_AACHOOSER_SCROLL_TIME);
  1915. SetScrollRange(hsb, SB_CTL, 0, 10000, FALSE);
  1916. //
  1917. //
  1918. //
  1919. CheckDlgButton(hwnd, IDD_AACHOOSER_CHECK_NONREALTIME, TRUE);
  1920. SendMessage(hwnd, WM_ACMAPP_ACM_NOTIFY, 0, 0L);
  1921. return (TRUE);
  1922. case WM_ACMAPP_ACM_NOTIFY:
  1923. AppHourGlass(TRUE);
  1924. hcb = GetDlgItem(hwnd, IDD_AACHOOSER_COMBO_DRIVER);
  1925. SetWindowRedraw(hcb, FALSE);
  1926. ComboBox_ResetContent(hcb);
  1927. ComboBox_AddString(hcb, TEXT("[ACM Driver Mapper]"));
  1928. AcmAppDebugLog(NULL);
  1929. acmDriverEnum(AcmAppChooserDriverEnumCallback, (DWORD)(UINT)hcb, 0L);
  1930. ComboBox_SetCurSel(hcb, 0);
  1931. SetWindowRedraw(hcb, TRUE);
  1932. f = AcmAppChooserUpdateDisplay(hwnd, paacd);
  1933. EnableWindow(GetDlgItem(hwnd, IDOK), f);
  1934. EnableWindow(GetDlgItem(hwnd, IDD_AACHOOSER_BTN_PROPERTIES), f);
  1935. AppHourGlass(FALSE);
  1936. break;
  1937. case WM_HSCROLL:
  1938. f = (BOOL)HANDLE_WM_HSCROLL(hwnd, wParam, lParam, AcmAppChooserScrollConvertTime);
  1939. f = TRUE;
  1940. if (f)
  1941. {
  1942. AppHourGlass(TRUE);
  1943. f = AcmAppChooserUpdateDisplay(hwnd, paacd);
  1944. EnableWindow(GetDlgItem(hwnd, IDOK), f);
  1945. EnableWindow(GetDlgItem(hwnd, IDD_AACHOOSER_BTN_PROPERTIES), f);
  1946. AppHourGlass(FALSE);
  1947. }
  1948. return (TRUE);
  1949. case WM_COMMAND:
  1950. uId = GET_WM_COMMAND_ID(wParam, lParam);
  1951. f = FALSE;
  1952. switch (uId)
  1953. {
  1954. case IDD_AACHOOSER_BTN_BROWSE:
  1955. f = AcmAppChooserSaveFile(hwnd, paacd);
  1956. break;
  1957. case IDD_AACHOOSER_BTN_PROPERTIES:
  1958. f = AcmAppChooserProperties(hwnd, paacd);
  1959. break;
  1960. case IDD_AACHOOSER_BTN_FORMAT_OPTIONS:
  1961. case IDD_AACHOOSER_BTN_FORMAT:
  1962. f = (IDD_AACHOOSER_BTN_FORMAT_OPTIONS == uId);
  1963. f = AcmAppChooserFormat(hwnd, paacd, f);
  1964. break;
  1965. case IDD_AACHOOSER_BTN_FILTER_OPTIONS:
  1966. case IDD_AACHOOSER_BTN_FILTER:
  1967. f = (IDD_AACHOOSER_BTN_FILTER_OPTIONS == uId);
  1968. f = AcmAppChooserFilter(hwnd, paacd, f);
  1969. break;
  1970. case IDD_AACHOOSER_COMBO_DRIVER:
  1971. uCmd = GET_WM_COMMAND_CMD(wParam, lParam);
  1972. switch (uCmd)
  1973. {
  1974. case CBN_SELCHANGE:
  1975. f = TRUE;
  1976. break;
  1977. }
  1978. break;
  1979. case IDD_AACHOOSER_CHECK_FILTER:
  1980. case IDD_AACHOOSER_CHECK_NONREALTIME:
  1981. case IDD_AACHOOSER_CHECK_ASYNC:
  1982. f = TRUE;
  1983. break;
  1984. case IDOK:
  1985. hedit = GetDlgItem(hwnd, IDD_AACHOOSER_EDIT_FILE_OUTPUT);
  1986. Edit_GetText(hedit, paacd->szFilePathDst, SIZEOF(paacd->szFilePathDst));
  1987. case IDCANCEL:
  1988. EndDialog(hwnd, (IDOK == uId));
  1989. break;
  1990. }
  1991. //
  1992. //
  1993. //
  1994. if (f)
  1995. {
  1996. AppHourGlass(TRUE);
  1997. f = AcmAppChooserUpdateDisplay(hwnd, paacd);
  1998. EnableWindow(GetDlgItem(hwnd, IDOK), f);
  1999. EnableWindow(GetDlgItem(hwnd, IDD_AACHOOSER_BTN_PROPERTIES), f);
  2000. AppHourGlass(FALSE);
  2001. }
  2002. break;
  2003. }
  2004. return (FALSE);
  2005. } // AcmAppDlgProcChooser()