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.

264 lines
6.0 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // finish page
  4. //
  5. // 12-19-97 sburns
  6. #include "headers.hxx"
  7. #include "finish.hpp"
  8. #include "resource.h"
  9. #include "common.hpp"
  10. #include "state.hpp"
  11. FinishPage::FinishPage()
  12. :
  13. WizardPage(
  14. IDD_FINISH,
  15. IDS_FINISH_PAGE_TITLE,
  16. IDS_FINISH_PAGE_SUBTITLE,
  17. false),
  18. needToKillSelection(false)
  19. {
  20. LOG_CTOR(FinishPage);
  21. }
  22. FinishPage::~FinishPage()
  23. {
  24. LOG_DTOR(FinishPage);
  25. }
  26. void
  27. FinishPage::OnInit()
  28. {
  29. LOG_FUNCTION(FinishPage::OnInit);
  30. SetLargeFont(hwnd, IDC_BIG_BOLD_TITLE);
  31. Win::PropSheet_CancelToClose(Win::GetParent(hwnd));
  32. // Since the multi-line edit control has a bug that causes it to eat
  33. // enter keypresses, we will subclass the control to make it forward
  34. // those keypresses to the page as WM_COMMAND messages
  35. // This workaround from phellyar.
  36. // NTRAID#NTBUG9-232092-2001/07/02-sburns
  37. multiLineEdit.Init(Win::GetDlgItem(hwnd, IDC_MESSAGE));
  38. }
  39. static
  40. String
  41. getCompletionMessage()
  42. {
  43. LOG_FUNCTION(getCompletionMessage);
  44. String message;
  45. State& state = State::GetInstance();
  46. State::Operation operation = state.GetOperation();
  47. if (state.GetOperationResultsCode() == State::SUCCESS)
  48. {
  49. switch (operation)
  50. {
  51. case State::REPLICA:
  52. case State::FOREST:
  53. case State::TREE:
  54. case State::CHILD:
  55. {
  56. String domain =
  57. operation == State::REPLICA
  58. ? state.GetReplicaDomainDNSName()
  59. : state.GetNewDomainDNSName();
  60. message = String::format(IDS_FINISH_PROMOTE, domain.c_str());
  61. String site = state.GetInstalledSite();
  62. if (!site.empty())
  63. {
  64. message +=
  65. String::format(
  66. IDS_FINISH_SITE,
  67. site.c_str());
  68. }
  69. break;
  70. }
  71. case State::DEMOTE:
  72. {
  73. message = String::load(IDS_FINISH_DEMOTE);
  74. break;
  75. }
  76. case State::ABORT_BDC_UPGRADE:
  77. {
  78. message = String::load(IDS_FINISH_ABORT_BDC_UPGRADE);
  79. break;
  80. }
  81. case State::NONE:
  82. default:
  83. {
  84. ASSERT(false);
  85. break;
  86. }
  87. }
  88. }
  89. else
  90. {
  91. switch (operation)
  92. {
  93. case State::REPLICA:
  94. case State::FOREST:
  95. case State::TREE:
  96. case State::CHILD:
  97. {
  98. message = String::load(IDS_FINISH_FAILURE);
  99. break;
  100. }
  101. case State::DEMOTE:
  102. {
  103. message = String::load(IDS_FINISH_DEMOTE_FAILURE);
  104. break;
  105. }
  106. case State::ABORT_BDC_UPGRADE:
  107. {
  108. message = String::load(IDS_FINISH_ABORT_BDC_UPGRADE_FAILURE);
  109. break;
  110. }
  111. case State::NONE:
  112. default:
  113. {
  114. ASSERT(false);
  115. break;
  116. }
  117. }
  118. }
  119. return message + L"\r\n\r\n" + state.GetFinishMessages();
  120. }
  121. bool
  122. FinishPage::OnSetActive()
  123. {
  124. LOG_FUNCTION(FinishPage::OnSetActive);
  125. Win::PropSheet_SetWizButtons(
  126. Win::GetParent(hwnd),
  127. PSWIZB_FINISH);
  128. State& state = State::GetInstance();
  129. if (state.RunHiddenUnattended())
  130. {
  131. Win::PropSheet_PressButton(Win::GetParent(hwnd), PSBTN_FINISH);
  132. }
  133. else
  134. {
  135. Win::SetDlgItemText(hwnd, IDC_MESSAGE, getCompletionMessage());
  136. needToKillSelection = true;
  137. }
  138. return true;
  139. }
  140. bool
  141. FinishPage::OnCommand(
  142. HWND windowFrom,
  143. unsigned controlIdFrom,
  144. unsigned code)
  145. {
  146. bool result = false;
  147. switch (controlIdFrom)
  148. {
  149. case IDCANCEL:
  150. {
  151. // multi-line edit control eats escape keys. This is a workaround
  152. // from ericb, to forward the message to the prop sheet.
  153. Win::SendMessage(
  154. Win::GetParent(hwnd),
  155. WM_COMMAND,
  156. MAKEWPARAM(controlIdFrom, code),
  157. (LPARAM) windowFrom);
  158. break;
  159. }
  160. case IDC_MESSAGE:
  161. {
  162. switch (code)
  163. {
  164. case EN_SETFOCUS:
  165. {
  166. if (needToKillSelection)
  167. {
  168. // kill the text selection
  169. Win::Edit_SetSel(windowFrom, -1, -1);
  170. needToKillSelection = false;
  171. result = true;
  172. }
  173. break;
  174. }
  175. case MultiLineEditBoxThatForwardsEnterKey::FORWARDED_ENTER:
  176. {
  177. // our subclasses mutli-line edit control will send us
  178. // WM_COMMAND messages when the enter key is pressed. We
  179. // reinterpret this message as a press on the default button of
  180. // the prop sheet.
  181. // This workaround from phellyar.
  182. // NTRAID#NTBUG9-232092-2001/07/02-sburns
  183. // CODEWORK: There are several instances of this code so far;
  184. // looks like it merits a common base class.
  185. HWND propSheet = Win::GetParent(hwnd);
  186. int defaultButtonId =
  187. Win::Dialog_GetDefaultButtonId(propSheet);
  188. // we expect that there is always a default button on the prop sheet
  189. ASSERT(defaultButtonId);
  190. Win::SendMessage(
  191. propSheet,
  192. WM_COMMAND,
  193. MAKELONG(defaultButtonId, BN_CLICKED),
  194. 0);
  195. result = true;
  196. break;
  197. }
  198. }
  199. break;
  200. }
  201. default:
  202. {
  203. // do nothing
  204. break;
  205. }
  206. }
  207. return result;
  208. }
  209. bool
  210. FinishPage::OnWizFinish()
  211. {
  212. LOG_FUNCTION(FinishPage::OnWizFinish);
  213. return true;
  214. }