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.

254 lines
6.5 KiB

  1. //--------------------------------------------------------------------------;
  2. //
  3. // File: perfpage.cpp
  4. //
  5. // Copyright (c) 1997 Microsoft Corporation. All rights reserved
  6. //
  7. //--------------------------------------------------------------------------;
  8. #include "mmcpl.h"
  9. #include <windowsx.h>
  10. #ifdef DEBUG
  11. #undef DEBUG
  12. #include <mmsystem.h>
  13. #define DEBUG
  14. #else
  15. #include <mmsystem.h>
  16. #endif
  17. #include <commctrl.h>
  18. #include <prsht.h>
  19. #include <regstr.h>
  20. #include "utils.h"
  21. #include "medhelp.h"
  22. #include "advaudio.h"
  23. #include "perfpage.h"
  24. ////////////
  25. // Defines
  26. ////////////
  27. //////////////
  28. // Help ID's
  29. //////////////
  30. #pragma data_seg(".text")
  31. const static DWORD aAdvAudioHelp[] = {
  32. IDC_ACCELERATION, IDH_ADV_AUDIO_ACCELERATION,
  33. IDC_HWMESSAGE, IDH_ADV_AUDIO_ACCELERATION,
  34. IDC_SRCQUALITY, IDH_ADV_AUDIO_SRCQUALITY,
  35. IDC_SRCMSG, IDH_ADV_AUDIO_SRCQUALITY,
  36. IDC_DEFAULTS, IDH_ADV_AUDIO_RESTOREDEFAULTS,
  37. IDC_ICON_3, IDH_COMM_GROUPBOX,
  38. IDC_TEXT_14, IDH_COMM_GROUPBOX,
  39. IDC_TEXT_15, IDH_COMM_GROUPBOX,
  40. IDC_TEXT_16, IDH_ADV_AUDIO_ACCELERATION,
  41. IDC_TEXT_17, IDH_ADV_AUDIO_SRCQUALITY,
  42. IDC_TEXT_18, IDH_ADV_AUDIO_ACCELERATION,
  43. IDC_TEXT_19, IDH_ADV_AUDIO_ACCELERATION,
  44. IDC_TEXT_20, IDH_ADV_AUDIO_SRCQUALITY,
  45. IDC_TEXT_21, IDH_ADV_AUDIO_SRCQUALITY,
  46. 0, 0
  47. };
  48. #pragma data_seg()
  49. //////////////
  50. // Functions
  51. //////////////
  52. void SetHardwareLevel(HWND hwnd, DWORD dwHWLevel)
  53. {
  54. TCHAR str[255];
  55. SendDlgItemMessage( hwnd, IDC_ACCELERATION, TBM_SETPOS, TRUE, dwHWLevel);
  56. LoadString( ghInst, IDS_AUDHW1 + dwHWLevel, str, sizeof( str )/sizeof(TCHAR) );
  57. SetDlgItemText(hwnd, IDC_HWMESSAGE, str);
  58. gAudData.current.dwHWLevel = dwHWLevel;
  59. ToggleApplyButton(hwnd);
  60. }
  61. void SetSRCLevel(HWND hwnd, DWORD dwSRCLevel)
  62. {
  63. TCHAR str[255];
  64. SendDlgItemMessage( hwnd, IDC_SRCQUALITY, TBM_SETPOS, TRUE, dwSRCLevel);
  65. LoadString( ghInst, IDS_SRCQUALITY1 + dwSRCLevel, str, sizeof( str )/sizeof(TCHAR) );
  66. SetDlgItemText(hwnd, IDC_SRCMSG, str);
  67. gAudData.current.dwSRCLevel = dwSRCLevel;
  68. ToggleApplyButton(hwnd);
  69. }
  70. void RestoreDefaults(HWND hwnd)
  71. {
  72. // Check if we can set the acceleration level
  73. if (SUCCEEDED(CheckDSAccelerationPriv(gAudData.devGuid, gAudData.fRecord, NULL)))
  74. {
  75. SetHardwareLevel(hwnd,gAudData.dwDefaultHWLevel);
  76. }
  77. // Check if we can set the quality level
  78. if (SUCCEEDED(CheckDSSrcQualityPriv(gAudData.devGuid, gAudData.fRecord, NULL)))
  79. {
  80. SetSRCLevel(hwnd,DEFAULT_SRC_LEVEL);
  81. }
  82. }
  83. BOOL InitAdvDialog(HWND hwnd)
  84. {
  85. HWND hwndDlgItem;
  86. BOOL fEnableAcceleration;
  87. BOOL fEnableSrcQuality;
  88. DWORD dwHWLevel = gAudData.current.dwHWLevel;
  89. DWORD dwSRCLevel = gAudData.current.dwSRCLevel;
  90. SendDlgItemMessage( hwnd, IDC_ACCELERATION, TBM_SETRANGE, TRUE, MAKELONG( 0, MAX_HW_LEVEL ) );
  91. SendDlgItemMessage( hwnd, IDC_SRCQUALITY, TBM_SETRANGE, TRUE, MAKELONG( 0, MAX_SRC_LEVEL ) );
  92. SetHardwareLevel(hwnd,dwHWLevel);
  93. SetSRCLevel(hwnd,dwSRCLevel);
  94. // Check if we can set the acceleration level
  95. if (FAILED(CheckDSAccelerationPriv(gAudData.devGuid, gAudData.fRecord, NULL)))
  96. {
  97. // No - disable the slider
  98. fEnableAcceleration = FALSE;
  99. }
  100. else
  101. {
  102. // Yes - enable the slider
  103. fEnableAcceleration = TRUE;
  104. }
  105. // Enable/disable the acceleration slider appropriately
  106. hwndDlgItem = GetDlgItem( hwnd, IDC_ACCELERATION );
  107. if (hwndDlgItem)
  108. {
  109. EnableWindow( hwndDlgItem, fEnableAcceleration );
  110. }
  111. // Check if we can set the quality level
  112. if (FAILED(CheckDSSrcQualityPriv(gAudData.devGuid, gAudData.fRecord, NULL)))
  113. {
  114. // No - disable the slider
  115. fEnableSrcQuality = FALSE;
  116. }
  117. else
  118. {
  119. // Yes - enable the slider
  120. fEnableSrcQuality = TRUE;
  121. }
  122. // Enable/disable the quality slider appropriately
  123. hwndDlgItem = GetDlgItem( hwnd, IDC_SRCQUALITY );
  124. if (hwndDlgItem)
  125. {
  126. EnableWindow( hwndDlgItem, fEnableSrcQuality );
  127. }
  128. // Enable/disable the defaults button
  129. hwndDlgItem = GetDlgItem( hwnd, IDC_DEFAULTS );
  130. if (hwndDlgItem)
  131. {
  132. EnableWindow( hwndDlgItem, fEnableAcceleration || fEnableSrcQuality );
  133. }
  134. return(TRUE);
  135. }
  136. INT_PTR CALLBACK PerformanceHandler(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  137. {
  138. BOOL fReturnVal = FALSE;
  139. switch (msg)
  140. {
  141. default:
  142. fReturnVal = FALSE;
  143. break;
  144. case WM_INITDIALOG:
  145. {
  146. fReturnVal = InitAdvDialog(hDlg);
  147. }
  148. break;
  149. case WM_CONTEXTMENU:
  150. {
  151. WinHelp((HWND)wParam, gszHelpFile, HELP_CONTEXTMENU, (UINT_PTR)(LPTSTR)aAdvAudioHelp);
  152. fReturnVal = TRUE;
  153. }
  154. break;
  155. case WM_HELP:
  156. {
  157. WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle, gszHelpFile, HELP_WM_HELP, (UINT_PTR)(LPTSTR)aAdvAudioHelp);
  158. fReturnVal = TRUE;
  159. }
  160. break;
  161. case WM_HSCROLL:
  162. {
  163. HWND hScroll = (HWND) lParam;
  164. if (hScroll == GetDlgItem(hDlg,IDC_ACCELERATION))
  165. {
  166. SetHardwareLevel(hDlg,(DWORD) SendDlgItemMessage( hDlg, IDC_ACCELERATION, TBM_GETPOS, 0, 0 ));
  167. }
  168. else if (hScroll == GetDlgItem(hDlg, IDC_SRCQUALITY))
  169. {
  170. SetSRCLevel(hDlg, (DWORD) SendDlgItemMessage( hDlg, IDC_SRCQUALITY, TBM_GETPOS, 0, 0 ));
  171. }
  172. }
  173. break;
  174. case WM_COMMAND:
  175. {
  176. switch (LOWORD(wParam))
  177. {
  178. case IDC_DEFAULTS:
  179. RestoreDefaults(hDlg);
  180. break;
  181. default:
  182. fReturnVal = FALSE;
  183. break;
  184. }
  185. break;
  186. }
  187. case WM_NOTIFY:
  188. {
  189. LPNMHDR pnmh = (LPNMHDR) lParam;
  190. switch (pnmh->code)
  191. {
  192. case PSN_APPLY:
  193. {
  194. ApplyCurrentSettings(&gAudData);
  195. }
  196. }
  197. }
  198. }
  199. return fReturnVal;
  200. }