ReactOS 0.4.15-dev-5667-ged97270
dragdropimpl.h
Go to the documentation of this file.
1// IDataObjectImpl.h: interface for the CIDataObjectImpl class.
2/**************************************************************************
3 THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF
4 ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
5 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
6 PARTICULAR PURPOSE.
7 Author: Leon Finker 11/2000
8 Modifications: replaced ATL by STL, Martin Fuchs 7/2003
9**************************************************************************/
10
11#include <vector>
12using std::vector;
13
14
16
19 FORMATETC* _format;
20 STGMEDIUM* _medium;
21};
22
24
25
28 : public IComSrvBase<IEnumFORMATETC, EnumFormatEtcImpl>, public SimpleComObject
29{
31
32private:
35 size_t m_iCur;
36
37public:
38 EnumFormatEtcImpl(const FormatArray& ArrFE);
39 EnumFormatEtcImpl(const StorageArray& ArrFE);
40 virtual ~EnumFormatEtcImpl() {}
41
42 //IEnumFORMATETC members
43 virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG*);
45 virtual HRESULT STDMETHODCALLTYPE Reset(void);
47};
48
51 : public IComSrvBase<IDropSource, IDropSourceImpl>, public SimpleComObject
52{
54
56
57public:
59
61 : super(IID_IDropSource),
62 m_cRefCount(0),
64 {
65 }
66
67 virtual ~IDropSourceImpl() {}
68
69 //IDropSource
71 /* [in] */ BOOL fEscapePressed,
72 /* [in] */ DWORD grfKeyState);
73
75 /* [in] */ DWORD dwEffect);
76};
77
80 : public IComSrvBase<IDataObject, IDataObjectImpl>, public SimpleComObject
81 //public IAsyncOperation
82{
84
87
89
90public:
91 IDataObjectImpl(IDropSourceImpl* pDropSource);
92 virtual ~IDataObjectImpl();
93
94 void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc);
95
96 //IDataObject
97 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData(
98 /* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn,
99 /* [out] */ STGMEDIUM __RPC_FAR *pmedium);
100
101 virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetDataHere(
102 /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc,
103 /* [out][in] */ STGMEDIUM __RPC_FAR *pmedium);
104
106 /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc);
107
109 /* [unique][in] */ FORMATETC __RPC_FAR *pformatectIn,
110 /* [out] */ FORMATETC __RPC_FAR *pformatetcOut);
111
112 virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetData(
113 /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc,
114 /* [unique][in] */ STGMEDIUM __RPC_FAR *pmedium,
115 /* [in] */ BOOL fRelease);
116
118 /* [in] */ DWORD dwDirection,
119 /* [out] */ IEnumFORMATETC __RPC_FAR *__RPC_FAR *ppenumFormatEtc);
120
122 /* [in] */ FORMATETC __RPC_FAR *pformatetc,
123 /* [in] */ DWORD advf,
124 /* [unique][in] */ IAdviseSink __RPC_FAR *pAdvSink,
125 /* [out] */ DWORD __RPC_FAR *pdwConnection);
126
128 /* [in] */ DWORD dwConnection);
129
131 /* [out] */ IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise);
132
133 //IAsyncOperation
134 //virtual HRESULT STDMETHODCALLTYPE SetAsyncMode(
135 // /* [in] */ BOOL fDoOpAsync)
136 //{
137 // return E_NOTIMPL;
138 //}
139 //
140 //virtual HRESULT STDMETHODCALLTYPE GetAsyncMode(
141 // /* [out] */ BOOL __RPC_FAR *pfIsOpAsync)
142 //{
143 // return E_NOTIMPL;
144 //}
145 //
146 //virtual HRESULT STDMETHODCALLTYPE StartOperation(
147 // /* [optional][unique][in] */ IBindCtx __RPC_FAR *pbcReserved)
148 //{
149 // return E_NOTIMPL;
150 //}
151 //
152 //virtual HRESULT STDMETHODCALLTYPE InOperation(
153 // /* [out] */ BOOL __RPC_FAR *pfInAsyncOp)
154 //{
155 // return E_NOTIMPL;
156 //}
157 //
158 //virtual HRESULT STDMETHODCALLTYPE EndOperation(
159 // /* [in] */ HRESULT hResult,
160 // /* [unique][in] */ IBindCtx __RPC_FAR *pbcReserved,
161 // /* [in] */ DWORD dwEffects)
162 //{
163 // return E_NOTIMPL;
164 //}*/
165};
166
169{
173
176
177protected:
179
180public:
182 virtual ~IDropTargetImpl();
183
184 void AddSuportedFormat(FORMATETC& ftetc) {m_formatetc.push_back(ftetc);}
185
186 //return values: true - release the medium. false - don't release the medium
187 virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) = 0;
188
190 /* [in] */ REFIID riid,
191 /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
194
195 bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect);
197 /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
198 /* [in] */ DWORD grfKeyState,
199 /* [in] */ POINTL pt,
200 /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
202 /* [in] */ DWORD grfKeyState,
203 /* [in] */ POINTL pt,
204 /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
207 /* [unique][in] */ IDataObject __RPC_FAR *pDataObj,
208 /* [in] */ DWORD grfKeyState,
209 /* [in] */ POINTL pt,
210 /* [out][in] */ DWORD __RPC_FAR *pdwEffect);
211};
212
215{
217
218public:
220 {
221 if (FAILED(CoCreateInstance(CLSID_DragDropHelper,
222 NULL,
223 CLSCTX_INPROC_SERVER,
224 IID_IDragSourceHelper,
225 (void**)&pDragSourceHelper)))
227 }
228
230 {
231 if (pDragSourceHelper != NULL)
232 {
235 }
236 }
237
238 // IDragSourceHelper
240 POINT& pt, // cursor position in client coords of the window
241 RECT& rc, // selected item's bounding rect
242 IDataObject* pDataObject,
243 COLORREF crColorKey=GetSysColor(COLOR_WINDOW)// color of the window used for transparent effect.
244 )
245 {
246 if (pDragSourceHelper == NULL)
247 return E_FAIL;
248
249 SHDRAGIMAGE di;
250 BITMAP bm;
251 GetObject(hBitmap, sizeof(bm), &bm);
252 di.sizeDragImage.cx = bm.bmWidth;
253 di.sizeDragImage.cy = bm.bmHeight;
254 di.hbmpDragImage = hBitmap;
255 di.crColorKey = crColorKey;
256 di.ptOffset.x = pt.x - rc.left;
257 di.ptOffset.y = pt.y - rc.top;
258 return pDragSourceHelper->InitializeFromBitmap(&di, pDataObject);
259 }
260
262 {
263 if (pDragSourceHelper == NULL)
264 return E_FAIL;
265 return pDragSourceHelper->InitializeFromWindow(hwnd, &pt, pDataObject);
266 }
267};
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
implementation of IDragSourceHelper interface
Definition: dragdropimpl.h:215
virtual ~DragSourceHelper()
Definition: dragdropimpl.h:229
HRESULT InitializeFromBitmap(HBITMAP hBitmap, POINT &pt, RECT &rc, IDataObject *pDataObject, COLORREF crColorKey=GetSysColor(COLOR_WINDOW))
Definition: dragdropimpl.h:239
HRESULT InitializeFromWindow(HWND hwnd, POINT &pt, IDataObject *pDataObject)
Definition: dragdropimpl.h:261
IDragSourceHelper * pDragSourceHelper
Definition: dragdropimpl.h:216
implementation of IEnumFORMATETC interface
Definition: dragdropimpl.h:29
FormatArray m_pFmtEtc
Definition: dragdropimpl.h:34
virtual ~EnumFormatEtcImpl()
Definition: dragdropimpl.h:40
virtual HRESULT STDMETHODCALLTYPE Skip(ULONG)
virtual HRESULT STDMETHODCALLTYPE Clone(IEnumFORMATETC **)
virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG *)
IComSrvBase< IEnumFORMATETC, EnumFormatEtcImpl > super
Definition: dragdropimpl.h:30
virtual HRESULT STDMETHODCALLTYPE Reset(void)
implementation of IDataObject interface
Definition: dragdropimpl.h:82
virtual HRESULT STDMETHODCALLTYPE SetData(FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pmedium, BOOL fRelease)
virtual HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC __RPC_FAR *__RPC_FAR *ppenumFormatEtc)
virtual HRESULT STDMETHODCALLTYPE QueryGetData(FORMATETC __RPC_FAR *pformatetc)
virtual HRESULT STDMETHODCALLTYPE GetDataHere(FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pmedium)
virtual HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(FORMATETC __RPC_FAR *pformatectIn, FORMATETC __RPC_FAR *pformatetcOut)
virtual HRESULT STDMETHODCALLTYPE GetData(FORMATETC __RPC_FAR *pformatetcIn, STGMEDIUM __RPC_FAR *pmedium)
StorageArray _storage
Definition: dragdropimpl.h:88
void CopyMedium(STGMEDIUM *pMedDest, STGMEDIUM *pMedSrc, FORMATETC *pFmtSrc)
IDropSourceImpl * m_pDropSource
Definition: dragdropimpl.h:85
virtual HRESULT STDMETHODCALLTYPE DAdvise(FORMATETC __RPC_FAR *pformatetc, DWORD advf, IAdviseSink __RPC_FAR *pAdvSink, DWORD __RPC_FAR *pdwConnection)
IComSrvBase< IDataObject, IDataObjectImpl > super
Definition: dragdropimpl.h:83
virtual HRESULT STDMETHODCALLTYPE EnumDAdvise(IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise)
virtual ~IDataObjectImpl()
virtual HRESULT STDMETHODCALLTYPE DUnadvise(DWORD dwConnection)
implementation of IDropSource interface
Definition: dragdropimpl.h:52
virtual HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect)
IComSrvBase< IDropSource, IDropSourceImpl > super
Definition: dragdropimpl.h:53
virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
virtual ~IDropSourceImpl()
Definition: dragdropimpl.h:67
implementation of IDropTarget interface
Definition: dragdropimpl.h:169
virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect)
virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
IDropTargetHelper * m_pDropTargetHelper
Definition: dragdropimpl.h:172
virtual HRESULT STDMETHODCALLTYPE DragLeave()
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
virtual bool OnDrop(FORMATETC *pFmtEtc, STGMEDIUM &medium, DWORD *pdwEffect)=0
void AddSuportedFormat(FORMATETC &ftetc)
Definition: dragdropimpl.h:184
virtual ~IDropTargetImpl()
FORMATETC * m_pSupportedFrmt
Definition: dragdropimpl.h:175
virtual ULONG STDMETHODCALLTYPE AddRef()
Definition: dragdropimpl.h:192
FormatArray m_formatetc
Definition: dragdropimpl.h:174
virtual ULONG STDMETHODCALLTYPE Release()
virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
static HBITMAP hBitmap
Definition: timezone.c:26
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
vector< DataStorage > StorageArray
Definition: dragdropimpl.h:23
vector< FORMATETC > FormatArray
Definition: dragdropimpl.h:15
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
HRESULT InitializeFromBitmap([in] LPSHDRAGIMAGE pshdi, [in] IDataObject *pDataObject)
HRESULT InitializeFromWindow([in] HWND hwnd, [in] POINT *ppt, [in] IDataObject *pDataObject)
ULONG Release()
#define FAILED(hr)
Definition: intsafe.h:51
static HBITMAP
Definition: button.c:44
#define false
Definition: osdep.h:35
#define REFIID
Definition: guiddef.h:118
#define __RPC_FAR
Definition: rpc.h:56
structure containing information for one format of EnumFormatEtcImpl
Definition: dragdropimpl.h:18
FORMATETC * _format
Definition: dragdropimpl.h:19
STGMEDIUM * _medium
Definition: dragdropimpl.h:20
Definition: bl.h:1331
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379
uint32_t * LPDWORD
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:300
#define GetObject
Definition: wingdi.h:4468
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_WINDOW
Definition: winuser.h:912