Click here to Skip to main content
15,896,063 members
Articles / Desktop Programming / MFC

DragSourceHelper MFC

Rate me:
Please Sign up or sign in to vote.
4.38/5 (7 votes)
19 Jan 20032 min read 96.9K   1.5K   23  
Making use of the IDragSourceHelper interface with MFC
// OleDataObjectEx.cpp : implementation file
//

#include "stdafx.h"
#include "OleDataSourceEx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

// interface map for our object
BEGIN_INTERFACE_MAP(COleDataSourceEx, COleDataSource)
	INTERFACE_PART(COleDataSourceEx, IID_IDataObject, DataObj)
END_INTERFACE_MAP()

STDMETHODIMP_(ULONG) COleDataSourceEx::XDataObj::AddRef()
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->ExternalAddRef();
}

STDMETHODIMP_(ULONG) COleDataSourceEx::XDataObj::Release()
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->ExternalRelease();
}

STDMETHODIMP COleDataSourceEx::XDataObj::QueryInterface(
	REFIID iid, LPVOID* ppvObj)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->ExternalQueryInterface(&iid, ppvObj);
}

STDMETHODIMP COleDataSourceEx::XDataObj::GetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.GetData(pFormatetc,pmedium);
}

STDMETHODIMP COleDataSourceEx::XDataObj::GetDataHere(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.GetDataHere(pFormatetc,pmedium);
}

STDMETHODIMP COleDataSourceEx::XDataObj::QueryGetData(LPFORMATETC pFormatetc)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.QueryGetData(pFormatetc);
}

STDMETHODIMP COleDataSourceEx::XDataObj::GetCanonicalFormatEtc(LPFORMATETC pFormatetcIn, LPFORMATETC pFormatetcOut)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.GetCanonicalFormatEtc(pFormatetcIn,pFormatetcOut);
}

STDMETHODIMP COleDataSourceEx::XDataObj::SetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium, BOOL fRelease)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	// normal processing
	HRESULT hr = pThis->m_xDataObject.SetData(pFormatetc,pmedium,fRelease);
	if (hr==DATA_E_FORMATETC) {
		// cache the data explicitly
		pThis->CacheData(pFormatetc->cfFormat,pmedium,pFormatetc);
		return S_OK;
	}
	// normal error
	return hr;
}

STDMETHODIMP COleDataSourceEx::XDataObj::EnumFormatEtc(DWORD dwDirection, LPENUMFORMATETC* ppenumFormatetc)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.EnumFormatEtc(dwDirection,ppenumFormatetc);
}

STDMETHODIMP COleDataSourceEx::XDataObj::DAdvise(LPFORMATETC pFormatetc, DWORD advf, LPADVISESINK pAdvSink, LPDWORD pdwConnection)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.DAdvise(pFormatetc,advf,pAdvSink,pdwConnection);
}

STDMETHODIMP COleDataSourceEx::XDataObj::DUnadvise(DWORD dwConnection)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.DUnadvise(dwConnection);
}

STDMETHODIMP COleDataSourceEx::XDataObj::EnumDAdvise(LPENUMSTATDATA* ppenumAdvise)
{
	METHOD_PROLOGUE(COleDataSourceEx, DataObj)
	return pThis->m_xDataObject.EnumDAdvise(ppenumAdvise);
}

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.

License

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


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions