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 / chap17 / patron / iclisite.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  4.9 KB  |  240 lines

  1. /*
  2.  * ICLISITE.CPP
  3.  * Patron Chapter 17
  4.  *
  5.  * Implementation of the IOleClientSite interface for
  6.  * Patron's tenants.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "patron.h"
  17.  
  18.  
  19. /*
  20.  * CImpIOleClientSite::CImpIOleClientSite
  21.  * CImpIOleClientSite::~CImpIOleClientSite
  22.  *
  23.  * Parameters (Constructor):
  24.  *  pTenant         PCTenant of the tenant we're in.
  25.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  26.  */
  27.  
  28. CImpIOleClientSite::CImpIOleClientSite(PCTenant pTenant
  29.     , LPUNKNOWN pUnkOuter)
  30.     {
  31.     m_cRef=0;
  32.     m_pTen=pTenant;
  33.     m_pUnkOuter=pUnkOuter;
  34.     return;
  35.     }
  36.  
  37. CImpIOleClientSite::~CImpIOleClientSite(void)
  38.     {
  39.     return;
  40.     }
  41.  
  42.  
  43.  
  44.  
  45. /*
  46.  * CImpIOleClientSite::QueryInterface
  47.  * CImpIOleClientSite::AddRef
  48.  * CImpIOleClientSite::Release
  49.  *
  50.  * Purpose:
  51.  *  IUnknown members for CImpIOleClientSite object.
  52.  */
  53.  
  54. STDMETHODIMP CImpIOleClientSite::QueryInterface(REFIID riid
  55.     , PPVOID ppv)
  56.     {
  57.     return m_pUnkOuter->QueryInterface(riid, ppv);
  58.     }
  59.  
  60.  
  61. STDMETHODIMP_(ULONG) CImpIOleClientSite::AddRef(void)
  62.     {
  63.     ++m_cRef;
  64.     return m_pUnkOuter->AddRef();
  65.     }
  66.  
  67. STDMETHODIMP_(ULONG) CImpIOleClientSite::Release(void)
  68.     {
  69.     --m_cRef;
  70.     return m_pUnkOuter->Release();
  71.     }
  72.  
  73.  
  74.  
  75.  
  76. /*
  77.  * CImpIOleClientSite::SaveObject
  78.  *
  79.  * Purpose:
  80.  *  Requests that the container call OleSave for the object that
  81.  *  lives here.  Typically this happens on server shutdown.
  82.  *
  83.  * Parameters:
  84.  *  None
  85.  *
  86.  * Return Value:
  87.  *  HRESULT         Standard.
  88.  */
  89.  
  90. STDMETHODIMP CImpIOleClientSite::SaveObject(void)
  91.     {
  92.     //We're already set up with the tenant to save; this is trivial.
  93.     m_pTen->Update();
  94.     return NOERROR;
  95.     }
  96.  
  97.  
  98.  
  99.  
  100.  
  101. /*
  102.  * CImpIOleClientSite::GetMoniker
  103.  *
  104.  * Purpose:
  105.  *  Retrieves the moniker for the site in which this object lives,
  106.  *  either the moniker relative to the container or the full
  107.  *  moniker.
  108.  *
  109.  * Parameters:
  110.  *  dwAssign        DWORD specifying that the object wants moniker
  111.  *                  assignment.  Yeah.  Right.  Got any bridges to
  112.  *                  sell?
  113.  *  dwWhich         DWORD identifying which moniker the object
  114.  *                  wants, either the container's moniker, the
  115.  *                  moniker relative to this client site, or the
  116.  *                  full moniker.
  117.  *
  118.  * Return Value:
  119.  *  HRESULT         Standard.
  120.  */
  121.  
  122. STDMETHODIMP CImpIOleClientSite::GetMoniker(DWORD dwAssign
  123.     , DWORD dwWhich, LPMONIKER *ppmk)
  124.     {
  125.     *ppmk=NULL;
  126.  
  127.     /*
  128.      * We don't yet want to allow for linking to embedded objects
  129.      * within us, so we just fail for now.  If you are only a simple
  130.      * container you never have to implement this function.
  131.      */
  132.     return ResultFromScode(E_NOTIMPL);
  133.     }
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. /*
  141.  * CImpIOleClientSite::GetContainer
  142.  *
  143.  * Purpose:
  144.  *  Returns a pointer to the document's IOleContainer interface.
  145.  *
  146.  * Parameters:
  147.  *  ppContainer     LPOLECONTAINER * in which to return the
  148.  *                  interface.
  149.  *
  150.  * Return Value:
  151.  *  HRESULT         Standard.
  152.  */
  153.  
  154. STDMETHODIMP CImpIOleClientSite::GetContainer(LPOLECONTAINER
  155.     * ppContainer)
  156.     {
  157.     //Only necessary if you allow linking to embeddings
  158.     *ppContainer=NULL;
  159.     return ResultFromScode(E_NOTIMPL);
  160.     }
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. /*
  168.  * CImpIOleClientSite::ShowObject
  169.  *
  170.  * Purpose:
  171.  *  Tells the container to bring the object fully into view as much
  172.  *  as possible, that is, scroll the document.
  173.  *
  174.  * Parameters:
  175.  *  None
  176.  *
  177.  * Return Value:
  178.  *  HRESULT         Standard.
  179.  */
  180.  
  181. STDMETHODIMP CImpIOleClientSite::ShowObject(void)
  182.     {
  183.     /*
  184.      * We let the tenant do this, since it can access the current
  185.      * scroll position as a friend of CPages whereas we cannot.
  186.      */
  187.     m_pTen->ShowYourself();
  188.     return NOERROR;
  189.     }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196. /*
  197.  * CImpIOleClientSite::OnShowWindow
  198.  *
  199.  * Purpose:
  200.  *  Informs the container if the object is showing itself or
  201.  *  hiding itself.  This is done only in the opening mode and allows
  202.  *  the container to know when to shade or unshade the object.
  203.  *
  204.  * Parameters:
  205.  *  fShow           BOOL indiciating that the object is being shown
  206.  *                  (TRUE) or hidden (FALSE).
  207.  * Return Value:
  208.  *  HRESULT         Standard.
  209.  */
  210.  
  211. STDMETHODIMP CImpIOleClientSite::OnShowWindow(BOOL fShow)
  212.     {
  213.     //All we have to do is tell the tenant of the open state change.
  214.     m_pTen->ShowAsOpen(fShow);
  215.     return NOERROR;
  216.     }
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223. /*
  224.  * CImpIOleClientSite::RequestNewObjectLayout
  225.  *
  226.  * Purpose:
  227.  *  Called when the object needs more room in the container.
  228.  *
  229.  * Parameters:
  230.  *  None
  231.  *
  232.  * Return Value:
  233.  *  HRESULT         Standard.
  234.  */
  235.  
  236. STDMETHODIMP CImpIOleClientSite::RequestNewObjectLayout(void)
  237.     {
  238.     return ResultFromScode(E_NOTIMPL);
  239.     }
  240.