home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap24 / polyline / iipobj.cpp < prev    next >
C/C++ Source or Header  |  1995-05-03  |  5KB  |  221 lines

  1. /*
  2.  * IIPOBJ.CPP
  3.  * Polyline Component Chapter 24
  4.  *
  5.  * IOleInPlaceObject interface implementation for Polyline
  6.  *
  7.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Microsoft
  10.  * Internet  :  kraigb@microsoft.com
  11.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  12.  */
  13.  
  14.  
  15. #include "polyline.h"
  16.  
  17.  
  18. /*
  19.  * CImpIOleInPlaceObject::CImpIOleInPlaceObject
  20.  * CImpIOleInPlaceObject::~CImpIOleInPlaceObject
  21.  *
  22.  * Parameters (Constructor):
  23.  *  pObj            PCPolyline of the object we're in.
  24.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  25.  */
  26.  
  27. CImpIOleInPlaceObject::CImpIOleInPlaceObject(PCPolyline pObj
  28.     , LPUNKNOWN pUnkOuter)
  29.     {
  30.     m_cRef=0;
  31.     m_pObj=pObj;
  32.     m_pUnkOuter=pUnkOuter;
  33.     return;
  34.     }
  35.  
  36. CImpIOleInPlaceObject::~CImpIOleInPlaceObject(void)
  37.     {
  38.     return;
  39.     }
  40.  
  41.  
  42.  
  43. /*
  44.  * CImpIOleInPlaceObject::QueryInterface
  45.  * CImpIOleInPlaceObject::AddRef
  46.  * CImpIOleInPlaceObject::Release
  47.  *
  48.  * Purpose:
  49.  *  IUnknown members for CImpIOleInPlaceObject object.
  50.  */
  51.  
  52. STDMETHODIMP CImpIOleInPlaceObject::QueryInterface(REFIID riid
  53.     , PPVOID ppv)
  54.     {
  55.     return m_pUnkOuter->QueryInterface(riid, ppv);
  56.     }
  57.  
  58.  
  59. STDMETHODIMP_(ULONG) CImpIOleInPlaceObject::AddRef(void)
  60.     {
  61.     ++m_cRef;
  62.     return m_pUnkOuter->AddRef();
  63.     }
  64.  
  65. STDMETHODIMP_(ULONG) CImpIOleInPlaceObject::Release(void)
  66.     {
  67.     --m_cRef;
  68.     return m_pUnkOuter->Release();
  69.     }
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * CImpIOleInPlaceObject::GetWindow
  76.  *
  77.  * Purpose:
  78.  *  Retrieves the handle of the window associated with the object
  79.  *  on which this interface is implemented.
  80.  *
  81.  * Parameters:
  82.  *  phWnd           HWND * in which to store the window handle.
  83.  *
  84.  * Return Value:
  85.  *  HRESULT         NOERROR if successful, E_FAIL if there is no
  86.  *                  window.
  87.  */
  88.  
  89. STDMETHODIMP CImpIOleInPlaceObject::GetWindow(HWND *phWnd)
  90.     {
  91.     if (NULL!=m_pObj->m_pHW)
  92.         *phWnd=m_pObj->m_pHW->Window();
  93.     else
  94.         *phWnd=m_pObj->m_hWnd;
  95.  
  96.     return NOERROR;
  97.     }
  98.  
  99.  
  100.  
  101.  
  102. /*
  103.  * CImpIOleInPlaceObject::ContextSensitiveHelp
  104.  *
  105.  * Purpose:
  106.  *  Instructs the object on which this interface is implemented to
  107.  *  enter or leave a context-sensitive help mode.
  108.  *
  109.  * Parameters:
  110.  *  fEnterMode      BOOL TRUE to enter the mode, FALSE otherwise.
  111.  *
  112.  * Return Value:
  113.  *  HRESULT         NOERROR or an error code
  114.  */
  115.  
  116. STDMETHODIMP CImpIOleInPlaceObject::ContextSensitiveHelp
  117.     (BOOL fEnterMode)
  118.     {
  119.     return ResultFromScode(E_NOTIMPL);
  120.     }
  121.  
  122.  
  123.  
  124.  
  125. /*
  126.  * CImpIOleInPlaceObject::InPlaceDeactivate
  127.  *
  128.  * Purpose:
  129.  *  Instructs the object to deactivate itself from an in-place state
  130.  *  and to discard any Undo state.
  131.  *
  132.  * Parameters:
  133.  *  None
  134.  *
  135.  * Return Value:
  136.  *  HRESULT         NOERROR or an error code
  137.  */
  138.  
  139. STDMETHODIMP CImpIOleInPlaceObject::InPlaceDeactivate(void)
  140.     {
  141.     m_pObj->InPlaceDeactivate();
  142.     return NOERROR;
  143.     }
  144.  
  145.  
  146.  
  147.  
  148. /*
  149.  * CImpIOleInPlaceObject::UIDeactivate
  150.  *
  151.  * Purpose:
  152.  *  Instructs the object to just remove any in-place user interface
  153.  *  but to do no other deactivation.  The object should just hide
  154.  *  the UI components but not destroy them until InPlaceDeactivate
  155.  *  is called.
  156.  *
  157.  * Parameters:
  158.  *  None
  159.  *
  160.  * Return Value:
  161.  *  HRESULT         NOERROR or an error code
  162.  */
  163.  
  164. STDMETHODIMP CImpIOleInPlaceObject::UIDeactivate(void)
  165.     {
  166.     m_pObj->UIDeactivate();
  167.     return NOERROR;
  168.     }
  169.  
  170.  
  171.  
  172.  
  173. /*
  174.  * CImpIOleInPlaceObject::SetObjectRects
  175.  *
  176.  * Purpose:
  177.  *  Provides the object with rectangles describing the position of
  178.  *  the object in the container window as well as its visible area.
  179.  *
  180.  * Parameters:
  181.  *  prcPos          LPCRECT providing the object's full rectangle
  182.  *                  relative to the continer's document.  The object
  183.  *                  should scale to this rectangle.
  184.  *  prcClip         LPCRECT describing the visible area of the object
  185.  *                  which should not draw outside these areas.
  186.  *
  187.  * Return Value:
  188.  *  HRESULT         NOERROR or an error code
  189.  */
  190.  
  191. STDMETHODIMP CImpIOleInPlaceObject::SetObjectRects(LPCRECT prcPos
  192.     , LPCRECT prcClip)
  193.     {
  194.     if (NULL!=m_pObj->m_pHW)
  195.         m_pObj->m_pHW->RectsSet((LPRECT)prcPos, (LPRECT)prcClip);
  196.  
  197.     return NOERROR;
  198.     }
  199.  
  200.  
  201.  
  202.  
  203. /*
  204.  * CImpIOleInPlaceObject::ReactivateAndUndo
  205.  *
  206.  * Purpose:
  207.  *  Instructs the object to reactivate itself in-place and perform
  208.  *  whatever Undo means for it.
  209.  *
  210.  * Parameters:
  211.  *  None
  212.  *
  213.  * Return Value:
  214.  *  HRESULT         NOERROR or an error code
  215.  */
  216.  
  217. STDMETHODIMP CImpIOleInPlaceObject::ReactivateAndUndo(void)
  218.     {
  219.     return m_pObj->InPlaceActivate(m_pObj->m_pIOleClientSite, TRUE);
  220.     }
  221.