--- trunk/reactos/subsys/system/explorer/utility/dragdropimpl.cpp 2005-09-25 17:52:12 UTC (rev 18062)
+++ trunk/reactos/subsys/system/explorer/utility/dragdropimpl.cpp 2005-09-25 17:59:20 UTC (rev 18063)
@@ -22,7 +22,8 @@
//////////////////////////////////////////////////////////////////////
IDataObjectImpl::IDataObjectImpl(IDropSourceImpl* pDropSource)
- : m_pDropSource(pDropSource),
+ : super(IID_IDataObject),
+ m_pDropSource(pDropSource),
m_cRefCount(0)
{
}
@@ -33,37 +34,6 @@
ReleaseStgMedium(it->_medium);
}
-STDMETHODIMP IDataObjectImpl::QueryInterface(/* [in] */ REFIID riid,
-/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
-{
- *ppvObject = NULL;
- if (IID_IUnknown==riid || IID_IDataObject==riid)
- *ppvObject=this;
- /*if (riid == IID_IAsyncOperation)
- *ppvObject=(IAsyncOperation*)this;*/
- if (NULL!=*ppvObject)
- {
- ((LPUNKNOWN)*ppvObject)->AddRef();
- return S_OK;
- }
- return E_NOINTERFACE;
-}
-
-STDMETHODIMP_(ULONG) IDataObjectImpl::AddRef()
-{
- return ++m_cRefCount;
-}
-
-STDMETHODIMP_(ULONG) IDataObjectImpl::Release()
-{
- long nTemp = --m_cRefCount;
-
- if (nTemp == 0)
- delete this;
-
- return nTemp;
-}
-
STDMETHODIMP IDataObjectImpl::GetData(
/* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn,
/* [out] */ STGMEDIUM __RPC_FAR *pmedium)
@@ -255,38 +225,6 @@
// IDropSourceImpl Class
//////////////////////////////////////////////////////////////////////
-STDMETHODIMP IDropSourceImpl::QueryInterface(/* [in] */ REFIID riid,
- /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
-{
- *ppvObject = NULL;
- if (IID_IUnknown==riid || IID_IDropSource==riid)
- *ppvObject=this;
-
- if (*ppvObject != NULL)
- {
- ((LPUNKNOWN)*ppvObject)->AddRef();
- return S_OK;
- }
- return E_NOINTERFACE;
-}
-
-STDMETHODIMP_(ULONG) IDropSourceImpl::AddRef()
-{
- return ++m_cRefCount;
-}
-
-STDMETHODIMP_(ULONG) IDropSourceImpl::Release()
-{
- long nTemp = --m_cRefCount;
-
- assert(nTemp >= 0);
-
- if (nTemp == 0)
- delete this;
-
- return nTemp;
-}
-
STDMETHODIMP IDropSourceImpl::QueryContinueDrag(
/* [in] */ BOOL fEscapePressed,
/* [in] */ DWORD grfKeyState)
@@ -314,7 +252,8 @@
//////////////////////////////////////////////////////////////////////
EnumFormatEtcImpl::EnumFormatEtcImpl(const FormatArray& ArrFE)
- : m_cRefCount(0),
+ : super(IID_IEnumFORMATETC),
+ m_cRefCount(0),
m_iCur(0)
{
for(FormatArray::const_iterator it=ArrFE.begin(); it!=ArrFE.end(); ++it)
@@ -322,46 +261,16 @@
}
EnumFormatEtcImpl::EnumFormatEtcImpl(const StorageArray& ArrFE)
- : m_cRefCount(0),
+ : super(IID_IEnumFORMATETC),
+ m_cRefCount(0),
m_iCur(0)
{
for(StorageArray::const_iterator it=ArrFE.begin(); it!=ArrFE.end(); ++it)
m_pFmtEtc.push_back(*it->_format);
}
-STDMETHODIMP EnumFormatEtcImpl::QueryInterface(REFIID refiid, void** ppv)
+STDMETHODIMP EnumFormatEtcImpl::Next(ULONG celt,LPFORMATETC lpFormatEtc, ULONG* pceltFetched)
{
- *ppv = NULL;
- if (IID_IUnknown==refiid || IID_IEnumFORMATETC==refiid)
- *ppv=this;
-
- if (*ppv != NULL)
- {
- ((LPUNKNOWN)*ppv)->AddRef();
- return S_OK;
- }
- return E_NOINTERFACE;
-}
-
-STDMETHODIMP_(ULONG) EnumFormatEtcImpl::AddRef(void)
-{
- return ++m_cRefCount;
-}
-
-STDMETHODIMP_(ULONG) EnumFormatEtcImpl::Release(void)
-{
- long nTemp = --m_cRefCount;
-
- assert(nTemp >= 0);
-
- if (nTemp == 0)
- delete this;
-
- return nTemp;
-}
-
-STDMETHODIMP EnumFormatEtcImpl::Next( ULONG celt,LPFORMATETC lpFormatEtc, ULONG* pceltFetched)
-{
if (pceltFetched != NULL)
*pceltFetched=0;
--- trunk/reactos/subsys/system/explorer/utility/dragdropimpl.h 2005-09-25 17:52:12 UTC (rev 18062)
+++ trunk/reactos/subsys/system/explorer/utility/dragdropimpl.h 2005-09-25 17:59:20 UTC (rev 18063)
@@ -4,7 +4,7 @@
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
- Author: Leon Finker 11/2000
+ Author: Leon Finker 11/2000
Modifications: replaced ATL by STL, Martin Fuchs 7/2003
**************************************************************************/
@@ -24,60 +24,64 @@
/// implementation of IEnumFORMATETC interface
-class EnumFormatEtcImpl : public IEnumFORMATETC
+class EnumFormatEtcImpl
+ : public IComSrvBase<IEnumFORMATETC, EnumFormatEtcImpl>, public SimpleComObject
{
- private:
- ULONG m_cRefCount;
- FormatArray m_pFmtEtc;
- size_t m_iCur;
+ typedef IComSrvBase<IEnumFORMATETC, EnumFormatEtcImpl> super;
- public:
- EnumFormatEtcImpl(const FormatArray& ArrFE);
+private:
+ ULONG m_cRefCount;
+ FormatArray m_pFmtEtc;
+ size_t m_iCur;
+
+public:
+ EnumFormatEtcImpl(const FormatArray& ArrFE);
EnumFormatEtcImpl(const StorageArray& ArrFE);
virtual ~EnumFormatEtcImpl() {}
- //IUnknown members
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void**);
- virtual ULONG STDMETHODCALLTYPE AddRef(void);
- virtual ULONG STDMETHODCALLTYPE Release(void);
-
- //IEnumFORMATETC members
- virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG*);
- virtual HRESULT STDMETHODCALLTYPE Skip(ULONG);
- virtual HRESULT STDMETHODCALLTYPE Reset(void);
- virtual HRESULT STDMETHODCALLTYPE Clone(IEnumFORMATETC**);
+ //IEnumFORMATETC members
+ virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG*);
+ virtual HRESULT STDMETHODCALLTYPE Skip(ULONG);
+ virtual HRESULT STDMETHODCALLTYPE Reset(void);
+ virtual HRESULT STDMETHODCALLTYPE Clone(IEnumFORMATETC**);
};
/// implementation of IDropSource interface
-class IDropSourceImpl : public IDropSource
+class IDropSourceImpl
+ : public IComSrvBase<IDropSource, IDropSourceImpl>, public SimpleComObject
{
+ typedef IComSrvBase<IDropSource, IDropSourceImpl> super;
+
long m_cRefCount;
public:
bool m_bDropped;
- IDropSourceImpl::IDropSourceImpl() : m_cRefCount(0), m_bDropped(false) {}
+ IDropSourceImpl()
+ : super(IID_IDropSource),
+ m_cRefCount(0),
+ m_bDropped(false)
+ {
+ }
+
virtual ~IDropSourceImpl() {}
- //IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(
- /* [in] */ REFIID riid,
- /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
- virtual ULONG STDMETHODCALLTYPE AddRef();
- virtual ULONG STDMETHODCALLTYPE Release();
-
//IDropSource
- virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
- /* [in] */ BOOL fEscapePressed,
- /* [in] */ DWORD grfKeyState);
+ virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
+ /* [in] */ BOOL fEscapePressed,
+ /* [in] */ DWORD grfKeyState);
- virtual HRESULT STDMETHODCALLTYPE GiveFeedback(
- /* [in] */ DWORD dwEffect);
+ virtual HRESULT STDMETHODCALLTYPE GiveFeedback(
+ /* [in] */ DWORD dwEffect);
};
/// implementation of IDataObject interface
-class IDataObjectImpl : public IDataObject//,public IAsyncOperation
+class IDataObjectImpl
+ : public IComSrvBase<IDataObject, IDataObjectImpl>, public SimpleComObject
+ //public IAsyncOperation
{
+ typedef IComSrvBase<IDataObject, IDataObjectImpl> super;
+
IDropSourceImpl* m_pDropSource;
long m_cRefCount;
@@ -89,79 +93,72 @@
void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc);
- //IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(
- /* [in] */ REFIID riid,
- /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
- virtual ULONG STDMETHODCALLTYPE AddRef();
- virtual ULONG STDMETHODCALLTYPE Release();
-
//IDataObject
virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData(
- /* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn,
- /* [out] */ STGMEDIUM __RPC_FAR *pmedium);
+ /* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn,
+ /* [out] */ STGMEDIUM __RPC_FAR *pmedium);
- virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetDataHere(
- /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc,
- /* [out][in] */ STGMEDIUM __RPC_FAR *pmedium);
+ virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetDataHere(
+ /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc,
+ /* [out][in] */ STGMEDIUM __RPC_FAR *pmedium);
- virtual HRESULT STDMETHODCALLTYPE QueryGetData(
- /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc);
+ virtual HRESULT STDMETHODCALLTYPE QueryGetData(
+ /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc);
- virtual HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(
- /* [unique][in] */ FORMATETC __RPC_FAR *pformatectIn,
- /* [out] */ FORMATETC __RPC_FAR *pformatetcOut);
+ virtual HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(
+ /* [unique][in] */ FORMATETC __RPC_FAR *pformatectIn,
+ /* [out] */ FORMATETC __RPC_FAR *pformatetcOut);
- virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetData(
- /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc,
- /* [unique][in] */ STGMEDIUM __RPC_FAR *pmedium,
- /* [in] */ BOOL fRelease);
+ virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetData(
+ /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc,
+ /* [unique][in] */ STGMEDIUM __RPC_FAR *pmedium,
+ /* [in] */ BOOL fRelease);
- virtual HRESULT STDMETHODCALLTYPE EnumFormatEtc(
- /* [in] */ DWORD dwDirection,
- /* [out] */ IEnumFORMATETC __RPC_FAR *__RPC_FAR *ppenumFormatEtc);
+ virtual HRESULT STDMETHODCALLTYPE EnumFormatEtc(
+ /* [in] */ DWORD dwDirection,
+ /* [out] */ IEnumFORMATETC __RPC_FAR *__RPC_FAR *ppenumFormatEtc);
- virtual HRESULT STDMETHODCALLTYPE DAdvise(
- /* [in] */ FORMATETC __RPC_FAR *pformatetc,
- /* [in] */ DWORD advf,
- /* [unique][in] */ IAdviseSink __RPC_FAR *pAdvSink,
- /* [out] */ DWORD __RPC_FAR *pdwConnection);
+ virtual HRESULT STDMETHODCALLTYPE DAdvise(
+ /* [in] */ FORMATETC __RPC_FAR *pformatetc,
+ /* [in] */ DWORD advf,
+ /* [unique][in] */ IAdviseSink __RPC_FAR *pAdvSink,
+ /* [out] */ DWORD __RPC_FAR *pdwConnection);
- virtual HRESULT STDMETHODCALLTYPE DUnadvise(
- /* [in] */ DWORD dwConnection);
+ virtual HRESULT STDMETHODCALLTYPE DUnadvise(
+ /* [in] */ DWORD dwConnection);
- virtual HRESULT STDMETHODCALLTYPE EnumDAdvise(
- /* [out] */ IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise);
+ virtual HRESULT STDMETHODCALLTYPE EnumDAdvise(
+ /* [out] */ IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise);
//IAsyncOperation
- //virtual HRESULT STDMETHODCALLTYPE SetAsyncMode(
- // /* [in] */ BOOL fDoOpAsync)
+ //virtual HRESULT STDMETHODCALLTYPE SetAsyncMode(
+ // /* [in] */ BOOL fDoOpAsync)
//{
// return E_NOTIMPL;
//}
- //
- //virtual HRESULT STDMETHODCALLTYPE GetAsyncMode(
- // /* [out] */ BOOL __RPC_FAR *pfIsOpAsync)
+ //
+ //virtual HRESULT STDMETHODCALLTYPE GetAsyncMode(
+ // /* [out] */ BOOL __RPC_FAR *pfIsOpAsync)
//{
// return E_NOTIMPL;
//}
- //
- //virtual HRESULT STDMETHODCALLTYPE StartOperation(
- // /* [optional][unique][in] */ IBindCtx __RPC_FAR *pbcReserved)
+ //
+ //virtual HRESULT STDMETHODCALLTYPE StartOperation(
+ // /* [optional][unique][in] */ IBindCtx __RPC_FAR *pbcReserved)
//{
// return E_NOTIMPL;
//}
- //
- //virtual HRESULT STDMETHODCALLTYPE InOperation(
- // /* [out] */ BOOL __RPC_FAR *pfInAsyncOp)
+ //
+ //virtual HRESULT STDMETHODCALLTYPE InOperation(
+ // /* [out] */ BOOL __RPC_FAR *pfInAsyncOp)
//{
// return E_NOTIMPL;
//}
- //
- //virtual HRESULT STDMETHODCALLTYPE EndOperation(
- // /* [in] */ HRESULT hResult,
- // /* [unique][in] */ IBindCtx __RPC_FAR *pbcReserved,
- // /* [in] */ DWORD dwEffects)
+ //
+ //virtual HRESULT STDMETHODCALLTYPE EndOperation(
+ // /* [in] */ HRESULT hResult,
+ // /* [unique][in] */ IBindCtx __RPC_FAR *pbcReserved,
+ // /* [in] */ DWORD dwEffects)
//{
// return E_NOTIMPL;
//}*/
@@ -195,22 +192,22 @@
virtual ULONG STDMETHODCALLTYPE AddRef() {return ++m_cRefCount;}
virtual ULONG STDMETHODCALLTYPE Release();
- bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect);
+ bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect);
virtual HRESULT STDMETHODCALLTYPE DragEnter(
- /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
- /* [in] */ DWORD grfKeyState,
- /* [in] */ POINTL pt,
- /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
- virtual HRESULT STDMETHODCALLTYPE DragOver(
- /* [in] */ DWORD grfKeyState,
- /* [in] */ POINTL pt,
- /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
- virtual HRESULT STDMETHODCALLTYPE DragLeave();
- virtual HRESULT STDMETHODCALLTYPE Drop(
- /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
- /* [in] */ DWORD grfKeyState,
- /* [in] */ POINTL pt,
- /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
+ /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
+ /* [in] */ DWORD grfKeyState,
+ /* [in] */ POINTL pt,
+ /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
+ virtual HRESULT STDMETHODCALLTYPE DragOver(
+ /* [in] */ DWORD grfKeyState,
+ /* [in] */ POINTL pt,
+ /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
+ virtual HRESULT STDMETHODCALLTYPE DragLeave();
+ virtual HRESULT STDMETHODCALLTYPE Drop(
+ /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
+ /* [in] */ DWORD grfKeyState,
+ /* [in] */ POINTL pt,
+ /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
};
/// implementation of IDragSourceHelper interface
@@ -222,10 +219,10 @@
DragSourceHelper()
{
if (FAILED(CoCreateInstance(CLSID_DragDropHelper,
- NULL,
- CLSCTX_INPROC_SERVER,
- IID_IDragSourceHelper,
- (void**)&pDragSourceHelper)))
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IDragSourceHelper,
+ (void**)&pDragSourceHelper)))
pDragSourceHelper = NULL;
}
@@ -239,7 +236,7 @@
}
// IDragSourceHelper
- HRESULT InitializeFromBitmap(HBITMAP hBitmap,
+ HRESULT InitializeFromBitmap(HBITMAP hBitmap,
POINT& pt, // cursor position in client coords of the window
RECT& rc, // selected item's bounding rect
IDataObject* pDataObject,
@@ -249,19 +246,19 @@
if (pDragSourceHelper == NULL)
return E_FAIL;
- SHDRAGIMAGE di;
- BITMAP bm;
- GetObject(hBitmap, sizeof(bm), &bm);
- di.sizeDragImage.cx = bm.bmWidth;
- di.sizeDragImage.cy = bm.bmHeight;
- di.hbmpDragImage = hBitmap;
- di.crColorKey = crColorKey;
- di.ptOffset.x = pt.x - rc.left;
- di.ptOffset.y = pt.y - rc.top;
- return pDragSourceHelper->InitializeFromBitmap(&di, pDataObject);
+ SHDRAGIMAGE di;
+ BITMAP bm;
+ GetObject(hBitmap, sizeof(bm), &bm);
+ di.sizeDragImage.cx = bm.bmWidth;
+ di.sizeDragImage.cy = bm.bmHeight;
+ di.hbmpDragImage = hBitmap;
+ di.crColorKey = crColorKey;
+ di.ptOffset.x = pt.x - rc.left;
+ di.ptOffset.y = pt.y - rc.top;
+ return pDragSourceHelper->InitializeFromBitmap(&di, pDataObject);
}
- HRESULT InitializeFromWindow(HWND hwnd, POINT& pt,IDataObject* pDataObject)
+ HRESULT InitializeFromWindow(HWND hwnd, POINT& pt,IDataObject* pDataObject)
{
if (pDragSourceHelper == NULL)
return E_FAIL;