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.

400 lines
18 KiB

  1. #include "precomp.h"
  2. #include <comdef.h>
  3. #include "rsop.h"
  4. ///////////////////////////////////////////////////////////
  5. void InitLogoDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  6. {
  7. __try
  8. {
  9. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  10. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  11. if (SUCCEEDED(hr))
  12. {
  13. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  14. long nPSObjects = pDRD->GetPSObjCount();
  15. BOOL bCustomLogoHandled = FALSE;
  16. BOOL bBrandAnimHandled = FALSE;
  17. for (long nObj = 0; nObj < nPSObjects; nObj++)
  18. {
  19. // customizeLogoBitmaps field
  20. if (!bCustomLogoHandled)
  21. {
  22. _variant_t vtValue;
  23. hr = paPSObj[nObj]->pObj->Get(L"customizeAnimatedBitmaps", 0, &vtValue, NULL, NULL);
  24. BOOL fBrandAnim = FALSE;
  25. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  26. {
  27. fBrandAnim = vtValue.boolVal ? TRUE : FALSE;
  28. bBrandAnimHandled = TRUE;
  29. }
  30. if (fBrandAnim)
  31. {
  32. CheckDlgButton(hDlg, IDC_ANIMBITMAP, BST_CHECKED);
  33. // smallAnimatedBitmapPath field
  34. hr = paPSObj[nObj]->pObj->Get(L"smallAnimatedBitmapPath", 0, &vtValue, NULL, NULL);
  35. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  36. {
  37. _bstr_t bstrVal = vtValue;
  38. SetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, (LPCTSTR)bstrVal);
  39. }
  40. // largeAnimatedBitmapPath field
  41. hr = paPSObj[nObj]->pObj->Get(L"largeAnimatedBitmapPath", 0, &vtValue, NULL, NULL);
  42. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  43. {
  44. _bstr_t bstrVal = vtValue;
  45. SetDlgItemText(hDlg, IDE_BIGANIMBITMAP, (LPCTSTR)bstrVal);
  46. }
  47. }
  48. hr = paPSObj[nObj]->pObj->Get(L"customizeLogoBitmaps", 0, &vtValue, NULL, NULL);
  49. BOOL fBrandBmps = FALSE;
  50. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  51. {
  52. fBrandBmps = vtValue.boolVal ? TRUE : FALSE;
  53. bCustomLogoHandled = TRUE;
  54. }
  55. if (fBrandBmps)
  56. {
  57. CheckDlgButton(hDlg, IDC_BITMAPCHECK, BST_CHECKED);
  58. // smallCustomLogoBitmapPath field
  59. hr = paPSObj[nObj]->pObj->Get(L"smallCustomLogoBitmapPath", 0, &vtValue, NULL, NULL);
  60. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  61. {
  62. _bstr_t bstrVal = vtValue;
  63. SetDlgItemText(hDlg, IDC_BITMAP2, (LPCTSTR)bstrVal);
  64. }
  65. // largeCustomLogoBitmapPath field
  66. hr = paPSObj[nObj]->pObj->Get(L"largeCustomLogoBitmapPath", 0, &vtValue, NULL, NULL);
  67. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  68. {
  69. _bstr_t bstrVal = vtValue;
  70. SetDlgItemText(hDlg, IDC_BITMAP, (LPCTSTR)bstrVal);
  71. }
  72. }
  73. }
  74. // no need to process other GPOs since enabled properties have been found
  75. if (bCustomLogoHandled && bBrandAnimHandled)
  76. break;
  77. }
  78. }
  79. }
  80. __except(TRUE)
  81. {
  82. }
  83. }
  84. /////////////////////////////////////////////////////////////////////
  85. HRESULT InitSmallLogoPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  86. {
  87. return InitGenericPrecedencePage(pDRD, hwndList, L"smallCustomLogoBitmapPath");
  88. }
  89. /////////////////////////////////////////////////////////////////////
  90. HRESULT InitLargeLogoPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  91. {
  92. return InitGenericPrecedencePage(pDRD, hwndList, L"largeCustomLogoBitmapPath");
  93. }
  94. /////////////////////////////////////////////////////////////////////
  95. HRESULT InitSmallBmpPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  96. {
  97. return InitGenericPrecedencePage(pDRD, hwndList, L"smallAnimatedBitmapPath");
  98. }
  99. /////////////////////////////////////////////////////////////////////
  100. HRESULT InitLargeBmpPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  101. {
  102. return InitGenericPrecedencePage(pDRD, hwndList, L"largeAnimatedBitmapPath");
  103. }
  104. ///////////////////////////////////////////////////////////
  105. void DisplayBitmap(HWND hControl, LPCTSTR pcszFileName, int nBitmapId)
  106. {
  107. HANDLE hBmp = (HANDLE) GetWindowLongPtr(hControl, GWLP_USERDATA);
  108. if(ISNONNULL(pcszFileName) && PathFileExists(pcszFileName))
  109. ShowBitmap(hControl, pcszFileName, 0, &hBmp);
  110. else
  111. ShowBitmap(hControl, TEXT(""), nBitmapId, &hBmp);
  112. SetWindowLongPtr(hControl, GWLP_USERDATA, (LONG_PTR)hBmp);
  113. }
  114. ///////////////////////////////////////////////////////////
  115. void ReleaseBitmap(HWND hControl)
  116. {
  117. HANDLE hBmp = (HANDLE) GetWindowLongPtr(hControl, GWLP_USERDATA);
  118. if (hBmp)
  119. DeleteObject(hBmp);
  120. }
  121. ///////////////////////////////////////////////////////////
  122. INT_PTR CALLBACK LogoDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  123. {
  124. // Retrieve Property Sheet Page info for each call into dlg proc.
  125. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  126. TCHAR szLargeBmp[MAX_PATH];
  127. TCHAR szSmallBmp[MAX_PATH];
  128. TCHAR szLargeAnimBmp[MAX_PATH];
  129. TCHAR szSmallAnimBmp[MAX_PATH];
  130. TCHAR szWorkDir[MAX_PATH];
  131. BOOL fBrandBmps,fBrandAnim;;
  132. int nStatus;
  133. switch(msg)
  134. {
  135. case WM_SETFONT:
  136. //a change to mmc requires us to do this logic for all our property pages that use common controls
  137. INITCOMMONCONTROLSEX iccx;
  138. iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
  139. iccx.dwICC = ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES |ICC_TREEVIEW_CLASSES;
  140. InitCommonControlsEx(&iccx);
  141. break;
  142. case WM_INITDIALOG:
  143. SetPropSheetCookie(hDlg, lParam);
  144. EnableDBCSChars(hDlg, IDC_BITMAP);
  145. EnableDBCSChars(hDlg, IDC_BITMAP2);
  146. // find out if this dlg is in RSoP mode
  147. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  148. if (psCookie->pCS->IsRSoP())
  149. {
  150. EnableDlgItem2(hDlg, IDC_BITMAPCHECK, FALSE);
  151. EnableDlgItem2(hDlg, IDC_BITMAP2, FALSE);
  152. EnableDlgItem2(hDlg, IDC_BROWSEICON2, FALSE);
  153. EnableDlgItem2(hDlg, IDC_BITMAP, FALSE);
  154. EnableDlgItem2(hDlg, IDC_BROWSEICON, FALSE);
  155. EnableDlgItem2(hDlg, IDC_ANIMBITMAP, FALSE);
  156. EnableDlgItem2(hDlg, IDC_BROWSEBIG, FALSE);
  157. EnableDlgItem2(hDlg, IDE_BIGANIMBITMAP, FALSE);
  158. EnableDlgItem2(hDlg, IDC_BROWSESMALL, FALSE);
  159. EnableDlgItem2(hDlg, IDE_SMALLANIMBITMAP, FALSE);
  160. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  161. if (pDRD != NULL)
  162. InitLogoDlgInRSoPMode(hDlg, pDRD);
  163. }
  164. else
  165. {
  166. EnableDBCSChars(hDlg, IDE_SMALLANIMBITMAP);
  167. EnableDBCSChars(hDlg, IDE_BIGANIMBITMAP);
  168. Edit_LimitText(GetDlgItem(hDlg, IDE_SMALLANIMBITMAP), countof(szSmallAnimBmp) - 1);
  169. Edit_LimitText(GetDlgItem(hDlg, IDE_BIGANIMBITMAP), countof(szLargeAnimBmp) - 1);
  170. Edit_LimitText(GetDlgItem(hDlg, IDC_BITMAP), countof(szLargeBmp) - 1);
  171. Edit_LimitText(GetDlgItem(hDlg, IDC_BITMAP2), countof(szSmallBmp) - 1);
  172. }
  173. break;
  174. case WM_COMMAND:
  175. switch (GET_WM_COMMAND_ID(wParam, lParam))
  176. {
  177. case IDC_BROWSEBIG:
  178. GetDlgItemText(hDlg, IDE_BIGANIMBITMAP, szLargeAnimBmp, countof(szLargeAnimBmp));
  179. if(BrowseForFile(hDlg, szLargeAnimBmp, countof(szLargeAnimBmp), GFN_BMP))
  180. SetDlgItemText(hDlg, IDE_BIGANIMBITMAP, szLargeAnimBmp);
  181. break;
  182. case IDC_BROWSESMALL:
  183. GetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, szSmallAnimBmp, countof(szSmallAnimBmp));
  184. if(BrowseForFile(hDlg, szSmallAnimBmp, countof(szSmallAnimBmp), GFN_BMP))
  185. SetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, szSmallAnimBmp);
  186. break;
  187. case IDC_ANIMBITMAP:
  188. fBrandAnim = (IsDlgButtonChecked(hDlg, IDC_ANIMBITMAP) == BST_CHECKED);
  189. EnableDlgItem2(hDlg, IDE_BIGANIMBITMAP, fBrandAnim);
  190. EnableDlgItem2(hDlg, IDC_BROWSEBIG, fBrandAnim);
  191. EnableDlgItem2(hDlg, IDC_BIGANIMBITMAP_TXT, fBrandAnim);
  192. EnableDlgItem2(hDlg, IDE_SMALLANIMBITMAP, fBrandAnim);
  193. EnableDlgItem2(hDlg, IDC_BROWSESMALL, fBrandAnim);
  194. EnableDlgItem2(hDlg, IDC_SMALLANIMBITMAP_TXT, fBrandAnim);
  195. break;
  196. case IDC_BROWSEICON:
  197. if(HIWORD(wParam) == BN_CLICKED)
  198. {
  199. GetDlgItemText(hDlg, IDC_BITMAP, szLargeBmp, countof(szLargeBmp));
  200. if(BrowseForFile(hDlg, szLargeBmp, countof(szLargeBmp), GFN_BMP))
  201. SetDlgItemText(hDlg, IDC_BITMAP, szLargeBmp);
  202. break;
  203. }
  204. return FALSE;
  205. case IDC_BROWSEICON2:
  206. if(HIWORD(wParam) == BN_CLICKED)
  207. {
  208. GetDlgItemText(hDlg, IDC_BITMAP2, szSmallBmp, countof(szSmallBmp));
  209. if(BrowseForFile(hDlg, szSmallBmp, countof(szSmallBmp), GFN_BMP))
  210. SetDlgItemText(hDlg, IDC_BITMAP2, szSmallBmp);
  211. break;
  212. }
  213. return FALSE;
  214. case IDC_BITMAPCHECK:
  215. if(HIWORD(wParam) == BN_CLICKED)
  216. {
  217. fBrandBmps = (IsDlgButtonChecked(hDlg, IDC_BITMAPCHECK) == BST_CHECKED);
  218. EnableDlgItem2(hDlg, IDC_BITMAP, fBrandBmps);
  219. EnableDlgItem2(hDlg, IDC_BROWSEICON, fBrandBmps);
  220. EnableDlgItem2(hDlg, IDC_LARGEBITMAP_TXT, fBrandBmps);
  221. EnableDlgItem2(hDlg, IDC_BROWSEICON2, fBrandBmps);
  222. EnableDlgItem2(hDlg, IDC_BITMAP2, fBrandBmps);
  223. EnableDlgItem2(hDlg, IDC_SMALLBITMAP_TXT, fBrandBmps);
  224. break;
  225. }
  226. return FALSE;
  227. default:
  228. return FALSE;
  229. }
  230. break;
  231. case WM_HELP: // F1
  232. ShowHelpTopic(hDlg);
  233. break;
  234. case WM_NOTIFY:
  235. switch (((LPNMHDR)lParam)->code)
  236. {
  237. TCHAR szMsgTitle[1024];
  238. TCHAR szMsgText[1024];
  239. case PSN_HELP:
  240. ShowHelpTopic(hDlg);
  241. break;
  242. case PSN_SETACTIVE:
  243. // don't do any of this stuff in RSoP mode
  244. if (!psCookie->pCS->IsRSoP())
  245. {
  246. // load information from ins file
  247. SetDlgItemTextFromIns(hDlg, IDE_BIGANIMBITMAP, IDC_ANIMBITMAP, IS_ANIMATION,
  248. TEXT("Big_Path"), GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  249. SetDlgItemTextFromIns(hDlg, IDE_SMALLANIMBITMAP, IDC_ANIMBITMAP, IS_ANIMATION,
  250. TEXT("Small_Path"), GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  251. InsGetString(IS_SMALLLOGO, TEXT("Path"),
  252. szSmallBmp, ARRAYSIZE(szSmallBmp), GetInsFile(hDlg));
  253. InsGetString(IS_LARGELOGO, TEXT("Path"),
  254. szLargeBmp, ARRAYSIZE(szLargeBmp), GetInsFile(hDlg), NULL, &fBrandBmps);
  255. SetDlgItemTextTriState(hDlg, IDC_BITMAP2, IDC_BITMAPCHECK, szSmallBmp, fBrandBmps);
  256. SetDlgItemTextTriState(hDlg, IDC_BITMAP, IDC_BITMAPCHECK, szLargeBmp, fBrandBmps);
  257. fBrandAnim = (IsDlgButtonChecked(hDlg, IDC_ANIMBITMAP) == BST_CHECKED);
  258. EnableDlgItem2(hDlg, IDC_BROWSEBIG, fBrandAnim);
  259. EnableDlgItem2(hDlg, IDC_BIGANIMBITMAP_TXT, fBrandAnim);
  260. EnableDlgItem2(hDlg, IDC_BROWSESMALL, fBrandAnim);
  261. EnableDlgItem2(hDlg, IDC_SMALLANIMBITMAP_TXT, fBrandAnim);
  262. EnableDlgItem2(hDlg, IDC_BROWSEICON, fBrandBmps);
  263. EnableDlgItem2(hDlg, IDC_LARGEBITMAP_TXT, fBrandBmps);
  264. EnableDlgItem2(hDlg, IDC_BROWSEICON2, fBrandBmps);
  265. EnableDlgItem2(hDlg, IDC_SMALLBITMAP_TXT, fBrandBmps);
  266. }
  267. break;
  268. case PSN_APPLY:
  269. if (psCookie->pCS->IsRSoP())
  270. return FALSE;
  271. else
  272. {
  273. //code from old animation dlg
  274. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\ANIMBMP"), szWorkDir);
  275. fBrandAnim = (IsDlgButtonChecked(hDlg, IDC_ANIMBITMAP) == BST_CHECKED);
  276. GetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, szSmallAnimBmp, countof(szSmallAnimBmp));
  277. GetDlgItemText(hDlg, IDE_BIGANIMBITMAP, szLargeAnimBmp, countof(szLargeAnimBmp));
  278. if (fBrandAnim && (!IsAnimBitmapFileValid(hDlg, IDE_SMALLANIMBITMAP, szSmallAnimBmp, NULL, IDS_TOOBIG22, IDS_TOOSMALL22, 22, 22) ||
  279. !IsAnimBitmapFileValid(hDlg, IDE_BIGANIMBITMAP, szLargeAnimBmp, NULL, IDS_TOOBIG38, IDS_TOOSMALL38, 38, 38)))
  280. {
  281. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  282. break;
  283. }
  284. //code from original custicon dlg
  285. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\LOGO"), szWorkDir);
  286. fBrandBmps = (IsDlgButtonChecked(hDlg, IDC_BITMAPCHECK) == BST_CHECKED);
  287. GetDlgItemText(hDlg, IDC_BITMAP2, szSmallBmp, countof(szSmallBmp));
  288. GetDlgItemText(hDlg, IDC_BITMAP, szLargeBmp, countof(szLargeBmp));
  289. if (fBrandBmps && (!IsBitmapFileValid(hDlg, IDC_BITMAP2, szSmallBmp, NULL, 22, 22, IDS_TOOBIG22, IDS_TOOSMALL22) ||
  290. !IsBitmapFileValid(hDlg, IDC_BITMAP, szLargeBmp, NULL, 38, 38, IDS_TOOBIG38, IDS_TOOSMALL38)))
  291. {
  292. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  293. break;
  294. }
  295. nStatus = TS_CHECK_OK;
  296. IsTriStateValid(hDlg, IDC_BITMAP2, IDC_BITMAPCHECK, &nStatus,
  297. res2Str(IDS_QUERY_CLEARSETTING, szMsgText, countof(szMsgText)),
  298. res2Str(IDS_TITLE, szMsgTitle, countof(szMsgTitle)));
  299. IsTriStateValid(hDlg, IDC_BITMAP, IDC_BITMAPCHECK, &nStatus, szMsgText, szMsgTitle);
  300. IsTriStateValid(hDlg, IDE_SMALLANIMBITMAP, IDC_ANIMBITMAP, &nStatus,
  301. res2Str(IDS_QUERY_CLEARSETTING, szMsgText, countof(szMsgText)),
  302. res2Str(IDS_TITLE, szMsgTitle, countof(szMsgTitle)));
  303. IsTriStateValid(hDlg, IDE_BIGANIMBITMAP, IDC_ANIMBITMAP, &nStatus,
  304. szMsgText, szMsgTitle);
  305. if (nStatus == TS_CHECK_ERROR ||
  306. !AcquireWriteCriticalSection(hDlg))
  307. {
  308. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  309. break;
  310. }
  311. CopyLogoBmp(hDlg, szSmallBmp, IS_SMALLLOGO, szWorkDir, GetInsFile(hDlg));
  312. CopyLogoBmp(hDlg, szLargeBmp, IS_LARGELOGO, szWorkDir, GetInsFile(hDlg));
  313. CopyAnimBmp(hDlg, szSmallAnimBmp, szWorkDir, IK_SMALLBITMAP, TEXT("Small_Path"), GetInsFile(hDlg));
  314. CopyAnimBmp(hDlg, szLargeAnimBmp, szWorkDir, IK_LARGEBITMAP, TEXT("Big_Path"), GetInsFile(hDlg));
  315. InsWriteBool(IS_ANIMATION, IK_DOANIMATION, fBrandAnim, GetInsFile(hDlg));
  316. if (PathIsDirectoryEmpty(szWorkDir))
  317. PathRemovePath(szWorkDir);
  318. if (PathIsDirectoryEmpty(szWorkDir))
  319. PathRemovePath(szWorkDir);
  320. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  321. }
  322. break;
  323. default:
  324. return FALSE;
  325. }
  326. break;
  327. default:
  328. return FALSE;
  329. }
  330. return TRUE;
  331. }