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.

874 lines
22 KiB

  1. /*
  2. * Copyright (c) 1996 1997, 1998 Philips CE I&C
  3. *
  4. * FILE PRPPAGE1.CPP
  5. * DATE 7-1-97
  6. * VERSION 1.00
  7. * AUTHOR M.J. Verberne
  8. * DESCRIPTION Property page 1
  9. * HISTORY
  10. */
  11. #include <windows.h>
  12. #include <winioctl.h>
  13. #include <ks.h>
  14. #include <ksmedia.h>
  15. #include <commctrl.h>
  16. #include "resource.h"
  17. #include "prpcom.h"
  18. #include "debug.h"
  19. #include "phvcmext.h"
  20. #include "prpctrl.h"
  21. #include "prppage1.h"
  22. /*======================== LOCAL DATA ====================================*/
  23. static BOOL bInitialized = FALSE;
  24. static BOOL bWB_Freeze = TRUE;
  25. static BOOL bAE_Freeze = TRUE;
  26. static VFWEXT_INFO VfWExtInfo;
  27. static char *Shutter_Speed_Strings[11] =
  28. {
  29. "1/10000", "1/5000",
  30. "1/2500", "1/1500",
  31. "1/1000", "1/500",
  32. "1/250", "1/100",
  33. "1/50", "1/33",
  34. "1/25",
  35. };
  36. static PRPCTRL WB_Red_Gain_Ctrl =
  37. {
  38. PRPCTRL_TYPE_SLIDER,
  39. IDS_WB_RED_GAIN,
  40. IDE_WB_RED_GAIN,
  41. IDT_WB_RED_GAIN,
  42. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  43. KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_RED_GAIN,
  44. FALSE,
  45. NULL,
  46. 0,
  47. 0
  48. };
  49. static PRPCTRL WB_Blue_Gain_Ctrl =
  50. {
  51. PRPCTRL_TYPE_SLIDER,
  52. IDS_WB_BLUE_GAIN,
  53. IDE_WB_BLUE_GAIN,
  54. IDT_WB_BLUE_GAIN,
  55. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  56. KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_BLUE_GAIN,
  57. FALSE,
  58. NULL,
  59. 0,
  60. 0
  61. };
  62. static PRPCTRL WB_Speed_Ctrl =
  63. {
  64. PRPCTRL_TYPE_SLIDER,
  65. IDS_WB_SPEED,
  66. IDE_WB_SPEED,
  67. IDT_WB_SPEED,
  68. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  69. KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_SPEED,
  70. TRUE,
  71. NULL,
  72. 0,
  73. 0
  74. };
  75. static PRPCTRL AE_AGC_Ctrl =
  76. {
  77. PRPCTRL_TYPE_SLIDER,
  78. IDS_AE_AGC,
  79. IDE_AE_AGC,
  80. IDT_AE_AGC,
  81. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  82. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC,
  83. FALSE,
  84. NULL,
  85. 0,
  86. 0
  87. };
  88. static PRPCTRL AE_Shutter_Speed_Ctrl =
  89. {
  90. PRPCTRL_TYPE_SLIDER,
  91. IDS_AE_SHUTTER_SPEED,
  92. IDE_AE_SHUTTER_SPEED,
  93. IDT_AE_SHUTTER_SPEED,
  94. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  95. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED,
  96. TRUE,
  97. Shutter_Speed_Strings,
  98. 0,
  99. 0
  100. };
  101. static PRPCTRL AE_Control_Speed_Ctrl =
  102. {
  103. PRPCTRL_TYPE_SLIDER,
  104. IDS_AE_CONTROL_SPEED,
  105. IDE_AE_CONTROL_SPEED,
  106. IDT_AE_CONTROL_SPEED,
  107. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  108. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_CONTROL_SPEED,
  109. TRUE,
  110. NULL,
  111. 0,
  112. 0
  113. };
  114. static PRPCTRL AE_FlickerlessCtrl =
  115. {
  116. PRPCTRL_TYPE_CHECKBOX,
  117. IDC_AE_FLICKERLESS,
  118. 0,
  119. 0,
  120. STATIC_PROPSETID_PHILIPS_CUSTOM_PROP,
  121. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS,
  122. FALSE,
  123. NULL,
  124. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS_OFF,
  125. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_FLICKERLESS_ON
  126. };
  127. /*======================== LOCAL FUNCTION DEFINITIONS ====================*/
  128. static INT_PTR CALLBACK PRPPAGE1_PageDlgProc(
  129. HWND hDlg,
  130. UINT uMessage,
  131. WPARAM wParam,
  132. LPARAM lParam);
  133. static UINT _stdcall PRPPAGE1_PageCallback(
  134. HWND hwnd,
  135. UINT uMsg,
  136. LPPROPSHEETPAGE ppsp);
  137. static BOOL PRPPAGE1_ExtSetActive(
  138. HWND hDlg,
  139. WPARAM wParam,
  140. LPARAM lParam);
  141. static BOOL PRPPAGE1_PageDlgProc_DoCommand(
  142. HWND hDlg,
  143. WPARAM wParam,
  144. LPARAM lParam);
  145. static BOOL PRPPAGE1_Init_WB(
  146. HWND hDlg,
  147. WPARAM wParam,
  148. LPARAM lParam);
  149. static BOOL PRPPAGE1_Init_AE(
  150. HWND hDlg,
  151. WPARAM wParam,
  152. LPARAM lParam);
  153. static BOOL PRPPAGE1_Handle_WB_Mode(
  154. HWND hDlg,
  155. WPARAM wParam,
  156. LPARAM lParam);
  157. static BOOL PRPPAGE1_Handle_AE_Mode(
  158. HWND hDlg,
  159. WPARAM wParam,
  160. LPARAM lParam);
  161. static BOOL PRPPAGE1_Handle_Slider(
  162. HWND hDlg,
  163. WPARAM wParam,
  164. LPARAM lParam);
  165. static BOOL PRPPAGE1_Handle_AE_Flickerless(
  166. HWND hDlg,
  167. WPARAM wParam,
  168. LPARAM lParam);
  169. static void PRPPAGE1_EnableControls(
  170. HWND hDlg,
  171. BOOL bEnable);
  172. static void PRPPAGE1_Handle_Err_Comm(
  173. HWND hDlg);
  174. static void PRPPAGE1_Handle_Err_Dev_Chg(
  175. HWND hDlg);
  176. /*======================== EXPORTED FUNCTIONS =============================*/
  177. /*-------------------------------------------------------------------------*/
  178. HPROPSHEETPAGE PRPPAGE1_CreatePage(
  179. LPFNEXTDEVIO pfnDeviceIoControl,
  180. LPARAM lParam,
  181. HINSTANCE hInst)
  182. /*-------------------------------------------------------------------------*/
  183. {
  184. PROPSHEETPAGE psPage;
  185. HPROPSHEETPAGE hPage;
  186. // save device info
  187. VfWExtInfo.pfnDeviceIoControl = pfnDeviceIoControl;
  188. VfWExtInfo.lParam = lParam;
  189. // create page
  190. psPage.dwSize = sizeof(psPage);
  191. psPage.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK;
  192. psPage.hInstance = hInst;
  193. psPage.pszTemplate = MAKEINTRESOURCE(IDD_VCM_NALA1);
  194. psPage.pszIcon = NULL;
  195. psPage.pfnDlgProc = PRPPAGE1_PageDlgProc;
  196. psPage.pcRefParent = 0;
  197. psPage.pfnCallback = (LPFNPSPCALLBACK) PRPPAGE1_PageCallback;
  198. psPage.lParam = (LPARAM) &VfWExtInfo;
  199. hPage = CreatePropertySheetPage(&psPage);
  200. return hPage;
  201. }
  202. /*======================== LOCAL FUNCTIONS ================================*/
  203. /*-------------------------------------------------------------------------*/
  204. static INT_PTR CALLBACK PRPPAGE1_PageDlgProc(
  205. HWND hDlg,
  206. UINT uMessage,
  207. WPARAM wParam,
  208. LPARAM lParam)
  209. /*-------------------------------------------------------------------------*/
  210. {
  211. switch (uMessage)
  212. {
  213. case WM_INITDIALOG:
  214. SetWindowLongPtr(hDlg,DWLP_USER, (LPARAM) &VfWExtInfo);
  215. return TRUE;
  216. case WM_COMMAND:
  217. return PRPPAGE1_PageDlgProc_DoCommand(hDlg, wParam, lParam);
  218. case WM_NOTIFY:
  219. if (((NMHDR FAR *)lParam)->code == PSN_SETACTIVE)
  220. return PRPPAGE1_ExtSetActive(hDlg, wParam, lParam);
  221. break;
  222. case WM_HSCROLL:
  223. PRPPAGE1_Handle_Slider(hDlg, wParam, lParam);
  224. return TRUE;
  225. }
  226. return FALSE; // default processing
  227. }
  228. /*-------------------------------------------------------------------------*/
  229. static UINT _stdcall PRPPAGE1_PageCallback(
  230. HWND hwnd,
  231. UINT uMsg,
  232. LPPROPSHEETPAGE ppsp)
  233. /*-------------------------------------------------------------------------*/
  234. {
  235. switch(uMsg)
  236. {
  237. case PSPCB_CREATE:
  238. return 1;
  239. case PSPCB_RELEASE:
  240. return 0;
  241. }
  242. return 0;
  243. }
  244. /*-------------------------------------------------------------------------*/
  245. static BOOL PRPPAGE1_ExtSetActive(
  246. HWND hDlg,
  247. WPARAM wParam,
  248. LPARAM lParam)
  249. /*-------------------------------------------------------------------------*/
  250. {
  251. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  252. BOOL bResult;
  253. // Open the device and initialize the controls
  254. if (PRPCOM_HasDeviceChanged(
  255. pVfWExtInfo->pfnDeviceIoControl,
  256. pVfWExtInfo->lParam))
  257. {
  258. // Oops, device is not the same anymore
  259. goto PRPPAGE1_ExtSetActive_Err_Dev_Chg;
  260. }
  261. // enable all controls
  262. PRPPAGE1_EnableControls(hDlg, TRUE);
  263. // initialize WB
  264. bResult = PRPPAGE1_Init_WB(hDlg, wParam, lParam);
  265. if (!bResult)
  266. goto PRPPAGE1_ExtSetActive_Err_Comm;
  267. // initialize AE
  268. bResult &= PRPPAGE1_Init_AE(hDlg, wParam, lParam);
  269. if (!bResult)
  270. goto PRPPAGE1_ExtSetActive_Err_Comm;
  271. // All ok
  272. bInitialized = TRUE;
  273. return TRUE;
  274. PRPPAGE1_ExtSetActive_Err_Dev_Chg:
  275. PRPPAGE1_Handle_Err_Dev_Chg(hDlg);
  276. return FALSE;
  277. PRPPAGE1_ExtSetActive_Err_Comm:
  278. PRPPAGE1_Handle_Err_Comm(hDlg);
  279. return FALSE;
  280. }
  281. /*-------------------------------------------------------------------------*/
  282. static BOOL PRPPAGE1_PageDlgProc_DoCommand(
  283. HWND hDlg,
  284. WPARAM wParam,
  285. LPARAM lParam)
  286. /*-------------------------------------------------------------------------*/
  287. {
  288. BOOL bResult;
  289. switch(LOWORD(wParam))
  290. {
  291. case IDR_WB_MODE_AUTO:
  292. case IDR_WB_MODE_FIXED:
  293. case IDR_WB_MODE_MANUAL:
  294. bResult = PRPPAGE1_Handle_WB_Mode(hDlg, wParam, lParam);
  295. if (!bResult)
  296. goto PRPPAGE1_PageDlgProc_DoCommand_Err_Comm;
  297. break;
  298. case IDR_AE_MODE_AUTO:
  299. case IDR_AE_MODE_FIXED:
  300. case IDR_AE_MODE_MANUAL:
  301. bResult = PRPPAGE1_Handle_AE_Mode(hDlg, wParam, lParam);
  302. if (!bResult)
  303. goto PRPPAGE1_PageDlgProc_DoCommand_Err_Comm;
  304. break;
  305. case IDC_AE_FLICKERLESS:
  306. bResult = PRPPAGE1_Handle_AE_Flickerless(hDlg, wParam, lParam);
  307. if (!bResult)
  308. goto PRPPAGE1_PageDlgProc_DoCommand_Err_Comm;
  309. break;
  310. default:
  311. return FALSE; // default processing
  312. }
  313. return TRUE; // message processed
  314. PRPPAGE1_PageDlgProc_DoCommand_Err_Comm:
  315. PRPPAGE1_Handle_Err_Comm(hDlg);
  316. return TRUE; // message processed
  317. }
  318. /*-------------------------------------------------------------------------*/
  319. static BOOL PRPPAGE1_Init_WB(
  320. HWND hDlg,
  321. WPARAM wParam,
  322. LPARAM lParam)
  323. /*-------------------------------------------------------------------------*/
  324. {
  325. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  326. LONG lWB_Mode;
  327. BOOL bResult, bAuto, bFreeze, bManual;
  328. // Get white balance mode from camera
  329. bResult = PRPCOM_Get_Value(
  330. PROPSETID_PHILIPS_CUSTOM_PROP,
  331. KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE,
  332. pVfWExtInfo->pfnDeviceIoControl,
  333. pVfWExtInfo->lParam,
  334. &lWB_Mode);
  335. if (!bResult)
  336. return FALSE;
  337. // check whitebalance mode
  338. switch(lWB_Mode)
  339. {
  340. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_INDOOR:
  341. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_OUTDOOR:
  342. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_TL:
  343. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_AUTO:
  344. case KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_MANUAL:
  345. break;
  346. default:
  347. return FALSE;
  348. }
  349. // switch to freeze mode if indoor, outdoor or tl
  350. // (these are not supported by the ui)
  351. if (lWB_Mode != KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_AUTO &&
  352. lWB_Mode != KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_MANUAL)
  353. {
  354. lWB_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_MANUAL;
  355. // Set new WhiteBalance mode
  356. bResult = PRPCOM_Set_Value(
  357. PROPSETID_PHILIPS_CUSTOM_PROP,
  358. KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE,
  359. pVfWExtInfo->pfnDeviceIoControl,
  360. pVfWExtInfo->lParam,
  361. lWB_Mode);
  362. if (!bResult)
  363. return FALSE;
  364. }
  365. // set radio buttons
  366. bAuto = lWB_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_AUTO;
  367. if (bInitialized)
  368. {
  369. bFreeze = !bAuto && bWB_Freeze;
  370. bManual = !bAuto && !bWB_Freeze;
  371. }
  372. else
  373. {
  374. // if not initialized assume fixed mode when not auto
  375. bFreeze = !bAuto;
  376. bManual = FALSE;
  377. }
  378. bWB_Freeze = bFreeze;
  379. SendMessage(GetDlgItem(hDlg, IDR_WB_MODE_AUTO),
  380. BM_SETCHECK, bAuto, 0);
  381. SendMessage(GetDlgItem(hDlg, IDR_WB_MODE_FIXED),
  382. BM_SETCHECK, bFreeze, 0);
  383. SendMessage(GetDlgItem(hDlg, IDR_WB_MODE_MANUAL),
  384. BM_SETCHECK, bManual, 0);
  385. // update controls
  386. bResult = PRPCTRL_Init(hDlg, &WB_Red_Gain_Ctrl, bManual);
  387. if (!bResult)
  388. return FALSE;
  389. bResult = PRPCTRL_Init(hDlg, &WB_Blue_Gain_Ctrl, bManual);
  390. if (!bResult)
  391. return FALSE;
  392. bResult = PRPCTRL_Init(hDlg, &WB_Speed_Ctrl, bAuto);
  393. if (!bResult)
  394. return FALSE;
  395. return TRUE;
  396. }
  397. /*-------------------------------------------------------------------------*/
  398. static BOOL PRPPAGE1_Init_AE(
  399. HWND hDlg,
  400. WPARAM wParam,
  401. LPARAM lParam)
  402. /*-------------------------------------------------------------------------*/
  403. {
  404. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  405. LONG lAE_Shutter_Mode, lAE_AGC_Mode;
  406. BOOL bResult, bAuto, bFreeze, bManual;;
  407. // Get Shutter Mode from camera
  408. bResult = PRPCOM_Get_Value(
  409. PROPSETID_PHILIPS_CUSTOM_PROP,
  410. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE,
  411. pVfWExtInfo->pfnDeviceIoControl,
  412. pVfWExtInfo->lParam,
  413. &lAE_Shutter_Mode);
  414. if (!bResult)
  415. return FALSE;
  416. // check Shutter Mode
  417. switch(lAE_Shutter_Mode)
  418. {
  419. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO:
  420. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED:
  421. break;
  422. default:
  423. return FALSE;
  424. }
  425. // Get AGC Mode from camera
  426. bResult = PRPCOM_Get_Value(
  427. PROPSETID_PHILIPS_CUSTOM_PROP,
  428. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE,
  429. pVfWExtInfo->pfnDeviceIoControl,
  430. pVfWExtInfo->lParam,
  431. &lAE_AGC_Mode);
  432. if (!bResult)
  433. return FALSE;
  434. // check AGC Mode
  435. switch(lAE_AGC_Mode)
  436. {
  437. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_AUTO:
  438. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED:
  439. break;
  440. default:
  441. return FALSE;
  442. }
  443. // Situation where Shutter Mode = Auto and AGC Mode = Fixed or vice versa
  444. // not supported. In those cases, switch to fixed
  445. if (lAE_Shutter_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO &&
  446. lAE_AGC_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED)
  447. {
  448. // Set Shutter Mode to Fixed
  449. bResult = PRPCOM_Set_Value(
  450. PROPSETID_PHILIPS_CUSTOM_PROP,
  451. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE,
  452. pVfWExtInfo->pfnDeviceIoControl,
  453. pVfWExtInfo->lParam,
  454. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED);
  455. if (!bResult)
  456. return FALSE;
  457. lAE_Shutter_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED;
  458. }
  459. else if (lAE_Shutter_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED &&
  460. lAE_AGC_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_AUTO)
  461. {
  462. // Set AGC Mode to Fixed
  463. bResult = PRPCOM_Set_Value(
  464. PROPSETID_PHILIPS_CUSTOM_PROP,
  465. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE,
  466. pVfWExtInfo->pfnDeviceIoControl,
  467. pVfWExtInfo->lParam,
  468. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED);
  469. if (!bResult)
  470. return FALSE;
  471. lAE_AGC_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED;
  472. }
  473. // set radio buttons
  474. bAuto = lAE_Shutter_Mode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO;
  475. if (bInitialized)
  476. {
  477. bFreeze = !bAuto && bAE_Freeze;
  478. bManual = !bAuto && !bAE_Freeze;
  479. }
  480. else
  481. {
  482. // if not initialized assume fixed mode when not auto
  483. bFreeze = !bAuto;
  484. bManual = FALSE;
  485. }
  486. bAE_Freeze = bFreeze;
  487. SendMessage(GetDlgItem(hDlg, IDR_AE_MODE_AUTO),
  488. BM_SETCHECK, bAuto, 0);
  489. SendMessage(GetDlgItem(hDlg, IDR_AE_MODE_FIXED),
  490. BM_SETCHECK, bFreeze, 0);
  491. SendMessage(GetDlgItem(hDlg, IDR_AE_MODE_MANUAL),
  492. BM_SETCHECK, bManual, 0);
  493. // update controls
  494. bResult = PRPCTRL_Init(hDlg, &AE_AGC_Ctrl, bManual);
  495. if (!bResult)
  496. return FALSE;
  497. bResult = PRPCTRL_Init(hDlg, &AE_Shutter_Speed_Ctrl, bManual);
  498. if (!bResult)
  499. return FALSE;
  500. bResult = PRPCTRL_Init(hDlg, &AE_Control_Speed_Ctrl, bAuto);
  501. if (!bResult)
  502. return FALSE;
  503. bResult = PRPCTRL_Init(hDlg, &AE_FlickerlessCtrl, bAuto);
  504. if (!bResult)
  505. return FALSE;
  506. return TRUE;
  507. }
  508. /*-------------------------------------------------------------------------*/
  509. static BOOL PRPPAGE1_Handle_WB_Mode(
  510. HWND hDlg,
  511. WPARAM wParam,
  512. LPARAM lParam)
  513. /*-------------------------------------------------------------------------*/
  514. {
  515. BOOL bResult = TRUE;
  516. LONG lWB_Mode;
  517. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  518. // Only process checked events for these radio buttons
  519. if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) != BST_CHECKED)
  520. return TRUE;
  521. // get new mode
  522. switch(LOWORD(wParam))
  523. {
  524. case IDR_WB_MODE_AUTO:
  525. lWB_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_AUTO;
  526. bWB_Freeze = FALSE;
  527. break;
  528. case IDR_WB_MODE_FIXED:
  529. lWB_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_MANUAL;
  530. bWB_Freeze = TRUE;
  531. break;
  532. case IDR_WB_MODE_MANUAL:
  533. lWB_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE_MANUAL;
  534. bWB_Freeze = FALSE;
  535. break;
  536. default:
  537. return FALSE;
  538. }
  539. // Set new WhiteBalance mode
  540. bResult = PRPCOM_Set_Value(
  541. PROPSETID_PHILIPS_CUSTOM_PROP,
  542. KSPROPERTY_PHILIPS_CUSTOM_PROP_WB_MODE,
  543. pVfWExtInfo->pfnDeviceIoControl,
  544. pVfWExtInfo->lParam,
  545. lWB_Mode);
  546. if (!bResult)
  547. return FALSE;
  548. // update controls
  549. bResult = PRPCTRL_Enable(hDlg, &WB_Red_Gain_Ctrl,
  550. LOWORD(wParam) == IDR_WB_MODE_MANUAL);
  551. if (!bResult)
  552. return FALSE;
  553. bResult = PRPCTRL_Enable(hDlg, &WB_Blue_Gain_Ctrl,
  554. LOWORD(wParam) == IDR_WB_MODE_MANUAL);
  555. if (!bResult)
  556. return FALSE;
  557. bResult = PRPCTRL_Enable(hDlg, &WB_Speed_Ctrl,
  558. LOWORD(wParam) == IDR_WB_MODE_AUTO);
  559. if (!bResult)
  560. return FALSE;
  561. return TRUE;
  562. }
  563. /*-------------------------------------------------------------------------*/
  564. static BOOL PRPPAGE1_Handle_AE_Mode(
  565. HWND hDlg,
  566. WPARAM wParam,
  567. LPARAM lParam)
  568. /*-------------------------------------------------------------------------*/
  569. {
  570. BOOL bResult = TRUE;
  571. LONG lAE_Shutter_Mode, lAE_AGC_Mode, lAE_Shutter_Speed;
  572. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  573. // Only process checked events for these radio buttons
  574. if (SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) != BST_CHECKED)
  575. return TRUE;
  576. // get new mode
  577. switch(LOWORD(wParam))
  578. {
  579. case IDR_AE_MODE_AUTO:
  580. lAE_Shutter_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO;
  581. lAE_AGC_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_AUTO;
  582. bAE_Freeze = FALSE;
  583. break;
  584. case IDR_AE_MODE_FIXED:
  585. lAE_Shutter_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED;
  586. lAE_AGC_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED;
  587. bAE_Freeze = TRUE;
  588. break;
  589. case IDR_AE_MODE_MANUAL:
  590. lAE_Shutter_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED;
  591. lAE_AGC_Mode = KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE_FIXED;
  592. bAE_Freeze = FALSE;
  593. break;
  594. default:
  595. return FALSE;
  596. }
  597. // Set new shutter mode
  598. bResult = PRPCOM_Set_Value(
  599. PROPSETID_PHILIPS_CUSTOM_PROP,
  600. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE,
  601. pVfWExtInfo->pfnDeviceIoControl,
  602. pVfWExtInfo->lParam,
  603. lAE_Shutter_Mode);
  604. if (!bResult)
  605. return FALSE;
  606. // Set new AGC Mode
  607. bResult = PRPCOM_Set_Value(
  608. PROPSETID_PHILIPS_CUSTOM_PROP,
  609. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_AGC_MODE,
  610. pVfWExtInfo->pfnDeviceIoControl,
  611. pVfWExtInfo->lParam,
  612. lAE_AGC_Mode);
  613. if (!bResult)
  614. return FALSE;
  615. // pitfall for shutter speed: if switched to manual
  616. // we must set the value to one of the 11 discrete
  617. // values available
  618. if (LOWORD(wParam) == IDR_AE_MODE_MANUAL)
  619. {
  620. // Get shutterspeed
  621. bResult = PRPCOM_Get_Value(
  622. PROPSETID_PHILIPS_CUSTOM_PROP,
  623. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED,
  624. pVfWExtInfo->pfnDeviceIoControl,
  625. pVfWExtInfo->lParam,
  626. &lAE_Shutter_Speed);
  627. if (!bResult)
  628. return FALSE;
  629. // Set shutterspeed
  630. bResult = PRPCOM_Set_Value(
  631. PROPSETID_PHILIPS_CUSTOM_PROP,
  632. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED,
  633. pVfWExtInfo->pfnDeviceIoControl,
  634. pVfWExtInfo->lParam,
  635. lAE_Shutter_Speed);
  636. if (!bResult)
  637. return FALSE;
  638. }
  639. // update controls
  640. bResult = PRPCTRL_Enable(hDlg, &AE_AGC_Ctrl,
  641. LOWORD(wParam) == IDR_AE_MODE_MANUAL);
  642. if (!bResult)
  643. return FALSE;
  644. bResult = PRPCTRL_Enable(hDlg, &AE_Shutter_Speed_Ctrl,
  645. LOWORD(wParam) == IDR_AE_MODE_MANUAL);
  646. if (!bResult)
  647. return FALSE;
  648. bResult = PRPCTRL_Enable(hDlg, &AE_Control_Speed_Ctrl,
  649. LOWORD(wParam) == IDR_AE_MODE_AUTO);
  650. if (!bResult)
  651. return FALSE;
  652. bResult = PRPCTRL_Enable(hDlg, &AE_FlickerlessCtrl,
  653. LOWORD(wParam) == IDR_AE_MODE_AUTO);
  654. if (!bResult)
  655. return FALSE;
  656. return TRUE;
  657. }
  658. /*-------------------------------------------------------------------------*/
  659. static BOOL PRPPAGE1_Handle_Slider(
  660. HWND hDlg,
  661. WPARAM wParam,
  662. LPARAM lParam)
  663. /*-------------------------------------------------------------------------*/
  664. {
  665. PRPCTRL_INFO *pCtrl;
  666. WORD Ctrl;
  667. BOOL bResult = TRUE;
  668. // only process when scrolling is done
  669. if (LOWORD(wParam) != SB_ENDSCROLL && LOWORD(wParam) != SB_THUMBTRACK)
  670. return TRUE;
  671. // get control id
  672. Ctrl = (WORD)GetWindowLong((HWND)lParam, GWL_ID);
  673. // get control object
  674. switch(Ctrl)
  675. {
  676. case IDS_WB_RED_GAIN:
  677. pCtrl = &WB_Red_Gain_Ctrl;
  678. break;
  679. case IDS_WB_BLUE_GAIN:
  680. pCtrl = &WB_Blue_Gain_Ctrl;
  681. break;
  682. case IDS_WB_SPEED:
  683. pCtrl = &WB_Speed_Ctrl;
  684. break;
  685. case IDS_AE_CONTROL_SPEED:
  686. pCtrl = &AE_Control_Speed_Ctrl;
  687. break;
  688. case IDS_AE_SHUTTER_SPEED:
  689. pCtrl = &AE_Shutter_Speed_Ctrl;
  690. break;
  691. case IDS_AE_AGC:
  692. pCtrl = &AE_AGC_Ctrl;
  693. break;
  694. default:
  695. return FALSE;
  696. }
  697. // process the message
  698. bResult = PRPCTRL_Handle_Msg(hDlg, pCtrl);
  699. if (!bResult)
  700. goto PRPPAGE1_Handle_Slider_Err_Comm;
  701. return TRUE;
  702. PRPPAGE1_Handle_Slider_Err_Comm:
  703. PRPPAGE1_Handle_Err_Comm(hDlg);
  704. return TRUE; // message processed
  705. }
  706. /*-------------------------------------------------------------------------*/
  707. static BOOL PRPPAGE1_Handle_AE_Flickerless(
  708. HWND hDlg,
  709. WPARAM wParam,
  710. LPARAM lParam)
  711. /*-------------------------------------------------------------------------*/
  712. {
  713. PRPCTRL_INFO *pCtrl;
  714. BOOL bResult;
  715. // get control object
  716. pCtrl = &AE_FlickerlessCtrl;
  717. // process the message
  718. bResult = PRPCTRL_Handle_Msg(hDlg, pCtrl);
  719. if (!bResult)
  720. return FALSE;
  721. return TRUE;
  722. }
  723. /*-------------------------------------------------------------------------*/
  724. static void PRPPAGE1_EnableControls(
  725. HWND hDlg,
  726. BOOL bEnable)
  727. /*-------------------------------------------------------------------------*/
  728. {
  729. static WORD Controls[] =
  730. {
  731. IDR_WB_MODE_AUTO, IDR_WB_MODE_FIXED,
  732. IDR_WB_MODE_MANUAL, IDR_AE_MODE_AUTO,
  733. IDR_AE_MODE_FIXED, IDR_AE_MODE_MANUAL,
  734. IDS_WB_SPEED, IDS_WB_RED_GAIN,
  735. IDS_WB_BLUE_GAIN, IDS_AE_AGC,
  736. IDS_AE_SHUTTER_SPEED, IDS_AE_CONTROL_SPEED,
  737. IDE_WB_SPEED, IDE_WB_RED_GAIN,
  738. IDE_WB_BLUE_GAIN, IDE_AE_AGC,
  739. IDE_AE_SHUTTER_SPEED, IDE_AE_CONTROL_SPEED,
  740. IDC_AE_FLICKERLESS,
  741. IDT_WB_MODE, IDT_WB_SPEED,
  742. IDT_WB_RED_GAIN, IDT_WB_BLUE_GAIN,
  743. IDT_WB, IDT_AE_MODE,
  744. IDT_AE_AGC, IDT_AE_SHUTTER_SPEED,
  745. IDT_AE, IDT_AE_CONTROL_SPEED,
  746. 0
  747. };
  748. int i = 0;
  749. while(Controls[i] != 0)
  750. EnableWindow(GetDlgItem(hDlg, Controls[i++]), bEnable);
  751. }
  752. /*-------------------------------------------------------------------------*/
  753. static void PRPPAGE1_Handle_Err_Comm(
  754. HWND hDlg)
  755. /*-------------------------------------------------------------------------*/
  756. {
  757. char Msg_Err_Comm[132] = "";
  758. // disable everything
  759. PRPPAGE1_EnableControls(hDlg, FALSE);
  760. // load the message text from resource
  761. LoadString(hInst, IDS_MSG_ERR_COMM, Msg_Err_Comm, 132);
  762. // notify the user
  763. MessageBox(hDlg, Msg_Err_Comm,"Error", MB_OK | MB_ICONERROR);
  764. }
  765. /*-------------------------------------------------------------------------*/
  766. static void PRPPAGE1_Handle_Err_Dev_Chg(
  767. HWND hDlg)
  768. /*-------------------------------------------------------------------------*/
  769. {
  770. char Msg_Err_Dev_Chg[132] = "";
  771. // disable everything
  772. PRPPAGE1_EnableControls(hDlg, FALSE);
  773. // load the message text from resource
  774. LoadString(hInst, IDS_MSG_ERR_DEV_CHG, Msg_Err_Dev_Chg, 132);
  775. // notify the user
  776. MessageBox(hDlg, Msg_Err_Dev_Chg,"Warning", MB_OK);
  777. }