home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / source / chap04 / lst42 / ipframe.cpp next >
Encoding:
C/C++ Source or Header  |  1996-09-26  |  3.0 KB  |  113 lines

  1. // IpFrame.cpp : implementation of the CInPlaceFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "lst42.h"
  6.  
  7. #include "IpFrame.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CInPlaceFrame
  17.  
  18. IMPLEMENT_DYNCREATE(CInPlaceFrame, COleIPFrameWnd)
  19.  
  20. BEGIN_MESSAGE_MAP(CInPlaceFrame, COleIPFrameWnd)
  21.     //{{AFX_MSG_MAP(CInPlaceFrame)
  22.     ON_WM_CREATE()
  23.     //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CInPlaceFrame construction/destruction
  28.  
  29. CInPlaceFrame::CInPlaceFrame()
  30. {
  31. }
  32.  
  33. CInPlaceFrame::~CInPlaceFrame()
  34. {
  35. }
  36.  
  37. int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  38. {
  39.     if (COleIPFrameWnd::OnCreate(lpCreateStruct) == -1)
  40.         return -1;
  41.  
  42.     // CResizeBar implements in-place resizing.
  43.     if (!m_wndResizeBar.Create(this))
  44.     {
  45.         TRACE0("Failed to create resize bar\n");
  46.         return -1;      // fail to create
  47.     }
  48.  
  49.     // By default, it is a good idea to register a drop-target that does
  50.     //  nothing with your frame window.  This prevents drops from
  51.     //  "falling through" to a container that supports drag-drop.
  52.     m_dropTarget.Register(this);
  53.  
  54.     return 0;
  55. }
  56.  
  57. // OnCreateControlBars is called by the framework to create control bars on the
  58. //  container application's windows.  pWndFrame is the top level frame window of
  59. //  the container and is always non-NULL.  pWndDoc is the doc level frame window
  60. //  and will be NULL when the container is an SDI application.  A server
  61. //  application can place MFC control bars on either window.
  62. BOOL CInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* pWndDoc)
  63. {
  64.     // Set owner to this window, so messages are delivered to correct app
  65.     m_wndToolBar.SetOwner(this);
  66.  
  67.     // Create toolbar on client's frame window
  68.     if (!m_wndToolBar.Create(pWndFrame) ||
  69.         !m_wndToolBar.LoadToolBar(IDR_SRVR_INPLACE))
  70.     {
  71.         TRACE0("Failed to create toolbar\n");
  72.         return FALSE;
  73.     }
  74.  
  75.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  76.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  77.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  78.  
  79.     // TODO: Delete these three lines if you don't want the toolbar to
  80.     //  be dockable
  81.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  82.     pWndFrame->EnableDocking(CBRS_ALIGN_ANY);
  83.     pWndFrame->DockControlBar(&m_wndToolBar);
  84.  
  85.     return TRUE;
  86. }
  87.  
  88. BOOL CInPlaceFrame::PreCreateWindow(CREATESTRUCT& cs)
  89. {
  90.     // TODO: Modify the Window class or styles here by modifying
  91.     //  the CREATESTRUCT cs
  92.  
  93.     return COleIPFrameWnd::PreCreateWindow(cs);
  94. }
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CInPlaceFrame diagnostics
  98.  
  99. #ifdef _DEBUG
  100. void CInPlaceFrame::AssertValid() const
  101. {
  102.     COleIPFrameWnd::AssertValid();
  103. }
  104.  
  105. void CInPlaceFrame::Dump(CDumpContext& dc) const
  106. {
  107.     COleIPFrameWnd::Dump(dc);
  108. }
  109. #endif //_DEBUG
  110.  
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CInPlaceFrame commands
  113.