|
//
// (C) Copyright by Victor Derks <vba64@xs4all.nl>
//
// See README.TXT for the details of the software licence.
//
#pragma once
#include <objidl.h>
#include <comdef.h>
#include "macros.h"
#include "util.h"
#include "formatetc.h"
#include "enumformatetcptr.h"
namespace MSF
{
class IDataObjectPtr : public ::IDataObjectPtr
{
public:
IDataObjectPtr() : ::IDataObjectPtr()
{
}
explicit IDataObjectPtr(const CLSID& clsid, IUnknown* pOuter = NULL, DWORD dwClsContext = CLSCTX_ALL) :
::IDataObjectPtr(clsid, pOuter, dwClsContext)
{
}
// Purpose: Constructs a smart-pointer from any IUnknown-based interface pointer.
template<typename _InterfaceType> IDataObjectPtr(_InterfaceType* p) :
::IDataObjectPtr(p)
{
}
// Purpose: Constructs a smart-pointer from any other smart pointer.
template<typename _OtherIID> IDataObjectPtr(const _com_ptr_t<_OtherIID>& p) :
::IDataObjectPtr(p)
{
}
IDataObjectPtr(IDataObject* pInterface) :
::IDataObjectPtr(pInterface)
{
}
bool IsSupportedFormat(CLIPFORMAT clipformat, DWORD dwDirection)
{
IEnumFORMATETCPtr renumformatetc = EnumFormatEtc(dwDirection);
CFormatEtc formatetc;
while (renumformatetc.Next(formatetc))
{
if (formatetc.cfFormat == clipformat)
return true;
formatetc.Dispose();
}
return false;
}
bool IsSupportedFormat(LPCTSTR lpszFormat, DWORD dwDirection)
{
return IsSupportedFormat(RegisterCf(lpszFormat), dwDirection);
}
IEnumFORMATETCPtr EnumFormatEtc(DWORD dwDirection)
{
IEnumFORMATETCPtr renumformatetc;
RaiseExceptionIfFailed(GetInterfacePtr()->EnumFormatEtc(dwDirection, &renumformatetc));
return renumformatetc;
}
void GetData(const FORMATETC& formatetc, STGMEDIUM& stgmedium)
{
RaiseExceptionIfFailed(GetInterfacePtr()->GetData(&const_cast<FORMATETC&>(formatetc), &stgmedium));
}
void SetData(const FORMATETC& formatetc, const STGMEDIUM& stgmedium, bool fRelease)
{
RaiseExceptionIfFailed(GetInterfacePtr()->SetData(&const_cast<FORMATETC&>(formatetc), &const_cast<STGMEDIUM&>(stgmedium), fRelease));
}
};
} // end MSF namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Victor lives in Nijmegen, the oldest city in The Netherlands.
He studied Applied Physics in Delft and works Hitachi High-Tech Analytical Science.