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.

180 lines
4.3 KiB

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "evtview.h"
  5. #include "MainFrm.h"
  6. #include "globals.h"
  7. #include "doc.h"
  8. #include "schview.h"
  9. #include "clusname.h"
  10. #include "getevent.h"
  11. extern CEvtviewDoc *pEventDoc ;
  12. extern CScheduleView oScheduleView ;
  13. extern DWORD GetEvent (EVENTTHREADPARAM *pThreadParam) ;
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CMainFrame
  21. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  22. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  23. //{{AFX_MSG_MAP(CMainFrame)
  24. ON_MESSAGE (WM_GOTEVENT, OnGotEvent)
  25. ON_MESSAGE (WM_EXITEVENTTHREAD, OnExitEventThread)
  26. ON_WM_CREATE()
  27. ON_COMMAND(IDM_NEWEVENTCONNECTION, OnNeweventconnection)
  28. ON_COMMAND(IDM_SCHEDULE_MODIFYSCHEDULES, OnScheduleModifyschedules)
  29. ON_COMMAND(IDM_VIEWSHEDULE, OnViewshedule)
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. static UINT indicators[] =
  33. {
  34. ID_SEPARATOR, // status line indicator
  35. ID_INDICATOR_CAPS,
  36. ID_INDICATOR_NUM,
  37. ID_INDICATOR_SCRL,
  38. ID_INDICATOR_TIME,
  39. };
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CMainFrame construction/destruction
  42. CMainFrame::CMainFrame()
  43. {
  44. // TODO: add member initialization code here
  45. }
  46. CMainFrame::~CMainFrame()
  47. {
  48. }
  49. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  50. {
  51. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  52. return -1;
  53. if (!m_wndToolBar.Create(this) ||
  54. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  55. {
  56. TRACE0("Failed to create toolbar\n");
  57. return -1; // fail to create
  58. }
  59. if (!m_wndStatusBar.Create(this) ||
  60. !m_wndStatusBar.SetIndicators(indicators,
  61. sizeof(indicators)/sizeof(UINT)))
  62. {
  63. TRACE0("Failed to create status bar\n");
  64. return -1; // fail to create
  65. }
  66. UINT nId, nStyle ;
  67. int cxWidth ;
  68. m_wndStatusBar.GetPaneInfo (4, nId, nStyle, cxWidth) ;
  69. cxWidth *= 2 ;
  70. m_wndStatusBar.SetPaneInfo (4, nId, nStyle, cxWidth) ;
  71. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  72. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  73. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  74. // TODO: Delete these three lines if you don't want the toolbar to
  75. // be dockable
  76. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  77. EnableDocking(CBRS_ALIGN_ANY);
  78. DockControlBar(&m_wndToolBar);
  79. return 0;
  80. }
  81. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  82. {
  83. // TODO: Modify the Window class or styles here by modifying
  84. // the CREATESTRUCT cs
  85. return CMDIFrameWnd::PreCreateWindow(cs);
  86. }
  87. // This function is called when the event thread exits.
  88. LRESULT CMainFrame::OnExitEventThread(WPARAM wParam, LPARAM lParam)
  89. {
  90. CEvtviewDoc *pEventDoc = (CEvtviewDoc *) wParam ;
  91. pEventDoc->OnCloseDocument () ;
  92. return 0 ;
  93. }
  94. LRESULT CMainFrame::OnGotEvent(WPARAM wParam, LPARAM lParam)
  95. {
  96. CEvtviewDoc *pEventDoc = (CEvtviewDoc *) wParam ;
  97. pEventDoc->GotEvent ((PEVTFILTER_TYPE)lParam) ;
  98. return 0 ;
  99. }
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CMainFrame diagnostics
  102. #ifdef _DEBUG
  103. void CMainFrame::AssertValid() const
  104. {
  105. CMDIFrameWnd::AssertValid();
  106. }
  107. void CMainFrame::Dump(CDumpContext& dc) const
  108. {
  109. CMDIFrameWnd::Dump(dc);
  110. }
  111. #endif //_DEBUG
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CMainFrame message handlers
  114. void CMainFrame::OnNeweventconnection()
  115. {
  116. CGetClusterName oClusterName ;
  117. if (oClusterName.DoModal () == IDOK)
  118. {
  119. ((CEvtviewApp *)AfxGetApp ())->OnFileNew () ;
  120. // EVENTTHREADPARAM *pThreadParam = new EVENTTHREADPARAM ;
  121. // pThreadParam->pDoc = pEventDOc ;
  122. // pThreadParam->hWnd = m_pMainWnd->m_hWnd ;
  123. wcscpy (pEventDoc->sThreadParam.szSourceName, oClusterName.m_stClusterName) ;
  124. pEventDoc->SetTitle (oClusterName.m_stClusterName.IsEmpty()?L"Local":oClusterName.m_stClusterName) ;
  125. pEventDoc->pWorkerThread = AfxBeginThread ((AFX_THREADPROC)EventThread, &pEventDoc->sThreadParam) ;
  126. // pEventDoc->pWorkerThread = AfxBeginThread ((AFX_THREADPROC)GetEvent, pEventDoc,
  127. // THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED) ;
  128. // pEventDoc->pWorkerThread->ResumeThread () ;
  129. }
  130. }
  131. void CMainFrame::OnScheduleModifyschedules()
  132. {
  133. AddSchedule () ;
  134. }
  135. void CMainFrame::OnViewshedule()
  136. {
  137. if (oScheduleView.GetSafeHwnd())
  138. oScheduleView.ShowWindow (SW_SHOW) ;
  139. else oScheduleView.Create (CScheduleView::IDD) ;
  140. }