Source code of Windows XP (NT5)
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.

153 lines
2.6 KiB

  1. // Copyright (C) 1997-2001 Microsoft Corporation
  2. //
  3. // allow user to set forest version
  4. // NTRAID#NTBUG9-159663-2001/04/18-sburns
  5. //
  6. // 18 Apr 2001 sburns
  7. #include "headers.hxx"
  8. #include "resource.h"
  9. #include "page.hpp"
  10. #include "ForestVersionPage.hpp"
  11. #include "state.hpp"
  12. ForestVersionPage::ForestVersionPage()
  13. :
  14. DCPromoWizardPage(
  15. IDD_FOREST_VERSION,
  16. IDS_FOREST_VERSION_PAGE_TITLE,
  17. IDS_FOREST_VERSION_PAGE_SUBTITLE)
  18. {
  19. LOG_CTOR(ForestVersionPage);
  20. }
  21. ForestVersionPage::~ForestVersionPage()
  22. {
  23. LOG_DTOR(ForestVersionPage);
  24. }
  25. void
  26. ForestVersionPage::OnInit()
  27. {
  28. LOG_FUNCTION(ForestVersionPage::OnInit);
  29. State& state = State::GetInstance();
  30. if (state.UsingAnswerFile())
  31. {
  32. String option =
  33. state.GetAnswerFileOption(State::OPTION_SET_FOREST_VERSION);
  34. if (option.icompare(State::VALUE_YES) == 0)
  35. {
  36. Win::CheckDlgButton(hwnd, IDC_SET_VERSION, BST_CHECKED);
  37. return;
  38. }
  39. }
  40. Win::CheckDlgButton(hwnd, IDC_SET_VERSION, BST_UNCHECKED);
  41. }
  42. bool
  43. ForestVersionPage::OnCommand(
  44. HWND /* windowFrom */ ,
  45. unsigned controlIDFrom,
  46. unsigned code)
  47. {
  48. // LOG_FUNCTION(ForestVersionPage::OnCommand);
  49. switch (controlIDFrom)
  50. {
  51. case IDC_SET_VERSION:
  52. {
  53. if (code == BN_CLICKED)
  54. {
  55. SetChanged(controlIDFrom);
  56. return true;
  57. }
  58. }
  59. default:
  60. {
  61. // do nothing
  62. break;
  63. }
  64. }
  65. return false;
  66. }
  67. bool
  68. ForestVersionPage::OnSetActive()
  69. {
  70. LOG_FUNCTION(ForestVersionPage::OnSetActive);
  71. ASSERT(State::GetInstance().GetOperation() == State::FOREST);
  72. Win::PropSheet_SetWizButtons(
  73. Win::GetParent(hwnd),
  74. PSWIZB_BACK | PSWIZB_NEXT);
  75. State& state = State::GetInstance();
  76. if (state.RunHiddenUnattended())
  77. {
  78. // skip the page.
  79. LOG(L"skipping ForestVersionPage");
  80. Wizard& wiz = GetWizard();
  81. if (wiz.IsBacktracking())
  82. {
  83. // backup once again
  84. wiz.Backtrack(hwnd);
  85. return true;
  86. }
  87. int nextPage = ForestVersionPage::Validate();
  88. if (nextPage != -1)
  89. {
  90. GetWizard().SetNextPageID(hwnd, nextPage);
  91. }
  92. else
  93. {
  94. state.ClearHiddenWhileUnattended();
  95. }
  96. }
  97. return true;
  98. }
  99. int
  100. ForestVersionPage::Validate()
  101. {
  102. LOG_FUNCTION(ForestVersionPage::Validate);
  103. State& state = State::GetInstance();
  104. int nextPage = IDD_PATHS;
  105. state.SetSetForestVersionFlag(Win::IsDlgButtonChecked(hwnd, IDC_SET_VERSION));
  106. LOG(String::format(L"next = %1!d!", nextPage));
  107. return nextPage;
  108. }