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.

206 lines
4.3 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation
  2. //
  3. // File: NICSelectionPage.cpp
  4. //
  5. // Synopsis: Defines the NIC selection Page for the CYS
  6. // Wizard. This page lets the user choose
  7. // between the NIC that is on the public network
  8. //
  9. // History: 03/13/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "InstallationUnitProvider.h"
  13. #include "NICSelectionPage.h"
  14. #include "state.h"
  15. static PCWSTR NIC_SELECTION_PAGE_HELP = L"cys.chm::/sag_ADserverRoles.htm";
  16. NICSelectionPage::NICSelectionPage()
  17. :
  18. CYSWizardPage(
  19. IDD_NIC_SELECTION_PAGE,
  20. IDS_NIC_SELECTION_TITLE,
  21. IDS_NIC_SELECTION_SUBTITLE,
  22. NIC_SELECTION_PAGE_HELP)
  23. {
  24. LOG_CTOR(NICSelectionPage);
  25. }
  26. NICSelectionPage::~NICSelectionPage()
  27. {
  28. LOG_DTOR(NICSelectionPage);
  29. }
  30. void
  31. NICSelectionPage::OnInit()
  32. {
  33. LOG_FUNCTION(NICSelectionPage::OnInit);
  34. InitializeNICListView();
  35. FillNICListView();
  36. }
  37. void
  38. NICSelectionPage::InitializeNICListView()
  39. {
  40. LOG_FUNCTION(NICSelectionPage::InitializeNICListView);
  41. // Add the columns to the list view
  42. HWND hwndBox = Win::GetDlgItem(hwnd, IDC_NIC_LIST);
  43. // Get the width of the list view so we can set the column widths
  44. RECT rect;
  45. ::ZeroMemory(&rect, sizeof(RECT));
  46. HRESULT hr = Win::GetClientRect(
  47. hwndBox,
  48. rect);
  49. ASSERT(SUCCEEDED(hr));
  50. long width = rect.right - rect.left;
  51. LVCOLUMN column;
  52. ZeroMemory(&column, sizeof(LVCOLUMN));
  53. // Load the column names
  54. String networkCardColumn = String::load(IDS_NIC_COLUMN);
  55. String statusColumn = String::load(IDS_STATUS_COLUMN);
  56. String addressColumn = String::load(IDS_ADDRESS_COLUMN);
  57. column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_ORDER;
  58. // Insert the NIC column using 40% of the width
  59. column.iOrder = 0;
  60. column.cx = static_cast<int>((float)width * 0.4);
  61. column.pszText = const_cast<wchar_t*>(networkCardColumn.c_str());
  62. Win::ListView_InsertColumn(
  63. hwndBox,
  64. 0,
  65. column);
  66. // Insert the Status column using 30% of the width
  67. column.iOrder = 1;
  68. column.cx = static_cast<int>((float)width * 0.3);
  69. column.pszText = const_cast<wchar_t*>(statusColumn.c_str());
  70. Win::ListView_InsertColumn(
  71. hwndBox,
  72. 1,
  73. column);
  74. // Insert the IP Address column using 30% of the width
  75. column.iOrder = 2;
  76. column.cx = static_cast<int>((float)width * 0.3);
  77. column.pszText = const_cast<wchar_t*>(addressColumn.c_str());
  78. Win::ListView_InsertColumn(
  79. hwndBox,
  80. 2,
  81. column);
  82. }
  83. void
  84. NICSelectionPage::FillNICListView()
  85. {
  86. LOG_FUNCTION(NICSelectionPage::FillNICListView);
  87. // Add the NICs to the list view
  88. HWND hwndBox = Win::GetDlgItem(hwnd, IDC_NIC_LIST);
  89. State& state = State::GetInstance();
  90. for(
  91. unsigned int nicIndex = 0;
  92. nicIndex < state.GetNICCount();
  93. ++nicIndex)
  94. {
  95. // Add the nic to the list
  96. // NOTE: the index in the list view directly cooresponds
  97. // to the index into the NIC list held in the state
  98. // object
  99. NetworkInterface nic = state.GetNIC(nicIndex);
  100. LVITEM listItem;
  101. ZeroMemory(&listItem, sizeof(LVITEM));
  102. listItem.iSubItem = 0;
  103. listItem.mask = LVIF_TEXT;
  104. listItem.pszText = const_cast<wchar_t*>(nic.GetDescription().c_str());
  105. /* listItem.mask |= LVIF_IMAGE;
  106. if (isInstalled)
  107. {
  108. listItem.iImage = 0;
  109. }
  110. else
  111. {
  112. listItem.iImage = 1;
  113. }
  114. */
  115. int newItem = Win::ListView_InsertItem(
  116. hwndBox,
  117. listItem);
  118. ASSERT(newItem >= 0);
  119. ASSERT(newItem == (int)nicIndex);
  120. if (newItem >= 0)
  121. {
  122. // Add the status and the ipaddress
  123. listItem.iItem = newItem;
  124. listItem.iSubItem = 2;
  125. listItem.pszText = const_cast<wchar_t*>(nic.GetStringIPAddress().c_str());
  126. Win::ListView_SetItem(
  127. hwndBox,
  128. listItem);
  129. }
  130. }
  131. }
  132. bool
  133. NICSelectionPage::OnSetActive()
  134. {
  135. LOG_FUNCTION(NICSelectionPage::OnSetActive);
  136. Win::PropSheet_SetWizButtons(
  137. Win::GetParent(hwnd),
  138. PSWIZB_NEXT | PSWIZB_BACK);
  139. return true;
  140. }
  141. int
  142. NICSelectionPage::Validate()
  143. {
  144. LOG_FUNCTION(NICSelectionPage::Validate);
  145. int nextPage = IDD_AD_DOMAIN_NAME_PAGE;
  146. LOG(String::format(
  147. L"nextPage = %1!d!",
  148. nextPage));
  149. return nextPage;
  150. }