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 / ipframe.cpp next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  4.0 KB  |  136 lines

  1. // ipframe.cpp : implementation of the CInPlaceFrame 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.  
  15. #include "scribble.h"
  16. #include "ipframe.h"
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CInPlaceFrame
  25.  
  26. IMPLEMENT_DYNCREATE(CInPlaceFrame, COleDocIPFrameWnd)
  27.  
  28. BEGIN_MESSAGE_MAP(CInPlaceFrame, COleDocIPFrameWnd)
  29.     //{{AFX_MSG_MAP(CInPlaceFrame)
  30.     ON_WM_CREATE()
  31.     //}}AFX_MSG_MAP
  32.     // Global help commands
  33.     ON_COMMAND(ID_HELP_INDEX, COleDocIPFrameWnd::OnHelpIndex)
  34.     ON_COMMAND(ID_HELP_USING, COleDocIPFrameWnd::OnHelpUsing)
  35.     ON_COMMAND(ID_HELP, COleDocIPFrameWnd::OnHelp)
  36.     ON_COMMAND(ID_DEFAULT_HELP, COleDocIPFrameWnd::OnHelpIndex)
  37.     ON_COMMAND(ID_CONTEXT_HELP, COleDocIPFrameWnd::OnContextHelp)
  38. END_MESSAGE_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // arrays of IDs used to initialize control bars
  42.  
  43. // toolbar buttons - IDs are command buttons
  44. static UINT BASED_CODE buttons[] =
  45. {
  46.     // same order as in the bitmap 'itoolbar.bmp'
  47.     ID_EDIT_CUT,
  48.     ID_EDIT_COPY,
  49.     ID_EDIT_PASTE,
  50.         ID_SEPARATOR,
  51.     ID_PEN_THICK_OR_THIN,
  52.         ID_SEPARATOR,
  53.     ID_APP_ABOUT,
  54.     ID_CONTEXT_HELP,
  55. };
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CInPlaceFrame construction/destruction
  59.  
  60. CInPlaceFrame::CInPlaceFrame()
  61. {
  62. }
  63.  
  64. CInPlaceFrame::~CInPlaceFrame()
  65. {
  66. }
  67.  
  68. int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  69. {
  70.     if (COleDocIPFrameWnd::OnCreate(lpCreateStruct) == -1)
  71.         return -1;
  72.  
  73.     // CResizeBar implements in-place resizing.
  74.     if (!m_wndResizeBar.Create(this))
  75.     {
  76.         TRACE0("Failed to create resize bar\n");
  77.         return -1;      // fail to create
  78.     }
  79.  
  80.     // By default, it is a good idea to register a drop-target that does
  81.     //  nothing with your frame window.  This prevents drops from
  82.     //  "falling through" to a container that supports drag-drop.
  83.     m_dropTarget.Register(this);
  84.  
  85.     return 0;
  86. }
  87.  
  88. // OnCreateControlBars is called by the framework to create control bars on the
  89. //  container application's windows.  pWndFrame is the top level frame window of
  90. //  the container and is always non-NULL.  pWndDoc is the doc level frame window
  91. //  and will be NULL when the container is an SDI application.  A server
  92. //  application can place MFC control bars on either window.
  93. BOOL CInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* pWndDoc)
  94. {
  95.     // Create toolbar on client's frame window
  96.     if (!m_wndToolBar.Create(pWndFrame) ||
  97.         !m_wndToolBar.LoadBitmap(IDR_SCRIBTYPE_SRVR_IP) ||
  98.         !m_wndToolBar.SetButtons(buttons, sizeof(buttons)/sizeof(UINT)))
  99.     {
  100.         TRACE0("Failed to create toolbar\n");
  101.         return FALSE;
  102.     }
  103.     // Set owner to this window, so messages are delivered to correct app
  104.     m_wndToolBar.SetOwner(this);
  105.  
  106.     // TODO: Delete these three lines if you don't want the toolbar to
  107.     //  be dockable
  108.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  109.     pWndFrame->EnableDocking(CBRS_ALIGN_ANY);
  110.     pWndFrame->DockControlBar(&m_wndToolBar);
  111.  
  112.     // TODO: Remove this if you don't want tool tips
  113.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  114.         CBRS_TOOLTIPS | CBRS_FLYBY);
  115.  
  116.     return TRUE;
  117. }
  118.  
  119. /////////////////////////////////////////////////////////////////////////////
  120. // CInPlaceFrame diagnostics
  121.  
  122. #ifdef _DEBUG
  123. void CInPlaceFrame::AssertValid() const
  124. {
  125.     COleDocIPFrameWnd::AssertValid();
  126. }
  127.  
  128. void CInPlaceFrame::Dump(CDumpContext& dc) const
  129. {
  130.     COleDocIPFrameWnd::Dump(dc);
  131. }
  132. #endif //_DEBUG
  133.  
  134. /////////////////////////////////////////////////////////////////////////////
  135. // CInPlaceFrame commands
  136.