MAINFRM.CPP
上传用户:gzfeiyu199
上传日期:2021-09-15
资源大小:68k
文件大小:5k
源码类别:

编辑框

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "Demo_DevStudio.h"
  5. #include "TreeViewClass.h"
  6. #include "TreeViewFile.h"
  7. #include "TreeViewResource.h"
  8. #include "MainFrm.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMainFrame
  16. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  17. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  18. ON_COMMAND_EX(CG_ID_VIEW_OUTPUT, OnBarCheck)
  19. ON_UPDATE_COMMAND_UI(CG_ID_VIEW_OUTPUT, OnUpdateControlBarMenu)
  20. ON_COMMAND_EX(CG_ID_VIEW_WORKSPACE, OnBarCheck)
  21. ON_UPDATE_COMMAND_UI(CG_ID_VIEW_WORKSPACE, OnUpdateControlBarMenu)
  22. //{{AFX_MSG_MAP(CMainFrame)
  23. ON_WM_CREATE()
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. static UINT indicators[] =
  27. {
  28. ID_SEPARATOR,           // status line indicator
  29. ID_INDICATOR_CAPS,
  30. ID_INDICATOR_NUM,
  31. ID_INDICATOR_SCRL,
  32. };
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMainFrame construction/destruction
  35. CMainFrame::CMainFrame()
  36. {
  37. }
  38. CMainFrame::~CMainFrame()
  39. {
  40. }
  41. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  42. {
  43. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  44. return -1;
  45. if (!m_wndToolBar.Create(this) ||
  46. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  47. {
  48. TRACE0("Failed to create toolbarn");
  49. return -1;      // fail to create
  50. }
  51. if (!m_wndStatusBar.Create(this) ||
  52. !m_wndStatusBar.SetIndicators(indicators,
  53.   sizeof(indicators)/sizeof(UINT)))
  54. {
  55. TRACE0("Failed to create status barn");
  56. return -1;      // fail to create
  57. }
  58. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  59. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  60. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  61. // TODO: Delete these three lines if you don't want the toolbar to
  62. //  be dockable
  63. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  64. EnableDocking(CBRS_ALIGN_ANY);
  65. DockControlBar(&m_wndToolBar);
  66. // Install cool menus.
  67. InstallCoolMenus(this, IDR_MAINFRAME);
  68. // Create the image list to be used with the control bars.
  69. m_ImageList.Create(IDB_IMAGELIST, 13, 1, RGB(0,255,0));
  70. // CG: The following block was inserted by the 'Dialog Bar' component
  71. {
  72. m_wndWorkspace.SetBtnImageList (&m_ImageList);
  73. m_wndWorkspace.SetMenuID(IDR_POPUP);
  74. // Initialize dialog bar m_wndWorkspace
  75. if (!m_wndWorkspace.Create(this, CG_ID_VIEW_WORKSPACE,
  76. _T("Workspace"), CSize(220,200)))
  77. {
  78. TRACE0("Failed to create dialog bar m_wndWorkspacen");
  79. return -1; // fail to create
  80. }
  81. // Add the views to the tab control.
  82. m_wndWorkspace.AddView(_T("Class"),    RUNTIME_CLASS(CTreeViewClass));
  83. m_wndWorkspace.AddView(_T("Resource"), RUNTIME_CLASS(CTreeViewResource));
  84. m_wndWorkspace.AddView(_T("Files"),    RUNTIME_CLASS(CTreeViewFile));
  85. // Define the image list to use with the tab control
  86. m_TabImages.Create (IDB_IL_TAB, 16, 1, RGB(0,255,0));
  87. m_wndWorkspace.SetTabImageList(&m_TabImages);
  88.     // allow bar to be resized when floating
  89.     m_wndWorkspace.SetBarStyle(m_wndWorkspace.GetBarStyle() |
  90.     CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  91. m_wndWorkspace.EnableDocking(CBRS_ALIGN_ANY);
  92. EnableDocking(CBRS_ALIGN_ANY);
  93. DockControlBar(&m_wndWorkspace, AFX_IDW_DOCKBAR_LEFT);
  94. }
  95. // CG: The following block was inserted by the 'Dialog Bar' component
  96. {
  97. m_wndOutput.SetBtnImageList (&m_ImageList);
  98. m_wndOutput.SetMenuID(IDR_POPUP);
  99. // Initialize dialog bar m_wndOutput
  100. if (!m_wndOutput.Create(this, CG_ID_VIEW_OUTPUT,
  101. _T("Output"), CSize(200,100)))
  102. {
  103. TRACE0("Failed to create dialog bar m_wndOutputn");
  104. return -1; // fail to create
  105. }
  106.     // allow bar to be resized when floating
  107.     m_wndOutput.SetBarStyle(m_wndOutput.GetBarStyle() |
  108.     CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  109. m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
  110. EnableDocking(CBRS_ALIGN_ANY);
  111. DockControlBar(&m_wndOutput, AFX_IDW_DOCKBAR_BOTTOM);
  112. }
  113. return 0;
  114. }
  115. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  116. {
  117. // TODO: Modify the Window class or styles here by modifying
  118. //  the CREATESTRUCT cs
  119. return CMDIFrameWnd::PreCreateWindow(cs);
  120. }
  121. /////////////////////////////////////////////////////////////////////////////
  122. // CMainFrame diagnostics
  123. #ifdef _DEBUG
  124. void CMainFrame::AssertValid() const
  125. {
  126. CMDIFrameWnd::AssertValid();
  127. }
  128. void CMainFrame::Dump(CDumpContext& dc) const
  129. {
  130. CMDIFrameWnd::Dump(dc);
  131. }
  132. #endif //_DEBUG
  133. /////////////////////////////////////////////////////////////////////////////
  134. // CMainFrame message handlers