Leaked source code of windows server 2003
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.

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