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.

137 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. doc.cpp
  5. Abstract:
  6. Author:
  7. Sivaprasad Padisetty (sivapad) 6/25/97
  8. Revision History:
  9. --*/
  10. #include "stdafx.h"
  11. #include "evtview.h"
  12. #include "Doc.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CEvtviewDoc
  20. IMPLEMENT_DYNCREATE(CEvtviewDoc, CDocument)
  21. BEGIN_MESSAGE_MAP(CEvtviewDoc, CDocument)
  22. //{{AFX_MSG_MAP(CEvtviewDoc)
  23. // NOTE - the ClassWizard will add and remove mapping macros here.
  24. // DO NOT EDIT what you see in these blocks of generated code!
  25. //}}AFX_MSG_MAP
  26. END_MESSAGE_MAP()
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CEvtviewDoc construction/destruction
  29. extern CEvtviewDoc *pEventDoc ;
  30. CEvtviewDoc::CEvtviewDoc()
  31. {
  32. // TODO: add one-time construction code here
  33. pEventDoc = this ;
  34. dwCount = 0 ;
  35. dwMaxCount = 1000 ;
  36. sThreadParam.hWnd = AfxGetApp ()->m_pMainWnd->GetSafeHwnd () ;
  37. sThreadParam.pDoc = this ;
  38. sThreadParam.hEvent = CreateEvent (NULL, FALSE, FALSE, NULL) ;
  39. }
  40. CEvtviewDoc::~CEvtviewDoc()
  41. {
  42. // TerminateThread (pWorkerThread->m_hThread, 1) ;
  43. SetEvent (sThreadParam.hEvent) ;
  44. WaitForSingleObject (pWorkerThread->m_hThread, INFINITE) ;
  45. ClearAllEvents () ;
  46. }
  47. BOOL CEvtviewDoc::OnNewDocument()
  48. {
  49. if (!CDocument::OnNewDocument())
  50. return FALSE;
  51. // TODO: add reinitialization code here
  52. // (SDI documents will reuse this document)
  53. return TRUE;
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CEvtviewDoc serialization
  57. void CEvtviewDoc::Serialize(CArchive& ar)
  58. {
  59. if (ar.IsStoring())
  60. {
  61. // TODO: add storing code here
  62. }
  63. else
  64. {
  65. // TODO: add loading code here
  66. }
  67. }
  68. void CEvtviewDoc::GotEvent (PEVTFILTER_TYPE p_pEventDetails)
  69. {
  70. PEVTFILTER_TYPE pEventDetails = new EVTFILTER_TYPE (*p_pEventDetails) ;
  71. dwCount++ ;
  72. if ((DWORD)ptrlstEvent.GetCount() >= dwMaxCount)
  73. {
  74. delete (PEVTFILTER_TYPE) ptrlstEvent.RemoveHead () ;
  75. }
  76. ptrlstEvent.AddTail (pEventDetails) ;
  77. UpdateAllViews (NULL, (LPARAM)pEventDetails) ;
  78. }
  79. void CEvtviewDoc::ClearAllEvents ()
  80. {
  81. dwCount = 0 ;
  82. POSITION pos = ptrlstEvent.GetHeadPosition () ;
  83. while (pos)
  84. delete (PEVTFILTER_TYPE) ptrlstEvent.GetNext (pos) ;
  85. ptrlstEvent.RemoveAll () ;
  86. UpdateAllViews (NULL, 0) ;
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CEvtviewDoc diagnostics
  90. #ifdef _DEBUG
  91. void CEvtviewDoc::AssertValid() const
  92. {
  93. CDocument::AssertValid();
  94. }
  95. void CEvtviewDoc::Dump(CDumpContext& dc) const
  96. {
  97. CDocument::Dump(dc);
  98. }
  99. #endif //_DEBUG
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CEvtviewDoc commands