MainFrm.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3. #include "stdafx.h"
  4. #include "Demo.h"
  5. #include "MainFrm.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMainFrame
  13. IMPLEMENT_DYNCREATE(CMainFrame, CResizableFrame)
  14. BEGIN_MESSAGE_MAP(CMainFrame, CResizableFrame)
  15. //{{AFX_MSG_MAP(CMainFrame)
  16. ON_WM_CREATE()
  17. //}}AFX_MSG_MAP
  18. END_MESSAGE_MAP()
  19. static UINT indicators[] =
  20. {
  21. ID_SEPARATOR, // status line indicator
  22. ID_INDICATOR_CAPS,
  23. ID_INDICATOR_NUM,
  24. ID_INDICATOR_SCRL,
  25. };
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMainFrame construction/destruction
  28. CMainFrame::CMainFrame()
  29. {
  30. }
  31. CMainFrame::~CMainFrame()
  32. {
  33. }
  34. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  35. {
  36. if (CResizableFrame::OnCreate(lpCreateStruct) == -1)
  37. return -1;
  38. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  39. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  40. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  41. {
  42. TRACE0("Failed to create toolbar\n");
  43. return -1; // fail to create
  44. }
  45. if (!m_wndStatusBar.Create(this) ||
  46. !m_wndStatusBar.SetIndicators(indicators,
  47. sizeof(indicators)/sizeof(UINT)))
  48. {
  49. TRACE0("Failed to create status bar\n");
  50. return -1; // fail to create
  51. }
  52. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  53. EnableDocking(CBRS_ALIGN_ANY);
  54. DockControlBar(&m_wndToolBar);
  55. // save/restore window position and size
  56. EnableSaveRestore(_T("DemoSDI"));
  57. return 0;
  58. }
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CMainFrame diagnostics
  61. #ifdef _DEBUG
  62. void CMainFrame::AssertValid() const
  63. {
  64. CResizableFrame::AssertValid();
  65. }
  66. void CMainFrame::Dump(CDumpContext& dc) const
  67. {
  68. CResizableFrame::Dump(dc);
  69. }
  70. #endif //_DEBUG
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CMainFrame message handlers