home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / ipdrive / mainfrm.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  131 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 "ipdrive.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_DYNCREATE(CMainFrame, CFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  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 (CFrameWnd::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. #if (_MFC_VER > 0x300)
  101.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  102.     EnableDocking(CBRS_ALIGN_ANY);
  103.     DockControlBar(&m_wndToolBar);
  104.  
  105.     // TODO: Remove this if you don't want tool tips
  106.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  107.         CBRS_TOOLTIPS | CBRS_FLYBY);
  108. #endif
  109.  
  110.     return 0;
  111. }
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CMainFrame diagnostics
  115.  
  116. #ifdef _DEBUG
  117. void CMainFrame::AssertValid() const
  118. {
  119.     CFrameWnd::AssertValid();
  120. }
  121.  
  122. void CMainFrame::Dump(CDumpContext& dc) const
  123. {
  124.     CFrameWnd::Dump(dc);
  125. }
  126.  
  127. #endif //_DEBUG
  128.  
  129. /////////////////////////////////////////////////////////////////////////////
  130. // CMainFrame message handlers
  131.