home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c11 / lab01 / ex01 / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.5 KB  |  115 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "afxdisp.h"
  6.  
  7. #include "browse.h"
  8.  
  9. #include "MainFrm.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMainFrame
  19.  
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21.  
  22. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  23.     //{{AFX_MSG_MAP(CMainFrame)
  24.         // NOTE - the ClassWizard will add and remove mapping macros here.
  25.         //    DO NOT EDIT what you see in these blocks of generated code !
  26.     ON_WM_CREATE()
  27.     //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29.  
  30.  
  31. static UINT indicators[] =
  32. {
  33.     ID_SEPARATOR,           // status line indicator
  34.     ID_INDICATOR_CAPS,
  35.     ID_INDICATOR_NUM,
  36.     ID_INDICATOR_SCRL,
  37. };
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CMainFrame construction/destruction
  41.  
  42. CMainFrame::CMainFrame()
  43. {
  44.     // TODO: add member initialization code here
  45.     
  46. }
  47.  
  48. CMainFrame::~CMainFrame()
  49. {
  50. }
  51.  
  52. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  53. {
  54.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  55.         return -1;
  56.     
  57.     if (!m_wndToolBar.Create(this) ||
  58.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  59.     {
  60.         TRACE0("Failed to create toolbar\n");
  61.         return -1;      // fail to create
  62.     }
  63.  
  64.     if (!m_wndStatusBar.Create(this) ||
  65.         !m_wndStatusBar.SetIndicators(indicators,
  66.           sizeof(indicators)/sizeof(UINT)))
  67.     {
  68.         TRACE0("Failed to create status bar\n");
  69.         return -1;      // fail to create
  70.     }
  71.  
  72.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  73.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  74.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  75.  
  76.     // TODO: Delete these three lines if you don't want the toolbar to
  77.     //  be dockable
  78.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  79.     EnableDocking(CBRS_ALIGN_ANY);
  80.     DockControlBar(&m_wndToolBar);
  81.  
  82.     return 0;
  83. }
  84.  
  85. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  86. {
  87.     // TODO: Modify the Window class or styles here by modifying
  88.     //  the CREATESTRUCT cs
  89.  
  90.     return CFrameWnd::PreCreateWindow(cs);
  91. }
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CMainFrame diagnostics
  95.  
  96. #ifdef _DEBUG
  97. void CMainFrame::AssertValid() const
  98. {
  99.     CFrameWnd::AssertValid();
  100. }
  101.  
  102. void CMainFrame::Dump(CDumpContext& dc) const
  103. {
  104.     CFrameWnd::Dump(dc);
  105. }
  106.  
  107. #endif //_DEBUG
  108.  
  109.  
  110. void CMainFrame::Status(LPCTSTR text)
  111. {
  112.     m_wndStatusBar.SetPaneText(0,text,TRUE);
  113.  
  114. }
  115.