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.

181 lines
5.9 KiB

  1. #include "precomp.h"
  2. #include "rsop.h"
  3. /////////////////////////////////////////////////////////////////////
  4. void InitTitleDlgInRSoPMode(HWND hDlg, CDlgRSoPData *pDRD)
  5. {
  6. __try
  7. {
  8. _bstr_t bstrClass = L"RSOP_IEAKPolicySetting";
  9. HRESULT hr = pDRD->GetArrayOfPSObjects(bstrClass);
  10. if (SUCCEEDED(hr))
  11. {
  12. CPSObjData **paPSObj = pDRD->GetPSObjArray();
  13. long nPSObjects = pDRD->GetPSObjCount();
  14. BOOL bTitleHandled = FALSE;
  15. for (long nObj = 0; nObj < nPSObjects; nObj++)
  16. {
  17. // titleBarText field
  18. _variant_t vtValue;
  19. hr = paPSObj[nObj]->pObj->Get(L"titleBarCustomText", 0, &vtValue, NULL, NULL);
  20. if (SUCCEEDED(hr) && !IsVariantNull(vtValue))
  21. {
  22. _bstr_t bstrValue = vtValue;
  23. BOOL bChecked = (bstrValue.length() > 0);
  24. SetDlgItemTextTriState(hDlg, IDE_TITLE, IDC_TITLE, (LPTSTR)bstrValue, bChecked);
  25. bTitleHandled = TRUE;
  26. }
  27. // no need to process other GPOs since enabled properties have been found
  28. if (bTitleHandled)
  29. break;
  30. }
  31. }
  32. EnableDlgItem2(hDlg, IDC_TITLE, FALSE);
  33. EnableDlgItem2(hDlg, IDE_TITLE, FALSE);
  34. }
  35. __except(TRUE)
  36. {
  37. }
  38. }
  39. /////////////////////////////////////////////////////////////////////
  40. HRESULT InitTitlePrecPage(CDlgRSoPData *pDRD, HWND hwndList)
  41. {
  42. return InitGenericPrecedencePage(pDRD, hwndList, L"titleBarCustomText");
  43. }
  44. /////////////////////////////////////////////////////////////////////
  45. INT_PTR CALLBACK TitleDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  46. {
  47. // Retrieve Property Sheet Page info for each call into dlg proc.
  48. LPPROPSHEETCOOKIE psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  49. TCHAR szTitle[MAX_PATH];
  50. TCHAR szFullTitle[1024];
  51. TCHAR szTemp[MAX_PATH];
  52. DWORD dwTitlePrefixLen = 0;
  53. BOOL fTitle;
  54. int nStatus;
  55. switch( msg )
  56. {
  57. case WM_INITDIALOG:
  58. SetPropSheetCookie(hDlg, lParam);
  59. EnableDBCSChars(hDlg, IDE_TITLE);
  60. psCookie = (LPPROPSHEETCOOKIE)GetWindowLongPtr(hDlg, DWLP_USER);
  61. if (psCookie->pCS->IsRSoP())
  62. {
  63. EnableDlgItem2(hDlg, IDC_TITLE, FALSE);
  64. EnableDlgItem2(hDlg, IDE_TITLE, FALSE);
  65. CDlgRSoPData *pDRD = GetDlgRSoPData(hDlg, psCookie->pCS);
  66. if (pDRD)
  67. InitTitleDlgInRSoPMode(hDlg, pDRD);
  68. }
  69. else
  70. {
  71. LoadString(g_hUIInstance, IDS_TITLE_PREFIX, szTitle, countof(szTitle));
  72. dwTitlePrefixLen = StrLen(szTitle);
  73. // browser will only display 74 chars before cutting off title
  74. Edit_LimitText(GetDlgItem(hDlg, IDE_TITLE), 74 - dwTitlePrefixLen);
  75. }
  76. break;
  77. case WM_DESTROY:
  78. if (psCookie->pCS->IsRSoP())
  79. DestroyDlgRSoPData(hDlg);
  80. break;
  81. case WM_COMMAND:
  82. if (GET_WM_COMMAND_CMD(wParam, lParam) != BN_CLICKED)
  83. return FALSE;
  84. switch (GET_WM_COMMAND_ID(wParam, lParam))
  85. {
  86. case IDC_TITLE:
  87. fTitle = (IsDlgButtonChecked(hDlg, IDC_TITLE) == BST_CHECKED);
  88. EnableDlgItem2(hDlg, IDE_TITLE, fTitle);
  89. EnableDlgItem2(hDlg, IDC_TITLE_TXT, fTitle);
  90. break;
  91. default:
  92. return FALSE;
  93. }
  94. break;
  95. case WM_HELP: // F1
  96. ShowHelpTopic(hDlg);
  97. break;
  98. case WM_NOTIFY:
  99. switch (((LPNMHDR)lParam)->code)
  100. {
  101. TCHAR szMsgTitle[1024];
  102. TCHAR szMsgText[1024];
  103. case PSN_HELP:
  104. ShowHelpTopic(hDlg);
  105. break;
  106. case PSN_SETACTIVE:
  107. // don't do any of this stuff in RSoP mode
  108. if (!psCookie->pCS->IsRSoP())
  109. {
  110. SetDlgItemTextFromIns(hDlg, IDE_TITLE, IDC_TITLE, IS_BRANDING, TEXT("Window_Title_CN"),
  111. GetInsFile(hDlg), NULL, INSIO_TRISTATE);
  112. EnableDlgItem2(hDlg, IDC_TITLE_TXT, (IsDlgButtonChecked(hDlg, IDC_TITLE) == BST_CHECKED));
  113. }
  114. break;
  115. case PSN_APPLY:
  116. if (psCookie->pCS->IsRSoP())
  117. return FALSE;
  118. else
  119. {
  120. nStatus = TS_CHECK_OK;
  121. IsTriStateValid(hDlg, IDE_TITLE, IDC_TITLE, &nStatus,
  122. res2Str(IDS_QUERY_CLEARSETTING, szMsgText, countof(szMsgText)),
  123. res2Str(IDS_TITLE, szMsgTitle, countof(szMsgTitle)));
  124. if (nStatus == TS_CHECK_ERROR || !AcquireWriteCriticalSection(hDlg))
  125. {
  126. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  127. break;
  128. }
  129. fTitle = GetDlgItemTextTriState(hDlg, IDE_TITLE, IDC_TITLE, szTitle,countof(szTitle));
  130. // BUGBUG: <oliverl> revisit this in IE6 when we have server-side file
  131. InsWriteString(IS_BRANDING, TEXT("Window_Title_CN"), szTitle, GetInsFile(hDlg),
  132. fTitle, NULL, INSIO_SERVERONLY | INSIO_TRISTATE);
  133. *szFullTitle = TEXT('\0');
  134. if (ISNONNULL(szTitle))
  135. {
  136. LoadString(g_hUIInstance, IDS_TITLE_PREFIX, szTemp, countof(szTemp));
  137. wnsprintf(szFullTitle, countof(szFullTitle), szTemp, szTitle);
  138. }
  139. InsWriteString(IS_BRANDING, IK_WINDOWTITLE, szFullTitle, GetInsFile(hDlg),
  140. fTitle, NULL, INSIO_TRISTATE);
  141. SignalPolicyChanged(hDlg, FALSE, TRUE, &g_guidClientExt, &g_guidSnapinExt);
  142. }
  143. break;
  144. default:
  145. return FALSE;
  146. }
  147. break;
  148. default:
  149. return FALSE;
  150. }
  151. return TRUE;
  152. }