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 / ioleobj.cpp < prev    next >
C/C++ Source or Header  |  1996-05-21  |  11KB  |  530 lines

  1. /*
  2.  * IOLEOBJ.CPP
  3.  *
  4.  * Template IOleObject 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 "ioleobj.h"
  15.  
  16.  
  17. /*
  18.  * CImpIOleObject::CImpIOleObject
  19.  * CImpIOleObject::~CImpIOleObject
  20.  *
  21.  * Parameters (Constructor):
  22.  *  pObj            LPVOID of the object we're in.
  23.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  24.  */
  25.  
  26. CImpIOleObject::CImpIOleObject(LPVOID pObj, LPUNKNOWN pUnkOuter)
  27.     {
  28.     m_cRef=0;
  29.     m_pObj=pObj;
  30.     m_pUnkOuter=pUnkOuter;
  31.     return;
  32.     }
  33.  
  34. CImpIOleObject::~CImpIOleObject(void)
  35.     {
  36.     return;
  37.     }
  38.  
  39.  
  40.  
  41. /*
  42.  * CImpIOleObject::QueryInterface
  43.  * CImpIOleObject::AddRef
  44.  * CImpIOleObject::Release
  45.  *
  46.  * Purpose:
  47.  *  Delegating IUnknown members for CImpIOleObject.
  48.  */
  49.  
  50. STDMETHODIMP CImpIOleObject::QueryInterface(REFIID riid
  51.     , LPVOID *ppv)
  52.     {
  53.     return m_pUnkOuter->QueryInterface(riid, ppv);
  54.     }
  55.  
  56. STDMETHODIMP_(ULONG) CImpIOleObject::AddRef(void)
  57.     {
  58.     ++m_cRef;
  59.     return m_pUnkOuter->AddRef();
  60.     }
  61.  
  62. STDMETHODIMP_(ULONG) CImpIOleObject::Release(void)
  63.     {
  64.     --m_cRef;
  65.     return m_pUnkOuter->Release();
  66.     }
  67.  
  68.  
  69.  
  70.  
  71.  
  72. /*
  73.  * CImpIOleObject::SetClientSite
  74.  *
  75.  * Purpose:
  76.  *  Provides the object with a pointer to the IOleClient site
  77.  *  representing the container in which this object resides.
  78.  *
  79.  * Parameters:
  80.  *  pIOleClientSite LPOLECLIENTSITE to the container's interface.
  81.  */
  82.  
  83. STDMETHODIMP CImpIOleObject::SetClientSite
  84.     (LPOLECLIENTSITE pIOleClientSite)
  85.     {
  86.     return NOERROR;
  87.     }
  88.  
  89.  
  90.  
  91.  
  92.  
  93. /*
  94.  * CImpIOleObject::GetClientSite
  95.  *
  96.  * Purpose:
  97.  *  Asks the object for the client site provided in SetClientSite.
  98.  *  If you have not seen SetClientSite yet, return a NULL in
  99.  *  ppIOleClientSite.
  100.  *
  101.  * Parameters:
  102.  *  ppIOleClientSite    LPOLECLIENTSITE * in which to store
  103.  *                      the pointer.
  104.  */
  105.  
  106. STDMETHODIMP CImpIOleObject::GetClientSite(LPOLECLIENTSITE
  107.     *ppIOleClientSite)
  108.     {
  109.     return ResultFromScode(E_NOTIMPL);
  110.     }
  111.  
  112.  
  113.  
  114.  
  115.  
  116. /*
  117.  * CImpIOleObject::SetHostNames
  118.  *
  119.  * Purpose:
  120.  *  Provides the object with names of the container application and
  121.  *  the object in the container to use in object user interface.
  122.  *
  123.  * Parameters:
  124.  *  pszApp          LPCOLESTR of the container application.
  125.  *  pszObj          LPCOLESTR of some name useful in window titles.
  126.  */
  127.  
  128. STDMETHODIMP CImpIOleObject::SetHostNames(LPCOLESTR pszApp
  129.     , LPCOLESTR pszObj)
  130.     {
  131.     return ResultFromScode(E_NOTIMPL);
  132.     }
  133.  
  134.  
  135.  
  136.  
  137.  
  138. /*
  139.  * CImpIOleObject::Close
  140.  *
  141.  * Purpose:
  142.  *  Forces the object to close down its user interface and unload.
  143.  *
  144.  * Parameters:
  145.  *  dwSaveOption    DWORD describing the circumstances under which
  146.  *                  the object is being saved and closed.
  147.  */
  148.  
  149. STDMETHODIMP CImpIOleObject::Close(DWORD dwSaveOption)
  150.     {
  151.     return ResultFromScode(E_NOTIMPL);
  152.     }
  153.  
  154.  
  155.  
  156.  
  157.  
  158. /*
  159.  * CImpIOleObject::SetMoniker
  160.  *
  161.  * Purpose:
  162.  *  Informs the object of its moniker or its container's moniker
  163.  *  depending on dwWhich.
  164.  *
  165.  * Parameters:
  166.  *  dwWhich         DWORD describing whether the moniker is the
  167.  *                  object's or the container's.
  168.  *  pmk             LPMONIKER with the name.
  169.  */
  170.  
  171. STDMETHODIMP CImpIOleObject::SetMoniker(DWORD dwWhich
  172.     , LPMONIKER pmk)
  173.     {
  174.     return ResultFromScode(E_NOTIMPL);
  175.     }
  176.  
  177.  
  178.  
  179.  
  180.  
  181. /*
  182.  * CImpIOleObject::GetMoniker
  183.  *
  184.  * Purpose:
  185.  *  Asks the object for a moniker that can later be used to
  186.  *  reconnect to it.
  187.  *
  188.  * Parameters:
  189.  *  dwAssign        DWORD determining how to assign the moniker to
  190.  *                  to the object.
  191.  *  dwWhich         DWORD describing which moniker the caller wants.
  192.  *  ppmk            LPMONIKER * into which to store the moniker.
  193.  */
  194.  
  195. STDMETHODIMP CImpIOleObject::GetMoniker(DWORD dwAssign
  196.     , DWORD dwWhichMoniker, LPMONIKER *ppmk)
  197.     {
  198.     return ResultFromScode(E_NOTIMPL);
  199.     }
  200.  
  201.  
  202.  
  203.  
  204.  
  205. /*
  206.  * CImpIOleObject::InitFromData
  207.  *
  208.  * Purpose:
  209.  *  Initilizes the object from the contents of a data object.
  210.  *
  211.  * Parameters:
  212.  *  pIDataObject    LPDATAOBJECT containing the data.
  213.  *  fCreation       BOOL indicating if this is part of a new
  214.  *                  creation.  If FALSE, the container is trying
  215.  *                  to paste here.
  216.  *  dwReserved      DWORD reserved.
  217.  */
  218.  
  219. STDMETHODIMP CImpIOleObject::InitFromData(LPDATAOBJECT pIDataObject
  220.     , BOOL fCreation, DWORD dwReserved)
  221.     {
  222.     return ResultFromScode(E_NOTIMPL);
  223.     }
  224.  
  225.  
  226.  
  227.  
  228.  
  229. /*
  230.  * CImpIOleObject::GetClipboardData
  231.  *
  232.  * Purpose:
  233.  *  Returns an IDataObject pointer to the caller representing what
  234.  *  would be on the clipboard if the server did an Edit/Copy using
  235.  *  OleSetClipboard.
  236.  *
  237.  * Parameters:
  238.  *  dwReserved      DWORD reserved.
  239.  *  ppIDataObj      LPDATAOBJECT * into which to store the
  240.  *                  pointer.
  241.  */
  242.  
  243. STDMETHODIMP CImpIOleObject::GetClipboardData(DWORD dwReserved
  244.     , LPDATAOBJECT *ppIDataObj)
  245.     {
  246.     return ResultFromScode(E_NOTIMPL);
  247.     }
  248.  
  249.  
  250.  
  251.  
  252.  
  253. /*
  254.  * CImpIOleObject::DoVerb
  255.  *
  256.  * Purpose:
  257.  *  Executes an object-defined action.
  258.  *
  259.  * Parameters:
  260.  *  iVerb           LONG index of the verb to execute.
  261.  *  pMSG            LPMSG describing the event causing the
  262.  *                  activation.
  263.  *  pIOleClientSite LPOLECLIENTSITE to the site involved.
  264.  *  lIndex          LONG the piece on which execution is happening.
  265.  *  hWndParent      HWND of the window in which the object can play
  266.  *                  in-place.
  267.  *  pRectPos        LPRECT of the object in hWndParent where the
  268.  *                  object can play in-place if desired.
  269.  */
  270.  
  271. STDMETHODIMP CImpIOleObject::DoVerb(LONG iVerb, LPMSG PMSG
  272.     , LPOLECLIENTSITE pIOleClientSite, LONG lIndex
  273.     , HWND hWndParent, LPCRECT pRectPos)
  274.     {
  275.     return ResultFromScode(E_NOTIMPL);
  276.     }
  277.  
  278.  
  279.  
  280.  
  281.  
  282. /*
  283.  * CImpIOleObject::EnumVerbs
  284.  *
  285.  * Purpose:
  286.  *  Creates an enumerator that knows the object's verbs.  If you
  287.  *  need to change the verb list dynamically, then you'll need to
  288.  *  implement this, otherwise you can return OLE_S_USEREG.
  289.  *
  290.  * Parameters:
  291.  *  ppEnum          LPENUMOLEVERB * into which to return the
  292.  *                  enum.
  293.  */
  294.  
  295. STDMETHODIMP CImpIOleObject::EnumVerbs(LPENUMOLEVERB *ppEnum)
  296.     {
  297.     //Trivial implementation if you fill the regDB.
  298.     return ResultFromScode(OLE_S_USEREG);
  299.     }
  300.  
  301.  
  302.  
  303.  
  304.  
  305. /*
  306.  * CImpIOleObject::Update
  307.  *
  308.  * Purpose:
  309.  *  Insures that the object is up to date.  This is mostly used for
  310.  *  caching but you must make sure that you recursively call all
  311.  *  nested objects you contain as well.
  312.  *
  313.  * Parameters:
  314.  *  None
  315.  */
  316.  
  317. STDMETHODIMP CImpIOleObject::Update(void)
  318.     {
  319.     return ResultFromScode(E_NOTIMPL);
  320.     }
  321.  
  322.  
  323.  
  324.  
  325.  
  326. /*
  327.  * CImpIOleObject::IsUpToDate
  328.  *
  329.  * Purpose:
  330.  *  Returns if the object is currently up to date, which involves
  331.  *  asking all contained object inside this object if they are up
  332.  *  to date as well.
  333.  *
  334.  * Parameters:
  335.  *  None
  336.  *
  337.  * Return Value:
  338.  *  HRESULT         NOERROR if successful, S_FALSE if dirty.
  339.  */
  340.  
  341. STDMETHODIMP CImpIOleObject::IsUpToDate(void)
  342.     {
  343.     return NOERROR;
  344.     }
  345.  
  346.  
  347.  
  348.  
  349.  
  350. /*
  351.  * CImpIOleObject::GetUserClassID
  352.  *
  353.  * Purpose:
  354.  *  Used for linked objects, this returns the class ID of what end
  355.  *  users think they are editing.
  356.  *
  357.  * Parameters:
  358.  *  pClsID          LPCLSID in which to store the CLSID.
  359.  */
  360.  
  361. STDMETHODIMP CImpIOleObject::GetUserClassID(LPCLSID pClsID)
  362.     {
  363.     return ResultFromScode(E_NOTIMPL);
  364.     }
  365.  
  366.  
  367.  
  368.  
  369.  
  370. /*
  371.  * CImpIOleObject::GetUserType
  372.  *
  373.  * Purpose:
  374.  *  Determines the user-presentable name of the object.
  375.  *
  376.  * Parameters:
  377.  *  dwForm          DWORD describing which form of the string
  378.  *                  is desired.
  379.  *  pszType         LPTSTR * into which to return the pointer to
  380.  *                  the type string.
  381.  */
  382.  
  383. STDMETHODIMP CImpIOleObject::GetUserType(DWORD dwForm
  384.     , LPTSTR *ppszType)
  385.     {
  386.     return ResultFromScode(OLE_S_USEREG);
  387.     }
  388.  
  389.  
  390.  
  391.  
  392.  
  393. /*
  394.  * CImpIOleObject::SetExtent
  395.  *
  396.  * Purpose:
  397.  *  Sets the size of the object in HIMETRIC units.
  398.  *
  399.  * Parameters:
  400.  *  dwAspect        DWORD of the aspect affected.
  401.  *  pszl            LPSIZEL containing the new size.
  402.  */
  403.  
  404. STDMETHODIMP CImpIOleObject::SetExtent(DWORD dwAspect, LPSIZEL pszl)
  405.     {
  406.     return ResultFromScode(E_NOTIMPL);
  407.     }
  408.  
  409.  
  410.  
  411.  
  412.  
  413. /*
  414.  * CImpIOleObject::GetExtent
  415.  *
  416.  * Purpose:
  417.  *  Retrieves the size of the object in HIMETRIC units.
  418.  *
  419.  * Parameters:
  420.  *  dwAspect        DWORD of the aspect requested
  421.  *  pszl            LPSIZEL into which to store the size.
  422.  */
  423.  
  424. STDMETHODIMP CImpIOleObject::GetExtent(DWORD dwAspect, LPSIZEL pszl)
  425.     {
  426.     return ResultFromScode(E_NOTIMPL);
  427.     }
  428.  
  429.  
  430.  
  431.  
  432.  
  433. /*
  434.  * CImpIOleObject::Advise
  435.  *
  436.  * Purpose:
  437.  *  Provides an IAdviseSink to the object for notifications.
  438.  *
  439.  * Parameters:
  440.  *  pIAdviseSink    LPADVISESINK to notify.
  441.  *  pdwConn         LPDWORD into which to store a connection key.
  442.  */
  443.  
  444. STDMETHODIMP CImpIOleObject::Advise(LPADVISESINK pIAdviseSink
  445.     , LPDWORD pdwConn)
  446.     {
  447.     return ResultFromScode(E_NOTIMPL);
  448.     }
  449.  
  450.  
  451.  
  452.  
  453.  
  454. /*
  455.  * CImpIOleObject::Unadvise
  456.  *
  457.  * Purpose:
  458.  *  Terminates a previous advise connection from Advise.
  459.  *
  460.  * Parameters:
  461.  *  dwConn          DWORD connection key from Advise.
  462.  */
  463.  
  464. STDMETHODIMP CImpIOleObject::Unadvise(DWORD dwConn)
  465.     {
  466.     return ResultFromScode(E_NOTIMPL);
  467.     }
  468.  
  469.  
  470.  
  471.  
  472.  
  473. /*
  474.  * CImpIOleObject::EnumAdvise
  475.  *
  476.  * Purpose:
  477.  *  Creates and returns a enumeration of the advises on this object.
  478.  *
  479.  * Parameters:
  480.  *  ppEnum          LPENUMSTATDATA * in which to return the
  481.  *                  enumerator.
  482.  */
  483.  
  484. STDMETHODIMP CImpIOleObject::EnumAdvise(LPENUMSTATDATA *ppEnum)
  485.     {
  486.     return ResultFromScode(E_NOTIMPL);
  487.     }
  488.  
  489.  
  490.  
  491.  
  492.  
  493. /*
  494.  * CImpIOleObject::GetMiscStatus
  495.  *
  496.  * Purpose:
  497.  *  Returns a set of miscellaneous status flags for the object.
  498.  *
  499.  * Parameters:
  500.  *  dwAspect        DWORD of the aspect in question.
  501.  *  pdwStatus       LPDWORD in which to store the flags.
  502.  */
  503.  
  504. STDMETHODIMP CImpIOleObject::GetMiscStatus(DWORD dwAspect
  505.     , LPDWORD pdwStatus)
  506.     {
  507.     return ResultFromScode(OLE_S_USEREG);
  508.     }
  509.  
  510.  
  511.  
  512.  
  513.  
  514. /*
  515.  * CImpIOleObject::SetColorScheme
  516.  *
  517.  * Purpose:
  518.  *  Provides the object with the color palette as recommended by
  519.  *  the container application that also knows the palettes of other
  520.  *  objects.  The object here is not required to use these colors.
  521.  *
  522.  * Parameters:
  523.  *  pLP             LPLOGPALETTE providing the colors.
  524.  */
  525.  
  526. STDMETHODIMP CImpIOleObject::SetColorScheme(LPLOGPALETTE pLP)
  527.     {
  528.     return ResultFromScode(E_NOTIMPL);
  529.     }
  530.