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.

888 lines
34 KiB

  1. /****************************************************************************
  2. * @doc INTERNAL SYSTEMP
  3. *
  4. * @module SystemP.cpp | Source file for the <c CSystemProperty>
  5. * class used to implement a property page to test the TAPI control
  6. * interface <i ITQualityControllerConfiglerConfig>.
  7. ***************************************************************************/
  8. #include "Precomp.h"
  9. extern HINSTANCE ghInst;
  10. /****************************************************************************
  11. * @doc INTERNAL CSYSTEMPMETHOD
  12. *
  13. * @mfunc void | CSystemProperty | CSystemProperty | This
  14. * method is the constructor for property objects. It
  15. * calls the base class constructor, calls InitCommonControlsEx, and saves
  16. * pointers to the <i ITQualityControllerConfig> interfaces.
  17. *
  18. * @parm HWND | hDlg | Specifies a handle to the parent property page.
  19. *
  20. * @parm ULONG | IDLabel | Specifies a label ID for the property.
  21. *
  22. * @parm ULONG | IDMinControl | Specifies a label ID for the associated
  23. * property edit control where the Minimum value of the property appears.
  24. *
  25. * @parm ULONG | IDMaxControl | Specifies a label ID for the associated
  26. * property edit control where the Maximum value of the property appears.
  27. *
  28. * @parm ULONG | IDDefaultControl | Specifies a label ID for the associated
  29. * property edit control where the Default value of the property appears.
  30. *
  31. * @parm ULONG | IDStepControl | Specifies a label ID for the associated
  32. * property edit control where the Stepping Delta value of the property appears.
  33. *
  34. * @parm ULONG | IDEditControl | Specifies a label ID for the associated
  35. * property edit control where the value of the property appears.
  36. *
  37. * @parm ULONG | IDTrackbarControl | Specifies a label ID for the associated
  38. * property slide bar.
  39. *
  40. * @parm ULONG | IDProgressControl | Specifies a label ID for the associated
  41. * property slide bar.
  42. *
  43. * @parm ULONG | IDProperty | Specifies the ID of the Ks property.
  44. *
  45. * @parm ITQualityControllerConfiglerConfig* | pITQualityControllerConfiglerConfig | Specifies a pointer to the
  46. * <i ITQualityControllerConfiglerConfig> interface.
  47. *
  48. * @rdesc Nada.
  49. ***************************************************************************/
  50. CSystemProperty::CSystemProperty(HWND hDlg, ULONG IDLabel, ULONG IDMinControl, ULONG IDMaxControl, ULONG IDDefaultControl, ULONG IDStepControl, ULONG IDEditControl, ULONG IDTrackbarControl, ULONG IDProgressControl, ULONG IDProperty) //, ITStreamQualityControl *pITQualityControllerConfig)
  51. : CPropertyEditor(hDlg, IDLabel, IDMinControl, IDMaxControl, IDDefaultControl, IDStepControl, IDEditControl, IDTrackbarControl, IDProgressControl, IDProperty, 0)
  52. {
  53. INITCOMMONCONTROLSEX cc;
  54. FX_ENTRY("CSystemProperty::CSystemProperty")
  55. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  56. cc.dwSize = sizeof (INITCOMMONCONTROLSEX);
  57. cc.dwICC = ICC_UPDOWN_CLASS | ICC_BAR_CLASSES;
  58. InitCommonControlsEx(&cc);
  59. // It's fine if the interface pointers are NULL, we'll grey the
  60. // associated items in the property page
  61. // m_pITQualityControllerConfig = pITQualityControllerConfig;
  62. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  63. }
  64. /****************************************************************************
  65. * @doc INTERNAL CSYSTEMPMETHOD
  66. *
  67. * @mfunc void | CSystemProperty | ~CSystemProperty | This
  68. * method is the destructor for property objects. It
  69. * simply calls the base class destructor.
  70. *
  71. * @rdesc Nada.
  72. ***************************************************************************/
  73. CSystemProperty::~CSystemProperty()
  74. {
  75. FX_ENTRY("CSystemProperty::~CSystemProperty")
  76. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  77. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  78. }
  79. /****************************************************************************
  80. * @doc INTERNAL CSYSTEMPMETHOD
  81. *
  82. * @mfunc HRESULT | CSystemProperty | GetValue | This method queries for
  83. * the value of a property.
  84. *
  85. * @rdesc This method returns an HRESULT value that depends on the
  86. * implementation of the interface. HRESULT can include one of the
  87. * following standard constants, or other values not listed:
  88. *
  89. * @flag E_FAIL | Failure
  90. * @flag E_POINTER | Null pointer argument
  91. * @flag E_NOTIMPL | Method is not supported
  92. * @flag NOERROR | No error
  93. ***************************************************************************/
  94. HRESULT CSystemProperty::GetValue()
  95. {
  96. HRESULT Hr = E_NOTIMPL;
  97. LONG CurrentValue;
  98. TAPIControlFlags CurrentFlag;
  99. LONG Mode;
  100. FX_ENTRY("CSystemProperty::GetValue")
  101. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  102. /*
  103. switch (m_IDProperty)
  104. {
  105. case IDC_Max_OutputBandwidth:
  106. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Get(QualityController_MaxApplicationOutputBandwidth, &m_CurrentValue, &CurrentFlag)))
  107. {
  108. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMaxApplicationOutputBandwidth=%ld"), _fx_, m_CurrentValue));
  109. }
  110. else
  111. {
  112. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  113. }
  114. break;
  115. case IDC_Max_InputBandwidth:
  116. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Get(QualityController_MaxApplicationInputBandwidth, &m_CurrentValue, &CurrentFlag)))
  117. {
  118. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMaxApplicationInputBandwidth=%ld"), _fx_, m_CurrentValue));
  119. }
  120. else
  121. {
  122. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  123. }
  124. break;
  125. case IDC_Max_CPULoad:
  126. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Get(QualityController_MaxSystemCPULoad, &m_CurrentValue, &CurrentFlag)))
  127. {
  128. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMaxSystemCPULoad=%ld"), _fx_, m_CurrentValue));
  129. }
  130. else
  131. {
  132. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  133. }
  134. break;
  135. case IDC_Curr_OutputBandwidth:
  136. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Get(QualityController_CurrApplicationOutputBandwidth, &m_CurrentValue, &CurrentFlag)))
  137. {
  138. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwCurrApplicationOutputBandwidth=%ld"), _fx_, m_CurrentValue));
  139. }
  140. else
  141. {
  142. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  143. }
  144. break;
  145. case IDC_Curr_InputBandwidth:
  146. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Get(QualityController_CurrApplicationInputBandwidth, &m_CurrentValue, &CurrentFlag)))
  147. {
  148. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwCurrApplicationInputBandwidth=%ld"), _fx_, m_CurrentValue));
  149. }
  150. else
  151. {
  152. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  153. }
  154. break;
  155. case IDC_Curr_CPULoad:
  156. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Get(QualityController_CurrSystemCPULoad, &m_CurrentValue, &CurrentFlag)))
  157. {
  158. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwCurrSystemCPULoad=%ld"), _fx_, m_CurrentValue));
  159. }
  160. else
  161. {
  162. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  163. }
  164. break;
  165. default:
  166. Hr = E_UNEXPECTED;
  167. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Unknown property"), _fx_));
  168. }
  169. */
  170. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  171. return Hr;
  172. }
  173. /****************************************************************************
  174. * @doc INTERNAL CSYSTEMPMETHOD
  175. *
  176. * @mfunc HRESULT | CSystemProperty | SetValue | This method sets the
  177. * value of a property.
  178. *
  179. * @rdesc This method returns an HRESULT value that depends on the
  180. * implementation of the interface. HRESULT can include one of the
  181. * following standard constants, or other values not listed:
  182. *
  183. * @flag E_FAIL | Failure
  184. * @flag E_POINTER | Null pointer argument
  185. * @flag E_NOTIMPL | Method is not supported
  186. * @flag NOERROR | No error
  187. ***************************************************************************/
  188. HRESULT CSystemProperty::SetValue()
  189. {
  190. HRESULT Hr = E_NOTIMPL;
  191. LONG CurrentValue;
  192. FX_ENTRY("CSystemProperty::SetValue")
  193. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  194. /*
  195. switch (m_IDProperty)
  196. {
  197. case IDC_Max_OutputBandwidth:
  198. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Set(QualityController_MaxApplicationOutputBandwidth, m_CurrentValue, TAPIControl_Flags_None)))
  199. {
  200. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: dwMaxApplicationOutputBandwidth=%ld"), _fx_, m_CurrentValue));
  201. }
  202. else
  203. {
  204. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  205. }
  206. break;
  207. case IDC_Max_InputBandwidth:
  208. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Set(QualityController_MaxApplicationInputBandwidth, m_CurrentValue, TAPIControl_Flags_None)))
  209. {
  210. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: dwMaxApplicationInputBandwidth=%ld"), _fx_, m_CurrentValue));
  211. }
  212. else
  213. {
  214. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  215. }
  216. break;
  217. case IDC_Max_CPULoad:
  218. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->Set(QualityController_MaxSystemCPULoad, m_CurrentValue, TAPIControl_Flags_None)))
  219. {
  220. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMaxSystemCPULoad=%ld"), _fx_, m_CurrentValue));
  221. }
  222. else
  223. {
  224. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  225. }
  226. break;
  227. case IDC_Curr_OutputBandwidth:
  228. case IDC_Curr_InputBandwidth:
  229. case IDC_Curr_CPULoad:
  230. // This is a read-only property. Don't do anything.
  231. Hr = NOERROR;
  232. break;
  233. default:
  234. Hr = E_UNEXPECTED;
  235. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Unknown property"), _fx_));
  236. }
  237. */
  238. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  239. return Hr;
  240. }
  241. /****************************************************************************
  242. * @doc INTERNAL CSYSTEMPMETHOD
  243. *
  244. * @mfunc HRESULT | CSystemProperty | GetRange | This method retrieves
  245. * the range information of a property.
  246. *
  247. * @rdesc This method returns an HRESULT value that depends on the
  248. * implementation of the interface. HRESULT can include one of the
  249. * following standard constants, or other values not listed:
  250. *
  251. * @flag E_FAIL | Failure
  252. * @flag E_POINTER | Null pointer argument
  253. * @flag E_NOTIMPL | Method is not supported
  254. * @flag NOERROR | No error
  255. ***************************************************************************/
  256. HRESULT CSystemProperty::GetRange()
  257. {
  258. HRESULT Hr = E_NOTIMPL;
  259. LONG Min;
  260. LONG Max;
  261. LONG SteppingDelta;
  262. LONG Default;
  263. TAPIControlFlags CapsFlags;
  264. FX_ENTRY("CSystemProperty::GetRange")
  265. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  266. /*
  267. switch (m_IDProperty)
  268. {
  269. case IDC_Max_OutputBandwidth:
  270. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->GetRange(QualityController_MaxApplicationOutputBandwidth, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  271. {
  272. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  273. }
  274. else
  275. {
  276. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  277. }
  278. break;
  279. case IDC_Max_InputBandwidth:
  280. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->GetRange(QualityController_MaxApplicationInputBandwidth, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  281. {
  282. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  283. }
  284. else
  285. {
  286. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  287. }
  288. break;
  289. case IDC_Max_CPULoad:
  290. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->GetRange(QualityController_MaxSystemCPULoad, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  291. {
  292. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  293. }
  294. else
  295. {
  296. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  297. }
  298. break;
  299. case IDC_Curr_OutputBandwidth:
  300. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->GetRange(QualityController_CurrApplicationOutputBandwidth, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  301. {
  302. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  303. }
  304. else
  305. {
  306. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  307. }
  308. break;
  309. case IDC_Curr_InputBandwidth:
  310. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->GetRange(QualityController_CurrApplicationInputBandwidth, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  311. {
  312. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  313. }
  314. else
  315. {
  316. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  317. }
  318. break;
  319. case IDC_Curr_CPULoad:
  320. if (m_pITQualityControllerConfig && SUCCEEDED (Hr = m_pITQualityControllerConfig->GetRange(QualityController_CurrSystemCPULoad, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, &m_CapsFlags)))
  321. {
  322. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: *pdwMin=%ld, *pdwMax=%ld, *pdwSteppingDelta=%ld, *pdwDefault=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue));
  323. }
  324. else
  325. {
  326. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  327. }
  328. break;
  329. default:
  330. Hr = E_UNEXPECTED;
  331. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Unknown property"), _fx_));
  332. }
  333. */
  334. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  335. return Hr;
  336. }
  337. /****************************************************************************
  338. * @doc INTERNAL CSYSTEMPMETHOD
  339. *
  340. * @mfunc HPROPSHEETPAGE | CSystemProperties | OnCreate | This
  341. * method creates a new page for a property sheet.
  342. *
  343. * @rdesc Returns the handle to the new property sheet if successful, or
  344. * NULL otherwise.
  345. ***************************************************************************/
  346. HPROPSHEETPAGE CSystemProperties::OnCreate()
  347. {
  348. PROPSHEETPAGE psp;
  349. psp.dwSize = sizeof(psp);
  350. psp.dwFlags = PSP_USEREFPARENT;
  351. psp.hInstance = ghInst;
  352. psp.pszTemplate = MAKEINTRESOURCE(IDD_SystemProperties);
  353. psp.pfnDlgProc = BaseDlgProc;
  354. psp.pcRefParent = 0;
  355. psp.pfnCallback = (LPFNPSPCALLBACK)NULL;
  356. psp.lParam = (LPARAM)this;
  357. return CreatePropertySheetPage(&psp);
  358. }
  359. /****************************************************************************
  360. * @doc INTERNAL CSYSTEMPMETHOD
  361. *
  362. * @mfunc void | CSystemProperties | CSystemProperties | This
  363. * method is the constructor for the property page object. It simply
  364. * calls the constructor of the property page base class.
  365. *
  366. * @rdesc Nada.
  367. ***************************************************************************/
  368. CSystemProperties::CSystemProperties()
  369. {
  370. FX_ENTRY("CSystemProperties::CSystemProperties")
  371. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  372. // m_pITQualityControllerConfig = NULL;
  373. m_NumProperties = NUM_SYSTEM_CONTROLS;
  374. m_hDlg = NULL;
  375. for (int i = 0; i < m_NumProperties; i++)
  376. m_Controls[i] = NULL;
  377. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  378. }
  379. /****************************************************************************
  380. * @doc INTERNAL CSYSTEMPMETHOD
  381. *
  382. * @mfunc void | CSystemProperties | ~CSystemProperties | This
  383. * method is the destructor for the property page. It simply deletes all
  384. * the controls.
  385. *
  386. * @rdesc Nada.
  387. ***************************************************************************/
  388. CSystemProperties::~CSystemProperties()
  389. {
  390. int j;
  391. FX_ENTRY("CSystemProperties::~CSystemProperties")
  392. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  393. // Free the controls
  394. for (j = 0; j < m_NumProperties; j++)
  395. {
  396. if (m_Controls[j])
  397. {
  398. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  399. delete m_Controls[j], m_Controls[j] = NULL;
  400. }
  401. else
  402. {
  403. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  404. }
  405. }
  406. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  407. }
  408. /****************************************************************************
  409. * @doc INTERNAL CSYSTEMPMETHOD
  410. *
  411. * @mfunc HRESULT | CSystemProperties | OnConnect | This
  412. * method is called when the property page is connected to a TAPI object.
  413. *
  414. * @parm ITStream* | pStream | Specifies a pointer to the <i ITStream>
  415. * interface. It is used to QI for the <i ITQualityControllerConfig> and
  416. * <i ITFormatControl> interfaces.
  417. *
  418. * @rdesc This method returns an HRESULT value that depends on the
  419. * implementation of the interface. HRESULT can include one of the
  420. * following standard constants, or other values not listed:
  421. *
  422. * @flag E_FAIL | Failure
  423. * @flag E_POINTER | Null pointer argument
  424. * @flag E_NOTIMPL | Method is not supported
  425. * @flag NOERROR | No error
  426. ***************************************************************************/
  427. HRESULT CSystemProperties::OnConnect(ITAddress *pITAddress)
  428. {
  429. FX_ENTRY("CSystemProperties::OnConnect")
  430. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  431. // Get the quality control interfaces
  432. /*
  433. if (pITAddress && SUCCEEDED (pITAddress->QueryInterface(__uuidof(ITQualityControllerConfig), (void **)&m_pITQualityControllerConfig)))
  434. {
  435. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_pITQualityControllerConfig=0x%08lX"), _fx_, m_pITQualityControllerConfig));
  436. }
  437. else
  438. {
  439. m_pITQualityControllerConfig = NULL;
  440. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: Failed Hr=0x%08lX"), _fx_, Hr));
  441. }
  442. */
  443. // It's Ok if we couldn't get interface pointers
  444. // We'll just grey the controls in the property page
  445. // to make it clear to the user that they can't
  446. // control those properties on the capture device
  447. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  448. return NOERROR;
  449. }
  450. /****************************************************************************
  451. * @doc INTERNAL CSYSTEMPMETHOD
  452. *
  453. * @mfunc HRESULT | CSystemProperties | OnDisconnect | This
  454. * method is called when the property page is disconnected from the owning
  455. * filter.
  456. *
  457. * @rdesc This method returns an HRESULT value that depends on the
  458. * implementation of the interface. HRESULT can include one of the
  459. * following standard constants, or other values not listed:
  460. *
  461. * @flag NOERROR | No error
  462. ***************************************************************************/
  463. HRESULT CSystemProperties::OnDisconnect()
  464. {
  465. FX_ENTRY("CSystemProperties::OnDisconnect")
  466. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  467. // Validate input parameters
  468. /*
  469. if (!m_pITQualityControllerConfig)
  470. {
  471. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: already disconnected!"), _fx_));
  472. }
  473. else
  474. {
  475. // Release the interface
  476. m_pITQualityControllerConfig->Release();
  477. m_pITQualityControllerConfig = NULL;
  478. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: releasing m_pITQualityControllerConfig"), _fx_));
  479. }
  480. */
  481. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  482. return NOERROR;
  483. }
  484. /****************************************************************************
  485. * @doc INTERNAL CSYSTEMPMETHOD
  486. *
  487. * @mfunc HRESULT | CSystemProperties | OnActivate | This
  488. * method is called when the property page is activated.
  489. *
  490. * @rdesc This method returns an HRESULT value that depends on the
  491. * implementation of the interface. HRESULT can include one of the
  492. * following standard constants, or other values not listed:
  493. *
  494. * @flag E_FAIL | Failure
  495. * @flag E_POINTER | Null pointer argument
  496. * @flag E_NOTIMPL | Method is not supported
  497. * @flag NOERROR | No error
  498. ***************************************************************************/
  499. HRESULT CSystemProperties::OnActivate()
  500. {
  501. HRESULT Hr = E_OUTOFMEMORY;
  502. int j;
  503. FX_ENTRY("CSystemProperties::OnActivate")
  504. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  505. // Create the controls for the properties
  506. /*
  507. if (!(m_Controls[IDC_Curr_OutputBandwidth] = new CSystemProperty(m_hDlg, IDC_Curr_OutputBandwidth_Label, IDC_Curr_OutputBandwidth_Minimum, IDC_Curr_OutputBandwidth_Maximum, IDC_Curr_OutputBandwidth_Default, IDC_Curr_OutputBandwidth_Stepping, IDC_Curr_OutputBandwidth_Actual, IDC_Curr_OutputBandwidth_Slider, IDC_Curr_OutputBandwidth_Meter, IDC_Curr_OutputBandwidth, m_pITQualityControllerConfig)))
  508. {
  509. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[IDC_Curr_OutputBandwidth] failed - Out of memory"), _fx_));
  510. goto MyExit;
  511. }
  512. else
  513. {
  514. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[IDC_Curr_OutputBandwidth]=0x%08lX"), _fx_, m_Controls[IDC_Curr_OutputBandwidth]));
  515. }
  516. if (!(m_Controls[IDC_Curr_InputBandwidth] = new CSystemProperty(m_hDlg, IDC_Curr_InputBandwidth_Label, IDC_Curr_InputBandwidth_Minimum, IDC_Curr_InputBandwidth_Maximum, IDC_Curr_InputBandwidth_Default, IDC_Curr_InputBandwidth_Stepping, IDC_Curr_InputBandwidth_Actual, IDC_Curr_InputBandwidth_Slider, IDC_Curr_InputBandwidth_Meter, IDC_Curr_InputBandwidth, m_pITQualityControllerConfig)))
  517. {
  518. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[IDC_Curr_InputBandwidth] failed - Out of memory"), _fx_));
  519. goto MyError0;
  520. }
  521. else
  522. {
  523. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[IDC_Curr_InputBandwidth]=0x%08lX"), _fx_, m_Controls[IDC_Curr_InputBandwidth]));
  524. }
  525. if (!(m_Controls[IDC_Curr_CPULoad] = new CSystemProperty(m_hDlg, IDC_Curr_CPULoad_Label, IDC_Curr_CPULoad_Minimum, IDC_Curr_CPULoad_Maximum, IDC_Curr_CPULoad_Default, IDC_Curr_CPULoad_Stepping, IDC_Curr_CPULoad_Actual, IDC_Curr_CPULoad_Slider, IDC_Curr_CPULoad_Meter, IDC_Curr_CPULoad, m_pITQualityControllerConfig)))
  526. {
  527. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[IDC_Curr_CPULoad] failed - Out of memory"), _fx_));
  528. goto MyError1;
  529. }
  530. else
  531. {
  532. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[IDC_Curr_CPULoad]=0x%08lX"), _fx_, m_Controls[IDC_Curr_CPULoad]));
  533. }
  534. if (!(m_Controls[IDC_Max_OutputBandwidth] = new CSystemProperty(m_hDlg, IDC_Max_OutputBandwidth_Label, IDC_Max_OutputBandwidth_Minimum, IDC_Max_OutputBandwidth_Maximum, IDC_Max_OutputBandwidth_Default, IDC_Max_OutputBandwidth_Stepping, IDC_Max_OutputBandwidth_Actual, IDC_Max_OutputBandwidth_Slider, IDC_Max_OutputBandwidth_Meter, IDC_Max_OutputBandwidth, m_pITQualityControllerConfig)))
  535. {
  536. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[IDC_Max_OutputBandwidth] failed - Out of memory"), _fx_));
  537. goto MyError2;
  538. }
  539. else
  540. {
  541. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[IDC_Max_OutputBandwidth]=0x%08lX"), _fx_, m_Controls[IDC_Max_OutputBandwidth]));
  542. }
  543. if (!(m_Controls[IDC_Max_InputBandwidth] = new CSystemProperty(m_hDlg, IDC_Max_InputBandwidth_Label, IDC_Max_InputBandwidth_Minimum, IDC_Max_InputBandwidth_Maximum, IDC_Max_InputBandwidth_Default, IDC_Max_InputBandwidth_Stepping, IDC_Max_InputBandwidth_Actual, IDC_Max_InputBandwidth_Slider, IDC_Max_InputBandwidth_Meter, IDC_Max_InputBandwidth, m_pITQualityControllerConfig)))
  544. {
  545. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[IDC_Max_InputBandwidth] failed - Out of memory"), _fx_));
  546. goto MyError3;
  547. }
  548. else
  549. {
  550. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[IDC_Max_InputBandwidth]=0x%08lX"), _fx_, m_Controls[IDC_Max_InputBandwidth]));
  551. }
  552. if (!(m_Controls[IDC_Max_CPULoad] = new CSystemProperty(m_hDlg, IDC_Max_CPULoad_Label, IDC_Max_CPULoad_Minimum, IDC_Max_CPULoad_Maximum, IDC_Max_CPULoad_Default, IDC_Max_CPULoad_Stepping, IDC_Max_CPULoad_Actual, IDC_Max_CPULoad_Slider, IDC_Max_CPULoad_Meter, IDC_Max_CPULoad, m_pITQualityControllerConfig)))
  553. {
  554. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[IDC_Max_CPULoad] failed - Out of memory"), _fx_));
  555. goto MyError4;
  556. }
  557. else
  558. {
  559. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[IDC_Max_CPULoad]=0x%08lX"), _fx_, m_Controls[IDC_Max_CPULoad]));
  560. }
  561. // Initialize all the controls. If the initialization fails, it's Ok. It just means
  562. // that the TAPI control interface isn't implemented by the device. The dialog item
  563. // in the property page will be greyed, showing this to the user.
  564. for (j = 0; j < m_NumProperties; j++)
  565. {
  566. if (m_Controls[j]->Init())
  567. {
  568. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[%ld]->Init()"), _fx_, j));
  569. }
  570. else
  571. {
  572. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: m_Controls[%ld]->Init() failed"), _fx_, j));
  573. }
  574. }
  575. Hr = NOERROR;
  576. goto MyExit;
  577. MyError4:
  578. if (m_Controls[IDC_Max_InputBandwidth])
  579. delete m_Controls[IDC_Max_InputBandwidth], m_Controls[IDC_Max_InputBandwidth] = NULL;
  580. MyError3:
  581. if (m_Controls[IDC_Max_OutputBandwidth])
  582. delete m_Controls[IDC_Max_OutputBandwidth], m_Controls[IDC_Max_OutputBandwidth] = NULL;
  583. MyError2:
  584. if (m_Controls[IDC_Curr_CPULoad])
  585. delete m_Controls[IDC_Curr_CPULoad], m_Controls[IDC_Curr_CPULoad] = NULL;
  586. MyError1:
  587. if (m_Controls[IDC_Curr_InputBandwidth])
  588. delete m_Controls[IDC_Curr_InputBandwidth], m_Controls[IDC_Curr_InputBandwidth] = NULL;
  589. MyError0:
  590. if (m_Controls[IDC_Curr_OutputBandwidth])
  591. delete m_Controls[IDC_Curr_OutputBandwidth], m_Controls[IDC_Curr_OutputBandwidth] = NULL;
  592. MyExit:
  593. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  594. return Hr;
  595. */
  596. return S_OK;
  597. }
  598. /****************************************************************************
  599. * @doc INTERNAL CSYSTEMPMETHOD
  600. *
  601. * @mfunc HRESULT | CSystemProperties | OnDeactivate | This
  602. * method is called when the property page is dismissed.
  603. *
  604. * @rdesc This method returns an HRESULT value that depends on the
  605. * implementation of the interface. HRESULT can include one of the
  606. * following standard constants, or other values not listed:
  607. *
  608. * @flag NOERROR | No error
  609. ***************************************************************************/
  610. HRESULT CSystemProperties::OnDeactivate()
  611. {
  612. int j;
  613. FX_ENTRY("CSystemProperties::OnDeactivate")
  614. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  615. // Free the controls
  616. for (j = 0; j < m_NumProperties; j++)
  617. {
  618. if (m_Controls[j])
  619. {
  620. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  621. delete m_Controls[j], m_Controls[j] = NULL;
  622. }
  623. else
  624. {
  625. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  626. }
  627. }
  628. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  629. return NOERROR;
  630. }
  631. /****************************************************************************
  632. * @doc INTERNAL CSYSTEMPMETHOD
  633. *
  634. * @mfunc HRESULT | CSystemProperties | OnApplyChanges | This
  635. * method is called when the user applies changes to the property page.
  636. *
  637. * @rdesc This method returns an HRESULT value that depends on the
  638. * implementation of the interface. HRESULT can include one of the
  639. * following standard constants, or other values not listed:
  640. *
  641. * @flag E_FAIL | Failure
  642. * @flag E_POINTER | Null pointer argument
  643. * @flag E_NOTIMPL | Method is not supported
  644. * @flag NOERROR | No error
  645. ***************************************************************************/
  646. HRESULT CSystemProperties::OnApplyChanges()
  647. {
  648. HRESULT Hr = NOERROR;
  649. FX_ENTRY("CSystemProperties::OnApplyChanges")
  650. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  651. for (int j = IDC_Max_OutputBandwidth; j < IDC_Max_CPULoad; j++)
  652. {
  653. if (m_Controls[j])
  654. {
  655. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: calling m_Controls[%ld]=0x%08lX->OnApply"), _fx_, j, m_Controls[j]));
  656. if (m_Controls[j]->HasChanged())
  657. m_Controls[j]->OnApply();
  658. Hr = NOERROR;
  659. }
  660. else
  661. {
  662. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: can't calling m_Controls[%ld]=NULL->OnApply"), _fx_, j));
  663. Hr = E_UNEXPECTED;
  664. }
  665. }
  666. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  667. return Hr;
  668. }
  669. /****************************************************************************
  670. * @doc INTERNAL CSYSTEMPMETHOD
  671. *
  672. * @mfunc BOOL | CSystemProperties | BaseDlgProc | This
  673. * method is called when a message is sent to the property page dialog box.
  674. *
  675. * @rdesc By default, returns the value returned by the Win32 DefWindowProc function.
  676. ***************************************************************************/
  677. INT_PTR CALLBACK CSystemProperties::BaseDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  678. {
  679. CSystemProperties *pSV = (CSystemProperties*)GetWindowLong(hDlg, DWL_USER);
  680. int iNotify = HIWORD (wParam);
  681. int j;
  682. switch (uMsg)
  683. {
  684. case WM_INITDIALOG:
  685. {
  686. LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
  687. pSV = (CSystemProperties*)psp->lParam;
  688. pSV->m_hDlg = hDlg;
  689. SetWindowLong(hDlg, DWL_USER, (LPARAM)pSV);
  690. pSV->m_bInit = FALSE;
  691. //pSV->OnActivate();
  692. //pSV->m_bInit = TRUE;
  693. return TRUE;
  694. }
  695. break;
  696. case WM_TIMER:
  697. if (pSV && pSV->m_bInit)
  698. {
  699. // Update the Vu-Meters
  700. for (j = IDC_Curr_OutputBandwidth; j < IDC_Curr_CPULoad; j++)
  701. {
  702. if (pSV->m_Controls[j]->GetProgressHWnd())
  703. {
  704. pSV->m_Controls[j]->UpdateProgress();
  705. pSV->SetDirty();
  706. }
  707. }
  708. }
  709. break;
  710. case WM_HSCROLL:
  711. case WM_VSCROLL:
  712. if (pSV && pSV->m_bInit)
  713. {
  714. // Process all of the Trackbar messages
  715. for (j = IDC_Max_OutputBandwidth; j < IDC_Max_CPULoad; j++)
  716. {
  717. if (pSV->m_Controls[j]->GetTrackbarHWnd() == (HWND)lParam)
  718. {
  719. pSV->m_Controls[j]->OnScroll(uMsg, wParam, lParam);
  720. pSV->SetDirty();
  721. }
  722. }
  723. //pSV->OnApplyChanges();
  724. }
  725. break;
  726. case WM_COMMAND:
  727. if (pSV && pSV->m_bInit)
  728. {
  729. // Process all of the auto checkbox messages
  730. for (j = 0; j < pSV->m_NumProperties; j++)
  731. {
  732. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetAutoHWnd() == (HWND)lParam)
  733. {
  734. pSV->m_Controls[j]->OnAuto(uMsg, wParam, lParam);
  735. pSV->SetDirty();
  736. break;
  737. }
  738. }
  739. // Process all of the edit box messages
  740. for (j = 0; j < pSV->m_NumProperties; j++)
  741. {
  742. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetEditHWnd() == (HWND)lParam)
  743. {
  744. pSV->m_Controls[j]->OnEdit(uMsg, wParam, lParam);
  745. pSV->SetDirty();
  746. break;
  747. }
  748. }
  749. switch (LOWORD(wParam))
  750. {
  751. case IDC_CONTROL_DEFAULT:
  752. for (j = IDC_Max_OutputBandwidth; j < IDC_Max_CPULoad; j++)
  753. {
  754. if (pSV->m_Controls[j])
  755. pSV->m_Controls[j]->OnDefault();
  756. }
  757. break;
  758. default:
  759. break;
  760. }
  761. //pSV->OnApplyChanges();
  762. }
  763. break;
  764. case WM_NOTIFY:
  765. if (pSV)
  766. {
  767. switch (((NMHDR FAR *)lParam)->code)
  768. {
  769. case PSN_SETACTIVE:
  770. {
  771. // We call out here specially so we can mark this page as having been init'd.
  772. int iRet = pSV->OnActivate();
  773. pSV->m_bInit = TRUE;
  774. return iRet;
  775. }
  776. break;
  777. case PSN_APPLY:
  778. pSV->OnApplyChanges();
  779. break;
  780. case PSN_QUERYCANCEL:
  781. // return pSV->QueryCancel();
  782. break;
  783. default:
  784. break;
  785. }
  786. }
  787. break;
  788. default:
  789. return FALSE;
  790. }
  791. return TRUE;
  792. }
  793. /****************************************************************************
  794. * @doc INTERNAL CSYSTEMPMETHOD
  795. *
  796. * @mfunc BOOL | CSystemProperties | SetDirty | This
  797. * method notifies the property page site of changes.
  798. *
  799. * @rdesc Nada.
  800. ***************************************************************************/
  801. void CSystemProperties::SetDirty()
  802. {
  803. PropSheet_Changed(GetParent(m_hDlg), m_hDlg);
  804. }