home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / mdidocvw / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.8 KB  |  120 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14.  
  15. #include "stdafx.h"
  16. #include "MDI.h"
  17.  
  18. #include "MainFrm.h"
  19.  
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMainFrame
  28.  
  29. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  30.  
  31. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  32.     //{{AFX_MSG_MAP(CMainFrame)
  33.     ON_WM_CREATE()
  34.     //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36.  
  37. static UINT indicators[] =
  38. {
  39.     ID_SEPARATOR,           // status line indicator
  40.     ID_INDICATOR_CAPS,
  41.     ID_INDICATOR_NUM,
  42.     ID_INDICATOR_SCRL,
  43. };
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CMainFrame construction/destruction
  47.  
  48. CMainFrame::CMainFrame()
  49. {
  50. }
  51.  
  52. CMainFrame::~CMainFrame()
  53. {
  54. }
  55.  
  56. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  57. {
  58.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  59.         return -1;
  60.  
  61.     if (!m_wndToolBar.Create(this) ||
  62.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  63.     {
  64.         TRACE0("Failed to create toolbar\n");
  65.         return -1;      // fail to create
  66.     }
  67.  
  68. // set button styles for colors to TBBS_CHECKBOX
  69.  
  70.     m_wndToolBar.SetButtonStyle(6, TBBS_CHECKBOX);
  71.     m_wndToolBar.SetButtonStyle(7, TBBS_CHECKBOX);
  72.     m_wndToolBar.SetButtonStyle(10, TBBS_CHECKBOX);
  73.     m_wndToolBar.SetButtonStyle(11, TBBS_CHECKBOX);
  74.     m_wndToolBar.SetButtonStyle(12, TBBS_CHECKBOX);
  75.  
  76.     if (!m_wndStatusBar.Create(this) ||
  77.         !m_wndStatusBar.SetIndicators(indicators,
  78.           sizeof(indicators)/sizeof(UINT)))
  79.     {
  80.         TRACE0("Failed to create status bar\n");
  81.         return -1;      // fail to create
  82.     }
  83.  
  84.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  85.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  86.  
  87.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  88.     EnableDocking(CBRS_ALIGN_ANY);
  89.     DockControlBar(&m_wndToolBar);
  90.  
  91. // Add title for toolbar
  92.     m_wndToolBar.SetWindowText(_T("Standard"));
  93.  
  94.     return 0;
  95. }
  96.  
  97. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  98. {
  99.     return CMDIFrameWnd::PreCreateWindow(cs);
  100. }
  101.  
  102. /////////////////////////////////////////////////////////////////////////////
  103. // CMainFrame diagnostics
  104.  
  105. #ifdef _DEBUG
  106. void CMainFrame::AssertValid() const
  107. {
  108.     CMDIFrameWnd::AssertValid();
  109. }
  110.  
  111. void CMainFrame::Dump(CDumpContext& dc) const
  112. {
  113.     CMDIFrameWnd::Dump(dc);
  114. }
  115.  
  116. #endif //_DEBUG
  117.  
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CMainFrame message handlers
  120.