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.

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