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.

756 lines
27 KiB

  1. /****************************************************************************
  2. * @doc INTERNAL CAMERACP
  3. *
  4. * @module CameraCP.cpp | Source file for the <c CCameraControlProperty>
  5. * class used to implement a property page to test the control interface
  6. * <i ITCameraControl>.
  7. ***************************************************************************/
  8. #include "Precomp.h"
  9. extern HINSTANCE ghInst;
  10. /****************************************************************************
  11. * @doc INTERNAL CCAMERACPMETHOD
  12. *
  13. * @mfunc void | CCameraControlProperty | CCameraControlProperty | This
  14. * method is the constructor for camera control property objects. It
  15. * calls the base class constructor, calls InitCommonControlsEx, and saves
  16. * a pointer to the <i ITCameraControl> 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 ITCameraControl* | pInterface | Specifies a pointer to the
  46. * <i ITCameraControl> interface.
  47. *
  48. * @rdesc Nada.
  49. ***************************************************************************/
  50. CCameraControlProperty::CCameraControlProperty(HWND hDlg, ULONG IDLabel, ULONG IDMinControl, ULONG IDMaxControl, ULONG IDDefaultControl, ULONG IDStepControl, ULONG IDEditControl, ULONG IDTrackbarControl, ULONG IDProgressControl, ULONG IDProperty, ULONG IDAutoControl, ITCameraControl *pInterface)
  51. : CPropertyEditor(hDlg, IDLabel, IDMinControl, IDMaxControl, IDDefaultControl, IDStepControl, IDEditControl, IDTrackbarControl, IDProgressControl, IDProperty, IDAutoControl)
  52. {
  53. INITCOMMONCONTROLSEX cc;
  54. FX_ENTRY("CCameraControlProperty::CCameraControlProperty")
  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 CCAMERACPMETHOD
  66. *
  67. * @mfunc void | CCameraControlProperty | ~CCameraControlProperty | This
  68. * method is the destructor for camera control property objects. It
  69. * simply calls the base class destructor.
  70. *
  71. * @rdesc Nada.
  72. ***************************************************************************/
  73. CCameraControlProperty::~CCameraControlProperty()
  74. {
  75. FX_ENTRY("CCameraControlProperty::~CCameraControlProperty")
  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 CCAMERACPMETHOD
  81. *
  82. * @mfunc HRESULT | CCameraControlProperty | 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 CCameraControlProperty::GetValue()
  95. {
  96. HRESULT Hr = NOERROR;
  97. FX_ENTRY("CCameraControlProperty::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((TAPICameraControlProperty)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_pITCameraControl->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 CCAMERACPMETHOD
  120. *
  121. * @mfunc HRESULT | CCameraControlProperty | 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 CCameraControlProperty::SetValue()
  134. {
  135. HRESULT Hr = NOERROR;
  136. FX_ENTRY("CCameraControlProperty::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((TAPICameraControlProperty)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_pITCameraControl->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 CCAMERACPMETHOD
  159. *
  160. * @mfunc HRESULT | CCameraControlProperty | 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 CCameraControlProperty::GetRange()
  173. {
  174. HRESULT Hr = NOERROR;
  175. FX_ENTRY("CCameraControlProperty::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((TAPICameraControlProperty)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_pITCameraControl->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 | CCameraControlProperties | 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 CCameraControlProperties::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_CameraControlProperties);
  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 CCAMERACPMETHOD
  222. *
  223. * @mfunc void | CCameraControlProperties | CCameraControlProperties | 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. CCameraControlProperties::CCameraControlProperties()
  230. {
  231. FX_ENTRY("CCameraControlProperties::CCameraControlProperties")
  232. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  233. m_pITCameraControl = NULL;
  234. m_NumProperties = NUM_CAMERA_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 CCAMERACPMETHOD
  241. *
  242. * @mfunc void | CCameraControlProperties | ~CCameraControlProperties | This
  243. * method is the destructor for camera control property page. It
  244. * simply calls the base class destructor after deleting all the controls.
  245. *
  246. * @rdesc Nada.
  247. ***************************************************************************/
  248. CCameraControlProperties::~CCameraControlProperties()
  249. {
  250. int j;
  251. FX_ENTRY("CCameraControlProperties::~CCameraControlProperties")
  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 CCAMERACPMETHOD
  270. *
  271. * @mfunc HRESULT | CCameraControlProperties | 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 ITCameraControl> 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 CCameraControlProperties::OnConnect(ITStream *pStream)
  287. {
  288. HRESULT Hr = NOERROR;
  289. FX_ENTRY("CCameraControlProperties::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 camera control interface
  299. if (SUCCEEDED (Hr = pStream->QueryInterface(&m_pITCameraControl)))
  300. {
  301. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_pITCameraControl=0x%08lX"), _fx_, m_pITCameraControl));
  302. }
  303. else
  304. {
  305. m_pITCameraControl = 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 CCAMERACPMETHOD
  317. *
  318. * @mfunc HRESULT | CCameraControlProperties | 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 CCameraControlProperties::OnDisconnect()
  329. {
  330. FX_ENTRY("CCameraControlProperties::OnDisconnect")
  331. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  332. // Validate input parameters
  333. if (!m_pITCameraControl)
  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_pITCameraControl->Release();
  341. m_pITCameraControl = NULL;
  342. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: releasing m_pITCameraControl"), _fx_));
  343. }
  344. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  345. return NOERROR;
  346. }
  347. /****************************************************************************
  348. * @doc INTERNAL CCAMERACPMETHOD
  349. *
  350. * @mfunc HRESULT | CCameraControlProperties | 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 CCameraControlProperties::OnActivate()
  363. {
  364. HRESULT Hr = E_OUTOFMEMORY;
  365. int j;
  366. FX_ENTRY("CCameraControlProperties::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 CCameraControlProperty(m_hDlg, IDC_Pan_Label, IDC_Pan_Minimum, IDC_Pan_Maximum, IDC_Pan_Default, IDC_Pan_Stepping, IDC_Pan_Edit, IDC_Pan_Slider, 0, TAPICameraControl_Pan, IDC_Pan_Auto, m_pITCameraControl)))
  370. {
  371. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Pan] 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[TAPICameraControl_Pan]=0x%08lX"), _fx_, m_Controls[0]));
  377. }
  378. if (!(m_Controls[1] = new CCameraControlProperty(m_hDlg, IDC_Tilt_Label, IDC_Tilt_Minimum, IDC_Tilt_Maximum, IDC_Tilt_Default, IDC_Tilt_Stepping, IDC_Tilt_Edit, IDC_Tilt_Slider, 0, TAPICameraControl_Tilt, IDC_Tilt_Auto, m_pITCameraControl)))
  379. {
  380. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Tilt] 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[TAPICameraControl_Tilt]=0x%08lX"), _fx_, m_Controls[1]));
  386. }
  387. if (!(m_Controls[2] = new CCameraControlProperty(m_hDlg, IDC_Roll_Label, IDC_Roll_Minimum, IDC_Roll_Maximum, IDC_Roll_Default, IDC_Roll_Stepping, IDC_Roll_Edit, IDC_Roll_Slider, 0, TAPICameraControl_Roll, IDC_Roll_Auto, m_pITCameraControl)))
  388. {
  389. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Roll] 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[TAPICameraControl_Roll]=0x%08lX"), _fx_, m_Controls[2]));
  395. }
  396. if (!(m_Controls[3] = new CCameraControlProperty(m_hDlg, IDC_Zoom_Label, IDC_Zoom_Minimum, IDC_Zoom_Maximum, IDC_Zoom_Default, IDC_Zoom_Stepping, IDC_Zoom_Edit, IDC_Zoom_Slider, 0, TAPICameraControl_Zoom, IDC_Zoom_Auto, m_pITCameraControl)))
  397. {
  398. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Zoom] 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[TAPICameraControl_Zoom]=0x%08lX"), _fx_, m_Controls[3]));
  404. }
  405. if (!(m_Controls[4] = new CCameraControlProperty(m_hDlg, IDC_Exposure_Label, IDC_Exposure_Minimum, IDC_Exposure_Maximum, IDC_Exposure_Default, IDC_Exposure_Stepping, IDC_Exposure_Edit, IDC_Exposure_Slider, 0, TAPICameraControl_Exposure, IDC_Exposure_Auto, m_pITCameraControl)))
  406. {
  407. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Exposure] 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[TAPICameraControl_Exposure]=0x%08lX"), _fx_, m_Controls[4]));
  413. }
  414. if (!(m_Controls[5] = new CCameraControlProperty(m_hDlg, IDC_Iris_Label, IDC_Iris_Minimum, IDC_Iris_Maximum, IDC_Iris_Default, IDC_Iris_Stepping, IDC_Iris_Edit, IDC_Iris_Slider, 0, TAPICameraControl_Iris, IDC_Iris_Auto, m_pITCameraControl)))
  415. {
  416. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Iris] 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[TAPICameraControl_Iris]=0x%08lX"), _fx_, m_Controls[5]));
  422. }
  423. if (!(m_Controls[6] = new CCameraControlProperty(m_hDlg, IDC_Focus_Label, IDC_Focus_Minimum, IDC_Focus_Maximum, IDC_Focus_Default, IDC_Focus_Stepping, IDC_Focus_Edit, IDC_Focus_Slider, 0, TAPICameraControl_Focus, IDC_Focus_Auto, m_pITCameraControl)))
  424. {
  425. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_Focus] 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[TAPICameraControl_Focus]=0x%08lX"), _fx_, m_Controls[6]));
  431. }
  432. if (!(m_Controls[7] = new CCameraControlProperty(m_hDlg, 0, 0, 0, 0, 0, IDC_FlipVertical_Edit, 0, 0, TAPICameraControl_FlipVertical, 0, m_pITCameraControl)))
  433. {
  434. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_FlipVertical] failed - Out of memory"), _fx_));
  435. goto MyError6;
  436. }
  437. else
  438. {
  439. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[TAPICameraControl_FlipVertical]=0x%08lX"), _fx_, m_Controls[7]));
  440. }
  441. if (!(m_Controls[8] = new CCameraControlProperty(m_hDlg, 0, 0, 0, 0, 0, IDC_FlipHorizontal_Edit, 0, 0, TAPICameraControl_FlipHorizontal, 0, m_pITCameraControl)))
  442. {
  443. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: mew m_Controls[TAPICameraControl_FlipHorizontal] failed - Out of memory"), _fx_));
  444. goto MyError7;
  445. }
  446. else
  447. {
  448. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_Controls[TAPICameraControl_FlipHorizontal]=0x%08lX"), _fx_, m_Controls[8]));
  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. MyError7:
  467. if (m_Controls[7])
  468. delete m_Controls[7], m_Controls[7] = NULL;
  469. MyError6:
  470. if (m_Controls[6])
  471. delete m_Controls[6], m_Controls[6] = NULL;
  472. MyError5:
  473. if (m_Controls[5])
  474. delete m_Controls[5], m_Controls[5] = NULL;
  475. MyError4:
  476. if (m_Controls[4])
  477. delete m_Controls[4], m_Controls[4] = NULL;
  478. MyError3:
  479. if (m_Controls[3])
  480. delete m_Controls[3], m_Controls[3] = NULL;
  481. MyError2:
  482. if (m_Controls[2])
  483. delete m_Controls[2], m_Controls[2] = NULL;
  484. MyError1:
  485. if (m_Controls[1])
  486. delete m_Controls[1], m_Controls[1] = NULL;
  487. MyError0:
  488. if (m_Controls[0])
  489. delete m_Controls[0], m_Controls[0] = NULL;
  490. MyExit:
  491. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  492. return Hr;
  493. }
  494. /****************************************************************************
  495. * @doc INTERNAL CCAMERACPMETHOD
  496. *
  497. * @mfunc HRESULT | CCameraControlProperties | OnDeactivate | This
  498. * method is called when the property page is dismissed.
  499. *
  500. * @rdesc This method returns an HRESULT value that depends on the
  501. * implementation of the interface. HRESULT can include one of the
  502. * following standard constants, or other values not listed:
  503. *
  504. * @flag NOERROR | No error
  505. ***************************************************************************/
  506. HRESULT CCameraControlProperties::OnDeactivate()
  507. {
  508. int j;
  509. FX_ENTRY("CCameraControlProperties::OnDeactivate")
  510. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  511. // Free the controls
  512. for (j = 0; j < m_NumProperties; j++)
  513. {
  514. if (m_Controls[j])
  515. {
  516. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: deleting m_Controls[%ld]=0x%08lX"), _fx_, j, m_Controls[j]));
  517. delete m_Controls[j], m_Controls[j] = NULL;
  518. }
  519. else
  520. {
  521. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: control already freed"), _fx_));
  522. }
  523. }
  524. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  525. return NOERROR;
  526. }
  527. /****************************************************************************
  528. * @doc INTERNAL CCAMERACPMETHOD
  529. *
  530. * @mfunc HRESULT | CCameraControlProperties | OnApplyChanges | This
  531. * method is called when the user applies changes to the property page.
  532. *
  533. * @rdesc This method returns an HRESULT value that depends on the
  534. * implementation of the interface. HRESULT can include one of the
  535. * following standard constants, or other values not listed:
  536. *
  537. * @flag E_FAIL | Failure
  538. * @flag E_POINTER | Null pointer argument
  539. * @flag E_NOTIMPL | Method is not supported
  540. * @flag NOERROR | No error
  541. ***************************************************************************/
  542. HRESULT CCameraControlProperties::OnApplyChanges()
  543. {
  544. HRESULT Hr = NOERROR;
  545. FX_ENTRY("CCameraControlProperties::OnApplyChanges")
  546. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  547. for (int j = 0; j < m_NumProperties; j++)
  548. {
  549. if (m_Controls[j])
  550. {
  551. if (m_Controls[j]->HasChanged())
  552. {
  553. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: calling m_Controls[%ld]=0x%08lX->OnApply"), _fx_, j, m_Controls[j]));
  554. m_Controls[j]->OnApply();
  555. }
  556. }
  557. else
  558. {
  559. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: can't call m_Controls[%ld]=NULL->OnApply"), _fx_, j));
  560. Hr = E_UNEXPECTED;
  561. break;
  562. }
  563. }
  564. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  565. return Hr;
  566. }
  567. /****************************************************************************
  568. * @doc INTERNAL CCAMERACPMETHOD
  569. *
  570. * @mfunc BOOL | CCameraControlProperties | BaseDlgProc | This
  571. * method is called when a message is sent to the property page dialog box.
  572. *
  573. * @rdesc By default, returns the value returned by the Win32 DefWindowProc function.
  574. ***************************************************************************/
  575. INT_PTR CALLBACK CCameraControlProperties::BaseDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  576. {
  577. CCameraControlProperties *pSV = (CCameraControlProperties*)GetWindowLong(hDlg, DWL_USER);
  578. int iNotify = HIWORD (wParam);
  579. int j;
  580. switch (uMsg)
  581. {
  582. case WM_INITDIALOG:
  583. {
  584. LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
  585. pSV = (CCameraControlProperties*)psp->lParam;
  586. pSV->m_hDlg = hDlg;
  587. SetWindowLong(hDlg, DWL_USER, (LPARAM)pSV);
  588. pSV->m_bInit = FALSE;
  589. pSV->OnActivate();
  590. pSV->m_bInit = TRUE;
  591. return TRUE;
  592. }
  593. break;
  594. case WM_HSCROLL:
  595. case WM_VSCROLL:
  596. if (pSV && pSV->m_bInit)
  597. {
  598. // Process all of the Trackbar messages
  599. for (j = 0; j < pSV->m_NumProperties; j++)
  600. {
  601. if (pSV->m_Controls[j]->GetTrackbarHWnd() == (HWND)lParam)
  602. {
  603. pSV->m_Controls[j]->OnScroll(uMsg, wParam, lParam);
  604. pSV->SetDirty();
  605. }
  606. }
  607. pSV->OnApplyChanges();
  608. }
  609. break;
  610. case WM_COMMAND:
  611. if (pSV && pSV->m_bInit)
  612. {
  613. // Process all of the auto checkbox messages
  614. for (j = 0; j < pSV->m_NumProperties; j++)
  615. {
  616. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetAutoHWnd() == (HWND)lParam)
  617. {
  618. pSV->m_Controls[j]->OnAuto(uMsg, wParam, lParam);
  619. pSV->SetDirty();
  620. break;
  621. }
  622. }
  623. // Process all of the edit box messages
  624. for (j = 0; j < pSV->m_NumProperties; j++)
  625. {
  626. if (pSV->m_Controls[j] && pSV->m_Controls[j]->GetEditHWnd() == (HWND)lParam)
  627. {
  628. pSV->m_Controls[j]->OnEdit(uMsg, wParam, lParam);
  629. pSV->SetDirty();
  630. break;
  631. }
  632. }
  633. switch (LOWORD(wParam))
  634. {
  635. case IDC_CONTROL_DEFAULT:
  636. for (j = 0; j < pSV->m_NumProperties; j++)
  637. {
  638. if (pSV->m_Controls[j])
  639. pSV->m_Controls[j]->OnDefault();
  640. }
  641. break;
  642. default:
  643. break;
  644. }
  645. pSV->OnApplyChanges();
  646. }
  647. break;
  648. default:
  649. return FALSE;
  650. }
  651. return TRUE;
  652. }
  653. /****************************************************************************
  654. * @doc INTERNAL CCAMERACPMETHOD
  655. *
  656. * @mfunc BOOL | CCameraControlProperties | SetDirty | This
  657. * method notifies the property page site of changes.
  658. *
  659. * @rdesc Nada.
  660. ***************************************************************************/
  661. void CCameraControlProperties::SetDirty()
  662. {
  663. PropSheet_Changed(GetParent(m_hDlg), m_hDlg);
  664. }