MainFrm.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // MainFrm.cpp : CMainFrame 类的实现
  2. //
  3. #include "stdafx.h"
  4. #include "MDI.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #endif
  9. // CMainFrame
  10. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  11. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  12. ON_WM_CREATE()
  13. END_MESSAGE_MAP()
  14. static UINT indicators[] =
  15. {
  16. ID_SEPARATOR, // 状态行指示器
  17. ID_INDICATOR_CAPS,
  18. ID_INDICATOR_NUM,
  19. ID_INDICATOR_SCRL,
  20. };
  21. // CMainFrame 构造/析构
  22. CMainFrame::CMainFrame()
  23. {
  24. // TODO: 在此添加成员初始化代码
  25. }
  26. CMainFrame::~CMainFrame()
  27. {
  28. }
  29. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  30. {
  31. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  32. return -1;
  33. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  34. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  35. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  36. {
  37. TRACE0("未能创建工具栏\n");
  38. return -1; // 未能创建
  39. }
  40. if (!m_wndStatusBar.Create(this) ||
  41. !m_wndStatusBar.SetIndicators(indicators,
  42. sizeof(indicators)/sizeof(UINT)))
  43. {
  44. TRACE0("未能创建状态栏\n");
  45. return -1; // 未能创建
  46. }
  47. // TODO: 如果不需要工具栏可停靠,则删除这三行
  48. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  49. EnableDocking(CBRS_ALIGN_ANY);
  50. DockControlBar(&m_wndToolBar);
  51. return 0;
  52. }
  53. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  54. {
  55. if( !CMDIFrameWnd::PreCreateWindow(cs) )
  56. return FALSE;
  57. // TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
  58. // 样式
  59. return TRUE;
  60. }
  61. // CMainFrame 诊断
  62. #ifdef _DEBUG
  63. void CMainFrame::AssertValid() const
  64. {
  65. CMDIFrameWnd::AssertValid();
  66. }
  67. void CMainFrame::Dump(CDumpContext& dc) const
  68. {
  69. CMDIFrameWnd::Dump(dc);
  70. }
  71. #endif //_DEBUG
  72. // CMainFrame 消息处理程序