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.

141 lines
3.3 KiB

  1. // SchView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "evtview.h"
  5. #include "SchView.h"
  6. #include "globals.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CScheduleView dialog
  14. CScheduleView::CScheduleView(CWnd* pParent /*=NULL*/)
  15. : CDialog(CScheduleView::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CScheduleView)
  18. //}}AFX_DATA_INIT
  19. }
  20. void CScheduleView::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CScheduleView)
  24. DDX_Control(pDX, IDC_SCHEDULELIST, m_ctrlScheduleList);
  25. //}}AFX_DATA_MAP
  26. }
  27. BEGIN_MESSAGE_MAP(CScheduleView, CDialog)
  28. //{{AFX_MSG_MAP(CScheduleView)
  29. ON_MESSAGE (WM_REFRESH, OnRefresh)
  30. ON_BN_CLICKED(IDC_DETAILS, OnDetails)
  31. ON_BN_CLICKED(IDC_DELETE, OnDelete)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CScheduleView message handlers
  36. void GetScheduleFormatString (SCHEDULE_INFO *pSInfo, WCHAR *pszBuf)
  37. {
  38. POSITION pos ;
  39. SCHEDULE_ACTIONINFO *pAInfo ;
  40. pos = pSInfo->lstActionInfo.GetHeadPosition () ;
  41. *pszBuf = L'\0' ;
  42. if (pos)
  43. {
  44. pAInfo = (SCHEDULE_ACTIONINFO *) pSInfo->lstActionInfo.GetNext (pos) ;
  45. wsprintf (pszBuf, L"%s %s On:", GetType (aAction, pAInfo->dwActionType),
  46. pAInfo->stParam) ;
  47. }
  48. if (pSInfo->lstTimeInfo.GetCount())
  49. {
  50. wcscat (pszBuf, pSInfo->minTime.Format (L"%d %b %H:%M:%S")) ;
  51. }
  52. if (pSInfo->lstEventInfo.GetCount())
  53. {
  54. WCHAR szTmpBuf [200] ;
  55. SCHEDULE_EVENTINFO *pEventInfo = (SCHEDULE_EVENTINFO *) pSInfo->lstEventInfo.GetHead () ;
  56. swprintf (szTmpBuf, L"%s->%s(%s)", pEventInfo->szSourceName, GetType (pEventInfo->dwCatagory, pEventInfo->dwFilter), pEventInfo->szObjectName) ;
  57. wcscat (pszBuf, szTmpBuf) ;
  58. }
  59. }
  60. LRESULT CScheduleView::OnRefresh (WPARAM wParam, LPARAM lParam)
  61. {
  62. WCHAR szBuf [256] ;
  63. POSITION pos = ptrlstSInfo.GetHeadPosition () ;
  64. SCHEDULE_INFO *pSInfo ;
  65. m_ctrlScheduleList.ResetContent () ;
  66. while (pos)
  67. {
  68. pSInfo = (SCHEDULE_INFO *) ptrlstSInfo.GetNext (pos) ;
  69. GetScheduleFormatString (pSInfo, szBuf) ;
  70. m_ctrlScheduleList.AddString (szBuf) ;
  71. }
  72. return 0 ;
  73. }
  74. BOOL CScheduleView::OnInitDialog()
  75. {
  76. CDialog::OnInitDialog();
  77. OnRefresh (0, 0) ;
  78. return TRUE; // return TRUE unless you set the focus to a control
  79. // EXCEPTION: OCX Property Pages should return FALSE
  80. }
  81. void CScheduleView::OnDetails()
  82. {
  83. int iIndex ;
  84. if ((iIndex = m_ctrlScheduleList.GetCurSel ()) != LB_ERR)
  85. {
  86. POSITION pos = ptrlstSInfo.FindIndex (iIndex) ;
  87. SCHEDULE_INFO *pSInfo = (SCHEDULE_INFO *)ptrlstSInfo.GetAt (pos) ;
  88. WCHAR szBuf [256] ;
  89. if (ModifySchedule (pSInfo) == IDOK)
  90. {
  91. m_ctrlScheduleList.DeleteString (iIndex) ;
  92. GetScheduleFormatString (pSInfo, szBuf) ;
  93. m_ctrlScheduleList.InsertString (iIndex, szBuf) ;
  94. }
  95. }
  96. }
  97. void CScheduleView::OnDelete()
  98. {
  99. int iIndex ;
  100. if ((iIndex = m_ctrlScheduleList.GetCurSel ()) != LB_ERR)
  101. {
  102. POSITION pos = ptrlstSInfo.FindIndex (iIndex) ;
  103. SCHEDULE_INFO *pSInfo = (SCHEDULE_INFO *)ptrlstSInfo.GetAt (pos) ;
  104. FreeEventList (pSInfo->lstEventInfo) ;
  105. FreeActionList (pSInfo->lstActionInfo) ;
  106. FreeTimeList (pSInfo->lstTimeInfo) ;
  107. delete pSInfo ;
  108. ptrlstSInfo.RemoveAt (pos) ;
  109. ResetTimer () ;
  110. m_ctrlScheduleList.DeleteString (iIndex) ;
  111. }
  112. }