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.

202 lines
4.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: areaprog.cpp
  7. //
  8. // Contents: implementation of AreaProgress
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "resource.h"
  14. #include "wrapper.h"
  15. #include "AreaProg.h"
  16. #include "util.h"
  17. typedef enum {
  18. INDEX_PRIV =0,
  19. INDEX_GROUP,
  20. INDEX_REG,
  21. INDEX_FILE,
  22. INDEX_DS,
  23. INDEX_SERVICE,
  24. INDEX_POLICY,
  25. } AREA_INDEX;
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // AreaProgress dialog
  33. AreaProgress::AreaProgress(CWnd* pParent /*=NULL*/)
  34. : CHelpDialog(a199HelpIDs, IDD, pParent)
  35. {
  36. //{{AFX_DATA_INIT(AreaProgress)
  37. //}}AFX_DATA_INIT
  38. m_isDC = IsDomainController();
  39. m_nLastArea = -1;
  40. m_bmpChecked.LoadMappedBitmap(IDB_CHECK);
  41. m_bmpCurrent.LoadMappedBitmap(IDB_ARROW);
  42. }
  43. void AreaProgress::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(AreaProgress)
  47. DDX_Control(pDX, IDC_PROGRESS1, m_ctlProgress);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(AreaProgress, CHelpDialog)
  51. //{{AFX_MSG_MAP(AreaProgress)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // AreaProgress message handlers
  56. BOOL AreaProgress::OnInitDialog()
  57. {
  58. CDialog::OnInitDialog();
  59. int i,nAreas;
  60. CString strAreas[NUM_AREAS];
  61. // Map AREAs to string descriptions of the area
  62. i = GetAreaIndex(AREA_PRIVILEGES);
  63. if (i >= 0) {
  64. strAreas[i].LoadString(IDS_PRIVILEGE);
  65. }
  66. i = GetAreaIndex(AREA_GROUP_MEMBERSHIP);
  67. if (i >= 0) {
  68. strAreas[i].LoadString(IDS_GROUPS);
  69. }
  70. i = GetAreaIndex(AREA_REGISTRY_SECURITY);
  71. if (i >= 0) {
  72. strAreas[i].LoadString(IDS_REGISTRY);
  73. }
  74. i = GetAreaIndex(AREA_FILE_SECURITY);
  75. if (i >= 0) {
  76. strAreas[i].LoadString(IDS_FILESTORE);
  77. }
  78. i = GetAreaIndex(AREA_DS_OBJECTS);
  79. if (i >= 0) {
  80. strAreas[i].LoadString(IDS_DSOBJECT);
  81. }
  82. i = GetAreaIndex(AREA_SYSTEM_SERVICE);
  83. if (i >= 0) {
  84. strAreas[i].LoadString(IDS_SERVICE);
  85. }
  86. i = GetAreaIndex(AREA_SECURITY_POLICY);
  87. if (i >= 0) {
  88. strAreas[i].LoadString(IDS_POLICY);
  89. }
  90. // Initialize Control Arrays
  91. nAreas = NUM_AREAS;
  92. if (!m_isDC) {
  93. nAreas--;
  94. }
  95. for(i=0;i< nAreas;i++) {
  96. m_stLabels[i].Attach(::GetDlgItem(GetSafeHwnd(),IDC_AREA1+i));
  97. m_stLabels[i].SetWindowText(strAreas[i]);
  98. // Make the label visible
  99. m_stLabels[i].ShowWindow(SW_SHOW);
  100. m_stIcons[i].Attach(::GetDlgItem(GetSafeHwnd(),IDC_ICON1+i));
  101. m_stIcons[i].ShowWindow(SW_SHOW);
  102. }
  103. return TRUE; // return TRUE unless you set the focus to a control
  104. // EXCEPTION: OCX Property Pages should return FALSE
  105. }
  106. int AreaProgress::GetAreaIndex(AREA_INFORMATION Area)
  107. {
  108. int dwIndex;
  109. switch(Area) {
  110. case AREA_PRIVILEGES:
  111. dwIndex = INDEX_PRIV;
  112. break;
  113. case AREA_GROUP_MEMBERSHIP:
  114. dwIndex = INDEX_GROUP;
  115. break;
  116. case AREA_REGISTRY_SECURITY:
  117. dwIndex = INDEX_REG;
  118. break;
  119. case AREA_FILE_SECURITY:
  120. dwIndex = INDEX_FILE;
  121. break;
  122. case AREA_DS_OBJECTS:
  123. dwIndex = INDEX_DS;
  124. break;
  125. case AREA_SYSTEM_SERVICE:
  126. dwIndex = INDEX_SERVICE;
  127. break;
  128. case AREA_SECURITY_POLICY:
  129. dwIndex = INDEX_POLICY;
  130. break;
  131. default:
  132. dwIndex = -1;
  133. }
  134. if (!m_isDC && (dwIndex == INDEX_DS)) {
  135. dwIndex = -1;
  136. }
  137. if (!m_isDC && (dwIndex > INDEX_DS)) {
  138. dwIndex--;
  139. }
  140. return dwIndex;
  141. }
  142. void AreaProgress::SetMaxTicks(DWORD dwTicks)
  143. {
  144. #if _MFC_VER >= 0x0600
  145. m_ctlProgress.SetRange32(0,dwTicks);
  146. #else
  147. m_ctlProgress.SetRange(0,dwTicks);
  148. #endif
  149. }
  150. void AreaProgress::SetCurTicks(DWORD dwTicks)
  151. {
  152. m_ctlProgress.SetPos(dwTicks);
  153. }
  154. void AreaProgress::SetArea(AREA_INFORMATION Area)
  155. {
  156. int i,target;
  157. target = GetAreaIndex(Area);
  158. if (target <= m_nLastArea) {
  159. return;
  160. }
  161. if (m_nLastArea < 0) {
  162. m_nLastArea = 0;
  163. }
  164. for(i=m_nLastArea;i<target;i++) {
  165. m_stIcons[i].SetBitmap(m_bmpChecked);
  166. }
  167. m_stIcons[target].SetBitmap(m_bmpCurrent);
  168. }