home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / bindscrb / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.5 KB  |  138 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 "scribble.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.     // Global help commands
  35.     ON_COMMAND(ID_HELP_INDEX, CMDIFrameWnd::OnHelpIndex)
  36.     ON_COMMAND(ID_HELP_USING, CMDIFrameWnd::OnHelpUsing)
  37.     ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
  38.     ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
  39.     ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpIndex)
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // arrays of IDs used to initialize control bars
  44.  
  45. // toolbar buttons - IDs are command buttons
  46. static UINT BASED_CODE buttons[] =
  47. {
  48.     // same order as in the bitmap 'toolbar.bmp'
  49.     ID_FILE_NEW,
  50.     ID_FILE_OPEN,
  51.     ID_FILE_SAVE,
  52.         ID_SEPARATOR,
  53.     ID_EDIT_CUT,
  54.     ID_EDIT_COPY,
  55.     ID_EDIT_PASTE,
  56.         ID_SEPARATOR,
  57.     ID_PEN_THICK_OR_THIN,
  58.         ID_SEPARATOR,
  59.     ID_FILE_PRINT,
  60.     ID_APP_ABOUT,
  61.     ID_CONTEXT_HELP,
  62. };
  63.  
  64. static UINT BASED_CODE indicators[] =
  65. {
  66.     ID_SEPARATOR,           // status line indicator
  67.     ID_INDICATOR_CAPS,
  68.     ID_INDICATOR_NUM,
  69.     ID_INDICATOR_SCRL,
  70. };
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CMainFrame construction/destruction
  74.  
  75. CMainFrame::CMainFrame()
  76. {
  77.     // TODO: add member initialization code here
  78.  
  79. }
  80.  
  81. CMainFrame::~CMainFrame()
  82. {
  83. }
  84.  
  85. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  86. {
  87.     if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  88.         return -1;
  89.  
  90.     if (!m_wndToolBar.Create(this) ||
  91.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  92.         !m_wndToolBar.SetButtons(buttons,
  93.           sizeof(buttons)/sizeof(UINT)))
  94.     {
  95.         TRACE0("Failed to create toolbar\n");
  96.         return -1;      // fail to create
  97.     }
  98.  
  99.     if (!m_wndStatusBar.Create(this) ||
  100.         !m_wndStatusBar.SetIndicators(indicators,
  101.           sizeof(indicators)/sizeof(UINT)))
  102.     {
  103.         TRACE0("Failed to create status bar\n");
  104.         return -1;      // fail to create
  105.     }
  106.  
  107.     // TODO: Delete these three lines if you don't want the toolbar to
  108.     //  be dockable
  109.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  110.     EnableDocking(CBRS_ALIGN_ANY);
  111.     DockControlBar(&m_wndToolBar);
  112.  
  113.    // Get tooltips on tool bar
  114.    m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle()
  115.                               | CBRS_TOOLTIPS | CBRS_FLYBY);
  116.  
  117.     return 0;
  118. }
  119.  
  120. /////////////////////////////////////////////////////////////////////////////
  121. // CMainFrame diagnostics
  122.  
  123. #ifdef _DEBUG
  124. void CMainFrame::AssertValid() const
  125. {
  126.     CMDIFrameWnd::AssertValid();
  127. }
  128.  
  129. void CMainFrame::Dump(CDumpContext& dc) const
  130. {
  131.     CMDIFrameWnd::Dump(dc);
  132. }
  133.  
  134. #endif //_DEBUG
  135.  
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CMainFrame message handlers
  138.