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 / interfac / iipsite.cpp < prev    next >
C/C++ Source or Header  |  1995-05-03  |  8KB  |  339 lines

  1. /*
  2.  * IIPSITE.CPP
  3.  *
  4.  * Template IOleInPlaceSite interface implementation.
  5.  *
  6.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Microsoft
  9.  * Internet  :  kraigb@microsoft.com
  10.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  11.  */
  12.  
  13.  
  14. #include "iipsite.h"
  15.  
  16.  
  17. /*
  18.  * CImpIOleInPlaceSite::CImpIOleInPlaceSite
  19.  * CImpIOleInPlaceSite::~CImpIOleInPlaceSite
  20.  *
  21.  * Parameters (Constructor):
  22.  *  pObj            LPVOID of the object we're in.
  23.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  24.  */
  25.  
  26. CImpIOleInPlaceSite::CImpIOleInPlaceSite(LPVOID pObj
  27.     , LPUNKNOWN pUnkOuter)
  28.     {
  29.     m_cRef=0;
  30.     m_pObj=pObj;
  31.     m_pUnkOuter=pUnkOuter;
  32.     return;
  33.     }
  34.  
  35. CImpIOleInPlaceSite::~CImpIOleInPlaceSite(void)
  36.     {
  37.     return;
  38.     }
  39.  
  40.  
  41.  
  42. /*
  43.  * CImpIOleInPlaceSite::QueryInterface
  44.  * CImpIOleInPlaceSite::AddRef
  45.  * CImpIOleInPlaceSite::Release
  46.  *
  47.  * Purpose:
  48.  *  IUnknown members for CImpIOleInPlaceSite object.
  49.  */
  50.  
  51. STDMETHODIMP CImpIOleInPlaceSite::QueryInterface(REFIID riid
  52.     , LPVOID *ppv)
  53.     {
  54.     return m_pUnkOuter->QueryInterface(riid, ppv);
  55.     }
  56.  
  57. STDMETHODIMP_(ULONG) CImpIOleInPlaceSite::AddRef(void)
  58.     {
  59.     ++m_cRef;
  60.     return m_pUnkOuter->AddRef();
  61.     }
  62.  
  63. STDMETHODIMP_(ULONG) CImpIOleInPlaceSite::Release(void)
  64.     {
  65.     --m_cRef;
  66.     return m_pUnkOuter->Release();
  67.     }
  68.  
  69.  
  70.  
  71.  
  72. /*
  73.  * CImpIOleInPlaceSite::GetWindow
  74.  *
  75.  * Purpose:
  76.  *  Retrieves the handle of the window associated with the object
  77.  *  on which this interface is implemented.
  78.  *
  79.  * Parameters:
  80.  *  phWnd           HWND * in which to store the window handle.
  81.  *
  82.  * Return Value:
  83.  *  HRESULT         NOERROR if successful, E_FAIL if no window.
  84.  */
  85.  
  86. STDMETHODIMP CImpIOleInPlaceSite::GetWindow(HWND *phWnd)
  87.     {
  88.     return ResultFromScode(E_FAIL);
  89.     }
  90.  
  91.  
  92.  
  93.  
  94. /*
  95.  * CImpIOleInPlaceSite::ContextSensitiveHelp
  96.  *
  97.  * Purpose:
  98.  *  Instructs the object on which this interface is implemented to
  99.  *  enter or leave a context-sensitive help mode.
  100.  *
  101.  * Parameters:
  102.  *  fEnterMode      BOOL TRUE to enter the mode, FALSE otherwise.
  103.  */
  104.  
  105. STDMETHODIMP CImpIOleInPlaceSite::ContextSensitiveHelp(
  106.     BOOL fEnterMode)
  107.     {
  108.     return NOERROR;
  109.     }
  110.  
  111.  
  112.  
  113.  
  114. /*
  115.  * CImpIOleInPlaceSite::CanInPlaceActivate
  116.  *
  117.  * Purpose:
  118.  *  Answers the server whether or not we can currently in-place
  119.  *  activate its object.  By implementing this interface we say
  120.  *  that we support in-place activation, but through this function
  121.  *  we indicate whether the object can currently be activated
  122.  *  in-place.  Linked objects, for example, cannot, meaning we
  123.  *  return S_FALSE.
  124.  *
  125.  * Parameters:
  126.  *  None
  127.  *
  128.  * Return Value:
  129.  *  HRESULT         NOERROR if we can in-place activate the
  130.  *                  object in this site, S_FALSE if not.
  131.  */
  132.  
  133. STDMETHODIMP CImpIOleInPlaceSite::CanInPlaceActivate(void)
  134.     {
  135.     return NOERROR;
  136.     }
  137.  
  138.  
  139.  
  140.  
  141. /*
  142.  * CImpIOleInPlaceSite::OnInPlaceActivate
  143.  *
  144.  * Purpose:
  145.  *  Informs the container that an object is being activated
  146.  *  in-place such that the container can prepare appropriately.
  147.  *  The container does not, however, make any user interface
  148.  *  changes at this point.  See OnUIActivate.
  149.  *
  150.  * Parameters:
  151.  *  None
  152.  */
  153.  
  154. STDMETHODIMP CImpIOleInPlaceSite::OnInPlaceActivate(void)
  155.     {
  156.     return NOERROR;
  157.     }
  158.  
  159.  
  160.  
  161.  
  162. /*
  163.  * CImpIOleInPlaceSite::OnInPlaceDeactivate
  164.  *
  165.  * Purpose:
  166.  *  Notifies the container that the object has deactivated itself
  167.  *  from an in-place state.  Opposite of OnInPlaceActivate.  The
  168.  *  container does not change any UI at this point.
  169.  *
  170.  * Parameters:
  171.  *  None
  172.  */
  173.  
  174. STDMETHODIMP CImpIOleInPlaceSite::OnInPlaceDeactivate(void)
  175.     {
  176.     return NOERROR;
  177.     }
  178.  
  179.  
  180.  
  181.  
  182. /*
  183.  * CImpIOleInPlaceSite::OnUIActivate
  184.  *
  185.  * Purpose:
  186.  *  Informs the container that the object is going to start
  187.  *  munging around with user interface, like replacing the menu.
  188.  *  The container should remove any relevant UI in preparation.
  189.  *
  190.  * Parameters:
  191.  *  None
  192.  */
  193.  
  194. STDMETHODIMP CImpIOleInPlaceSite::OnUIActivate(void)
  195.     {
  196.     return NOERROR;
  197.     }
  198.  
  199.  
  200.  
  201.  
  202. /*
  203.  * CImpIOleInPlaceSite::OnUIDeactivate
  204.  *
  205.  * Purpose:
  206.  *  Informs the container that the object is deactivating its
  207.  *  in-place user interface at which time the container may
  208.  *  reinstate its own.  Opposite of OnUIActivate.
  209.  *
  210.  * Parameters:
  211.  *  fUndoable       BOOL indicating if the object will actually
  212.  *                  perform an Undo if the container calls
  213.  *                  ReactivateAndUndo.
  214.  */
  215.  
  216. STDMETHODIMP CImpIOleInPlaceSite::OnUIDeactivate(BOOL fUndoable)
  217.     {
  218.     return NOERROR;
  219.     }
  220.  
  221.  
  222.  
  223.  
  224. /*
  225.  * CImpIOleInPlaceSite::DeactivateAndUndo
  226.  *
  227.  * Purpose:
  228.  *  If immediately after activation the object does an Undo, the
  229.  *  action being undone is the activation itself, and this call
  230.  *  informs the container that this is, in fact, what happened.
  231.  *  The container should call IOleInPlaceObject::UIDeactivate.
  232.  *
  233.  * Parameters:
  234.  *  None
  235.  */
  236.  
  237. STDMETHODIMP CImpIOleInPlaceSite::DeactivateAndUndo(void)
  238.     {
  239.     return NOERROR;
  240.     }
  241.  
  242.  
  243.  
  244.  
  245. /*
  246.  * CImpIOleInPlaceSite::DiscardUndoState
  247.  *
  248.  * Purpose:
  249.  *  Informs the container that something happened in the object
  250.  *  that means the container should discard any undo information
  251.  *  it currently maintains for the object.
  252.  *
  253.  * Parameters:
  254.  *  None
  255.  */
  256.  
  257. STDMETHODIMP CImpIOleInPlaceSite::DiscardUndoState(void)
  258.     {
  259.     return NOERROR;
  260.     }
  261.  
  262.  
  263.  
  264.  
  265. /*
  266.  * CImpIOleInPlaceSite::GetWindowContext
  267.  *
  268.  * Purpose:
  269.  *  Provides an in-place object with pointers to the frame and
  270.  *  document level in-place interfaces (IOleInPlaceFrame and
  271.  *  IOleInPlaceUIWindow) such that the object can do border
  272.  *  negotiation and so forth.  Also requests the position and
  273.  *  clipping rectangles of the object in the container and a
  274.  *  pointer to an OLEINPLACEFRAME info structure which contains
  275.  *  accelerator information.
  276.  *
  277.  *  Note that the two interfaces this call returns are not
  278.  *  available through QueryInterface on IOleInPlaceSite since they
  279.  *  live with the frame and document, but not the site.
  280.  *
  281.  * Parameters:
  282.  *  ppIIPFrame      LPOLEINPLACEFRAME * in which to return
  283.  *                  the AddRef'd pointer to the IOleInPlaceFrame.
  284.  *  ppIIPUIWindow   LPOLEINPLACEUIWINDOW * in which to return
  285.  *                  the AddRef'd pointer to the document's
  286.  *                  IOleInPlaceUIWindow.
  287.  *  prcPos          LPRECT in which to store the object's position.
  288.  *  prcClip         LPRECT in which to store the object's
  289.  *                  visible region.
  290.  *  pFI             LPOLEINPLACEFRAMEINFO for accelerator info.
  291.  */
  292.  
  293. STDMETHODIMP CImpIOleInPlaceSite::GetWindowContext(
  294.     LPOLEINPLACEFRAME *ppIIPFrame, LPOLEINPLACEUIWINDOW
  295.     *ppIIPUIWindow, LPRECT prcPos, LPRECT prcClip
  296.     , LPOLEINPLACEFRAMEINFO pFI)
  297.     {
  298.     return NOERROR;
  299.     }
  300.  
  301.  
  302.  
  303.  
  304. /*
  305.  * CImpIOleInPlaceSite::Scroll
  306.  *
  307.  * Purpose:
  308.  *  Asks the container to scroll the document, and thus the
  309.  *  object, by the given amounts in the sz parameter.
  310.  *
  311.  * Parameters:
  312.  *  sz              SIZE containing signed horizontal and vertical
  313.  *                  extents by which the container should scroll.
  314.  */
  315.  
  316. STDMETHODIMP CImpIOleInPlaceSite::Scroll(SIZE sz)
  317.     {
  318.     return NOERROR;
  319.     }
  320.  
  321.  
  322.  
  323.  
  324. /*
  325.  * CImpIOleInPlaceSite::OnPosRectChange
  326.  *
  327.  * Purpose:
  328.  *  Informs the container that the in-place object was resized.
  329.  *  The container must call IOleInPlaceObject::SetObjectRects.
  330.  *
  331.  * Parameters:
  332.  *  prcPos          LPCRECT containing the new size of the object.
  333.  */
  334.  
  335. STDMETHODIMP CImpIOleInPlaceSite::OnPosRectChange(LPCRECT prcPos)
  336.     {
  337.     return NOERROR;
  338.     }
  339.