MainFrm.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "mfc1.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. ID_SEPARATOR, // status line indicator
  16. ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL,
  17. };
  18. // CMainFrame construction/destruction
  19. CMainFrame::CMainFrame()
  20. {
  21. // TODO: add member initialization code here
  22. }
  23. CMainFrame::~CMainFrame()
  24. {
  25. }
  26. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  27. {
  28. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  29. return -1;
  30. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |
  31. CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |
  32. CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  33. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
  34. TRACE0("Failed to create toolbar\n");
  35. return -1; // fail to create
  36. }
  37. if (!m_wndStatusBar.Create(this) ||
  38. !m_wndStatusBar.SetIndicators(indicators,
  39. sizeof(indicators) / sizeof(UINT))) {
  40. TRACE0("Failed to create status bar\n");
  41. return -1; // fail to create
  42. }
  43. // TODO: Delete these three lines if you don't want the toolbar to be
  44. // dockable
  45. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  46. EnableDocking(CBRS_ALIGN_ANY);
  47. DockControlBar(&m_wndToolBar);
  48. return 0;
  49. }
  50. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  51. {
  52. if (!CMDIFrameWnd::PreCreateWindow(cs))
  53. return FALSE;
  54. // TODO: Modify the Window class or styles here by modifying
  55. // the CREATESTRUCT cs
  56. return TRUE;
  57. }
  58. // CMainFrame diagnostics
  59. #ifdef _DEBUG
  60. void CMainFrame::AssertValid() const
  61. {
  62. CMDIFrameWnd::AssertValid();
  63. }
  64. void CMainFrame::Dump(CDumpContext& dc) const
  65. {
  66. CMDIFrameWnd::Dump(dc);
  67. }
  68. #endif //_DEBUG
  69. // CMainFrame message handlers