|
//
// (C) Copyright by Victor Derks <vba64@xs4all.nl>
//
// See README.TXT for the details of the software licence.
//
#pragma once
#include "util.h"
namespace MSF
{
// Purpose: base class for Clipboard format handlers.
class CCfHandler
{
public:
CCfHandler(CLIPFORMAT clipformat, bool bCanGetData, bool bCanSetData) :
_clipformat(clipformat),
_bCanGetData(bCanGetData),
_bCanSetData(bCanSetData)
{
}
CCfHandler(LPCTSTR lpszFormat, bool bCanGetData, bool bCanSetData) :
_clipformat(RegisterCf(lpszFormat)),
_bCanGetData(bCanGetData),
_bCanSetData(bCanSetData)
{
}
virtual ~CCfHandler() throw()
{
}
CLIPFORMAT GetClipFormat() const throw()
{
return _clipformat;
}
bool CanGetData() const throw()
{
return _bCanGetData;
}
bool CanSetData() const throw()
{
return _bCanSetData;
}
virtual HRESULT Validate(const FORMATETC& formatetc) const throw()
{
if (formatetc.dwAspect != DVASPECT_CONTENT)
return DV_E_DVASPECT;
if (!IsBitSet(formatetc.tymed, TYMED_HGLOBAL))
return DV_E_TYMED;
if (formatetc.lindex != -1)
return DV_E_LINDEX;
return S_OK;
}
virtual void GetData(const FORMATETC&, STGMEDIUM&) const
{
}
virtual void SetData(const FORMATETC&, STGMEDIUM&, bool /*bRelease*/)
{
}
bool IsValid(const FORMATETC& formatetc, const STGMEDIUM& stgmedium) const
{
return SUCCEEDED(Validate(formatetc)) && formatetc.tymed == stgmedium.tymed;
}
private:
// Member variables.
CLIPFORMAT _clipformat;
bool _bCanGetData;
bool _bCanSetData;
};
}
|
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.