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.

253 lines
8.5 KiB

  1. #include "precomp.h"
  2. #include <comdef.h>
  3. #include "rsop.h"
  4. ///////////////////////////////////////////////////////////
  5. void InitAnimBmpDlgInRSoPMode(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 bBrandAnimHandled = FALSE;
  16. for (long nObj = 0; nObj < nPSObjects; nObj++)
  17. {
  18. // customizeAnimatedBitmaps field
  19. if (!bBrandAnimHandled)
  20. {
  21. _variant_t vtValue;
  22. hr = paPSObj[nObj]->pObj->Get(L"customizeAnimatedBitmaps", 0, &vtValue, NULL, NULL);
  23. BOOL fBrandAnim = FALSE;
  24. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  25. {
  26. fBrandAnim = vtValue.boolVal ? TRUE : FALSE;
  27. bBrandAnimHandled = TRUE;
  28. }
  29. if (fBrandAnim)
  30. {
  31. CheckDlgButton(hDlg, IDC_ANIMBITMAP, BST_CHECKED);
  32. // smallAnimatedBitmapPath field
  33. hr = paPSObj[nObj]->pObj->Get(L"smallAnimatedBitmapPath", 0, &vtValue, NULL, NULL);
  34. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  35. {
  36. _bstr_t bstrVal = vtValue;
  37. SetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, (LPCTSTR)bstrVal);
  38. }
  39. // largeAnimatedBitmapPath field
  40. hr = paPSObj[nObj]->pObj->Get(L"largeAnimatedBitmapPath", 0, &vtValue, NULL, NULL);
  41. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  42. {
  43. _bstr_t bstrVal = vtValue;
  44. SetDlgItemText(hDlg, IDE_BIGANIMBITMAP, (LPCTSTR)bstrVal);
  45. }
  46. }
  47. }
  48. // no need to process other GPOs since enabled properties have been found
  49. if (bBrandAnimHandled)
  50. break;
  51. }
  52. }
  53. }
  54. __except(TRUE)
  55. {
  56. }
  57. }
  58. /////////////////////////////////////////////////////////////////////
  59. HRESULT InitSmallBmpPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  60. {
  61. return InitGenericPrecedencePage(pDRD, hwndList, L"smallAnimatedBitmapPath");
  62. }
  63. /////////////////////////////////////////////////////////////////////
  64. HRESULT InitLargeBmpPrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  65. {
  66. return InitGenericPrecedencePage(pDRD, hwndList, L"largeAnimatedBitmapPath");
  67. }
  68. ///////////////////////////////////////////////////////////
  69. INT_PTR CALLBACK AnimBmpDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  70. {
  71. // Retrieve Property Sheet Page info for each call into dlg proc.
  72. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  73. TCHAR szLargeBmp[MAX_PATH];
  74. TCHAR szSmallBmp[MAX_PATH];
  75. TCHAR szWorkDir[MAX_PATH];
  76. BOOL fBrandAnim;
  77. int nStatus;
  78. switch(msg)
  79. {
  80. case WM_SETFONT:
  81. //a change to mmc requires us to do this logic for all our property pages that use common controls
  82. INITCOMMONCONTROLSEX iccx;
  83. iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
  84. iccx.dwICC = ICC_ANIMATE_CLASS | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES |ICC_TREEVIEW_CLASSES;
  85. InitCommonControlsEx(&iccx);
  86. break;
  87. case WM_INITDIALOG:
  88. SetPropSheetCookie(hDlg, lParam);
  89. EnableDBCSChars(hDlg, IDE_SMALLANIMBITMAP);
  90. EnableDBCSChars(hDlg, IDE_BIGANIMBITMAP);
  91. // find out if this dlg is in RSoP mode
  92. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  93. if (psCookie->pCS->IsRSoP())
  94. {
  95. EnableDlgItem2(hDlg, IDC_ANIMBITMAP, FALSE);
  96. EnableDlgItem2(hDlg, IDC_BROWSEBIG, FALSE);
  97. EnableDlgItem2(hDlg, IDE_BIGANIMBITMAP, FALSE);
  98. EnableDlgItem2(hDlg, IDC_BROWSESMALL, FALSE);
  99. EnableDlgItem2(hDlg, IDE_SMALLANIMBITMAP, FALSE);
  100. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  101. InitAnimBmpDlgInRSoPMode(hDlg, pDRD);
  102. }
  103. else
  104. {
  105. Edit_LimitText(GetDlgItem(hDlg, IDE_SMALLANIMBITMAP), countof(szSmallBmp) - 1);
  106. Edit_LimitText(GetDlgItem(hDlg, IDE_BIGANIMBITMAP), countof(szLargeBmp) - 1);
  107. }
  108. break;
  109. case WM_DESTROY:
  110. if (psCookie->pCS->IsRSoP())
  111. DestroyDlgRSoPData(hDlg);
  112. break;
  113. case WM_COMMAND:
  114. if (BN_CLICKED != GET_WM_COMMAND_CMD(wParam, lParam))
  115. return FALSE;
  116. switch (GET_WM_COMMAND_ID(wParam, lParam))
  117. {
  118. case IDC_BROWSEBIG:
  119. GetDlgItemText(hDlg, IDE_BIGANIMBITMAP, szLargeBmp, countof(szLargeBmp));
  120. if(BrowseForFile(hDlg, szLargeBmp, countof(szLargeBmp), GFN_BMP))
  121. SetDlgItemText(hDlg, IDE_BIGANIMBITMAP, szLargeBmp);
  122. break;
  123. case IDC_BROWSESMALL:
  124. GetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, szSmallBmp, countof(szSmallBmp));
  125. if(BrowseForFile(hDlg, szSmallBmp, countof(szSmallBmp), GFN_BMP))
  126. SetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, szSmallBmp);
  127. break;
  128. case IDC_ANIMBITMAP:
  129. fBrandAnim = (IsDlgButtonChecked(hDlg, IDC_ANIMBITMAP) == BST_CHECKED);
  130. EnableDlgItem2(hDlg, IDE_BIGANIMBITMAP, fBrandAnim);
  131. EnableDlgItem2(hDlg, IDC_BROWSEBIG, fBrandAnim);
  132. EnableDlgItem2(hDlg, IDC_BIGANIMBITMAP_TXT, fBrandAnim);
  133. EnableDlgItem2(hDlg, IDE_SMALLANIMBITMAP, fBrandAnim);
  134. EnableDlgItem2(hDlg, IDC_BROWSESMALL, fBrandAnim);
  135. EnableDlgItem2(hDlg, IDC_SMALLANIMBITMAP_TXT, fBrandAnim);
  136. break;
  137. default:
  138. return FALSE;
  139. }
  140. break;
  141. case WM_HELP: // F1
  142. ShowHelpTopic(hDlg);
  143. break;
  144. case WM_NOTIFY:
  145. switch (((LPNMHDR)lParam)->code)
  146. {
  147. TCHAR szMsgTitle[1024];
  148. TCHAR szMsgText[1024];
  149. case PSN_HELP:
  150. ShowHelpTopic(hDlg);
  151. break;
  152. case PSN_SETACTIVE:
  153. // don't do any of this stuff in RSoP mode
  154. if (!psCookie->pCS->IsRSoP())
  155. {
  156. // load information from ins file
  157. SetDlgItemTextFromIns(hDlg, IDE_BIGANIMBITMAP, IDC_ANIMBITMAP, IS_ANIMATION,
  158. TEXT("Big_Path"), GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  159. SetDlgItemTextFromIns(hDlg, IDE_SMALLANIMBITMAP, IDC_ANIMBITMAP, IS_ANIMATION,
  160. TEXT("Small_Path"), GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  161. fBrandAnim = (IsDlgButtonChecked(hDlg, IDC_ANIMBITMAP) == BST_CHECKED);
  162. EnableDlgItem2(hDlg, IDC_BROWSEBIG, fBrandAnim);
  163. EnableDlgItem2(hDlg, IDC_BIGANIMBITMAP_TXT, fBrandAnim);
  164. EnableDlgItem2(hDlg, IDC_BROWSESMALL, fBrandAnim);
  165. EnableDlgItem2(hDlg, IDC_SMALLANIMBITMAP_TXT, fBrandAnim);
  166. }
  167. break;
  168. case PSN_APPLY:
  169. if (psCookie->pCS->IsRSoP())
  170. return FALSE;
  171. else
  172. {
  173. CreateWorkDir(GetInsFile(hDlg), IEAK_GPE_BRANDING_SUBDIR TEXT("\\ANIMBMP"), szWorkDir);
  174. fBrandAnim = (IsDlgButtonChecked(hDlg, IDC_ANIMBITMAP) == BST_CHECKED);
  175. GetDlgItemText(hDlg, IDE_SMALLANIMBITMAP, szSmallBmp, countof(szSmallBmp));
  176. GetDlgItemText(hDlg, IDE_BIGANIMBITMAP, szLargeBmp, countof(szLargeBmp));
  177. if (fBrandAnim && (!IsAnimBitmapFileValid(hDlg, IDE_SMALLANIMBITMAP, szSmallBmp, NULL, IDS_TOOBIG22, IDS_TOOSMALL22, 22, 22) ||
  178. !IsAnimBitmapFileValid(hDlg, IDE_BIGANIMBITMAP, szLargeBmp, NULL, IDS_TOOBIG38, IDS_TOOSMALL38, 38, 38)))
  179. {
  180. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  181. break;
  182. }
  183. nStatus = TS_CHECK_OK;
  184. IsTriStateValid(hDlg, IDE_SMALLANIMBITMAP, IDC_ANIMBITMAP, &nStatus,
  185. res2Str(IDS_QUERY_CLEARSETTING, szMsgText, countof(szMsgText)),
  186. res2Str(IDS_TITLE, szMsgTitle, countof(szMsgTitle)));
  187. IsTriStateValid(hDlg, IDE_BIGANIMBITMAP, IDC_ANIMBITMAP, &nStatus,
  188. szMsgText, szMsgTitle);
  189. if (nStatus == TS_CHECK_ERROR ||
  190. !AcquireWriteCriticalSection(hDlg))
  191. {
  192. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  193. break;
  194. }
  195. CopyAnimBmp(hDlg, szSmallBmp, szWorkDir, IK_SMALLBITMAP, TEXT("Small_Path"), GetInsFile(hDlg));
  196. CopyAnimBmp(hDlg, szLargeBmp, szWorkDir, IK_LARGEBITMAP, TEXT("Big_Path"), GetInsFile(hDlg));
  197. InsWriteBool(IS_ANIMATION, IK_DOANIMATION, fBrandAnim, GetInsFile(hDlg));
  198. if (PathIsDirectoryEmpty(szWorkDir))
  199. PathRemovePath(szWorkDir);
  200. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  201. }
  202. break;
  203. default:
  204. return FALSE;
  205. }
  206. break;
  207. default:
  208. return FALSE;
  209. }
  210. return TRUE;
  211. }