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.

751 lines
27 KiB

  1. /****************************************************************************
  2. * @doc INTERNAL PROCAMPP
  3. *
  4. * @module ProcAmpP.cpp | Source file for the <c CProcAmpProperty>
  5. * class used to implement a property page to test the control interface
  6. * <i ITVideoSettings>.
  7. ***************************************************************************/
  8. #include "Precomp.h"
  9. extern HINSTANCE ghInst;
  10. /****************************************************************************
  11. * @doc INTERNAL CPROCAMPPMETHOD
  12. *
  13. * @mfunc void | CProcAmpProperty | CProcAmpProperty | This
  14. * method is the constructor for video proc amp control property objects. It
  15. * calls the base class constructor, calls InitCommonControlsEx, and saves
  16. * a pointer to the <i ITVideoSettings> interface.
  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 progress bar.
  42. *
  43. * @parm ULONG | IDProperty | Specifies the ID of the Ks property.
  44. *
  45. * @parm ITVideoSettings* | pInterface | Specifies a pointer to the
  46. * <i ITVideoSettings> interface.
  47. *
  48. * @rdesc Nada.
  49. ***************************************************************************/
  50. CProcAmpProperty::CProcAmpProperty(HWND hDlg, ULONG IDLabel, ULONG IDMinControl, ULONG IDMaxControl, ULONG IDDefaultControl, ULONG IDStepControl, ULONG IDEditControl, ULONG IDTrackbarControl, ULONG IDProgressControl, ULONG IDProperty, ULONG IDAutoControl, ITVideoSettings *pInterface)
  51. : CPropertyEditor(hDlg, IDLabel, IDMinControl, IDMaxControl, IDDefaultControl, IDStepControl, IDEditControl, IDTrackbarControl, IDProgressControl, IDProperty, IDAutoControl)
  52. {
  53. INITCOMMONCONTROLSEX cc;
  54. FX_ENTRY("CProcAmpProperty::CProcAmpProperty")
  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 pointer is NULL, we'll grey the
  60. // associated items in the property page
  61. m_pInterface = pInterface;
  62. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  63. }
  64. /****************************************************************************
  65. * @doc INTERNAL CPROCAMPPMETHOD
  66. *
  67. * @mfunc void | CProcAmpProperty | ~CProcAmpProperty | This
  68. * method is the destructor for video proc amp control property objects. It
  69. * simply calls the base class destructor.
  70. *
  71. * @rdesc Nada.
  72. ***************************************************************************/
  73. CProcAmpProperty::~CProcAmpProperty()
  74. {
  75. FX_ENTRY("CProcAmpProperty::~CProcAmpProperty")
  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 CPROCAMPPMETHOD
  81. *
  82. * @mfunc HRESULT | CProcAmpProperty | 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 CProcAmpProperty::GetValue()
  95. {
  96. HRESULT Hr = NOERROR;
  97. FX_ENTRY("CProcAmpProperty::GetValue")
  98. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  99. // Validate input parameters
  100. if (!m_pInterface)
  101. {
  102. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: invalid input parameter"), _fx_));
  103. Hr = E_FAIL;
  104. goto MyExit;
  105. }
  106. if (SUCCEEDED (Hr = m_pInterface->Get((VideoSettingsProperty)m_IDProperty, &m_CurrentValue, (TAPIControlFlags*)&m_CurrentFlags)))
  107. {
  108. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_CurrentValue=%ld, m_CurrentFlags=%ld"), _fx_, m_CurrentValue, m_CurrentFlags));
  109. }
  110. else
  111. {
  112. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: m_pITVideoSettings->Get failed Hr=0x%08lX"), _fx_, Hr));
  113. }
  114. MyExit:
  115. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  116. return Hr;
  117. }
  118. /****************************************************************************
  119. * @doc INTERNAL CPROCAMPPMETHOD
  120. *
  121. * @mfunc HRESULT | CProcAmpProperty | SetValue | This method sets the
  122. * value of a property.
  123. *
  124. * @rdesc This method returns an HRESULT value that depends on the
  125. * implementation of the interface. HRESULT can include one of the
  126. * following standard constants, or other values not listed:
  127. *
  128. * @flag E_FAIL | Failure
  129. * @flag E_POINTER | Null pointer argument
  130. * @flag E_NOTIMPL | Method is not supported
  131. * @flag NOERROR | No error
  132. ***************************************************************************/
  133. HRESULT CProcAmpProperty::SetValue()
  134. {
  135. HRESULT Hr = NOERROR;
  136. FX_ENTRY("CProcAmpProperty::SetValue")
  137. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  138. // Validate input parameters
  139. if (!m_pInterface)
  140. {
  141. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: invalid input parameter"), _fx_));
  142. Hr = E_FAIL;
  143. goto MyExit;
  144. }
  145. if (SUCCEEDED (Hr = m_pInterface->Set((VideoSettingsProperty)m_IDProperty, m_CurrentValue, (TAPIControlFlags)m_CurrentFlags)))
  146. {
  147. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_CurrentValue=%ld, m_CurrentFlags=%ld"), _fx_, m_CurrentValue, m_CurrentFlags));
  148. }
  149. else
  150. {
  151. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: m_pITVideoSettings->Set failed Hr=0x%08lX"), _fx_, Hr));
  152. }
  153. MyExit:
  154. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  155. return Hr;
  156. }
  157. /****************************************************************************
  158. * @doc INTERNAL CPROCAMPPMETHOD
  159. *
  160. * @mfunc HRESULT | CProcAmpProperty | GetRange | This method retrieves
  161. * the range information of a property.
  162. *
  163. * @rdesc This method returns an HRESULT value that depends on the
  164. * implementation of the interface. HRESULT can include one of the
  165. * following standard constants, or other values not listed:
  166. *
  167. * @flag E_FAIL | Failure
  168. * @flag E_POINTER | Null pointer argument
  169. * @flag E_NOTIMPL | Method is not supported
  170. * @flag NOERROR | No error
  171. ***************************************************************************/
  172. HRESULT CProcAmpProperty::GetRange()
  173. {
  174. HRESULT Hr = NOERROR;
  175. FX_ENTRY("CProcAmpProperty::GetRange")
  176. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  177. // Validate input parameters
  178. if (!m_pInterface)
  179. {
  180. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: invalid input parameter"), _fx_));
  181. Hr = E_FAIL;
  182. goto MyExit;
  183. }
  184. if (SUCCEEDED (Hr = m_pInterface->GetRange((VideoSettingsProperty)m_IDProperty, &m_Min, &m_Max, &m_SteppingDelta, &m_DefaultValue, (TAPIControlFlags*)&m_CapsFlags)))
  185. {
  186. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Min=%ld, m_Max=%ld, m_SteppingDelta=%ld, m_DefaultValue=%ld, m_CapsFlags=%ld"), _fx_, m_Min, m_Max, m_SteppingDelta, m_DefaultValue, m_CapsFlags));
  187. }
  188. else
  189. {
  190. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: m_pITVideoSettings->GetRange failed Hr=0x%08lX"), _fx_, Hr));
  191. }
  192. m_DefaultFlags = m_CapsFlags;
  193. MyExit:
  194. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  195. return Hr;
  196. }
  197. /****************************************************************************
  198. * @doc INTERNAL CCAMERACPMETHOD
  199. *
  200. * @mfunc HPROPSHEETPAGE | CProcAmpProperties | OnCreate | This
  201. * method creates a new page for a property sheet.
  202. *
  203. * @rdesc Returns the handle to the new property sheet if successful, or
  204. * NULL otherwise.
  205. ***************************************************************************/
  206. HPROPSHEETPAGE CProcAmpProperties::OnCreate(LPWSTR pszTitle)
  207. {
  208. PROPSHEETPAGE psp;
  209. psp.dwSize = sizeof(psp);
  210. psp.dwFlags = PSP_USEREFPARENT | PSP_USETITLE;
  211. psp.hInstance = ghInst;
  212. psp.pszTemplate = MAKEINTRESOURCE(IDD_VideoProcAmpProperties);
  213. psp.pszTitle = pszTitle;
  214. psp.pfnDlgProc = BaseDlgProc;
  215. psp.pcRefParent = 0;
  216. psp.pfnCallback = (LPFNPSPCALLBACK)NULL;
  217. psp.lParam = (LPARAM)this;
  218. return CreatePropertySheetPage(&psp);
  219. }
  220. /****************************************************************************
  221. * @doc INTERNAL CPROCAMPPMETHOD
  222. *
  223. * @mfunc void | CProcAmpProperties | CProcAmpProperties | This
  224. * method is the constructor for the property page object. It simply
  225. * calls the constructor of the property page base class.
  226. *
  227. * @rdesc Nada.
  228. ***************************************************************************/
  229. CProcAmpProperties::CProcAmpProperties()
  230. {
  231. FX_ENTRY("CProcAmpProperties::CProcAmpProperties")
  232. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  233. m_pITVideoSettings = NULL;
  234. m_NumProperties = NUM_PROCAMP_CONTROLS;
  235. for (int i = 0; i < m_NumProperties; i++)
  236. m_Controls[i] = NULL;
  237. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  238. }
  239. /****************************************************************************
  240. * @doc INTERNAL CPROCAMPPMETHOD
  241. *
  242. * @mfunc void | CProcAmpProperties | ~CProcAmpProperties | This
  243. * method is the destructor for the video proc amp control property page. It
  244. * simply calls the base class destructor after deleting all the controls.
  245. *
  246. * @rdesc Nada.
  247. ***************************************************************************/
  248. CProcAmpProperties::~CProcAmpProperties()
  249. {
  250. int j;
  251. FX_ENTRY("CProcAmpProperties::~CProcAmpProperties")
  252. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  253. // Free the controls
  254. for (j = 0; j < m_NumProperties; j++)
  255. {
  256. if (m_Controls[j])
  257. {
  258. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  259. delete m_Controls[j], m_Controls[j] = NULL;
  260. }
  261. else
  262. {
  263. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  264. }
  265. }
  266. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  267. }
  268. /****************************************************************************
  269. * @doc INTERNAL CPROCAMPPMETHOD
  270. *
  271. * @mfunc HRESULT | CProcAmpProperties | OnConnect | This
  272. * method is called when the property page is connected to a TAPI object.
  273. *
  274. * @parm ITStream* | pStream | Specifies a pointer to the <i ITStream>
  275. * interface. It is used to QI for the <i ITVideoSettings> interface.
  276. *
  277. * @rdesc This method returns an HRESULT value that depends on the
  278. * implementation of the interface. HRESULT can include one of the
  279. * following standard constants, or other values not listed:
  280. *
  281. * @flag E_FAIL | Failure
  282. * @flag E_POINTER | Null pointer argument
  283. * @flag E_NOTIMPL | Method is not supported
  284. * @flag NOERROR | No error
  285. ***************************************************************************/
  286. HRESULT CProcAmpProperties::OnConnect(ITStream *pStream)
  287. {
  288. HRESULT Hr = NOERROR;
  289. FX_ENTRY("CProcAmpProperties::OnConnect")
  290. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  291. // Validate input parameters
  292. if (!pStream)
  293. {
  294. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: invalid input parameter"), _fx_));
  295. Hr = E_POINTER;
  296. goto MyExit;
  297. }
  298. // Get the video proc amp interface
  299. if (SUCCEEDED (Hr = pStream->QueryInterface(&m_pITVideoSettings)))
  300. {
  301. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_pITVideoSettings=0x%08lX"), _fx_, m_pITVideoSettings));
  302. }
  303. else
  304. {
  305. m_pITVideoSettings = NULL;
  306. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: IOCTL failed Hr=0x%08lX"), _fx_, Hr));
  307. }
  308. // It's Ok if we couldn't get interface pointers. We'll just grey the controls in the property page
  309. // to make it clear to the user that they can't control those properties on the device
  310. Hr = NOERROR;
  311. MyExit:
  312. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  313. return Hr;
  314. }
  315. /****************************************************************************
  316. * @doc INTERNAL CPROCAMPPMETHOD
  317. *
  318. * @mfunc HRESULT | CProcAmpProperties | OnDisconnect | This
  319. * method is called when the property page is disconnected from the owning
  320. * filter.
  321. *
  322. * @rdesc This method returns an HRESULT value that depends on the
  323. * implementation of the interface. HRESULT can include one of the
  324. * following standard constants, or other values not listed:
  325. *
  326. * @flag NOERROR | No error
  327. ***************************************************************************/
  328. HRESULT CProcAmpProperties::OnDisconnect()
  329. {
  330. FX_ENTRY("CProcAmpProperties::OnDisconnect")
  331. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  332. // Validate input parameters
  333. if (!m_pITVideoSettings)
  334. {
  335. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: already disconnected!"), _fx_));
  336. }
  337. else
  338. {
  339. // Release the interface
  340. m_pITVideoSettings->Release();
  341. m_pITVideoSettings = NULL;
  342. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: releasing m_pITVideoSettings"), _fx_));
  343. }
  344. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  345. return NOERROR;
  346. }
  347. /****************************************************************************
  348. * @doc INTERNAL CPROCAMPPMETHOD
  349. *
  350. * @mfunc HRESULT | CProcAmpProperties | OnActivate | This
  351. * method is called when the property page is activated.
  352. *
  353. * @rdesc This method returns an HRESULT value that depends on the
  354. * implementation of the interface. HRESULT can include one of the
  355. * following standard constants, or other values not listed:
  356. *
  357. * @flag E_FAIL | Failure
  358. * @flag E_POINTER | Null pointer argument
  359. * @flag E_NOTIMPL | Method is not supported
  360. * @flag NOERROR | No error
  361. ***************************************************************************/
  362. HRESULT CProcAmpProperties::OnActivate()
  363. {
  364. HRESULT Hr = E_OUTOFMEMORY;
  365. int j;
  366. FX_ENTRY("CProcAmpProperties::OnActivate")
  367. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  368. // Create the controls for the properties
  369. if (!(m_Controls[0] = new CProcAmpProperty(m_hDlg, IDC_Brightness_Label, IDC_Brightness_Minimum, IDC_Brightness_Maximum, IDC_Brightness_Default, IDC_Brightness_Stepping, IDC_Brightness_Edit, IDC_Brightness_Slider, 0, VideoProcAmp_Brightness, IDC_Brightness_Auto, m_pITVideoSettings)))
  370. {
  371. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_Brightness] failed - Out of memory"), _fx_));
  372. goto MyExit;
  373. }
  374. else
  375. {
  376. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_Brightness]=0x%08lX"), _fx_, m_Controls[0]));
  377. }
  378. if (!(m_Controls[1] = new CProcAmpProperty(m_hDlg, IDC_Contrast_Label, IDC_Contrast_Minimum, IDC_Contrast_Maximum, IDC_Contrast_Default, IDC_Contrast_Stepping, IDC_Contrast_Edit, IDC_Contrast_Slider, 0, VideoProcAmp_Contrast, IDC_Contrast_Auto, m_pITVideoSettings)))
  379. {
  380. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_Contrast] failed - Out of memory"), _fx_));
  381. goto MyError0;
  382. }
  383. else
  384. {
  385. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_Contrast]=0x%08lX"), _fx_, m_Controls[1]));
  386. }
  387. if (!(m_Controls[2] = new CProcAmpProperty(m_hDlg, IDC_Hue_Label, IDC_Hue_Minimum, IDC_Hue_Maximum, IDC_Hue_Default, IDC_Hue_Stepping, IDC_Hue_Edit, IDC_Hue_Slider, 0, VideoProcAmp_Hue, IDC_Hue_Auto, m_pITVideoSettings)))
  388. {
  389. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_Hue] failed - Out of memory"), _fx_));
  390. goto MyError1;
  391. }
  392. else
  393. {
  394. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_Hue]=0x%08lX"), _fx_, m_Controls[2]));
  395. }
  396. if (!(m_Controls[3] = new CProcAmpProperty(m_hDlg, IDC_Saturation_Label, IDC_Saturation_Minimum, IDC_Saturation_Maximum, IDC_Saturation_Default, IDC_Saturation_Stepping, IDC_Saturation_Edit, IDC_Saturation_Slider, 0, VideoProcAmp_Saturation, IDC_Saturation_Auto, m_pITVideoSettings)))
  397. {
  398. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_Saturation] failed - Out of memory"), _fx_));
  399. goto MyError2;
  400. }
  401. else
  402. {
  403. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_Saturation]=0x%08lX"), _fx_, m_Controls[3]));
  404. }
  405. if (!(m_Controls[4] = new CProcAmpProperty(m_hDlg, IDC_Sharpness_Label, IDC_Sharpness_Minimum, IDC_Sharpness_Maximum, IDC_Sharpness_Default, IDC_Sharpness_Stepping, IDC_Sharpness_Edit, IDC_Sharpness_Slider, 0, VideoProcAmp_Sharpness, IDC_Sharpness_Auto, m_pITVideoSettings)))
  406. {
  407. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_Sharpness] failed - Out of memory"), _fx_));
  408. goto MyError3;
  409. }
  410. else
  411. {
  412. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_Sharpness]=0x%08lX"), _fx_, m_Controls[4]));
  413. }
  414. if (!(m_Controls[5] = new CProcAmpProperty(m_hDlg, IDC_Gamma_Label, IDC_Gamma_Minimum, IDC_Gamma_Maximum, IDC_Gamma_Default, IDC_Gamma_Stepping, IDC_Gamma_Edit, IDC_Gamma_Slider, 0, VideoProcAmp_Gamma, IDC_Gamma_Auto, m_pITVideoSettings)))
  415. {
  416. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_Gamma] failed - Out of memory"), _fx_));
  417. goto MyError4;
  418. }
  419. else
  420. {
  421. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_Gamma]=0x%08lX"), _fx_, m_Controls[5]));
  422. }
  423. if (!(m_Controls[6] = new CProcAmpProperty(m_hDlg, IDC_ColorEnable_Label, IDC_ColorEnable_Minimum, IDC_ColorEnable_Maximum, IDC_ColorEnable_Default, IDC_ColorEnable_Stepping, IDC_ColorEnable_Edit, IDC_ColorEnable_Slider, 0, VideoProcAmp_ColorEnable, IDC_ColorEnable_Auto, m_pITVideoSettings)))
  424. {
  425. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_ColorEnable] failed - Out of memory"), _fx_));
  426. goto MyError5;
  427. }
  428. else
  429. {
  430. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_ColorEnable]=0x%08lX"), _fx_, m_Controls[6]));
  431. }
  432. if (!(m_Controls[7] = new CProcAmpProperty(m_hDlg, IDC_WhiteBalance_Label, IDC_WhiteBalance_Minimum, IDC_WhiteBalance_Maximum, IDC_WhiteBalance_Default, IDC_WhiteBalance_Stepping, IDC_WhiteBalance_Edit, IDC_WhiteBalance_Slider, 0, VideoProcAmp_WhiteBalance, IDC_WhiteBalance_Auto, m_pITVideoSettings)))
  433. {
  434. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_WhiteBalance] failed - Out of memory"), _fx_));
  435. goto MyError5;
  436. }
  437. else
  438. {
  439. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_WhiteBalance]=0x%08lX"), _fx_, m_Controls[6]));
  440. }
  441. if (!(m_Controls[8] = new CProcAmpProperty(m_hDlg, IDC_BacklightComp_Label, IDC_BacklightComp_Minimum, IDC_BacklightComp_Maximum, IDC_BacklightComp_Default, IDC_BacklightComp_Stepping, IDC_BacklightComp_Edit, IDC_BacklightComp_Slider, 0, VideoProcAmp_BacklightCompensation, IDC_BacklightComp_Auto, m_pITVideoSettings)))
  442. {
  443. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[VideoProcAmp_BacklightComp] failed - Out of memory"), _fx_));
  444. goto MyError5;
  445. }
  446. else
  447. {
  448. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[VideoProcAmp_BacklightComp]=0x%08lX"), _fx_, m_Controls[6]));
  449. }
  450. // Initialize all the controls. If the initialization fails, it's Ok. It just means
  451. // that the TAPI control interface isn't implemented by the device. The dialog item
  452. // in the property page will be greyed, showing this to the user.
  453. for (j = 0; j < m_NumProperties; j++)
  454. {
  455. if (m_Controls[j]->Init())
  456. {
  457. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[%ld]->Init()"), _fx_, j));
  458. }
  459. else
  460. {
  461. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: m_Controls[%ld]->Init() failed"), _fx_, j));
  462. }
  463. }
  464. Hr = NOERROR;
  465. goto MyExit;
  466. MyError5:
  467. if (m_Controls[5])
  468. delete m_Controls[5], m_Controls[5] = NULL;
  469. MyError4:
  470. if (m_Controls[4])
  471. delete m_Controls[4], m_Controls[4] = NULL;
  472. MyError3:
  473. if (m_Controls[3])
  474. delete m_Controls[3], m_Controls[3] = NULL;
  475. MyError2:
  476. if (m_Controls[2])
  477. delete m_Controls[2], m_Controls[2] = NULL;
  478. MyError1:
  479. if (m_Controls[1])
  480. delete m_Controls[1], m_Controls[1] = NULL;
  481. MyError0:
  482. if (m_Controls[0])
  483. delete m_Controls[0], m_Controls[0] = NULL;
  484. MyExit:
  485. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  486. return Hr;
  487. }
  488. /****************************************************************************
  489. * @doc INTERNAL CPROCAMPPMETHOD
  490. *
  491. * @mfunc HRESULT | CProcAmpProperties | OnDeactivate | This
  492. * method is called when the property page is dismissed.
  493. *
  494. * @rdesc This method returns an HRESULT value that depends on the
  495. * implementation of the interface. HRESULT can include one of the
  496. * following standard constants, or other values not listed:
  497. *
  498. * @flag NOERROR | No error
  499. ***************************************************************************/
  500. HRESULT CProcAmpProperties::OnDeactivate()
  501. {
  502. int j;
  503. FX_ENTRY("CProcAmpProperties::OnDeactivate")
  504. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  505. // Free the controls
  506. for (j = 0; j < m_NumProperties; j++)
  507. {
  508. if (m_Controls[j])
  509. {
  510. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  511. delete m_Controls[j], m_Controls[j] = NULL;
  512. }
  513. else
  514. {
  515. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  516. }
  517. }
  518. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  519. return NOERROR;
  520. }
  521. /****************************************************************************
  522. * @doc INTERNAL CPROCAMPPMETHOD
  523. *
  524. * @mfunc HRESULT | CProcAmpProperties | OnApplyChanges | This
  525. * method is called when the user applies changes to the property page.
  526. *
  527. * @rdesc This method returns an HRESULT value that depends on the
  528. * implementation of the interface. HRESULT can include one of the
  529. * following standard constants, or other values not listed:
  530. *
  531. * @flag E_FAIL | Failure
  532. * @flag E_POINTER | Null pointer argument
  533. * @flag E_NOTIMPL | Method is not supported
  534. * @flag NOERROR | No error
  535. ***************************************************************************/
  536. HRESULT CProcAmpProperties::OnApplyChanges()
  537. {
  538. HRESULT Hr = NOERROR;
  539. FX_ENTRY("CProcAmpProperties::OnApplyChanges")
  540. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  541. for (int j = 0; j < m_NumProperties; j++)
  542. {
  543. if (m_Controls[j])
  544. {
  545. if (m_Controls[j]->HasChanged())
  546. {
  547. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: calling m_Controls[%ld]=0x%08lX->OnApply"), _fx_, j, m_Controls[j]));
  548. m_Controls[j]->OnApply();
  549. }
  550. }
  551. else
  552. {
  553. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: can't call m_Controls[%ld]=NULL->OnApply"), _fx_, j));
  554. Hr = E_UNEXPECTED;
  555. break;
  556. }
  557. }
  558. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  559. return Hr;
  560. }
  561. /****************************************************************************
  562. * @doc INTERNAL CCAMERACPMETHOD
  563. *
  564. * @mfunc BOOL | CProcAmpProperties | BaseDlgProc | This
  565. * method is called when a message is sent to the property page dialog box.
  566. *
  567. * @rdesc By default, returns the value returned by the Win32 DefWindowProc function.
  568. ***************************************************************************/
  569. INT_PTR CALLBACK CProcAmpProperties::BaseDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  570. {
  571. CProcAmpProperties *pSV = (CProcAmpProperties*)GetWindowLong(hDlg, DWL_USER);
  572. int iNotify = HIWORD (wParam);
  573. int j;
  574. switch (uMsg)
  575. {
  576. case WM_INITDIALOG:
  577. {
  578. LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
  579. pSV = (CProcAmpProperties*)psp->lParam;
  580. pSV->m_hDlg = hDlg;
  581. SetWindowLong(hDlg, DWL_USER, (LPARAM)pSV);
  582. pSV->m_bInit = FALSE;
  583. pSV->OnActivate();
  584. pSV->m_bInit = TRUE;
  585. return TRUE;
  586. }
  587. break;
  588. case WM_HSCROLL:
  589. case WM_VSCROLL:
  590. if (pSV && pSV->m_bInit)
  591. {
  592. // Process all of the Trackbar messages
  593. for (j = 0; j < pSV->m_NumProperties; j++)
  594. {
  595. if (pSV->m_Controls[j]->GetTrackbarHWnd() == (HWND)lParam)
  596. {
  597. pSV->m_Controls[j]->OnScroll(uMsg, wParam, lParam);
  598. pSV->SetDirty();
  599. }
  600. }
  601. pSV->OnApplyChanges();
  602. }
  603. break;
  604. case WM_COMMAND:
  605. if (pSV && pSV->m_bInit)
  606. {
  607. // Process all of the auto checkbox messages
  608. for (j = 0; j < pSV->m_NumProperties; j++)
  609. {
  610. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetAutoHWnd() == (HWND)lParam)
  611. {
  612. pSV->m_Controls[j]->OnAuto(uMsg, wParam, lParam);
  613. pSV->SetDirty();
  614. break;
  615. }
  616. }
  617. // Process all of the edit box messages
  618. for (j = 0; j < pSV->m_NumProperties; j++)
  619. {
  620. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetEditHWnd() == (HWND)lParam)
  621. {
  622. pSV->m_Controls[j]->OnEdit(uMsg, wParam, lParam);
  623. pSV->SetDirty();
  624. break;
  625. }
  626. }
  627. switch (LOWORD(wParam))
  628. {
  629. case IDC_CONTROL_DEFAULT:
  630. for (j = 0; j < pSV->m_NumProperties; j++)
  631. {
  632. if (pSV->m_Controls[j])
  633. pSV->m_Controls[j]->OnDefault();
  634. }
  635. break;
  636. default:
  637. break;
  638. }
  639. pSV->OnApplyChanges();
  640. }
  641. break;
  642. default:
  643. return FALSE;
  644. }
  645. return TRUE;
  646. }
  647. /****************************************************************************
  648. * @doc INTERNAL CPROCAMPPMETHOD
  649. *
  650. * @mfunc BOOL | CProcAmpProperties | SetDirty | This
  651. * method notifies the property page site of changes.
  652. *
  653. * @rdesc Nada.
  654. ***************************************************************************/
  655. void CProcAmpProperties::SetDirty()
  656. {
  657. PropSheet_Changed(GetParent(m_hDlg), m_hDlg);
  658. }