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 / idataobj.cpp < prev    next >
C/C++ Source or Header  |  1995-05-03  |  6KB  |  277 lines

  1. /*
  2.  * IDATAOBJ.CPP
  3.  *
  4.  * Template IDataObject 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 "idataobj.h"
  15.  
  16.  
  17. /*
  18.  * CImpIDataObject::CImpIDataObject
  19.  * CImpIDataObject::~CImpIDataObject
  20.  *
  21.  * Parameters (Constructor):
  22.  *  pObj            LPVOID of the object we're in.
  23.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  24.  */
  25.  
  26. CImpIDataObject::CImpIDataObject(LPVOID pObj, LPUNKNOWN pUnkOuter)
  27.     {
  28.     m_cRef=0;
  29.     m_pObj=pObj;
  30.     m_pUnkOuter=pUnkOuter;
  31.     return;
  32.     }
  33.  
  34. CImpIDataObject::~CImpIDataObject(void)
  35.     {
  36.     return;
  37.     }
  38.  
  39.  
  40.  
  41.  
  42. /*
  43.  * CImpIDataObject::QueryInterface
  44.  * CImpIDataObject::AddRef
  45.  * CImpIDataObject::Release
  46.  *
  47.  * Purpose:
  48.  *  Delegating IUnknown members for CImpIDataObject.
  49.  */
  50.  
  51. STDMETHODIMP CImpIDataObject::QueryInterface(REFIID riid
  52.     , LPVOID *ppv)
  53.     {
  54.     return m_pUnkOuter->QueryInterface(riid, ppv);
  55.     }
  56.  
  57. STDMETHODIMP_(ULONG) CImpIDataObject::AddRef(void)
  58.     {
  59.     ++m_cRef;
  60.     return m_pUnkOuter->AddRef();
  61.     }
  62.  
  63. STDMETHODIMP_(ULONG) CImpIDataObject::Release(void)
  64.     {
  65.     --m_cRef;
  66.     return m_pUnkOuter->Release();
  67.     }
  68.  
  69.  
  70.  
  71.  
  72.  
  73. /*
  74.  * CImpIDataObject::GetData
  75.  *
  76.  * Purpose:
  77.  *  Retrieves data described by a specific FormatEtc into a StgMedium
  78.  *  allocated by this function.  Used like GetClipboardData.
  79.  *
  80.  * Parameters:
  81.  *  pFE             LPFORMATETC describing the desired data.
  82.  *  pSTM            LPSTGMEDIUM in which to return the data.
  83.  */
  84.  
  85. STDMETHODIMP CImpIDataObject::GetData(LPFORMATETC pFE
  86.     , LPSTGMEDIUM pSTM)
  87.     {
  88.     return ResultFromScode(DATA_E_FORMATETC);
  89.     }
  90.  
  91.  
  92.  
  93.  
  94. /*
  95.  * CImpIDataObject::GetDataHere
  96.  *
  97.  * Purpose:
  98.  *  Renders the specific FormatEtc into caller-allocated medium
  99.  *  provided in pSTM.
  100.  *
  101.  * Parameters:
  102.  *  pFE             LPFORMATETC describing the desired data.
  103.  *  pSTM            LPSTGMEDIUM providing the medium into which
  104.  *                  wer render the data.
  105.  */
  106.  
  107. STDMETHODIMP CImpIDataObject::GetDataHere(LPFORMATETC pFE
  108.     , LPSTGMEDIUM pSTM)
  109.     {
  110.     return ResultFromScode(DATA_E_FORMATETC);
  111.     }
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. /*
  119.  * CImpIDataObject::QueryGetData
  120.  *
  121.  * Purpose:
  122.  *  Tests if a call to GetData with this FormatEtc will provide
  123.  *  any rendering; used like IsClipboardFormatAvailable.
  124.  *
  125.  * Parameters:
  126.  *  pFE             LPFORMATETC describing the desired data.
  127.  */
  128.  
  129. STDMETHODIMP CImpIDataObject::QueryGetData(LPFORMATETC pFE)
  130.     {
  131.     return ResultFromScode(S_FALSE);
  132.     }
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. /*
  140.  * CImpIDataObject::GetCanonicalFormatEtc
  141.  *
  142.  * Purpose:
  143.  *  Provides the caller with an equivalent FormatEtc to the one
  144.  *  provided when different FormatEtcs will produce exactly the
  145.  *  same renderings.
  146.  *
  147.  * Parameters:
  148.  *  pFEIn            LPFORMATETC of the first description.
  149.  *  pFEOut           LPFORMATETC of the equal description.
  150.  */
  151.  
  152. STDMETHODIMP CImpIDataObject::GetCanonicalFormatEtc(LPFORMATETC pFEIn
  153.     , LPFORMATETC pFEOut)
  154.     {
  155.     return ResultFromScode(DATA_S_SAMEFORMATETC);
  156.     }
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. /*
  164.  * CImpIDataObject::SetData
  165.  *
  166.  * Purpose:
  167.  *  Places data described by a FormatEtc and living in a StgMedium
  168.  *  into the object.  The object may be responsible to clean up the
  169.  *  StgMedium before exiting.
  170.  *
  171.  * Parameters:
  172.  *  pFE             LPFORMATETC describing the data to set.
  173.  *  pSTM            LPSTGMEDIUM containing the data.
  174.  *  fRelease        BOOL indicating if this function is responsible
  175.  *                  for freeing the data.
  176.  */
  177.  
  178. STDMETHODIMP CImpIDataObject::SetData(LPFORMATETC pFE
  179.     , LPSTGMEDIUM pSTM, BOOL fRelease)
  180.     {
  181.     return ResultFromScode(DATA_E_FORMATETC);
  182.     }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. /*
  190.  * CImpIDataObject::EnumFormatEtc
  191.  *
  192.  * Purpose:
  193.  *  Returns an IEnumFORMATETC object through which the caller can
  194.  *  iterate to learn about all the data formats this object can
  195.  *  provide through either GetData[Here] or SetData.
  196.  *
  197.  * Parameters:
  198.  *  dwDir           DWORD describing a data direction, either
  199.  *                  DATADIR_SET or DATADIR_GET.
  200.  *  ppEnum          LPENUMFORMATETC * in which to return the
  201.  *                  pointer to the enumerator.
  202.  */
  203.  
  204. STDMETHODIMP CImpIDataObject::EnumFormatEtc(DWORD dwDir
  205.     , LPENUMFORMATETC *ppEnum)
  206.     {
  207.     return ResultFromScode(E_FAIL);
  208.     }
  209.  
  210.  
  211.  
  212.  
  213.  
  214. /*
  215.  * CImpIDataObject::DAdvise
  216.  *
  217.  * Purpose:
  218.  *  Provides the data object with an IAdviseSink object that we are
  219.  *  responsible to notify when the data changes.
  220.  *
  221.  * Parameters:
  222.  *  ppFE            LPFORMATETC
  223.  *  dwFlags         DWORD carrying flags indicating how the advise
  224.  *                  sink wants to be treated.
  225.  *  pIAdviseSink    LPADVISESINK to the object to notify
  226.  *  pdwConn         LPDWORD into which we store a DWORD key
  227.  *                  identifying the advise connection.
  228.  */
  229.  
  230. STDMETHODIMP CImpIDataObject::DAdvise(LPFORMATETC pFE, DWORD dwFlags
  231.     , LPADVISESINK pIAdviseSink, LPDWORD pdwConn)
  232.     {
  233.     return ResultFromScode(E_OUTOFMEMORY);
  234.     }
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. /*
  242.  * CImpIDataObject::DUnadvise
  243.  *
  244.  * Purpose:
  245.  *  Turns off advising previously set up with Advise.
  246.  *
  247.  * Parameters:
  248.  *  dwConn          DWORD connection key returned from Advise.
  249.  */
  250.  
  251. STDMETHODIMP CImpIDataObject::DUnadvise(DWORD dwConn)
  252.     {
  253.     return ResultFromScode(E_FAIL);
  254.     }
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. /*
  262.  * CImpIDataObject::EnumDAdvise
  263.  *
  264.  * Purpose:
  265.  *  Returns an enumerator object through which the caller can find
  266.  *  all the agents currently receiving advises on this data object.
  267.  *
  268.  * Parameters:
  269.  *  ppEnum          LPENUMSTATDATA * in which to return the
  270.  *                  enumerator.
  271.  */
  272.  
  273. STDMETHODIMP CImpIDataObject::EnumDAdvise(LPENUMSTATDATA *ppEnum)
  274.     {
  275.     return ResultFromScode(E_FAIL);
  276.     }
  277.