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.

274 lines
6.3 KiB

  1. /* (C) Copyright Microsoft Corporation 1991-1994. All Rights Reserved */
  2. /* snddlg.c
  3. *
  4. * Routines for New & Custom Sound dialogs
  5. *
  6. */
  7. #include "nocrap.h"
  8. #include <windows.h>
  9. #include <windowsx.h>
  10. #include <mmsystem.h>
  11. #include <memory.h>
  12. #include <mmreg.h>
  13. #if WINVER >= 0x0400
  14. # include "..\..\msacm\msacm\msacm.h"
  15. #else
  16. # include <msacm.h>
  17. #endif
  18. #include <msacmdlg.h>
  19. #include "SoundRec.h"
  20. #include "srecnew.h"
  21. #include "srecids.h"
  22. #include "reg.h"
  23. /******************************************************************************
  24. * DECLARATIONS
  25. */
  26. /* Global variables
  27. */
  28. BOOL gfInFileNew = FALSE; // Are we in the file.new dialog?
  29. DWORD gdwMaxFormatSize= 0L; // Max format size for ACM
  30. /* Internal function declarations
  31. */
  32. void FAR PASCAL LoadACM(void);
  33. #ifndef CHICAGO
  34. //
  35. // Removed from the Win95 app due to Properties dialog
  36. //
  37. /*****************************************************************************
  38. * PUBLIC FUNCTIONS
  39. */
  40. #if 0
  41. #ifndef CHICAGO
  42. BOOL NewDlg_OnCommand(
  43. HWND hdlg,
  44. int id,
  45. HWND hctl,
  46. UINT unotify)
  47. {
  48. switch(id)
  49. {
  50. case IDD_ACMFORMATCHOOSE_CMB_CUSTOM:
  51. switch (unotify)
  52. {
  53. case CBN_SELCHANGE:
  54. {
  55. HWND hSet;
  56. int i = ComboBox_GetCurSel(hctl);
  57. hSet = GetDlgItem(hdlg, IDC_SETPREFERRED);
  58. if (!hSet)
  59. break;
  60. if (i == 0)
  61. {
  62. EnableWindow(hSet, FALSE);
  63. Button_SetCheck(hSet, 0);
  64. }
  65. else
  66. EnableWindow(hSet, TRUE);
  67. break;
  68. }
  69. }
  70. break;
  71. case IDC_SETPREFERRED:
  72. if (Button_GetCheck(hctl) != 0)
  73. {
  74. TCHAR sz[256];
  75. HWND hName;
  76. hName = GetDlgItem(hdlg, IDD_ACMFORMATCHOOSE_CMB_CUSTOM);
  77. if (!hName)
  78. break;
  79. ComboBox_GetText(hName, sz, SIZEOF(sz));
  80. SoundRec_SetDefaultFormat(sz);
  81. }
  82. break;
  83. default:
  84. break;
  85. }
  86. return FALSE;
  87. }
  88. UINT CALLBACK SoundRec_NewDlgHook(
  89. HWND hwnd,
  90. UINT uMsg,
  91. WPARAM wParam,
  92. LPARAM lParam)
  93. {
  94. switch(uMsg)
  95. {
  96. case WM_COMMAND:
  97. HANDLE_WM_COMMAND(hwnd, wParam, lParam, NewDlg_OnCommand);
  98. break;
  99. default:
  100. break;
  101. }
  102. return FALSE;
  103. }
  104. #endif
  105. #endif
  106. /* NewSndDialog()
  107. *
  108. * NewSndDialog - put up the new sound dialog box
  109. *
  110. *---------------------------------------------------------------------
  111. * 6/15/93 TimHa
  112. * Change to only work with ACM 2.0 chooser dialog or just default
  113. * to a 'best' format for the machine.
  114. *---------------------------------------------------------------------
  115. *
  116. */
  117. BOOL FAR PASCAL
  118. NewSndDialog(
  119. HINSTANCE hInst,
  120. HWND hwndParent,
  121. PWAVEFORMATEX pwfxPrev,
  122. UINT cbPrev,
  123. PWAVEFORMATEX *ppWaveFormat,
  124. PUINT pcbWaveFormat)
  125. {
  126. ACMFORMATCHOOSE cwf;
  127. MMRESULT mmr;
  128. PWAVEFORMATEX pwfx;
  129. DWORD cbwfx;
  130. DPF(TEXT("NewSndDialog called\n"));
  131. *ppWaveFormat = NULL;
  132. *pcbWaveFormat = 0;
  133. gfInFileNew = TRUE;
  134. mmr = acmMetrics(NULL
  135. , ACM_METRIC_MAX_SIZE_FORMAT
  136. , (LPVOID)&gdwMaxFormatSize);
  137. if (mmr != MMSYSERR_NOERROR || gdwMaxFormatSize == 0L)
  138. goto NewSndDefault;
  139. //
  140. // allocate a buffer at least as large as the previous
  141. // choice or the maximum format
  142. //
  143. cbwfx = max(cbPrev, gdwMaxFormatSize);
  144. pwfx = (PWAVEFORMATEX)GlobalAllocPtr(GHND, (UINT)cbwfx);
  145. if (NULL == pwfx)
  146. goto NewSndDefault;
  147. ZeroMemory(&cwf,sizeof(cwf));
  148. cwf.cbStruct = sizeof(cwf);
  149. cwf.hwndOwner = hwndParent;
  150. //
  151. // Give them an input format when they can record.
  152. //
  153. if (waveInGetNumDevs())
  154. cwf.fdwEnum = ACM_FORMATENUMF_INPUT;
  155. else
  156. cwf.fdwEnum = 0L;
  157. if (pwfxPrev)
  158. {
  159. CopyMemory(pwfx, pwfxPrev, cbPrev);
  160. cwf.fdwStyle = ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
  161. }
  162. cwf.pwfx = (LPWAVEFORMATEX)pwfx;
  163. cwf.cbwfx = cbwfx;
  164. cwf.hInstance = ghInst;
  165. #ifdef CHICAGO
  166. cwf.fdwStyle |= ACMFORMATCHOOSE_STYLEF_CONTEXTHELP;
  167. #endif
  168. mmr = acmFormatChoose(&cwf);
  169. if (mmr == MMSYSERR_NOERROR)
  170. {
  171. *ppWaveFormat = pwfx;
  172. *pcbWaveFormat = (UINT)cwf.cbwfx;
  173. }
  174. else
  175. {
  176. GlobalFreePtr(pwfx);
  177. }
  178. gfInFileNew = FALSE; // outta here
  179. return (mmr == MMSYSERR_NOERROR); // return our result
  180. NewSndDefault:
  181. if (SoundRec_GetDefaultFormat(&pwfx, &cbwfx))
  182. {
  183. if (waveInOpen(NULL
  184. , (UINT)WAVE_MAPPER
  185. , (LPWAVEFORMATEX)pwfx
  186. , 0L
  187. , 0L
  188. , WAVE_FORMAT_QUERY|WAVE_ALLOWSYNC) == MMSYSERR_NOERROR)
  189. {
  190. *ppWaveFormat = pwfx;
  191. *pcbWaveFormat = cbwfx;
  192. gfInFileNew = FALSE; // outta here
  193. return TRUE;
  194. }
  195. else
  196. GlobalFreePtr(pwfx);
  197. }
  198. cbwfx = sizeof(WAVEFORMATEX);
  199. pwfx = (WAVEFORMATEX *)GlobalAllocPtr(GHND, sizeof(WAVEFORMATEX));
  200. if (pwfx == NULL)
  201. return FALSE;
  202. CreateWaveFormat(pwfx,FMT_DEFAULT,(UINT)WAVE_MAPPER);
  203. *ppWaveFormat = pwfx;
  204. *pcbWaveFormat = cbwfx;
  205. gfInFileNew = FALSE; // outta here
  206. return TRUE;
  207. } /* NewSndDialog() */
  208. #endif
  209. /* These functions previously expected to dynaload ACM. From
  210. * now on, we implicitly load ACM.
  211. */
  212. /* LoadACM()
  213. */
  214. void FAR PASCAL
  215. LoadACM()
  216. {
  217. #ifdef CHICAGO
  218. extern UINT guChooserContextMenu;
  219. extern UINT guChooserContextHelp;
  220. #endif
  221. guiACMHlpMsg = RegisterWindowMessage(ACMHELPMSGSTRING);
  222. #ifdef CHICAGO
  223. guChooserContextMenu = RegisterWindowMessage( ACMHELPMSGCONTEXTMENU );
  224. guChooserContextHelp = RegisterWindowMessage( ACMHELPMSGCONTEXTHELP );
  225. #endif
  226. } /* LoadACM() */
  227. /* Free the MSACM[32] DLL. Inverse of LoadACM.
  228. */
  229. void FreeACM(void)
  230. {
  231. }