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.

262 lines
5.6 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // File: FinishPage.cpp
  4. //
  5. // Synopsis: Defines the Finish Page for the CYS
  6. // wizard
  7. //
  8. // History: 02/03/2001 JeffJon Created
  9. #include "pch.h"
  10. #include "resource.h"
  11. #include "uiutil.h"
  12. #include "InstallationUnitProvider.h"
  13. #include "FinishPage.h"
  14. FinishPage::FinishPage()
  15. :
  16. WizardPage(
  17. IDD_FINISH_PAGE,
  18. // Title and subtitle are not needed on the finish page
  19. // so just set a bogus one that gives good logging spew
  20. IDS_FINISH_TITLE,
  21. IDS_FINISH_SUBTITLE,
  22. false,
  23. true)
  24. {
  25. LOG_CTOR(FinishPage);
  26. }
  27. FinishPage::~FinishPage()
  28. {
  29. LOG_DTOR(FinishPage);
  30. }
  31. void
  32. FinishPage::OnInit()
  33. {
  34. LOG_FUNCTION(FinishPage::OnInit);
  35. // Since this page can be started directly
  36. // we have to be sure to set the wizard title
  37. Win::PropSheet_SetTitle(
  38. Win::GetParent(hwnd),
  39. 0,
  40. String::load(IDS_WIZARD_TITLE));
  41. SetLargeFont(hwnd, IDC_BIG_BOLD_TITLE);
  42. // Back should never be enabled
  43. Win::PropSheet_SetWizButtons(
  44. Win::GetParent(hwnd),
  45. PSWIZB_FINISH);
  46. // Disable the cancel button because
  47. // there is nothing to cancel once you
  48. // get here
  49. Win::EnableWindow(
  50. Win::GetDlgItem(
  51. Win::GetParent(hwnd),
  52. IDCANCEL),
  53. false);
  54. // Disable the X in the top right corner
  55. HMENU menu = GetSystemMenu(GetParent(hwnd), FALSE);
  56. if (menu)
  57. {
  58. EnableMenuItem(
  59. menu,
  60. SC_CLOSE,
  61. MF_BYCOMMAND | MF_GRAYED);
  62. }
  63. // Get the current installation type
  64. InstallationUnit& currentInstallationUnit =
  65. InstallationUnitProvider::GetInstance().GetCurrentInstallationUnit();
  66. // Get the finish text from the installation unit and put it in the finish box
  67. String finishTitle =
  68. currentInstallationUnit.GetFinishTitle();
  69. Win::SetDlgItemText(
  70. hwnd,
  71. IDC_BIG_BOLD_TITLE,
  72. finishTitle);
  73. String message =
  74. currentInstallationUnit.GetFinishText();
  75. Win::SetDlgItemText(
  76. hwnd,
  77. IDC_FINISH_MESSAGE,
  78. message);
  79. }
  80. bool
  81. FinishPage::OnSetActive()
  82. {
  83. LOG_FUNCTION(FinishPage::OnSetActive);
  84. Win::PostMessage(
  85. Win::GetParent(hwnd),
  86. WM_NEXTDLGCTL,
  87. (WPARAM) Win::GetDlgItem(Win::GetParent(hwnd), Wizard::FINISH_BTN_ID),
  88. TRUE);
  89. return true;
  90. }
  91. bool
  92. FinishPage::OnHelp()
  93. {
  94. LOG_FUNCTION(FinishPage::OnHelp);
  95. InstallationUnit& currentInstallationUnit =
  96. InstallationUnitProvider::GetInstance().GetCurrentInstallationUnit();
  97. String helpTag =
  98. currentInstallationUnit.GetAfterFinishHelp();
  99. if (currentInstallationUnit.Installing())
  100. {
  101. InstallationReturnType result = currentInstallationUnit.GetInstallResult();
  102. if (result != INSTALL_SUCCESS &&
  103. result != INSTALL_SUCCESS_REBOOT &&
  104. result != INSTALL_SUCCESS_PROMPT_REBOOT)
  105. {
  106. helpTag = currentInstallationUnit.GetFinishHelp();
  107. }
  108. }
  109. else
  110. {
  111. helpTag = currentInstallationUnit.GetFinishHelp();
  112. UnInstallReturnType result = currentInstallationUnit.GetUnInstallResult();
  113. if (result == UNINSTALL_SUCCESS ||
  114. result == UNINSTALL_SUCCESS_REBOOT ||
  115. result == UNINSTALL_SUCCESS_PROMPT_REBOOT)
  116. {
  117. helpTag = L"cys.chm::/cys_topnode.htm";
  118. }
  119. }
  120. LOG(String::format(
  121. L"helpTag = %1",
  122. helpTag.c_str()));
  123. ShowHelp(helpTag);
  124. return true;
  125. }
  126. bool
  127. FinishPage::OnWizFinish()
  128. {
  129. LOG_FUNCTION(FinishPage::OnWizFinish);
  130. Win::WaitCursor wait;
  131. bool result = false;
  132. // Run the post install actions
  133. if (InstallationUnitProvider::GetInstance().GetCurrentInstallationUnit().Installing() ||
  134. (State::GetInstance().IsRebootScenario() &&
  135. State::GetInstance().ShouldRunMYS()))
  136. {
  137. InstallationUnitProvider::GetInstance().
  138. GetCurrentInstallationUnit().DoPostInstallAction(hwnd);
  139. }
  140. LOG_BOOL(result);
  141. Win::SetWindowLongPtr(hwnd, DWLP_MSGRESULT, result ? TRUE : FALSE);
  142. if (!result)
  143. {
  144. // clean up the InstallationUnits so that all the data must be re-read if
  145. // if CYS automatically restarts
  146. InstallationUnitProvider::GetInstance().Destroy();
  147. }
  148. return true;
  149. }
  150. bool
  151. FinishPage::OnQueryCancel()
  152. {
  153. LOG_FUNCTION(FinishPage::OnQueryCancel);
  154. bool result = false;
  155. // set the rerun state to false so the wizard doesn't
  156. // just restart itself
  157. // State::GetInstance().SetRerunWizard(false);
  158. Win::SetWindowLongPtr(
  159. hwnd,
  160. DWLP_MSGRESULT,
  161. result ? TRUE : FALSE);
  162. return true;
  163. }
  164. bool
  165. FinishPage::OnNotify(
  166. HWND /*windowFrom*/,
  167. UINT_PTR controlIDFrom,
  168. UINT code,
  169. LPARAM lParam)
  170. {
  171. // LOG_FUNCTION(FinishPage::OnCommand);
  172. bool result = false;
  173. if (controlIDFrom == IDC_FINISH_MESSAGE)
  174. {
  175. switch (code)
  176. {
  177. case NM_CLICK:
  178. case NM_RETURN:
  179. {
  180. int linkIndex = LinkIndexFromNotifyLPARAM(lParam);
  181. InstallationUnitProvider::GetInstance().
  182. GetCurrentInstallationUnit().FinishLinkSelected(linkIndex, hwnd);
  183. }
  184. default:
  185. {
  186. // do nothing
  187. break;
  188. }
  189. }
  190. }
  191. else if (controlIDFrom == IDC_LOG_STATIC)
  192. {
  193. switch (code)
  194. {
  195. case NM_CLICK:
  196. case NM_RETURN:
  197. {
  198. ::OpenLogFile();
  199. }
  200. default:
  201. break;
  202. }
  203. }
  204. return result;
  205. }