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.

310 lines
8.6 KiB

  1. /*---------------------------------------------------------------------------
  2. File: MainDlg.cpp
  3. Comments: This dialog shows the summary statistics, including
  4. the number of agents successfully dispatched and completed, and the
  5. total number of objects processed for all agents. The number of objects
  6. processed is incremented to include the results for each agent when that
  7. agent finishes and writes back its result file.
  8. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  9. Proprietary and confidential to Mission Critical Software, Inc.
  10. REVISION LOG ENTRY
  11. Revision By: Christy Boles
  12. ---------------------------------------------------------------------------
  13. */// MainDlg.cpp : implementation file
  14. //
  15. #include "stdafx.h"
  16. #include "resource.h"
  17. #include "MainDlg.h"
  18. #include "Monitor.h"
  19. #include "Globals.h"
  20. #include "ResStr.h"
  21. #include "TReg.hpp"
  22. #include "HtmlHelpUtil.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #include <htmlhelp.h>
  29. #include "helpid.h"
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CMainDlg dialog
  32. CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
  33. : CPropertyPage(CMainDlg::IDD)
  34. {
  35. //{{AFX_DATA_INIT(CMainDlg)
  36. m_ErrorCount = _T("0");
  37. m_FinishedCount = _T("0");
  38. m_InstalledCount = _T("0");
  39. m_RunningCount = _T("0");
  40. m_TotalString = _T("");
  41. m_DirectoriesChanged = _T("0");
  42. m_DirectoriesExamined = _T("0");
  43. m_DirectoriesUnchanged = _T("0");
  44. m_FilesChanged = _T("0");
  45. m_FilesExamined = _T("0");
  46. m_FilesUnchanged = _T("0");
  47. m_SharesChanged = _T("0");
  48. m_SharesExamined = _T("0");
  49. m_SharesUnchanged = _T("0");
  50. m_MembersChanged = _T("0");
  51. m_MembersExamined = _T("0");
  52. m_MembersUnchanged = _T("0");
  53. m_RightsChanged = _T("0");
  54. m_RightsExamined = _T("0");
  55. m_RightsUnchanged = _T("0");
  56. //}}AFX_DATA_INIT
  57. }
  58. void CMainDlg::DoDataExchange(CDataExchange* pDX)
  59. {
  60. CPropertyPage::DoDataExchange(pDX);
  61. //{{AFX_DATA_MAP(CMainDlg)
  62. DDX_Control(pDX, IDC_INSTALL_PROGRESS, m_InstallProgCtrl);
  63. DDX_Control(pDX, IDC_COMPLETE_PROGESS, m_FinishProgCtrl);
  64. DDX_Text(pDX, IDC_ERROR_COUNT, m_ErrorCount);
  65. DDX_Text(pDX, IDC_FINISHED_COUNT, m_FinishedCount);
  66. DDX_Text(pDX, IDC_INSTALLED_COUNT, m_InstalledCount);
  67. DDX_Text(pDX, IDC_RUNNING_COUNT, m_RunningCount);
  68. DDX_Text(pDX, IDC_TOTAL, m_TotalString);
  69. DDX_Text(pDX, IDC_DirsChanged2, m_DirectoriesChanged);
  70. DDX_Text(pDX, IDC_DirsExamined, m_DirectoriesExamined);
  71. DDX_Text(pDX, IDC_DirsU, m_DirectoriesUnchanged);
  72. DDX_Text(pDX, IDC_FilesChanged, m_FilesChanged);
  73. DDX_Text(pDX, IDC_FilesExamined, m_FilesExamined);
  74. DDX_Text(pDX, IDC_FilesU, m_FilesUnchanged);
  75. DDX_Text(pDX, IDC_SharesChanged, m_SharesChanged);
  76. DDX_Text(pDX, IDC_SharesExamined2, m_SharesExamined);
  77. DDX_Text(pDX, IDC_SharesU, m_SharesUnchanged);
  78. DDX_Text(pDX, IDC_MembersChanged, m_MembersChanged);
  79. DDX_Text(pDX, IDC_MembersExamined, m_MembersExamined);
  80. DDX_Text(pDX, IDC_MembersU, m_MembersUnchanged);
  81. DDX_Text(pDX, IDC_RightsChanged, m_RightsChanged);
  82. DDX_Text(pDX, IDC_RightsExamined, m_RightsExamined);
  83. DDX_Text(pDX, IDC_RightsU, m_RightsUnchanged);
  84. //}}AFX_DATA_MAP
  85. }
  86. BEGIN_MESSAGE_MAP(CMainDlg, CPropertyPage)
  87. //{{AFX_MSG_MAP(CMainDlg)
  88. ON_WM_HELPINFO()
  89. //}}AFX_MSG_MAP
  90. ON_MESSAGE(DCT_UPDATE_COUNTS, OnUpdateCounts)
  91. ON_MESSAGE(DCT_UPDATE_TOTALS, OnUpdateTotals)
  92. END_MESSAGE_MAP()
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CMainDlg message handlers
  95. BOOL CMainDlg::OnSetActive()
  96. {
  97. BOOL rc = CPropertyPage::OnSetActive();
  98. CancelToClose( );
  99. return rc;
  100. }
  101. BOOL CMainDlg::OnInitDialog()
  102. {
  103. CPropertyPage::OnInitDialog();
  104. ComputerStats gStat;
  105. DetailStats dStat;
  106. gData.GetComputerStats(&gStat);
  107. gData.GetDetailStats(&dStat);
  108. // OnUpdateCounts(0,(long)&gStat);
  109. OnUpdateCounts(0, (LPARAM)&gStat);
  110. // OnUpdateTotals(0, (long)&dStat);
  111. OnUpdateTotals(0, (LPARAM)&dStat);
  112. gData.SetSummaryWindow(m_hWnd);
  113. return TRUE; // return TRUE unless you set the focus to a control
  114. // EXCEPTION: OCX Property Pages should return FALSE
  115. }
  116. //LRESULT CMainDlg::OnUpdateCounts(UINT nID, long x)
  117. LRESULT CMainDlg::OnUpdateCounts(UINT nID, LPARAM x)
  118. {
  119. UpdateData(TRUE);
  120. ComputerStats * pStat = (ComputerStats *)x;
  121. m_TotalString.FormatMessage(IDS_ServerCountMessage,pStat->total);
  122. m_InstalledCount.Format(L"%ld",pStat->numInstalled);
  123. m_RunningCount.Format(L"%ld",pStat->numRunning);
  124. m_FinishedCount.Format(L"%ld",pStat->numFinished);
  125. m_ErrorCount.Format(L"%ld",pStat->numError);
  126. #if _MFC_VER >= 0x0600
  127. m_InstallProgCtrl.SetRange32(0,pStat->total - pStat->numError);
  128. #else
  129. m_InstallProgCtrl.SetRange(0,pStat->total - pStat->numError);
  130. #endif
  131. // m_InstallProgCtrl.SetRange32(0,pStat->total - pStat->numError);
  132. m_InstallProgCtrl.SetPos(pStat->numInstalled);
  133. #if _MFC_VER >= 0x0600
  134. m_FinishProgCtrl.SetRange32(0,pStat->total - pStat->numError);
  135. #else
  136. m_FinishProgCtrl.SetRange(0,pStat->total - pStat->numError);
  137. #endif
  138. // m_FinishProgCtrl.SetRange32(0,pStat->total - pStat->numError);
  139. m_FinishProgCtrl.SetPos(pStat->numFinished);
  140. UpdateData(FALSE);
  141. return 0;
  142. }
  143. //LRESULT CMainDlg::OnUpdateTotals(UINT nID, long x)
  144. LRESULT CMainDlg::OnUpdateTotals(UINT nID, LPARAM x)
  145. {
  146. UpdateData(TRUE);
  147. DetailStats temp;
  148. DetailStats * pStat = &temp;
  149. gData.GetDetailStats(&temp);
  150. m_FilesChanged.Format(L"%ld",pStat->filesChanged);
  151. m_FilesExamined.Format(L"%ld",pStat->filesExamined);
  152. m_FilesUnchanged.Format(L"%ld",pStat->filesUnchanged);
  153. m_DirectoriesChanged.Format(L"%ld",pStat->directoriesChanged);
  154. m_DirectoriesExamined.Format(L"%ld",pStat->directoriesExamined);
  155. m_DirectoriesUnchanged.Format(L"%ld",pStat->directoriesUnchanged);
  156. m_SharesChanged.Format(L"%ld",pStat->sharesChanged);
  157. m_SharesExamined.Format(L"%ld",pStat->sharesExamined);
  158. m_SharesUnchanged.Format(L"%ld",pStat->sharesUnchanged);
  159. m_MembersChanged.Format(L"%ld",pStat->membersChanged);
  160. m_MembersExamined.Format(L"%ld",pStat->membersExamined);
  161. m_MembersUnchanged.Format(L"%ld",pStat->membersUnchanged);
  162. m_RightsChanged.Format(L"%ld",pStat->rightsChanged);
  163. m_RightsExamined.Format(L"%ld",pStat->rightsExamined);
  164. m_RightsUnchanged.Format(L"%ld",pStat->rightsUnchanged);
  165. UpdateData(FALSE);
  166. return 0;
  167. }
  168. void CMainDlg::OnOK()
  169. {
  170. CPropertyPage::OnOK();
  171. }
  172. void CMainDlg::WinHelp(DWORD dwData, UINT nCmd)
  173. {
  174. // TODO: Add your specialized code here and/or call the base class
  175. CPropertyPage::WinHelp(dwData, nCmd);
  176. }
  177. BOOL CMainDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  178. {
  179. LPNMHDR lpnm = (LPNMHDR) lParam;
  180. switch (lpnm->code)
  181. {
  182. case PSN_HELP :
  183. helpWrapper(m_hWnd, IDH_WINDOW_AGENT_SUMMARY);
  184. break;
  185. }
  186. return CPropertyPage::OnNotify(wParam, lParam, pResult);
  187. }
  188. HRESULT GetHelpFileFullPath( BSTR *bstrHelp )
  189. {
  190. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  191. USES_CONVERSION;
  192. HRESULT hr = S_OK;
  193. try
  194. {
  195. TRegKey key;
  196. DWORD rc;
  197. // open ADMT registry key
  198. rc = key.Open(GET_STRING(IDS_DOMAIN_ADMIN_REGKEY), HKEY_LOCAL_MACHINE);
  199. _com_util::CheckError(HRESULT_FROM_WIN32(rc));
  200. // query ADMT folder path from registry value
  201. _TCHAR szPath[_MAX_PATH];
  202. rc = key.ValueGetStr(_T("Directory"), szPath, sizeof(szPath));
  203. _com_util::CheckError(HRESULT_FROM_WIN32(rc));
  204. // if no path separator concatenate
  205. if (szPath[_tcslen(szPath) - 1] != _T('\\'))
  206. {
  207. _tcscat(szPath, _T("\\"));
  208. }
  209. // concatenate help file name
  210. CComBSTR bstrName;
  211. bstrName.LoadString(IDS_HELPFILE);
  212. _tcscat(szPath, OLE2CT(bstrName));
  213. *bstrHelp = SysAllocString(T2COLE(szPath));
  214. }
  215. catch (_com_error& ce)
  216. {
  217. hr = ce.Error();
  218. }
  219. catch (...)
  220. {
  221. hr = E_FAIL;
  222. }
  223. return hr;
  224. }
  225. void helpWrapper(HWND hwndDlg, int t)
  226. {
  227. CComBSTR bstrTopic;
  228. HRESULT hr = GetHelpFileFullPath( &bstrTopic);
  229. if ( SUCCEEDED(hr) )
  230. {
  231. HWND h = HtmlHelp(hwndDlg, bstrTopic, HH_HELP_CONTEXT, t );
  232. if (!IsInWorkArea(h))
  233. PlaceInWorkArea(h);
  234. }
  235. else
  236. {
  237. CString r,e;
  238. r.LoadString(IDS_MSG_HELP);
  239. e.LoadString(IDS_MSG_ERROR);
  240. MessageBox(hwndDlg,r,e,MB_OK|MB_ICONSTOP);
  241. }
  242. }
  243. BOOL CMainDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  244. {
  245. helpWrapper(m_hWnd, IDH_WINDOW_AGENT_SUMMARY);
  246. return CPropertyPage::OnHelpInfo(pHelpInfo);
  247. }