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.

186 lines
4.2 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // failure page
  4. //
  5. // 12-22-97 sburns
  6. #include "headers.hxx"
  7. #include "page.hpp"
  8. #include "FailurePage.hpp"
  9. #include "resource.h"
  10. #include "state.hpp"
  11. FailurePage::FailurePage()
  12. :
  13. DCPromoWizardPage(
  14. IDD_FAILURE,
  15. IDS_FAILURE_PAGE_TITLE,
  16. IDS_FAILURE_PAGE_SUBTITLE),
  17. needToKillSelection(false)
  18. {
  19. LOG_CTOR(FailurePage);
  20. }
  21. FailurePage::~FailurePage()
  22. {
  23. LOG_DTOR(FailurePage);
  24. }
  25. void
  26. FailurePage::OnInit()
  27. {
  28. LOG_FUNCTION(FailurePage::OnInit);
  29. // Since the multi-line edit control has a bug that causes it to eat
  30. // enter keypresses, we will subclass the control to make it forward
  31. // those keypresses to the page as WM_COMMAND messages
  32. // This workaround from phellyar.
  33. // NTRAID#NTBUG9-232092-2001/07/23-sburns
  34. multiLineEdit.Init(Win::GetDlgItem(hwnd, IDC_MESSAGE));
  35. }
  36. bool
  37. FailurePage::OnSetActive()
  38. {
  39. LOG_FUNCTION(FailurePage::OnSetActive);
  40. State& state = State::GetInstance();
  41. if (
  42. state.GetOperationResultsCode() == State::SUCCESS
  43. || state.RunHiddenUnattended() )
  44. {
  45. LOG(L"planning to Skip failure page");
  46. Wizard& wiz = GetWizard();
  47. if (wiz.IsBacktracking())
  48. {
  49. // backup once again
  50. wiz.Backtrack(hwnd);
  51. return true;
  52. }
  53. int nextPage = FailurePage::Validate();
  54. if (nextPage != -1)
  55. {
  56. wiz.SetNextPageID(hwnd, nextPage);
  57. return true;
  58. }
  59. state.ClearHiddenWhileUnattended();
  60. }
  61. Win::SetDlgItemText(hwnd, IDC_MESSAGE, state.GetFailureMessage());
  62. needToKillSelection = true;
  63. Win::PropSheet_SetWizButtons(
  64. Win::GetParent(hwnd),
  65. PSWIZB_BACK | PSWIZB_NEXT);
  66. return true;
  67. }
  68. int
  69. FailurePage::Validate()
  70. {
  71. LOG_FUNCTION(FailurePage::Validate);
  72. return IDD_FINISH;
  73. }
  74. bool
  75. FailurePage::OnCommand(
  76. HWND windowFrom,
  77. unsigned controlIdFrom,
  78. unsigned code)
  79. {
  80. bool result = false;
  81. switch (controlIdFrom)
  82. {
  83. case IDCANCEL:
  84. {
  85. // multi-line edit control eats escape keys. This is a workaround
  86. // from ericb, to forward the message to the prop sheet.
  87. Win::SendMessage(
  88. Win::GetParent(hwnd),
  89. WM_COMMAND,
  90. MAKEWPARAM(controlIdFrom, code),
  91. (LPARAM) windowFrom);
  92. break;
  93. }
  94. case IDC_MESSAGE:
  95. {
  96. switch (code)
  97. {
  98. case EN_SETFOCUS:
  99. {
  100. if (needToKillSelection)
  101. {
  102. // kill the text selection
  103. Win::Edit_SetSel(windowFrom, -1, -1);
  104. needToKillSelection = false;
  105. result = true;
  106. }
  107. break;
  108. }
  109. case MultiLineEditBoxThatForwardsEnterKey::FORWARDED_ENTER:
  110. {
  111. // our subclasses mutli-line edit control will send us
  112. // WM_COMMAND messages when the enter key is pressed. We
  113. // reinterpret this message as a press on the default button of
  114. // the prop sheet.
  115. // This workaround from phellyar.
  116. // NTRAID#NTBUG9-232092-2001/07/23-sburns
  117. // CODEWORK: There are several instances of this code so far;
  118. // looks like it merits a common base class.
  119. HWND propSheet = Win::GetParent(hwnd);
  120. int defaultButtonId =
  121. Win::Dialog_GetDefaultButtonId(propSheet);
  122. // we expect that there is always a default button on the prop sheet
  123. ASSERT(defaultButtonId);
  124. Win::SendMessage(
  125. propSheet,
  126. WM_COMMAND,
  127. MAKELONG(defaultButtonId, BN_CLICKED),
  128. 0);
  129. result = true;
  130. break;
  131. }
  132. }
  133. break;
  134. }
  135. default:
  136. {
  137. // do nothing
  138. break;
  139. }
  140. }
  141. return result;
  142. }