ReactOS  0.4.14-dev-49-gfb4591c
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>
12 using std::vector;
13 
14 
16 
18 struct DataStorage {
19  FORMATETC* _format;
20  STGMEDIUM* _medium;
21 };
22 
24 
25 
28  : public IComSrvBase<IEnumFORMATETC, EnumFormatEtcImpl>, public SimpleComObject
29 {
31 
32 private:
35  size_t m_iCur;
36 
37 public:
38  EnumFormatEtcImpl(const FormatArray& ArrFE);
39  EnumFormatEtcImpl(const StorageArray& ArrFE);
40  virtual ~EnumFormatEtcImpl() {}
41 
42  //IEnumFORMATETC members
45  virtual HRESULT STDMETHODCALLTYPE Reset(void);
47 };
48 
51  : public IComSrvBase<IDropSource, IDropSourceImpl>, public SimpleComObject
52 {
54 
56 
57 public:
58  bool m_bDropped;
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 
90 public:
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 
175  FORMATETC* m_pSupportedFrmt;
176 
177 protected:
179 
180 public:
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);
193  virtual ULONG STDMETHODCALLTYPE Release();
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 
218 public:
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 };
structure containing information for one format of EnumFormatEtcImpl
Definition: dragdropimpl.h:18
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
implementation of IDropSource interface
Definition: dragdropimpl.h:50
virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG *)
#define REFIID
Definition: guiddef.h:118
EnumFormatEtcImpl(const FormatArray &ArrFE)
void AddSuportedFormat(FORMATETC &ftetc)
Definition: dragdropimpl.h:184
IDragSourceHelper * pDragSourceHelper
Definition: dragdropimpl.h:216
HRESULT InitializeFromWindow([in] HWND hwnd, [in] POINT *ppt, [in] IDataObject *pDataObject)
FORMATETC * _format
Definition: dragdropimpl.h:19
#define pt(x, y)
Definition: drawing.c:79
REFIID riid
Definition: precomp.h:44
FORMATETC * m_pSupportedFrmt
Definition: dragdropimpl.h:175
bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect)
FormatArray m_formatetc
Definition: dragdropimpl.h:174
LONG top
Definition: windef.h:292
virtual ~DragSourceHelper()
Definition: dragdropimpl.h:229
virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
implementation of IDataObject interface
Definition: dragdropimpl.h:79
implementation of IEnumFORMATETC interface
Definition: dragdropimpl.h:27
LONG left
Definition: windef.h:291
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
IComSrvBase< IDataObject, IDataObjectImpl > super
Definition: dragdropimpl.h:83
#define E_FAIL
Definition: ddrawi.h:102
#define COLOR_WINDOW
Definition: winuser.h:908
IComSrvBase< IEnumFORMATETC, EnumFormatEtcImpl > super
Definition: dragdropimpl.h:30
DWORD WINAPI GetSysColor(_In_ int)
virtual HRESULT STDMETHODCALLTYPE Reset(void)
virtual HRESULT STDMETHODCALLTYPE QueryGetData(FORMATETC __RPC_FAR *pformatetc)
unsigned int BOOL
Definition: ntddk_ex.h:94
FormatArray m_pFmtEtc
Definition: dragdropimpl.h:34
HRESULT InitializeFromBitmap([in] LPSHDRAGIMAGE pshdi, [in] IDataObject *pDataObject)
ULONG Release()
smooth NULL
Definition: ftsmooth.c:416
STGMEDIUM * _medium
Definition: dragdropimpl.h:20
virtual HRESULT STDMETHODCALLTYPE DUnadvise(DWORD dwConnection)
#define __RPC_FAR
Definition: rpc.h:56
virtual ULONG STDMETHODCALLTYPE AddRef()
Definition: dragdropimpl.h:192
virtual HRESULT STDMETHODCALLTYPE DAdvise(FORMATETC __RPC_FAR *pformatetc, DWORD advf, IAdviseSink __RPC_FAR *pAdvSink, DWORD __RPC_FAR *pdwConnection)
virtual HRESULT STDMETHODCALLTYPE EnumDAdvise(IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise)
virtual ~IDataObjectImpl()
LONG HRESULT
Definition: typedefs.h:77
DWORD COLORREF
Definition: windef.h:285
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:376
virtual ~IDropTargetImpl()
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
virtual HRESULT STDMETHODCALLTYPE DragLeave()
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetObject
Definition: wingdi.h:4463
StorageArray _storage
Definition: dragdropimpl.h:88
virtual HRESULT STDMETHODCALLTYPE Clone(IEnumFORMATETC **)
virtual HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC __RPC_FAR *__RPC_FAR *ppenumFormatEtc)
void CopyMedium(STGMEDIUM *pMedDest, STGMEDIUM *pMedSrc, FORMATETC *pFmtSrc)
virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
IComSrvBase< IDropSource, IDropSourceImpl > super
Definition: dragdropimpl.h:53
#define false
Definition: stdbool.h:38
REFIID LPVOID * ppvObject
Definition: precomp.h:44
virtual ULONG STDMETHODCALLTYPE Release()
implementation of IDropTarget interface
Definition: dragdropimpl.h:168
virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
IDropTargetImpl(HWND m_hTargetWnd)
vector< FORMATETC > FormatArray
Definition: dragdropimpl.h:15
virtual HRESULT STDMETHODCALLTYPE GiveFeedback(DWORD dwEffect)
implementation of IDragSourceHelper interface
Definition: dragdropimpl.h:214
Definition: bl.h:1331
IDropSourceImpl * m_pDropSource
Definition: dragdropimpl.h:85
HRESULT InitializeFromBitmap(HBITMAP hBitmap, POINT &pt, RECT &rc, IDataObject *pDataObject, COLORREF crColorKey=GetSysColor(COLOR_WINDOW))
Definition: dragdropimpl.h:239
virtual HRESULT STDMETHODCALLTYPE GetDataHere(FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pmedium)
virtual HRESULT STDMETHODCALLTYPE SetData(FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pmedium, BOOL fRelease)
IDropTargetHelper * m_pDropTargetHelper
Definition: dragdropimpl.h:172
uint32_t * LPDWORD
Definition: typedefs.h:57
unsigned int ULONG
Definition: retypes.h:1
virtual HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(FORMATETC __RPC_FAR *pformatectIn, FORMATETC __RPC_FAR *pformatetcOut)
HRESULT InitializeFromWindow(HWND hwnd, POINT &pt, IDataObject *pDataObject)
Definition: dragdropimpl.h:261
virtual HRESULT STDMETHODCALLTYPE GetData(FORMATETC __RPC_FAR *pformatetcIn, STGMEDIUM __RPC_FAR *pmedium)
static HBITMAP
Definition: button.c:44
vector< DataStorage > StorageArray
Definition: dragdropimpl.h:23
virtual ~EnumFormatEtcImpl()
Definition: dragdropimpl.h:40
virtual HRESULT STDMETHODCALLTYPE Skip(ULONG)
static HBITMAP hBitmap
Definition: timezone.c:35
virtual bool OnDrop(FORMATETC *pFmtEtc, STGMEDIUM &medium, DWORD *pdwEffect)=0
virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
struct IEnumFORMATETC::tagFORMATETC * LPFORMATETC
virtual ~IDropSourceImpl()
Definition: dragdropimpl.h:67
IDataObjectImpl(IDropSourceImpl *pDropSource)