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.

213 lines
7.0 KiB

  1. // SummaryDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include "SummaryDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CSummaryDlg dialog
  13. CSummaryDlg::CSummaryDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CSummaryDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CSummaryDlg)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. }
  20. void CSummaryDlg::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CSummaryDlg)
  24. DDX_Control(pDX, IDC_DOMAINLIST, m_listCtrl);
  25. //}}AFX_DATA_MAP
  26. }
  27. BEGIN_MESSAGE_MAP(CSummaryDlg, CDialog)
  28. //{{AFX_MSG_MAP(CSummaryDlg)
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CSummaryDlg message handlers
  33. BOOL CSummaryDlg::OnInitDialog()
  34. {
  35. CDialog::OnInitDialog();
  36. // TODO: Add extra initialization here
  37. //Add columns and information to the list control
  38. CreateListCtrlColumns();
  39. AddDomainsToList();
  40. return TRUE; // return TRUE unless you set the focus to a control
  41. // EXCEPTION: OCX Property Pages should return FALSE
  42. }
  43. /*********************************************************************
  44. * *
  45. * Written by: Paul Thompson *
  46. * Date: 22 AUG 2000 *
  47. * *
  48. * This protected member function of the CSummaryDlg class is *
  49. * responsible for adding the domains in the 3 lists into the list *
  50. * control. Those domains in the populated list are also in the *
  51. * domain list, therefore they are ignored in the domain list *
  52. * processing. *
  53. * *
  54. *********************************************************************/
  55. //BEGIN AddDomainsToList
  56. void CSummaryDlg::AddDomainsToList()
  57. {
  58. /* local constants */
  59. const int POPULATE_COLUMN = 1;
  60. const int EXCLUDE_COLUMN = 2;
  61. /* local variables */
  62. POSITION currentPos; //current position in the list
  63. POSITION pos; //position in the domain list
  64. CString domainName; //name of domain from the list
  65. CString Text; //CString holder
  66. int nlistNum = 0; //current list item being added
  67. int ndx = 0; //while loop counter
  68. LVITEM aItem; //list control item to insert
  69. WCHAR sText[MAX_PATH]; //holds string to add
  70. /* function body */
  71. //add the domains that were successfully populated (and remove
  72. //from the domain list)
  73. currentPos = pPopulatedList->GetHeadPosition();
  74. while (ndx < pPopulatedList->GetCount())
  75. {
  76. //get domain name
  77. domainName = pPopulatedList->GetNext(currentPos);
  78. //insert in list control
  79. aItem.iItem = ndx;
  80. aItem.iSubItem = 0;
  81. aItem.mask = LVIF_TEXT;
  82. wcscpy(sText, (LPCTSTR)domainName);
  83. aItem.pszText = sText;
  84. m_listCtrl.InsertItem(&aItem);
  85. //add populated status
  86. Text.LoadString(IDS_POP_YES);
  87. wcscpy(sText, (LPCTSTR)Text);
  88. m_listCtrl.SetItemText(ndx, POPULATE_COLUMN, sText);
  89. //add excluded status
  90. Text.LoadString(IDS_POP_NO);
  91. wcscpy(sText, (LPCTSTR)Text);
  92. m_listCtrl.SetItemText(ndx, EXCLUDE_COLUMN, sText);
  93. //remove from the domain list
  94. if ((pos = pDomainList->Find(domainName)) != NULL)
  95. pDomainList->RemoveAt(pos);
  96. ndx++;
  97. }
  98. //add the domains that were not successfully populated and remain
  99. //in the domain list
  100. nlistNum = ndx;
  101. ndx = 0;
  102. currentPos = pDomainList->GetHeadPosition();
  103. while (ndx < pDomainList->GetCount())
  104. {
  105. //get domain name
  106. domainName = pDomainList->GetNext(currentPos);
  107. //insert in list control
  108. aItem.iItem = nlistNum + ndx;
  109. aItem.iSubItem = 0;
  110. aItem.mask = LVIF_TEXT;
  111. wcscpy(sText, (LPCTSTR)domainName);
  112. aItem.pszText = sText;
  113. m_listCtrl.InsertItem(&aItem);
  114. //add populated status
  115. Text.LoadString(IDS_POP_NO);
  116. wcscpy(sText, (LPCTSTR)Text);
  117. m_listCtrl.SetItemText(nlistNum+ndx, POPULATE_COLUMN, sText);
  118. //add excluded status
  119. m_listCtrl.SetItemText(nlistNum+ndx, EXCLUDE_COLUMN, sText);
  120. ndx++;
  121. }
  122. //add the domains that were excluded
  123. nlistNum += ndx;
  124. ndx = 0;
  125. currentPos = pExcludeList->GetHeadPosition();
  126. while (ndx < pExcludeList->GetCount())
  127. {
  128. //get domain name
  129. domainName = pExcludeList->GetNext(currentPos);
  130. //insert in list control
  131. aItem.iItem = nlistNum + ndx;
  132. aItem.iSubItem = 0;
  133. aItem.mask = LVIF_TEXT;
  134. wcscpy(sText, (LPCTSTR)domainName);
  135. aItem.pszText = sText;
  136. m_listCtrl.InsertItem(&aItem);
  137. //add populated status
  138. Text.LoadString(IDS_POP_NO);
  139. wcscpy(sText, (LPCTSTR)Text);
  140. m_listCtrl.SetItemText(nlistNum+ndx, POPULATE_COLUMN, sText);
  141. //add excluded status
  142. Text.LoadString(IDS_POP_YES);
  143. wcscpy(sText, (LPCTSTR)Text);
  144. m_listCtrl.SetItemText(nlistNum+ndx, EXCLUDE_COLUMN, sText);
  145. ndx++;
  146. }
  147. }
  148. //END AddDomainsToList
  149. /*********************************************************************
  150. * *
  151. * Written by: Paul Thompson *
  152. * Date: 22 AUG 2000 *
  153. * *
  154. * This protected member function of the CSummaryDlg class is *
  155. * responsible for adding the columns to the summary's list control. *
  156. * *
  157. *********************************************************************/
  158. //BEGIN CreateListCtrlColumns
  159. void CSummaryDlg::CreateListCtrlColumns()
  160. {
  161. /* local constants */
  162. /* local variables */
  163. CString Text;
  164. CRect rect;
  165. int columnWidth;
  166. /* function body */
  167. //get the width in pixels of the CListCtrl
  168. m_listCtrl.GetWindowRect(&rect);
  169. //create the domain name column
  170. Text.LoadString(IDS_DOMAIN_COLUMN_TITLE);
  171. columnWidth = (int)(rect.Width() * 0.6);
  172. m_listCtrl.InsertColumn(0, Text, LVCFMT_LEFT, columnWidth);
  173. //create the populated Yes/No column
  174. Text.LoadString(IDS_POPULATED_COLUMN_TITLE);
  175. columnWidth = (int)((rect.Width() - columnWidth) / 2);
  176. columnWidth -= 1; //make it fit in the control without a scrollbar
  177. m_listCtrl.InsertColumn(1, Text, LVCFMT_CENTER, columnWidth);
  178. //create the populated Yes/No column
  179. Text.LoadString(IDS_EXCLUDED_COLUMN_TITLE);
  180. columnWidth -= 1; //make it fit in the control without a scrollbar
  181. m_listCtrl.InsertColumn(2, Text, LVCFMT_CENTER, columnWidth);
  182. UpdateData(FALSE);
  183. }
  184. //END CreateListCtrlColumns