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.

200 lines
4.9 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: BeforeBeginPage.cpp
  4. //
  5. // Synopsis: Defines the Before You Begin Page for the CYS
  6. // Wizard. Tells the user what they should do
  7. // before running CYS.
  8. //
  9. // History: 03/14/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "InstallationUnitProvider.h"
  13. #include "BeforeBeginPage.h"
  14. #include "state.h"
  15. static PCWSTR BEFORE_BEGIN_PAGE_HELP = L"cys.chm::/cys_topnode.htm";
  16. static PCWSTR BEFORE_BEGIN_LINK_HELP = L"cys.chm::/cys_topnode.htm";
  17. BeforeBeginPage::BeforeBeginPage()
  18. :
  19. bulletFont(0),
  20. CYSWizardPage(
  21. IDD_BEFORE_BEGIN_PAGE,
  22. IDS_BEFORE_BEGIN_TITLE,
  23. IDS_BEFORE_BEGIN_SUBTITLE,
  24. BEFORE_BEGIN_PAGE_HELP)
  25. {
  26. LOG_CTOR(BeforeBeginPage);
  27. }
  28. BeforeBeginPage::~BeforeBeginPage()
  29. {
  30. LOG_DTOR(BeforeBeginPage);
  31. if (bulletFont)
  32. {
  33. HRESULT hr = Win::DeleteObject(bulletFont);
  34. ASSERT(SUCCEEDED(hr));
  35. }
  36. }
  37. void
  38. BeforeBeginPage::OnInit()
  39. {
  40. LOG_FUNCTION(BeforeBeginPage::OnInit);
  41. InitializeBulletedList();
  42. }
  43. void
  44. BeforeBeginPage::InitializeBulletedList()
  45. {
  46. LOG_FUNCTION(BeforeBeginPage::InitializeBulletedList);
  47. bulletFont = CreateFont(
  48. 0,
  49. 0,
  50. 0,
  51. 0,
  52. FW_NORMAL,
  53. 0,
  54. 0,
  55. 0,
  56. SYMBOL_CHARSET,
  57. OUT_CHARACTER_PRECIS,
  58. CLIP_CHARACTER_PRECIS,
  59. PROOF_QUALITY,
  60. VARIABLE_PITCH|FF_DONTCARE,
  61. L"Marlett");
  62. if (bulletFont)
  63. {
  64. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET1), bulletFont, true);
  65. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET2), bulletFont, true);
  66. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET3), bulletFont, true);
  67. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET4), bulletFont, true);
  68. Win::SetWindowFont(Win::GetDlgItem(hwnd, IDC_BULLET5), bulletFont, true);
  69. }
  70. else
  71. {
  72. LOG(String::format(
  73. L"Failed to create font for bullet list: hr = %1!x!",
  74. GetLastError()));
  75. }
  76. }
  77. bool
  78. BeforeBeginPage::OnSetActive()
  79. {
  80. LOG_FUNCTION(BeforeBeginPage::OnSetActive);
  81. Win::PropSheet_SetWizButtons(
  82. Win::GetParent(hwnd),
  83. PSWIZB_NEXT | PSWIZB_BACK);
  84. return true;
  85. }
  86. bool
  87. BeforeBeginPage::OnNotify(
  88. HWND /*windowFrom*/,
  89. unsigned controlIDFrom,
  90. unsigned code,
  91. LPARAM /*lParam*/)
  92. {
  93. // LOG_FUNCTION(BeforeBeginPage::OnCommand);
  94. bool result = false;
  95. if (IDC_LINK == controlIDFrom &&
  96. (NM_CLICK == code ||
  97. NM_RETURN == code))
  98. {
  99. Win::HtmlHelp(
  100. hwnd,
  101. BEFORE_BEGIN_LINK_HELP,
  102. HH_DISPLAY_TOPIC,
  103. 0);
  104. }
  105. return result;
  106. }
  107. int
  108. BeforeBeginPage::Validate()
  109. {
  110. LOG_FUNCTION(BeforeBeginPage::Validate);
  111. // Gather the machine network and role information
  112. State& state = State::GetInstance();
  113. if (!state.HasStateBeenRetrieved())
  114. {
  115. if (!state.RetrieveMachineConfigurationInformation(hwnd))
  116. {
  117. ASSERT(false);
  118. LOG(L"The machine configuration could not be retrieved.");
  119. return -1;
  120. }
  121. }
  122. int nextPage = IDD_DECISION_PAGE;
  123. /* Just for testing the NIC selection page
  124. int nextPage = IDD_CUSTOM_SERVER_PAGE;
  125. // The decision page should be shown only if we are not a DC, not a DHCP server,
  126. // not a DNS server, have only one or two NICs, and there is only one static
  127. // IP address on the interfaces
  128. if (!(state.IsDC() || state.IsUpgradeState()))
  129. {
  130. if (!InstallationUnitProvider::GetInstance().GetDHCPInstallationUnit().IsServiceInstalled() &&
  131. !InstallationUnitProvider::GetInstance().GetDNSInstallationUnit().IsServiceInstalled())
  132. {
  133. if (state.GetNICCount() == 1)
  134. {
  135. if (!state.IsDHCPAvailableOnNIC(0))
  136. {
  137. nextPage = IDD_DECISION_PAGE;
  138. }
  139. }
  140. else if (state.GetNICCount() == 2)
  141. {
  142. bool isDHCPAvailableOnNIC1 = state.IsDHCPAvailableOnNIC(0);
  143. bool isDHCPAvailableOnNIC2 = state.IsDHCPAvailableOnNIC(1);
  144. if ((!isDHCPAvailableOnNIC1 && isDHCPAvailableOnNIC2) ||
  145. (isDHCPAvailableOnNIC1 && !isDHCPAvailableOnNIC2))
  146. {
  147. // As long as only one of the interfaces has a
  148. // dynamically assigned IP address we can go
  149. // through the Express path
  150. nextPage = IDD_DECISION_PAGE;
  151. }
  152. }
  153. else
  154. {
  155. // If the machine doesn't have a NIC or
  156. // has more than 2 NICs then there is either no
  157. // reason to make this a network server or the
  158. // user is considered more advanced and should
  159. // run through the custom part of the wizard
  160. }
  161. }
  162. }
  163. */
  164. LOG(String::format(L"nextPage = %1!d!", nextPage));
  165. return nextPage;
  166. }