Monitor.cpp
上传用户:tenhai
上传日期:2021-02-19
资源大小:492k
文件大小:3k
源码类别:

组合框控件

开发平台:

Visual C++

  1. // Monitor.cpp: implementation of the CMonitor class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "propDoc.h"
  6. #include "propview.h"
  7. #include "slstDoc.h"
  8. #include "slstView.h"
  9. #include "ptreeDoc.h"
  10. #include "ptreeView.h"
  11. #include "prop.h"
  12. #include "Monitor.h"
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[]=__FILE__;
  16. #define new DEBUG_NEW
  17. #endif
  18. //////////////////////////////////////////////////////////////////////
  19. // Construction/Destruction
  20. //////////////////////////////////////////////////////////////////////
  21. CMonitor::CMonitor()
  22. {
  23. }
  24. CMonitor::~CMonitor()
  25. {
  26. }
  27. void CMonitor::display(CString str)
  28. {
  29. extern CPropApp theApp;
  30. POSITION propDocPos=theApp.m_pDocTemplate->GetFirstDocPosition();
  31. if (!propDocPos)
  32. return;
  33. CPropDoc *pDoc=(CPropDoc *)theApp.m_pDocTemplate->GetNextDoc(propDocPos);
  34.     POSITION propViewPos=pDoc->GetFirstViewPosition();
  35. if (!propViewPos)
  36. return;
  37. CPropView *pView = (CPropView *) pDoc->GetNextView(propViewPos);
  38. /*
  39. CMDIFrameWnd *pFrame = 
  40.              (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
  41. // Get the active MDI child window.
  42. CMDIChildWnd *pChild = 
  43.              (CMDIChildWnd *) pFrame->GetActiveFrame();
  44. // or CMDIChildWnd *pChild = pFrame->MDIGetActive();
  45. // Get the active view attached to the active MDI child
  46. // window.
  47. CPropView *pView = (CPropView *) pChild->GetActiveView();
  48. */
  49. CRichEditCtrl &pREC= pView->GetRichEditCtrl();
  50. pREC.ReplaceSel((LPCTSTR) str, FALSE);
  51. pView->UpdateWindow();
  52. }
  53. CMonitor theMonitor;
  54. void CMonitor::list(CString str)
  55. {
  56. extern CPropApp theApp;
  57. POSITION slstDocPos=theApp.m_sDocTemplate->GetFirstDocPosition();
  58. if (!slstDocPos)
  59. return;
  60. CSlstDoc *pDoc=(CSlstDoc *)theApp.m_sDocTemplate->GetNextDoc(slstDocPos);
  61.     POSITION slstViewPos=pDoc->GetFirstViewPosition();
  62. if (!slstViewPos)
  63. return;
  64. CSlstView *pView = (CSlstView *)pDoc->GetNextView(slstViewPos);
  65.    // Gain a reference to the list control itself
  66.     CTreeCtrl& pLSC = pView->GetTreeCtrl();
  67. TVINSERTSTRUCT tvInsert;
  68. tvInsert.hParent = NULL;
  69. tvInsert.hInsertAfter = NULL;
  70. tvInsert.item.mask = TVIF_TEXT;
  71. tvInsert.item.pszText=str.GetBuffer(1);
  72. pLSC.InsertItem(&tvInsert);
  73. pView->UpdateWindow();
  74. }
  75. void CMonitor::show(int id, CString str)
  76. {
  77. extern CPropApp theApp;
  78. POSITION ptreeDocPos=theApp.m_qDocTemplate->GetFirstDocPosition();
  79. if (!ptreeDocPos)
  80. return;
  81. CPtreeDoc *pDoc=(CPtreeDoc *)theApp.m_qDocTemplate->GetNextDoc(ptreeDocPos);
  82.     POSITION ptreeViewPos=pDoc->GetFirstViewPosition();
  83. if (!ptreeViewPos)
  84. return;
  85. CPtreeView *pView = (CPtreeView *)pDoc->GetNextView(ptreeViewPos);
  86. pView->UpdateTree(id, str);
  87. }