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

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "oldbars.h"
  15.  
  16. #include "mainfrm.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMainFrame
  25.  
  26. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  29.     //{{AFX_MSG_MAP(CMainFrame)
  30.         // NOTE - the ClassWizard will add and remove mapping macros here.
  31.         //    DO NOT EDIT what you see in these blocks of generated code !
  32.     ON_WM_CREATE()
  33.     //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // arrays of IDs used to initialize control bars
  38.  
  39. // toolbar buttons - IDs are command buttons
  40. static UINT BASED_CODE buttons[] =
  41. {
  42.     // same order as in the bitmap 'toolbar.bmp'
  43.     ID_FILE_NEW,
  44.     ID_FILE_OPEN,
  45.     ID_FILE_SAVE,
  46.         ID_SEPARATOR,
  47.     ID_EDIT_CUT,
  48.     ID_EDIT_COPY,
  49.     ID_EDIT_PASTE,
  50.         ID_SEPARATOR,
  51.     ID_FILE_PRINT,
  52.     ID_APP_ABOUT,
  53. };
  54.  
  55. static UINT BASED_CODE indicators[] =
  56. {
  57.     ID_SEPARATOR,           // status line indicator
  58.     ID_INDICATOR_CAPS,
  59.     ID_INDICATOR_NUM,
  60.     ID_INDICATOR_SCRL,
  61. };
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CMainFrame construction/destruction
  65.  
  66. CMainFrame::CMainFrame()
  67. {
  68.     // TODO: add member initialization code here
  69.  
  70. }
  71.  
  72. CMainFrame::~CMainFrame()
  73. {
  74. }
  75.  
  76. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  77. {
  78.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  79.         return -1;
  80.  
  81.     if (!m_wndToolBar.Create(this) ||
  82.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  83.         !m_wndToolBar.SetButtons(buttons,
  84.           sizeof(buttons)/sizeof(UINT)))
  85.     {
  86.         TRACE0("Failed to create toolbar\n");
  87.         return -1;      // fail to create
  88.     }
  89.  
  90.     if (!m_wndStatusBar.Create(this) ||
  91.         !m_wndStatusBar.SetIndicators(indicators,
  92.           sizeof(indicators)/sizeof(UINT)))
  93.     {
  94.         TRACE0("Failed to create status bar\n");
  95.         return -1;      // fail to create
  96.     }
  97.  
  98.     // TODO: Delete these three lines if you don't want the toolbar to
  99.     //  be dockable
  100.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  101.     EnableDocking(CBRS_ALIGN_ANY);
  102.     DockControlBar(&m_wndToolBar);
  103.  
  104.     // TODO: Remove this if you don't want tool tips
  105.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  106.         CBRS_TOOLTIPS | CBRS_FLYBY);
  107.  
  108.     return 0;
  109. }
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CMainFrame diagnostics
  113.  
  114. #ifdef _DEBUG
  115. void CMainFrame::AssertValid() const
  116. {
  117.     CMDIFrameWnd::AssertValid();
  118. }
  119.  
  120. void CMainFrame::Dump(CDumpContext& dc) const
  121. {
  122.     CMDIFrameWnd::Dump(dc);
  123. }
  124.  
  125. #endif //_DEBUG
  126.  
  127. /////////////////////////////////////////////////////////////////////////////
  128. // CMainFrame message handlers
  129.