ChildFrm.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // ChildFrm.cpp : CChildFrame 类的实现
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "ChildFrm.h"
  6. #include ".\childfrm.h"
  7. #include "MainFrm.h"
  8. #include "IDEView.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #endif
  12. // CChildFrame
  13. IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
  14. BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
  15. ON_WM_CLOSE()
  16. ON_WM_CREATE()
  17. END_MESSAGE_MAP()
  18. // CChildFrame 构造/析构
  19. CChildFrame::CChildFrame()
  20. {
  21. // TODO: 在此添加成员初始化代码
  22. m_bClose = FALSE;
  23. m_strPath = "";
  24. }
  25. CChildFrame::~CChildFrame()
  26. {
  27. }
  28. BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
  29. {
  30. // TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或样式
  31. if( !CMDIChildWnd::PreCreateWindow(cs) )
  32. return FALSE;
  33. if (g_bStartRun)
  34. cs.style&=~WS_CAPTION;
  35. return TRUE;
  36. }
  37. // CChildFrame 诊断
  38. #ifdef _DEBUG
  39. void CChildFrame::AssertValid() const
  40. {
  41. CMDIChildWnd::AssertValid();
  42. }
  43. void CChildFrame::Dump(CDumpContext& dc) const
  44. {
  45. CMDIChildWnd::Dump(dc);
  46. }
  47. #endif //_DEBUG
  48. // CChildFrame 消息处理程序
  49. void CChildFrame::OnClose()
  50. {
  51. // TODO: 在此添加消息处理程序代码和/或调用默认值
  52. CMainFrame *pMainFrm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
  53. if( pMainFrm->m_nViewCount == 1 && pMainFrm->m_bShutdown == FALSE )
  54. {
  55. MessageBox(g_strCannotLoseAllForm,g_strTip,MB_ICONWARNING);
  56. return;
  57. }
  58. if( ((CIDEView *)pMainFrm->m_pActiveView)->m_bModified==1 )
  59. {
  60. if(MessageBox(g_strSaveModify,g_strSelect,MB_YESNO|MB_ICONQUESTION) == IDYES)
  61. ((CIDEView *)pMainFrm->m_pActiveView)->FileSave();
  62. }
  63. pMainFrm->m_pActiveView = NULL;
  64. pMainFrm->MDINext();
  65. CMDIChildWnd* m_ChildFrame = (CChildFrame*)pMainFrm->GetActiveFrame();
  66. if( m_ChildFrame != NULL )
  67. {
  68. pMainFrm->m_pActiveView = (CFormView *)pMainFrm->GetActiveFrame()->GetActiveView();
  69. //pMainFrm->m_pActiveView->Invalidate();
  70. }
  71. m_bClose = TRUE;
  72. int nIndex = pMainFrm->GetIDEViewIndex(m_strPath);
  73. pMainFrm->m_nViewCount--;
  74. CMDIChildWnd::OnClose();
  75. if( nIndex != -1 )
  76. {
  77. //delete pMainFrm->m_pViewIDE[nIndex];
  78. pMainFrm->m_pViewIDE[nIndex] = NULL;
  79. }
  80. }
  81. int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  82. {
  83. //MDIMaximize( );
  84. if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
  85. return -1;
  86. // TODO: 在此添加您专用的创建代码
  87. SetWindowText( m_strDesc );
  88. return 0;
  89. }