MainFrm.cpp
上传用户:libwxy
上传日期:2007-01-02
资源大小:200k
文件大小:3k
源码类别:

工具条

开发平台:

Visual C++

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "comdef.h"
  5. #include "MDITest.h"
  6. #include "MainFrm.h"
  7. #include "ClassView.h"
  8. #include "FileView.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. //{{AFX_MSG_MAP(CMainFrame)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. //    DO NOT EDIT what you see in these blocks of generated code !
  21. ON_WM_CREATE()
  22. //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24. static UINT indicators[] =
  25. {
  26. ID_SEPARATOR,           // status line indicator
  27. ID_INDICATOR_CAPS,
  28. ID_INDICATOR_NUM,
  29. ID_INDICATOR_SCRL,
  30. };
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CMainFrame construction/destruction
  33. CMainFrame::CMainFrame()
  34. {
  35. // TODO: add member initialization code here
  36. }
  37. CMainFrame::~CMainFrame()
  38. {
  39. }
  40. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  41. {
  42. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  43. return -1;
  44. if (!m_wndToolBar.Create(this) ||
  45. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  46. {
  47. TRACE0("Failed to create toolbarn");
  48. return -1;      // fail to create
  49. }
  50. if (!m_wndStatusBar.Create(this) ||
  51. !m_wndStatusBar.SetIndicators(indicators,
  52.   sizeof(indicators)/sizeof(UINT)))
  53. {
  54. TRACE0("Failed to create status barn");
  55. return -1;      // fail to create
  56. }
  57. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  58. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  59. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  60. // TODO: Delete these three lines if you don't want the toolbar to
  61. //  be dockable
  62. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  63. EnableDocking(CBRS_ALIGN_ANY);
  64. DockControlBar(&m_wndToolBar);
  65. // SizingControlBar
  66. m_wndSTCBar.m_uiTabID = 300;
  67. m_wndSTCBar.m_uiTabImage = IDB_BITMAP1;
  68. m_wndSTCBar.Create(this, CSize(200, 100), 200);
  69. m_wndSTCBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  70. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  71. m_wndSTCBar.EnableDocking(CBRS_ALIGN_ANY);
  72. DockControlBar(&m_wndSTCBar, AFX_IDW_DOCKBAR_LEFT);
  73. m_wndSTCBar.AddView("Database", RUNTIME_CLASS(CClassView));
  74. m_wndSTCBar.AddView("Files", RUNTIME_CLASS(CFileView));
  75. return 0;
  76. }
  77. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  78. {
  79. // TODO: Modify the Window class or styles here by modifying
  80. //  the CREATESTRUCT cs
  81. return CMDIFrameWnd::PreCreateWindow(cs);
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CMainFrame diagnostics
  85. #ifdef _DEBUG
  86. void CMainFrame::AssertValid() const
  87. {
  88. CMDIFrameWnd::AssertValid();
  89. }
  90. void CMainFrame::Dump(CDumpContext& dc) const
  91. {
  92. CMDIFrameWnd::Dump(dc);
  93. }
  94. #endif //_DEBUG
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CMainFrame message handlers
  97. void CMainFrame::RecalcLayout(BOOL bNotify) 
  98. {
  99. CMDIFrameWnd::RecalcLayout(bNotify);
  100. CMDIFrameWnd::RecalcLayout(bNotify);
  101. }