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.

901 lines
23 KiB

  1. /*
  2. * Copyright (c) 1996 1997, 1998 Philips CE I&C
  3. *
  4. * FILE PRPPAGE2.CPP
  5. * DATE 7-1-97
  6. * VERSION 1.00
  7. * AUTHOR M.J. Verberne
  8. * DESCRIPTION Property page 1
  9. * HISTORY
  10. *
  11. */
  12. #include <windows.h>
  13. #include <winioctl.h>
  14. #include <ks.h>
  15. #include <ksmedia.h>
  16. #include "resource.h"
  17. #include "prpcom.h"
  18. #include "prpctrl.h"
  19. #include "debug.h"
  20. #include "phvcmext.h"
  21. #include "prppage2.h"
  22. /*-- Data types ----------------------------------------------------------*/
  23. /*-- Local data definitions ----------------------------------------------*/
  24. static VFWEXT_INFO VfWExtInfo;
  25. static PRPCTRL Brightness_Ctrl =
  26. {
  27. PRPCTRL_TYPE_SLIDER,
  28. IDS_BRIGHTNESS,
  29. IDE_BRIGHTNESS,
  30. IDT_BRIGHTNESS,
  31. STATIC_PROPSETID_VIDCAP_VIDEOPROCAMP,
  32. KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS,
  33. FALSE,
  34. NULL,
  35. 0,
  36. 0
  37. };
  38. static PRPCTRL Contrast_Ctrl =
  39. {
  40. PRPCTRL_TYPE_SLIDER,
  41. IDS_CONTRAST,
  42. IDE_CONTRAST,
  43. IDT_CONTRAST,
  44. STATIC_PROPSETID_VIDCAP_VIDEOPROCAMP,
  45. KSPROPERTY_VIDEOPROCAMP_CONTRAST,
  46. FALSE,
  47. NULL,
  48. 0,
  49. 0
  50. };
  51. static PRPCTRL Gamma_Ctrl =
  52. {
  53. PRPCTRL_TYPE_SLIDER,
  54. IDS_GAMMA,
  55. IDE_GAMMA,
  56. IDT_GAMMA,
  57. STATIC_PROPSETID_VIDCAP_VIDEOPROCAMP,
  58. KSPROPERTY_VIDEOPROCAMP_GAMMA,
  59. FALSE,
  60. NULL,
  61. 0,
  62. 0
  63. };
  64. static PRPCTRL ColorEnable_Ctrl =
  65. {
  66. PRPCTRL_TYPE_CHECKBOX,
  67. IDC_COLORENABLE,
  68. 0,
  69. 0,
  70. STATIC_PROPSETID_VIDCAP_VIDEOPROCAMP,
  71. KSPROPERTY_VIDEOPROCAMP_COLORENABLE,
  72. FALSE,
  73. NULL,
  74. 0,
  75. 0xff
  76. };
  77. static PRPCTRL BackLight_Compensation_Ctrl =
  78. {
  79. PRPCTRL_TYPE_CHECKBOX,
  80. IDC_BACKLIGHT_COMPENSATION,
  81. 0,
  82. 0,
  83. STATIC_PROPSETID_VIDCAP_VIDEOPROCAMP,
  84. KSPROPERTY_VIDEOPROCAMP_BACKLIGHT_COMPENSATION,
  85. FALSE,
  86. NULL,
  87. 0,
  88. 0xff
  89. };
  90. /*-- Local function definitions ------------------------------------------*/
  91. static INT_PTR CALLBACK PRPPAGE2_PageDlgProc(
  92. HWND hDlg,
  93. UINT uMessage,
  94. WPARAM wParam,
  95. LPARAM lParam);
  96. static UINT _stdcall PRPPAGE2_PageCallback(
  97. HWND hwnd,
  98. UINT uMsg,
  99. LPPROPSHEETPAGE ppsp);
  100. static BOOL PRPPAGE2_ExtSetActive(
  101. HWND hDlg,
  102. WPARAM wParam,
  103. LPARAM lParam);
  104. static BOOL PRPPAGE2_PageDlgProc_DoCommand(
  105. HWND hDlg,
  106. WPARAM wParam,
  107. LPARAM lParam);
  108. static BOOL PRPPAGE2_Init_Framerate(
  109. HWND hDlg,
  110. WPARAM wParam,
  111. LPARAM lParam);
  112. static BOOL PRPPAGE2_Init_ImageControls(
  113. HWND hDlg,
  114. WPARAM wParam,
  115. LPARAM lParam);
  116. static BOOL PRPPAGE2_Init_Defaults(
  117. HWND hDlg,
  118. WPARAM wParam,
  119. LPARAM lParam);
  120. static BOOL PRPPAGE2_Handle_Framerate(
  121. HWND hDlg,
  122. WPARAM wParam,
  123. LPARAM lParam);
  124. static BOOL PRPPAGE2_Handle_Slider(
  125. HWND hDlg,
  126. WPARAM wParam,
  127. LPARAM lParam);
  128. static BOOL PRPPAGE2_Handle_CheckBox(
  129. HWND hDlg,
  130. WPARAM wParam,
  131. LPARAM lParam);
  132. static BOOL PRPPAGE2_Handle_Defaults(
  133. HWND hDlg,
  134. WPARAM wParam,
  135. LPARAM lParam);
  136. static BOOL PRPPAGE2_Get_Framerate_Ctrl(
  137. HWND hDlg,
  138. BOOL bVGA,
  139. LONG lFramerate,
  140. WORD *pCtrl_Id);
  141. static BOOL PRPPAGE2_Get_Framerate_Value(
  142. HWND hDlg,
  143. PLONG plFramerate,
  144. WORD Ctrl_Id);
  145. static void PRPPAGE2_EnableControls(
  146. HWND hDlg,
  147. BOOL bEnable);
  148. static void PRPPAGE2_Handle_Err_Comm(
  149. HWND hDlg);
  150. static void PRPPAGE2_Handle_Err_Dev_Chg(
  151. HWND hDlg);
  152. /*======================== EXPORTED FUNCTIONS =============================*/
  153. /*-------------------------------------------------------------------------*/
  154. HPROPSHEETPAGE PRPPAGE2_CreatePage(
  155. LPFNEXTDEVIO pfnDeviceIoControl,
  156. LPARAM lParam,
  157. HINSTANCE hInst)
  158. /*-------------------------------------------------------------------------*/
  159. {
  160. PROPSHEETPAGE psPage;
  161. HPROPSHEETPAGE hPage;
  162. // save device info
  163. VfWExtInfo.pfnDeviceIoControl = pfnDeviceIoControl;
  164. VfWExtInfo.lParam = lParam;
  165. // create page
  166. psPage.dwSize = sizeof(psPage);
  167. psPage.dwFlags = PSP_USEREFPARENT | PSP_USECALLBACK;
  168. psPage.hInstance = hInst;
  169. psPage.pszTemplate = MAKEINTRESOURCE(IDD_VCM_NALA2);
  170. psPage.pszIcon = NULL;
  171. psPage.pfnDlgProc = PRPPAGE2_PageDlgProc;
  172. psPage.pcRefParent = 0;
  173. psPage.pfnCallback = (LPFNPSPCALLBACK) PRPPAGE2_PageCallback;
  174. psPage.lParam = (LPARAM) &VfWExtInfo;
  175. hPage = CreatePropertySheetPage(&psPage);
  176. return hPage;
  177. }
  178. /*-- Local functions ------------------------------------------------------*/
  179. /*-------------------------------------------------------------------------*/
  180. static INT_PTR CALLBACK PRPPAGE2_PageDlgProc(
  181. HWND hDlg,
  182. UINT uMessage,
  183. WPARAM wParam,
  184. LPARAM lParam)
  185. /*-------------------------------------------------------------------------*/
  186. {
  187. switch (uMessage)
  188. {
  189. case WM_INITDIALOG:
  190. SetWindowLongPtr(hDlg,DWLP_USER, (LPARAM) &VfWExtInfo);
  191. return TRUE;
  192. case WM_COMMAND:
  193. return PRPPAGE2_PageDlgProc_DoCommand(hDlg, wParam, lParam);
  194. case WM_NOTIFY:
  195. if (((NMHDR FAR *)lParam)->code == PSN_SETACTIVE)
  196. return PRPPAGE2_ExtSetActive(hDlg, wParam, lParam);
  197. break;
  198. case WM_HSCROLL:
  199. PRPPAGE2_Handle_Slider(hDlg, wParam, lParam);
  200. return TRUE;
  201. }
  202. return FALSE; // default processing
  203. }
  204. /*-------------------------------------------------------------------------*/
  205. static UINT _stdcall PRPPAGE2_PageCallback(
  206. HWND hwnd,
  207. UINT uMsg,
  208. LPPROPSHEETPAGE ppsp)
  209. /*-------------------------------------------------------------------------*/
  210. {
  211. switch(uMsg)
  212. {
  213. case PSPCB_CREATE:
  214. return 1;
  215. case PSPCB_RELEASE:
  216. return 0;
  217. }
  218. return 0;
  219. }
  220. /*-------------------------------------------------------------------------*/
  221. static int PRPPAGE2_ExtSetActive(
  222. HWND hDlg,
  223. WPARAM wParam,
  224. LPARAM lParam)
  225. /*-------------------------------------------------------------------------*/
  226. {
  227. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  228. BOOL bResult;
  229. // Open the device and initialize the controls
  230. if (PRPCOM_HasDeviceChanged(
  231. pVfWExtInfo->pfnDeviceIoControl,
  232. pVfWExtInfo->lParam))
  233. {
  234. // Oops, device is not the same anymore
  235. goto PRPPAGE2_ExtSetActive_Err_Dev_Chg;
  236. }
  237. // enable all controls
  238. PRPPAGE2_EnableControls(hDlg, TRUE);
  239. // initialize Framerate
  240. bResult = PRPPAGE2_Init_Framerate(hDlg, wParam, lParam);
  241. if (!bResult)
  242. goto PRPPAGE2_ExtSetActive_Err_Comm;
  243. // initialize Image controls
  244. bResult = PRPPAGE2_Init_ImageControls(hDlg, wParam, lParam);
  245. if (!bResult)
  246. goto PRPPAGE2_ExtSetActive_Err_Comm;
  247. // initialize Defaults
  248. bResult = PRPPAGE2_Init_Defaults(hDlg, wParam, lParam);
  249. if (!bResult)
  250. goto PRPPAGE2_ExtSetActive_Err_Comm;
  251. return TRUE;
  252. PRPPAGE2_ExtSetActive_Err_Dev_Chg:
  253. PRPPAGE2_Handle_Err_Dev_Chg(hDlg);
  254. return FALSE;
  255. PRPPAGE2_ExtSetActive_Err_Comm:
  256. PRPPAGE2_Handle_Err_Comm(hDlg);
  257. return FALSE;
  258. }
  259. /*-------------------------------------------------------------------------*/
  260. static BOOL PRPPAGE2_PageDlgProc_DoCommand(
  261. HWND hDlg,
  262. WPARAM wParam,
  263. LPARAM lParam)
  264. /*-------------------------------------------------------------------------*/
  265. {
  266. BOOL bResult;
  267. switch(LOWORD(wParam))
  268. {
  269. case IDR_FRAMERATE_VGA_375:
  270. case IDR_FRAMERATE_MR_375:
  271. case IDR_FRAMERATE_VGA_5:
  272. case IDR_FRAMERATE_MR_5:
  273. case IDR_FRAMERATE_VGA_75:
  274. case IDR_FRAMERATE_MR_75:
  275. case IDR_FRAMERATE_VGA_10:
  276. case IDR_FRAMERATE_MR_10:
  277. case IDR_FRAMERATE_MR_12:
  278. case IDR_FRAMERATE_VGA_15:
  279. case IDR_FRAMERATE_MR_15:
  280. case IDR_FRAMERATE_VGA_20:
  281. case IDR_FRAMERATE_MR_20:
  282. case IDR_FRAMERATE_VGA_24:
  283. case IDR_FRAMERATE_MR_24:
  284. bResult = PRPPAGE2_Handle_Framerate(hDlg, wParam, lParam);
  285. if (!bResult)
  286. goto PRPPAGE2_PageDlgProc_DoCommand_Err_Comm;
  287. break;
  288. case IDC_COLORENABLE:
  289. case IDC_BACKLIGHT_COMPENSATION:
  290. bResult = PRPPAGE2_Handle_CheckBox(hDlg, wParam, lParam);
  291. if (!bResult)
  292. goto PRPPAGE2_PageDlgProc_DoCommand_Err_Comm;
  293. break;
  294. case IDB_RESTORE_UD:
  295. case IDB_RESTORE_FD:
  296. case IDB_SAVE_UD:
  297. bResult = PRPPAGE2_Handle_Defaults(hDlg, wParam, lParam);
  298. if (!bResult)
  299. goto PRPPAGE2_PageDlgProc_DoCommand_Err_Comm;
  300. break;
  301. default:
  302. return FALSE; // default processing
  303. }
  304. return TRUE; // message processed
  305. PRPPAGE2_PageDlgProc_DoCommand_Err_Comm:
  306. PRPPAGE2_Handle_Err_Comm(hDlg);
  307. return TRUE; // message processed
  308. }
  309. /*-------------------------------------------------------------------------*/
  310. static BOOL PRPPAGE2_Init_Framerate(
  311. HWND hDlg,
  312. WPARAM wParam,
  313. LPARAM lParam)
  314. /*-------------------------------------------------------------------------*/
  315. {
  316. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  317. BOOL bResult = TRUE, bVGA;
  318. LONG lSensorType, lFramerate, lFramerates_Supported;
  319. WORD Ctrl_Id;
  320. WORD VGA_Button_Ids[7] = {
  321. IDR_FRAMERATE_VGA_375, IDR_FRAMERATE_VGA_5,
  322. IDR_FRAMERATE_VGA_75, IDR_FRAMERATE_VGA_10,
  323. IDR_FRAMERATE_VGA_15, IDR_FRAMERATE_VGA_20,
  324. IDR_FRAMERATE_VGA_24 };
  325. WORD MR_Button_Ids[8] = {
  326. IDR_FRAMERATE_MR_375, IDR_FRAMERATE_MR_5,
  327. IDR_FRAMERATE_MR_75, IDR_FRAMERATE_MR_10,
  328. IDR_FRAMERATE_MR_12, IDR_FRAMERATE_MR_15,
  329. IDR_FRAMERATE_MR_20, IDR_FRAMERATE_MR_24 };
  330. int VGA_Bits[7] = { 1, 2, 3, 4, 6, 7, 8 };
  331. int MR_Bits[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
  332. int i;
  333. // get sensortype from camera
  334. bResult = PRPCOM_Get_Value(
  335. PROPSETID_PHILIPS_CUSTOM_PROP,
  336. KSPROPERTY_PHILIPS_CUSTOM_PROP_SENSORTYPE,
  337. pVfWExtInfo->pfnDeviceIoControl,
  338. pVfWExtInfo->lParam,
  339. &lSensorType);
  340. if (!bResult)
  341. return FALSE;
  342. // check sensortype
  343. switch(lSensorType)
  344. {
  345. case KSPROPERTY_PHILIPS_CUSTOM_PROP_SENSORTYPE_PAL_MR:
  346. bVGA = FALSE;
  347. break;
  348. case KSPROPERTY_PHILIPS_CUSTOM_PROP_SENSORTYPE_VGA:
  349. bVGA = TRUE;
  350. break;
  351. default:
  352. return FALSE;
  353. }
  354. // hide / show control set
  355. for (i = 0; i < 7; i++)
  356. ShowWindow(GetDlgItem(hDlg, VGA_Button_Ids[i]), bVGA ? SW_SHOW: SW_HIDE);
  357. for (i = 0; i < 8; i++)
  358. ShowWindow(GetDlgItem(hDlg, MR_Button_Ids[i]), bVGA ? SW_HIDE : SW_SHOW);
  359. // reset framerate controls
  360. if (bVGA)
  361. for (i = 0; i < 7; i++)
  362. SendMessage(GetDlgItem(hDlg, VGA_Button_Ids[i]), BM_SETCHECK, 0, 0);
  363. else
  364. for (i = 0; i < 8; i++)
  365. SendMessage(GetDlgItem(hDlg, MR_Button_Ids[i]), BM_SETCHECK, 0, 0);
  366. // get framerate from camera
  367. bResult = PRPCOM_Get_Value(
  368. PROPSETID_PHILIPS_CUSTOM_PROP,
  369. KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE,
  370. pVfWExtInfo->pfnDeviceIoControl,
  371. pVfWExtInfo->lParam,
  372. &lFramerate);
  373. if (!bResult)
  374. return FALSE;
  375. // get control id associated with the framerate and sensortype
  376. bResult = PRPPAGE2_Get_Framerate_Ctrl(hDlg, bVGA, lFramerate, &Ctrl_Id);
  377. if (!bResult)
  378. return FALSE;
  379. if (Ctrl_Id)
  380. SendMessage(GetDlgItem(hDlg, Ctrl_Id), BM_SETCHECK, 1, 0);
  381. // get supported framerates
  382. bResult = PRPCOM_Get_Value(
  383. PROPSETID_PHILIPS_CUSTOM_PROP,
  384. KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATES_SUPPORTED,
  385. pVfWExtInfo->pfnDeviceIoControl,
  386. pVfWExtInfo->lParam,
  387. &lFramerates_Supported);
  388. if (!bResult)
  389. return FALSE;
  390. // enable / disable controls
  391. if (bVGA)
  392. for (i = 0; i < 7; i++)
  393. EnableWindow(GetDlgItem(hDlg, VGA_Button_Ids[i]), lFramerates_Supported & (0x1 << VGA_Bits[i]));
  394. else
  395. for (i = 0; i < 8; i++)
  396. EnableWindow(GetDlgItem(hDlg, MR_Button_Ids[i]), lFramerates_Supported & (0x1 << MR_Bits[i]));
  397. // 10 hz not supported in 1st silicium
  398. // PRPPAGE2_Get_Framerate_Ctrl(
  399. // hDlg,
  400. // bVGA,
  401. // KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_10,
  402. // &Ctrl_Id);
  403. // EnableWindow(GetDlgItem(hDlg, Ctrl_Id), FALSE);
  404. return TRUE;
  405. }
  406. /*-------------------------------------------------------------------------*/
  407. static BOOL PRPPAGE2_Init_ImageControls(
  408. HWND hDlg,
  409. WPARAM wParam,
  410. LPARAM lParam)
  411. /*-------------------------------------------------------------------------*/
  412. {
  413. BOOL bResult;
  414. LONG lEXP_ShutterMode;
  415. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  416. // Get Shutter Mode from camera
  417. bResult = PRPCOM_Get_Value(
  418. PROPSETID_PHILIPS_CUSTOM_PROP,
  419. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE,
  420. pVfWExtInfo->pfnDeviceIoControl,
  421. pVfWExtInfo->lParam,
  422. &lEXP_ShutterMode);
  423. if (!bResult)
  424. return FALSE;
  425. // check Shutter Mode
  426. switch(lEXP_ShutterMode)
  427. {
  428. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO:
  429. case KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_FIXED:
  430. break;
  431. default:
  432. return FALSE;
  433. }
  434. // update controls
  435. bResult = PRPCTRL_Init(hDlg, &Brightness_Ctrl, TRUE);
  436. if (!bResult)
  437. return FALSE;
  438. bResult = PRPCTRL_Init(hDlg, &Contrast_Ctrl,
  439. lEXP_ShutterMode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO);
  440. if (!bResult)
  441. return FALSE;
  442. bResult = PRPCTRL_Init(hDlg, &Gamma_Ctrl, TRUE);
  443. if (!bResult)
  444. return FALSE;
  445. bResult = PRPCTRL_Init(hDlg, &ColorEnable_Ctrl, TRUE);
  446. if (!bResult)
  447. return FALSE;
  448. bResult = PRPCTRL_Init(hDlg, &BackLight_Compensation_Ctrl,
  449. lEXP_ShutterMode == KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_MODE_AUTO);
  450. if (!bResult)
  451. return FALSE;
  452. return TRUE;
  453. }
  454. /*-------------------------------------------------------------------------*/
  455. static BOOL PRPPAGE2_Init_Defaults(
  456. HWND hDlg,
  457. WPARAM wParam,
  458. LPARAM lParam)
  459. /*-------------------------------------------------------------------------*/
  460. {
  461. // nothing to do
  462. return TRUE;
  463. }
  464. /*-------------------------------------------------------------------------*/
  465. static BOOL PRPPAGE2_Handle_Framerate(
  466. HWND hDlg,
  467. WPARAM wParam,
  468. LPARAM lParam)
  469. /*-------------------------------------------------------------------------*/
  470. {
  471. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  472. BOOL bResult;
  473. LONG lFramerate, lShutter_Speed;
  474. // get value corresponding to control id
  475. bResult = PRPPAGE2_Get_Framerate_Value(
  476. hDlg,
  477. &lFramerate,
  478. LOWORD(wParam));
  479. if (!bResult)
  480. return FALSE;
  481. // Save current Shutterspeed and shutter status
  482. bResult = PRPCOM_Get_Value(
  483. PROPSETID_PHILIPS_CUSTOM_PROP,
  484. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED,
  485. pVfWExtInfo->pfnDeviceIoControl,
  486. pVfWExtInfo->lParam,
  487. &lShutter_Speed);
  488. if (!bResult)
  489. return FALSE;
  490. // Set new framerate
  491. bResult = PRPCOM_Set_Value(
  492. PROPSETID_PHILIPS_CUSTOM_PROP,
  493. KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE,
  494. pVfWExtInfo->pfnDeviceIoControl,
  495. pVfWExtInfo->lParam,
  496. lFramerate);
  497. if (!bResult)
  498. return FALSE;
  499. // Set shutterspeed back to old value
  500. bResult = PRPCOM_Set_Value(
  501. PROPSETID_PHILIPS_CUSTOM_PROP,
  502. KSPROPERTY_PHILIPS_CUSTOM_PROP_AE_SHUTTER_SPEED,
  503. pVfWExtInfo->pfnDeviceIoControl,
  504. pVfWExtInfo->lParam,
  505. lShutter_Speed);
  506. if (!bResult)
  507. return FALSE;
  508. return TRUE;
  509. }
  510. /*-------------------------------------------------------------------------*/
  511. static BOOL PRPPAGE2_Handle_Slider(
  512. HWND hDlg,
  513. WPARAM wParam,
  514. LPARAM lParam)
  515. /*-------------------------------------------------------------------------*/
  516. {
  517. PRPCTRL_INFO *pCtrl;
  518. WORD Ctrl;
  519. BOOL bResult = TRUE;
  520. // only process when scrolling is done
  521. if (LOWORD(wParam) != SB_ENDSCROLL && LOWORD(wParam) != SB_THUMBTRACK)
  522. return TRUE;
  523. // get control id
  524. Ctrl = (WORD)GetWindowLong((HWND)lParam, GWL_ID);
  525. // get control object
  526. switch(Ctrl)
  527. {
  528. case IDS_BRIGHTNESS:
  529. pCtrl = &Brightness_Ctrl;
  530. break;
  531. case IDS_CONTRAST:
  532. pCtrl = &Contrast_Ctrl;
  533. break;
  534. case IDS_GAMMA:
  535. pCtrl = &Gamma_Ctrl;
  536. break;
  537. default:
  538. return FALSE;
  539. }
  540. // process the message
  541. bResult = PRPCTRL_Handle_Msg(hDlg, pCtrl);
  542. if (!bResult)
  543. goto PRPPAGE2_Handle_Slider_Err_Comm;
  544. return TRUE;
  545. PRPPAGE2_Handle_Slider_Err_Comm:
  546. PRPPAGE2_Handle_Err_Comm(hDlg);
  547. return FALSE;
  548. }
  549. /*-------------------------------------------------------------------------*/
  550. static BOOL PRPPAGE2_Handle_CheckBox(
  551. HWND hDlg,
  552. WPARAM wParam,
  553. LPARAM lParam)
  554. /*-------------------------------------------------------------------------*/
  555. {
  556. PRPCTRL_INFO *pCtrl;
  557. BOOL bResult;
  558. WORD Ctrl;
  559. // get control id
  560. Ctrl = (WORD)GetWindowLong((HWND)lParam, GWL_ID);
  561. // get control object
  562. switch(Ctrl)
  563. {
  564. case IDC_COLORENABLE:
  565. pCtrl = &ColorEnable_Ctrl;
  566. break;
  567. case IDC_BACKLIGHT_COMPENSATION:
  568. pCtrl = &BackLight_Compensation_Ctrl;
  569. break;
  570. default:
  571. return FALSE;
  572. }
  573. // process the message
  574. bResult = PRPCTRL_Handle_Msg(hDlg, pCtrl);
  575. if (!bResult)
  576. return FALSE;
  577. return TRUE;
  578. }
  579. /*-------------------------------------------------------------------------*/
  580. static BOOL PRPPAGE2_Handle_Defaults(
  581. HWND hDlg,
  582. WPARAM wParam,
  583. LPARAM lParam)
  584. /*-------------------------------------------------------------------------*/
  585. {
  586. BOOL bResult;
  587. PVFWEXT_INFO pVfWExtInfo = (PVFWEXT_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  588. switch(LOWORD(wParam))
  589. {
  590. case IDB_RESTORE_UD:
  591. bResult = PRPCOM_Set_Value(
  592. PROPSETID_PHILIPS_CUSTOM_PROP,
  593. KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS,
  594. pVfWExtInfo->pfnDeviceIoControl,
  595. pVfWExtInfo->lParam,
  596. KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS_RESTORE_USER);
  597. if (!bResult)
  598. return FALSE;
  599. break;
  600. case IDB_RESTORE_FD:
  601. bResult = PRPCOM_Set_Value(
  602. PROPSETID_PHILIPS_CUSTOM_PROP,
  603. KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS,
  604. pVfWExtInfo->pfnDeviceIoControl,
  605. pVfWExtInfo->lParam,
  606. KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS_RESTORE_FACTORY);
  607. if (!bResult)
  608. return FALSE;
  609. break;
  610. case IDB_SAVE_UD:
  611. bResult = PRPCOM_Set_Value(
  612. PROPSETID_PHILIPS_CUSTOM_PROP,
  613. KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS,
  614. pVfWExtInfo->pfnDeviceIoControl,
  615. pVfWExtInfo->lParam,
  616. KSPROPERTY_PHILIPS_CUSTOM_PROP_DEFAULTS_SAVE_USER);
  617. if (!bResult)
  618. return FALSE;
  619. break;
  620. default:
  621. return FALSE;
  622. }
  623. // reinitialize the property page
  624. bResult = PRPPAGE2_ExtSetActive(hDlg, wParam, lParam);
  625. if (!bResult)
  626. return FALSE;
  627. return TRUE;
  628. }
  629. /*-------------------------------------------------------------------------*/
  630. static BOOL PRPPAGE2_Get_Framerate_Ctrl(
  631. HWND hDlg,
  632. BOOL bVGA,
  633. LONG lFramerate,
  634. WORD *pCtrl_Id)
  635. /*-------------------------------------------------------------------------*/
  636. {
  637. if (bVGA)
  638. {
  639. switch(lFramerate)
  640. {
  641. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_VGA:
  642. (*pCtrl_Id) = 0;
  643. break;
  644. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_375:
  645. (*pCtrl_Id) = IDR_FRAMERATE_VGA_375;
  646. break;
  647. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_5:
  648. (*pCtrl_Id) = IDR_FRAMERATE_VGA_5;
  649. break;
  650. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_75:
  651. (*pCtrl_Id) = IDR_FRAMERATE_VGA_75;
  652. break;
  653. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_10:
  654. (*pCtrl_Id) = IDR_FRAMERATE_VGA_10;
  655. break;
  656. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_15:
  657. (*pCtrl_Id) = IDR_FRAMERATE_VGA_15;
  658. break;
  659. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_20:
  660. (*pCtrl_Id) = IDR_FRAMERATE_VGA_20;
  661. break;
  662. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_24:
  663. (*pCtrl_Id) = IDR_FRAMERATE_VGA_24;
  664. break;
  665. default:
  666. return FALSE;
  667. }
  668. }
  669. else
  670. {
  671. switch(lFramerate)
  672. {
  673. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_375:
  674. (*pCtrl_Id) = IDR_FRAMERATE_MR_375;
  675. break;
  676. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_5:
  677. (*pCtrl_Id) = IDR_FRAMERATE_MR_5;
  678. break;
  679. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_75:
  680. (*pCtrl_Id) = IDR_FRAMERATE_MR_75;
  681. break;
  682. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_10:
  683. (*pCtrl_Id) = IDR_FRAMERATE_MR_10;
  684. break;
  685. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_12:
  686. (*pCtrl_Id) = IDR_FRAMERATE_MR_12;
  687. break;
  688. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_15:
  689. (*pCtrl_Id) = IDR_FRAMERATE_MR_15;
  690. break;
  691. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_20:
  692. (*pCtrl_Id) = IDR_FRAMERATE_MR_20;
  693. break;
  694. case KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_24:
  695. (*pCtrl_Id) = IDR_FRAMERATE_MR_24;
  696. break;
  697. default:
  698. return FALSE;
  699. }
  700. }
  701. return TRUE;
  702. }
  703. /*-------------------------------------------------------------------------*/
  704. static BOOL PRPPAGE2_Get_Framerate_Value(
  705. HWND hDlg,
  706. PLONG plFramerate,
  707. WORD Ctrl_Id)
  708. /*-------------------------------------------------------------------------*/
  709. {
  710. switch(Ctrl_Id)
  711. {
  712. case IDR_FRAMERATE_VGA_375:
  713. case IDR_FRAMERATE_MR_375:
  714. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_375;
  715. break;
  716. case IDR_FRAMERATE_VGA_5:
  717. case IDR_FRAMERATE_MR_5:
  718. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_5;
  719. break;
  720. case IDR_FRAMERATE_VGA_75:
  721. case IDR_FRAMERATE_MR_75:
  722. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_75;
  723. break;
  724. case IDR_FRAMERATE_VGA_10:
  725. case IDR_FRAMERATE_MR_10:
  726. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_10;
  727. break;
  728. case IDR_FRAMERATE_MR_12:
  729. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_12;
  730. break;
  731. case IDR_FRAMERATE_VGA_15:
  732. case IDR_FRAMERATE_MR_15:
  733. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_15;
  734. break;
  735. case IDR_FRAMERATE_VGA_20:
  736. case IDR_FRAMERATE_MR_20:
  737. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_20;
  738. break;
  739. case IDR_FRAMERATE_VGA_24:
  740. case IDR_FRAMERATE_MR_24:
  741. (*plFramerate) = KSPROPERTY_PHILIPS_CUSTOM_PROP_FRAMERATE_24;
  742. break;
  743. }
  744. return TRUE;
  745. }
  746. /*-------------------------------------------------------------------------*/
  747. static void PRPPAGE2_EnableControls(
  748. HWND hDlg,
  749. BOOL bEnable)
  750. /*-------------------------------------------------------------------------*/
  751. {
  752. static WORD Controls[] =
  753. {
  754. IDR_FRAMERATE_VGA_375, IDR_FRAMERATE_MR_375,
  755. IDR_FRAMERATE_VGA_5, IDR_FRAMERATE_MR_5,
  756. IDR_FRAMERATE_VGA_75, IDR_FRAMERATE_MR_75,
  757. IDR_FRAMERATE_VGA_10, IDR_FRAMERATE_MR_10,
  758. IDR_FRAMERATE_MR_12, IDR_FRAMERATE_VGA_15,
  759. IDR_FRAMERATE_MR_15, IDR_FRAMERATE_VGA_20,
  760. IDR_FRAMERATE_MR_20, IDR_FRAMERATE_VGA_24,
  761. IDR_FRAMERATE_MR_24,
  762. IDS_BRIGHTNESS, IDS_CONTRAST,
  763. IDS_GAMMA,
  764. IDE_BRIGHTNESS, IDE_CONTRAST,
  765. IDE_GAMMA,
  766. IDT_BRIGHTNESS, IDT_CONTRAST,
  767. IDT_GAMMA, IDT_FRAMERATE,
  768. IDT_IMAGECONTROLS, IDT_DEFAULTS,
  769. IDT_UD, IDT_FD,
  770. IDC_COLORENABLE, IDC_BACKLIGHT_COMPENSATION,
  771. IDB_RESTORE_UD, IDB_SAVE_UD,
  772. IDB_RESTORE_FD,
  773. 0
  774. };
  775. int i = 0;
  776. while(Controls[i] != 0)
  777. EnableWindow(GetDlgItem(hDlg, Controls[i++]), bEnable);
  778. }
  779. /*-------------------------------------------------------------------------*/
  780. static void PRPPAGE2_Handle_Err_Comm(
  781. HWND hDlg)
  782. /*-------------------------------------------------------------------------*/
  783. {
  784. char Msg_Err_Comm[132] = "";
  785. // disable everything
  786. PRPPAGE2_EnableControls(hDlg, FALSE);
  787. // load the message text from resource
  788. LoadString(hInst, IDS_MSG_ERR_COMM, Msg_Err_Comm, 132);
  789. // notify the user
  790. MessageBox(hDlg, Msg_Err_Comm,"Error", MB_OK | MB_ICONERROR);
  791. }
  792. /*-------------------------------------------------------------------------*/
  793. static void PRPPAGE2_Handle_Err_Dev_Chg(
  794. HWND hDlg)
  795. /*-------------------------------------------------------------------------*/
  796. {
  797. char Msg_Err_Dev_Chg[132] = "";
  798. // disable everything
  799. PRPPAGE2_EnableControls(hDlg, FALSE);
  800. // load the message text from resource
  801. LoadString(hInst, IDS_MSG_ERR_DEV_CHG, Msg_Err_Dev_Chg, 132);
  802. // notify the user
  803. MessageBox(hDlg, Msg_Err_Dev_Chg,"Warning", MB_OK);
  804. }