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.

857 lines
24 KiB

  1. #include "precomp.h"
  2. #include "rsopsec.h"
  3. #include <regapix.h> // MAXIMUM_SUB_KEY_LENGTH, MAXIMUM_VALUE_NAME_LENGTH, MAXIMUM_DATA_LENGTH
  4. int g_nKeys, g_nLock; // indexes of the images
  5. HIMAGELIST g_hImageList;
  6. int g_iAllowAlways, g_iAllowNever;
  7. enum TreeNodeEnum{tneGeneral, tneAccessList, tneRatingSystemRoot, tneRatingSystemInfo, tneRatingSystemNode, tneNone};
  8. struct TreeNode{
  9. TreeNodeEnum tne;
  10. void *pData;
  11. TreeNode(){}
  12. TreeNode(TreeNodeEnum tneInit, void* pDataInit){tne=tneInit;pData=pDataInit;}
  13. };
  14. #define NUM_BITMAPS 2
  15. #define CX_BITMAP 16
  16. #define CY_BITMAP 16
  17. ///////////////////////////////////////////////////////////////////////////////
  18. // InitTreeViewImageLists - creates an image list, adds three bitmaps to
  19. // it, and associates the image list with a tree-view control.
  20. // Returns TRUE if successful or FALSE otherwise.
  21. // hwndTV - handle of the tree-view control
  22. ///////////////////////////////////////////////////////////////////////////////
  23. BOOL InitTreeViewImageLists(HWND hwndTV)
  24. {
  25. BOOL bRet = FALSE;
  26. // Create the image list.
  27. HIMAGELIST himl = ImageList_Create(CX_BITMAP, CY_BITMAP, FALSE, NUM_BITMAPS, 0);
  28. if (himl != NULL)
  29. {
  30. // Add the open file, closed file, and document bitmaps.
  31. HBITMAP hbmp = (HBITMAP) LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_KEYS),
  32. IMAGE_BITMAP, 0, 0,
  33. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  34. g_nKeys = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
  35. DeleteObject(hbmp);
  36. hbmp = (HBITMAP)LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_LOCK),
  37. IMAGE_BITMAP, 0, 0,
  38. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  39. g_nLock = ImageList_Add(himl, hbmp, (HBITMAP) NULL);
  40. DeleteObject(hbmp);
  41. // Fail if not all of the images were added.
  42. if (ImageList_GetImageCount(himl) >= NUM_BITMAPS)
  43. {
  44. // Associate the image list with the tree-view control.
  45. HIMAGELIST oldHiml = TreeView_SetImageList(hwndTV, himl, TVSIL_NORMAL);
  46. if(oldHiml != NULL)
  47. ImageList_Destroy(oldHiml);
  48. bRet = TRUE;
  49. }
  50. }
  51. return bRet;
  52. }
  53. ///////////////////////////////////////////////////////////////////////////////
  54. void ShowHideWindow(HWND hCtrl, BOOL fEnable)
  55. {
  56. EnableWindow(hCtrl, fEnable);
  57. ShowWindow(hCtrl, fEnable ? SW_SHOW : SW_HIDE);
  58. }
  59. ///////////////////////////////////////////////////////////////////////////////
  60. void DeleteBitmapWindow(HWND *phwnd)
  61. {
  62. if (*phwnd)
  63. {
  64. DeleteObject( (HGDIOBJ) SendMessage(*phwnd, STM_GETIMAGE, IMAGE_BITMAP, 0));
  65. DestroyWindow(*phwnd);
  66. *phwnd = 0;
  67. }
  68. }
  69. ///////////////////////////////////////////////////////////////////////////////
  70. void ControlsShow(HWND hDlg, PRSD *pPRSD, TreeNodeEnum tne)
  71. {
  72. BOOL fEnable;
  73. /*Bitmap placeholders never need to be seen*/
  74. ShowHideWindow(GetDlgItem(hDlg, IDC_PT_T_BITMAP_CATEGORY), FALSE);
  75. ShowHideWindow(GetDlgItem(hDlg, IDC_PT_T_BITMAP_LABEL), FALSE);
  76. /*Kill old graphic windows*/
  77. DeleteBitmapWindow(&pPRSD->hwndBitmapCategory);
  78. DeleteBitmapWindow(&pPRSD->hwndBitmapLabel);
  79. /*RatingSystemNode Controls*/
  80. fEnable = (tne == tneRatingSystemNode);
  81. ShowHideWindow(GetDlgItem(hDlg, IDC_PT_T_RSN_SDESC), fEnable);
  82. ShowHideWindow(GetDlgItem(hDlg, IDC_PT_TB_SELECT), fEnable);
  83. ShowHideWindow(GetDlgItem(hDlg, IDC_RATING_LABEL), fEnable);
  84. /*RatingSystemInfo Controls*/
  85. fEnable = (tne==tneRatingSystemInfo || tne==tneRatingSystemNode);
  86. ShowHideWindow(GetDlgItem(hDlg, IDC_PT_T_RSN_LDESC), fEnable);
  87. // ShowHideWindow(GetDlgItem(hDlg, IDC_DETAILSBUTTON), fEnable);
  88. EnableDlgItem2(hDlg, IDC_DETAILSBUTTON, FALSE);
  89. }
  90. ///////////////////////////////////////////////////////////////////////////////
  91. HTREEITEM AddOneItem(HWND hwndTree, HTREEITEM hParent, LPTSTR szText,
  92. HTREEITEM hInsAfter, LPARAM lpData, int iImage)
  93. {
  94. HTREEITEM hItem;
  95. TV_ITEM tvI;
  96. TV_INSERTSTRUCT tvIns;
  97. // The .pszText is filled in.
  98. tvI.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
  99. tvI.iSelectedImage = iImage;
  100. tvI.iImage = iImage;
  101. tvI.pszText = szText;
  102. tvI.cchTextMax = StrLen(szText);
  103. tvI.lParam = lpData;
  104. tvIns.item = tvI;
  105. tvIns.hInsertAfter = hInsAfter;
  106. tvIns.hParent = hParent;
  107. // Insert the item into the tree.
  108. hItem = (HTREEITEM)SendMessage(hwndTree, TVM_INSERTITEM, 0, (LPARAM)(LPTV_INSERTSTRUCT)&tvIns);
  109. return (hItem);
  110. }
  111. ///////////////////////////////////////////////////////////////////////////////
  112. TreeNode* TreeView_GetSelectionLParam(HWND hwndTree)
  113. {
  114. TV_ITEM tv;
  115. tv.mask = TVIF_HANDLE | TVIF_PARAM;
  116. tv.hItem = TreeView_GetSelection(hwndTree);
  117. if (SendMessage(hwndTree, TVM_GETITEM, 0, (LPARAM) &tv))
  118. return (TreeNode*) tv.lParam;
  119. else
  120. return 0;
  121. }
  122. ///////////////////////////////////////////////////////////////////////////////
  123. void PicsDlgInit(HWND hDlg, PRSD *pPRSD)
  124. {
  125. __try
  126. {
  127. HWND hwndTree = GetDlgItem(hDlg, IDC_PT_TREE);
  128. InitTreeViewImageLists(hwndTree);
  129. // get the zone settings for this zone
  130. if (NULL != pPRSD->pDRD->ConnectToNamespace())
  131. {
  132. HRESULT hr = pPRSD->pDRD->LoadContentRatingsObject();
  133. ComPtr<IWbemClassObject> pRatObj = pPRSD->pDRD->GetContentRatingsObject();
  134. if (SUCCEEDED(hr) && NULL != pRatObj)
  135. {
  136. // ratingSystemFileNames field
  137. _variant_t vtValue;
  138. hr = pRatObj->Get(L"ratingSystemFileNames", 0, &vtValue, NULL, NULL);
  139. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  140. {
  141. SAFEARRAY *psa = vtValue.parray;
  142. LONG lLBound, lUBound, cElements = 0L;
  143. hr = SafeArrayGetLBound(psa, 1, &lLBound);
  144. if (SUCCEEDED(hr))
  145. {
  146. hr = SafeArrayGetUBound(psa, 1, &lUBound);
  147. if (SUCCEEDED(hr))
  148. cElements = lUBound - lLBound + 1;
  149. }
  150. TreeNode *pTN = NULL;
  151. BSTR HUGEP *pbstr = NULL;
  152. hr = SafeArrayAccessData(psa, (void HUGEP**)&pbstr);
  153. if (SUCCEEDED(hr))
  154. {
  155. for (long nSys = 0; nSys < cElements; nSys++)
  156. {
  157. LPCTSTR szSystem = (LPCTSTR)pbstr[nSys];
  158. pTN = new TreeNode(tneRatingSystemInfo, NULL);
  159. ASSERT(pTN);
  160. AddOneItem(hwndTree, NULL, (LPTSTR)szSystem, TVI_SORT, (LPARAM)pTN, g_nLock);
  161. }
  162. }
  163. SafeArrayUnaccessData(psa);
  164. if (cElements > 0)
  165. {
  166. HTREEITEM hTreeItem = TreeView_GetNextItem(hwndTree,
  167. TreeView_GetRoot(hwndTree),
  168. TVGN_CHILD);
  169. if(NULL != hTreeItem)
  170. {
  171. TreeView_SelectItem(hwndTree, hTreeItem);
  172. pTN = TreeView_GetSelectionLParam(GetDlgItem(hDlg, IDC_PT_TREE));
  173. ControlsShow(hDlg, pPRSD, pTN->tne);
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. __except(TRUE)
  181. {
  182. }
  183. }
  184. ///////////////////////////////////////////////////////////////////////////////
  185. void KillTree(HWND hwnd, HTREEITEM hTree)
  186. {
  187. while (hTree != NULL)
  188. {
  189. /* If this node has any items under it, delete them as well. */
  190. HTREEITEM hChild = TreeView_GetChild(hwnd, hTree);
  191. if (hChild != NULL)
  192. KillTree(hwnd, hChild);
  193. HTREEITEM hNext = TreeView_GetNextSibling(hwnd, hTree);
  194. TreeView_SelectItem(hwnd, hTree);
  195. delete TreeView_GetSelectionLParam(hwnd);
  196. TreeView_DeleteItem(hwnd, hTree);
  197. hTree = hNext;
  198. }
  199. }
  200. ///////////////////////////////////////////////////////////////////////////////
  201. void PicsDlgUninit(HWND hDlg, PRSD *pPRSD)
  202. {
  203. HWND hwnd = GetDlgItem(hDlg, IDC_PT_TREE);
  204. KillTree(hwnd, TreeView_GetRoot(hwnd));
  205. ControlsShow(hDlg, pPRSD, tneNone);
  206. }
  207. ///////////////////////////////////////////////////////////////////////////////
  208. INT_PTR CALLBACK PicsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  209. {
  210. PRSD *pPRSD = NULL;
  211. switch (uMsg) {
  212. case WM_INITDIALOG:
  213. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  214. pPRSD = (PRSD *) ((PROPSHEETPAGE*)lParam)->lParam;
  215. PicsDlgInit(hDlg, pPRSD);
  216. return TRUE;
  217. // Set the initial state
  218. case WM_SYSCOLORCHANGE:
  219. {
  220. InitTreeViewImageLists(GetDlgItem(hDlg, IDC_PT_TREE));
  221. //force the trackbar to redraw its background with the new color
  222. pPRSD = (PRSD*) ((PROPSHEETPAGE*)GetWindowLongPtr(hDlg, DWLP_USER))->lParam;
  223. TV_ITEM tvm;
  224. ZeroMemory(&tvm,sizeof(tvm));
  225. tvm.hItem = TreeView_GetSelection(GetDlgItem(hDlg,IDC_PT_TREE));
  226. tvm.mask = TVIF_PARAM;
  227. TreeView_GetItem(GetDlgItem(hDlg,IDC_PT_TREE), &tvm);
  228. TreeNode *pTN = (TreeNode*)tvm.lParam;
  229. ControlsShow(hDlg, pPRSD, pTN->tne);
  230. break;
  231. }
  232. case WM_HSCROLL:
  233. case WM_VSCROLL:
  234. pPRSD = (PRSD *) ((PROPSHEETPAGE*)GetWindowLongPtr(hDlg, DWLP_USER))->lParam;
  235. switch (LOWORD(wParam)){
  236. case TB_THUMBTRACK:
  237. case TB_BOTTOM:
  238. case TB_ENDTRACK:
  239. case TB_LINEDOWN:
  240. case TB_LINEUP:
  241. case TB_PAGEDOWN:
  242. case TB_PAGEUP:
  243. case TB_THUMBPOSITION:
  244. case TB_TOP:
  245. // NewTrackbarPosition(hDlg, pPRSD);
  246. break;
  247. }
  248. break;
  249. case WM_COMMAND:
  250. switch (LOWORD(wParam)) {
  251. case IDC_DETAILSBUTTON:
  252. break;
  253. }
  254. return TRUE;
  255. case WM_NOTIFY: {
  256. NMHDR *lpnm = (NMHDR *) lParam;
  257. switch (lpnm->code) {
  258. /*save us*/
  259. case PSN_SETACTIVE:
  260. break;
  261. case PSN_APPLY:
  262. case PSN_RESET:
  263. // Do this if hit OK or Cancel, not Apply
  264. pPRSD = (PRSD *) ((PROPSHEETPAGE*)GetWindowLongPtr(hDlg, DWLP_USER))->lParam;
  265. SendMessage(hDlg,WM_SETREDRAW, FALSE,0L);
  266. PicsDlgUninit(hDlg, pPRSD);
  267. SendMessage(hDlg,WM_SETREDRAW, TRUE,0L);
  268. return TRUE;
  269. case TVN_ITEMEXPANDING:{
  270. NM_TREEVIEW *pNMT = (NM_TREEVIEW *) lParam;
  271. if (pNMT->action == TVE_COLLAPSE)
  272. {
  273. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE);
  274. return TRUE; //Suppress expanding tree.
  275. }
  276. break;
  277. }
  278. case TVN_SELCHANGED:
  279. {
  280. NM_TREEVIEW *pNMT = (NM_TREEVIEW *) lParam;
  281. TreeNode *pTN = ((TreeNode*) pNMT->itemNew.lParam);
  282. pPRSD = (PRSD*) ((PROPSHEETPAGE*)GetWindowLongPtr (hDlg, DWLP_USER))->lParam;
  283. ControlsShow(hDlg, pPRSD, pTN->tne);
  284. return TRUE;
  285. }
  286. }
  287. }
  288. break;
  289. /* case WM_HELP:
  290. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  291. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  292. break;
  293. case WM_CONTEXTMENU:
  294. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  295. (DWORD_PTR)(LPVOID)aIds);
  296. break;
  297. */ }
  298. return FALSE;
  299. }
  300. #define PICSRULES_ALWAYS 1
  301. #define PICSRULES_NEVER 0
  302. ///////////////////////////////////////////////////////////////////////////////
  303. void LoadSitesIntoList(HWND hwndList, ComPtr<IWbemClassObject> pRatObj,
  304. BSTR bstrProp, BOOL fAcceptReject)
  305. {
  306. __try
  307. {
  308. _variant_t vtValue;
  309. HRESULT hr = pRatObj->Get(bstrProp, 0, &vtValue, NULL, NULL);
  310. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  311. {
  312. SAFEARRAY *psa = vtValue.parray;
  313. LONG lLBound, lUBound, cElements = 0L;
  314. hr = SafeArrayGetLBound(psa, 1, &lLBound);
  315. if (SUCCEEDED(hr))
  316. {
  317. hr = SafeArrayGetUBound(psa, 1, &lUBound);
  318. if (SUCCEEDED(hr))
  319. cElements = lUBound - lLBound + 1;
  320. }
  321. BSTR HUGEP *pbstr = NULL;
  322. hr = SafeArrayAccessData(psa, (void HUGEP**)&pbstr);
  323. if (SUCCEEDED(hr))
  324. {
  325. //fill in the listview with known items
  326. for (long nSite = 0; nSite < cElements; nSite++)
  327. {
  328. LPCTSTR szSite = (LPCTSTR)pbstr[nSite];
  329. LV_ITEM lvItem;
  330. ZeroMemory(&lvItem, sizeof(lvItem));
  331. lvItem.mask = LVIF_TEXT|LVIF_IMAGE;
  332. lvItem.pszText = (LPTSTR)szSite;
  333. if (PICSRULES_NEVER == fAcceptReject)
  334. lvItem.iImage = g_iAllowNever;
  335. else
  336. lvItem.iImage = g_iAllowAlways;
  337. INT64 iIndex = SendMessage(hwndList, LVM_INSERTITEM, (WPARAM)0,
  338. (LPARAM)&lvItem);
  339. if (-1 == iIndex)
  340. break;
  341. }
  342. }
  343. SafeArrayUnaccessData(psa);
  344. }
  345. }
  346. __except(TRUE)
  347. {
  348. }
  349. }
  350. ///////////////////////////////////////////////////////////////////////////////
  351. void ApprovedSitesDlgInit(HWND hDlg, PRSD *pPRSD)
  352. {
  353. __try
  354. {
  355. HWND hwndList = GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDLIST);
  356. // get the zone settings for this zone
  357. if (NULL != pPRSD->pDRD->ConnectToNamespace())
  358. {
  359. HRESULT hr = pPRSD->pDRD->LoadContentRatingsObject();
  360. ComPtr<IWbemClassObject> pRatObj = pPRSD->pDRD->GetContentRatingsObject();
  361. if (SUCCEEDED(hr) && NULL != pRatObj)
  362. {
  363. // neverViewableSites field
  364. LoadSitesIntoList(hwndList, pRatObj, L"neverViewableSites",
  365. PICSRULES_NEVER);
  366. // alwaysViewableSites field
  367. LoadSitesIntoList(hwndList, pRatObj, L"alwaysViewableSites",
  368. PICSRULES_ALWAYS);
  369. }
  370. }
  371. // Set the column width to satisfy longest element
  372. ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
  373. // set focus to first item in list
  374. ListView_SetItemState(hwndList, 0, LVIS_FOCUSED, LVIS_FOCUSED);
  375. EnableDlgItem2(hDlg, IDC_PICSRULESAPPROVEDEDIT, FALSE);
  376. EnableDlgItem2(hDlg, IDC_PICSRULESAPPROVEDALWAYS, FALSE);
  377. EnableDlgItem2(hDlg, IDC_PICSRULESAPPROVEDNEVER, FALSE);
  378. EnableDlgItem2(hDlg, IDC_PICSRULESAPPROVEDREMOVE, FALSE);
  379. }
  380. __except(TRUE)
  381. {
  382. }
  383. }
  384. ///////////////////////////////////////////////////////////////////////////////
  385. INT_PTR CALLBACK ApprovedSitesDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  386. {
  387. PRSD *pPRSD;
  388. switch (uMsg)
  389. {
  390. case WM_INITDIALOG:
  391. {
  392. SetWindowLongPtr (hDlg, DWLP_USER, lParam);
  393. pPRSD = (PRSD *) ((PROPSHEETPAGE*)lParam)->lParam;
  394. RECT Rect;
  395. GetWindowRect(GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDLIST),&Rect);
  396. TEXTMETRIC tm;
  397. tm.tmAveCharWidth = 0;
  398. HDC hDC = GetDC(hDlg);
  399. if (hDC)
  400. {
  401. GetTextMetrics(hDC,&tm);
  402. ReleaseDC(hDlg,hDC);
  403. }
  404. LV_COLUMN lvColumn;
  405. lvColumn.mask = LVCF_FMT|LVCF_WIDTH;
  406. lvColumn.fmt = LVCFMT_LEFT;
  407. lvColumn.cx = Rect.right - Rect.left -GetSystemMetrics(SM_CXVSCROLL) -
  408. GetSystemMetrics(SM_CXSMICON) - tm.tmAveCharWidth;
  409. SendDlgItemMessage(hDlg, IDC_PICSRULESAPPROVEDLIST,
  410. LVM_INSERTCOLUMN, (WPARAM)0, (LPARAM)&lvColumn);
  411. UINT flags = 0;
  412. /* if(IS_WINDOW_RTL_MIRRORED(hDlg))
  413. flags |= ILC_MIRROR;
  414. */
  415. g_hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
  416. GetSystemMetrics(SM_CYSMICON),
  417. flags, 2, 0);
  418. HICON hIcon = (HICON) LoadImage(g_hInstance,
  419. MAKEINTRESOURCE(IDI_ACCEPTALWAYS),
  420. IMAGE_ICON, 16, 16,
  421. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  422. g_iAllowAlways=ImageList_AddIcon(g_hImageList,hIcon);
  423. DeleteObject(hIcon);
  424. hIcon = (HICON) LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ACCEPTNEVER),
  425. IMAGE_ICON, 16, 16,
  426. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  427. g_iAllowNever = ImageList_AddIcon(g_hImageList, hIcon);
  428. DeleteObject(hIcon);
  429. ListView_SetImageList(GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDLIST),g_hImageList,LVSIL_SMALL);
  430. //disable the remove button until someone selects something
  431. EnableWindow(GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDREMOVE),FALSE);
  432. //disable the always and never buttons until someone types something
  433. EnableWindow(GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDNEVER),FALSE);
  434. EnableWindow(GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDALWAYS),FALSE);
  435. ApprovedSitesDlgInit(hDlg, pPRSD);
  436. break;
  437. }
  438. case WM_SYSCOLORCHANGE:
  439. {
  440. pPRSD=(PRSD *) ((PROPSHEETPAGE*)GetWindowLongPtr(hDlg,DWLP_USER))->lParam;
  441. HWND hwndList = GetDlgItem(hDlg,IDC_PICSRULESAPPROVEDLIST);
  442. ListView_SetBkColor(hwndList, GetSysColor(COLOR_WINDOW));
  443. UINT flags = 0;
  444. /* if(IS_WINDOW_RTL_MIRRORED(hDlg))
  445. flags |= ILC_MIRROR;
  446. */
  447. g_hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
  448. GetSystemMetrics(SM_CYSMICON),
  449. flags, 2, 0);
  450. HICON hIcon = (HICON) LoadImage(g_hInstance,
  451. MAKEINTRESOURCE(IDI_ACCEPTALWAYS),
  452. IMAGE_ICON, 16, 16,
  453. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  454. g_iAllowAlways = ImageList_AddIcon(g_hImageList,hIcon);
  455. DeleteObject(hIcon);
  456. hIcon=(HICON) LoadImage(g_hInstance,
  457. MAKEINTRESOURCE(IDI_ACCEPTNEVER),
  458. IMAGE_ICON,
  459. 16,
  460. 16,
  461. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  462. g_iAllowNever = ImageList_AddIcon(g_hImageList,hIcon);
  463. DeleteObject(hIcon);
  464. HIMAGELIST hOldImageList = ListView_SetImageList(hwndList, g_hImageList, LVSIL_SMALL);
  465. if(hOldImageList != NULL)
  466. ImageList_Destroy(hOldImageList);
  467. break;
  468. }
  469. case WM_COMMAND:
  470. switch (LOWORD(wParam))
  471. {
  472. case IDC_PICSRULESAPPROVEDEDIT:
  473. break;
  474. case IDC_PICSRULESAPPROVEDNEVER:
  475. break;
  476. case IDC_PICSRULESAPPROVEDALWAYS:
  477. break;
  478. case IDC_PICSRULESAPPROVEDREMOVE:
  479. break;
  480. }
  481. return TRUE;
  482. case WM_NOTIFY: {
  483. NMHDR *lpnm = (NMHDR *) lParam;
  484. switch (lpnm->code) {
  485. case LVN_ITEMCHANGED:
  486. break;
  487. /*save us*/
  488. case PSN_APPLY:
  489. return TRUE;
  490. case PSN_RESET:
  491. return TRUE;
  492. }
  493. }
  494. break;
  495. /* case WM_HELP:
  496. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  497. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  498. break;
  499. case WM_CONTEXTMENU:
  500. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  501. (DWORD_PTR)(LPVOID)aIds);
  502. break;
  503. */ }
  504. return FALSE;
  505. }
  506. ///////////////////////////////////////////////////////////////////////////////
  507. void GeneralDlgInit(HWND hDlg, PRSD *pPRSD)
  508. {
  509. __try
  510. {
  511. // get the zone settings for this zone
  512. if (NULL != pPRSD->pDRD->ConnectToNamespace())
  513. {
  514. HRESULT hr = pPRSD->pDRD->LoadContentRatingsObject();
  515. ComPtr<IWbemClassObject> pRatObj = pPRSD->pDRD->GetContentRatingsObject();
  516. if (SUCCEEDED(hr) && NULL != pRatObj)
  517. {
  518. // viewUnknownRatedSites field
  519. _variant_t vtValue;
  520. hr = pRatObj->Get(L"viewUnknownRatedSites", 0, &vtValue, NULL, NULL);
  521. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  522. CheckDlgButton(hDlg, IDC_UNRATED, (bool)vtValue ? BST_CHECKED : BST_UNCHECKED);
  523. // passwordOverrideEnabled field
  524. hr = pRatObj->Get(L"passwordOverrideEnabled", 0, &vtValue, NULL, NULL);
  525. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  526. CheckDlgButton(hDlg, IDC_PLEASE_MOMMY, (bool)vtValue ? BST_CHECKED : BST_UNCHECKED);
  527. }
  528. }
  529. EnableDlgItem2(hDlg, IDC_UNRATED, FALSE);
  530. EnableDlgItem2(hDlg, IDC_PLEASE_MOMMY, FALSE);
  531. EnableDlgItem2(hDlg, IDC_CHANGE_PASSWORD, FALSE);
  532. EnableDlgItem2(hDlg, IDC_FINDRATINGS, FALSE);
  533. EnableDlgItem2(hDlg, IDC_PROVIDER, FALSE);
  534. }
  535. __except(TRUE)
  536. {
  537. }
  538. }
  539. ///////////////////////////////////////////////////////////////////////////////
  540. INT_PTR CALLBACK GeneralDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  541. {
  542. PRSD *pPRSD;
  543. switch (uMsg) {
  544. case WM_INITDIALOG:
  545. SetWindowLongPtr (hDlg, DWLP_USER, lParam);
  546. pPRSD = (PRSD *) ((PROPSHEETPAGE*)lParam)->lParam;
  547. GeneralDlgInit(hDlg, pPRSD);
  548. break;
  549. case WM_USER:
  550. break;
  551. case WM_COMMAND:
  552. switch (LOWORD(wParam)) {
  553. /*edit controls/check boxes. User updated these, highlight apply button*/
  554. case IDC_PROVIDER:
  555. break;
  556. case IDC_FINDRATINGS:
  557. break;
  558. case IDC_PLEASE_MOMMY:
  559. case IDC_UNRATED:
  560. break;
  561. case IDC_CHANGE_PASSWORD:
  562. break;
  563. }
  564. return TRUE;
  565. case WM_NOTIFY: {
  566. NMHDR *lpnm = (NMHDR *) lParam;
  567. switch (lpnm->code) {
  568. /*save us*/
  569. case PSN_APPLY:
  570. case PSN_RESET:
  571. return TRUE;
  572. }
  573. }
  574. break;
  575. /* case WM_HELP:
  576. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  577. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  578. break;
  579. case WM_CONTEXTMENU:
  580. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  581. (DWORD_PTR)(LPVOID)aIds);
  582. break;
  583. */ }
  584. return FALSE;
  585. }
  586. ///////////////////////////////////////////////////////////////////////////////
  587. void AdvancedDlgInit(HWND hDlg, PRSD *pPRSD)
  588. {
  589. __try
  590. {
  591. // get the zone settings for this zone
  592. if (NULL != pPRSD->pDRD->ConnectToNamespace())
  593. {
  594. HRESULT hr = pPRSD->pDRD->LoadContentRatingsObject();
  595. ComPtr<IWbemClassObject> pRatObj = pPRSD->pDRD->GetContentRatingsObject();
  596. if (SUCCEEDED(hr) && NULL != pRatObj)
  597. {
  598. // selectedRatingsBureau field
  599. _variant_t vtValue;
  600. hr = pRatObj->Get(L"selectedRatingsBureau", 0, &vtValue, NULL, NULL);
  601. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  602. {
  603. _bstr_t bstrValue = vtValue;
  604. HWND hwndCombo = GetDlgItem(hDlg, IDC_3RD_COMBO);
  605. INT_PTR nIndex = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)bstrValue);
  606. SendMessage(hwndCombo, CB_SETCURSEL, nIndex, nIndex);
  607. }
  608. }
  609. }
  610. EnableDlgItem2(hDlg, IDC_3RD_COMBO, FALSE);
  611. EnableDlgItem2(hDlg, IDC_PICSRULESOPEN, FALSE);
  612. EnableDlgItem2(hDlg, IDC_PICSRULESEDIT, FALSE);
  613. EnableDlgItem2(hDlg, IDC_PICSRULES_UP, FALSE);
  614. EnableDlgItem2(hDlg, IDC_PICSRULES_DOWN, FALSE);
  615. }
  616. __except(TRUE)
  617. {
  618. }
  619. }
  620. ///////////////////////////////////////////////////////////////////////////////
  621. INT_PTR CALLBACK AdvancedDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  622. {
  623. PRSD *pPRSD;
  624. switch (uMsg) {
  625. case WM_INITDIALOG:
  626. {
  627. SetWindowLongPtr (hDlg, DWLP_USER, lParam);
  628. pPRSD = (PRSD *) ((PROPSHEETPAGE*)lParam)->lParam;
  629. AdvancedDlgInit(hDlg, pPRSD);
  630. HICON hIcon = (HICON) LoadImage(g_hInstance,
  631. MAKEINTRESOURCE(IDI_PICSRULES_UP),
  632. IMAGE_ICON, 16, 16,
  633. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  634. SendDlgItemMessage(hDlg,IDC_PICSRULES_UP,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  635. hIcon = (HICON) LoadImage(g_hInstance,
  636. MAKEINTRESOURCE(IDI_PICSRULES_DOWN),
  637. IMAGE_ICON, 16, 16,
  638. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  639. SendDlgItemMessage(hDlg,IDC_PICSRULES_DOWN,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  640. break;
  641. }
  642. case WM_SYSCOLORCHANGE:
  643. {
  644. HICON hIcon = (HICON) LoadImage(g_hInstance,
  645. MAKEINTRESOURCE(IDI_PICSRULES_UP),
  646. IMAGE_ICON, 16, 16,
  647. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  648. HICON hOldIcon = (HICON) SendDlgItemMessage(hDlg,IDC_PICSRULES_UP,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  649. if (NULL != hOldIcon)
  650. DeleteObject(hOldIcon);
  651. hIcon = (HICON) LoadImage(g_hInstance,
  652. MAKEINTRESOURCE(IDI_PICSRULES_DOWN),
  653. IMAGE_ICON, 16, 16,
  654. LR_LOADTRANSPARENT|LR_DEFAULTCOLOR|LR_CREATEDIBSECTION);
  655. hOldIcon = (HICON) SendDlgItemMessage(hDlg,IDC_PICSRULES_DOWN,BM_SETIMAGE,(WPARAM) IMAGE_ICON,(LPARAM) hIcon);
  656. if (NULL != hOldIcon)
  657. DeleteObject(hOldIcon);
  658. break;
  659. }
  660. case WM_USER:
  661. break;
  662. case WM_COMMAND:
  663. switch (LOWORD(wParam)) {
  664. /*edit controls/check boxes. User updated these, highlight apply button*/
  665. case IDC_3RD_COMBO:
  666. switch(HIWORD(wParam)) {
  667. case CBN_EDITCHANGE:
  668. case CBN_SELENDOK:
  669. break;
  670. }
  671. break;
  672. case IDC_PICSRULES_LIST:
  673. {
  674. switch(HIWORD(wParam))
  675. {
  676. case LBN_SELCHANGE:
  677. break;
  678. }
  679. break;
  680. }
  681. case IDC_PICSRULES_UP:
  682. break;
  683. case IDC_PICSRULES_DOWN:
  684. break;
  685. case IDC_PICSRULESEDIT:
  686. break;
  687. case IDC_PICSRULESOPEN:
  688. break;
  689. }
  690. return TRUE;
  691. case WM_NOTIFY: {
  692. NMHDR *lpnm = (NMHDR *) lParam;
  693. switch (lpnm->code) {
  694. /*save us*/
  695. case PSN_SETACTIVE:
  696. break;
  697. case PSN_APPLY:
  698. case PSN_RESET:
  699. return TRUE;
  700. }
  701. }
  702. break;
  703. /* case WM_HELP:
  704. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  705. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  706. break;
  707. case WM_CONTEXTMENU:
  708. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  709. (DWORD_PTR)(LPVOID)aIds);
  710. break;
  711. */ }
  712. return FALSE;
  713. }