ReactOS 0.4.16-dev-319-g6cf4263
IDropTargetImpl Class Referenceabstract

implementation of IDropTarget interface More...

#include <dragdropimpl.h>

Inheritance diagram for IDropTargetImpl:
Collaboration diagram for IDropTargetImpl:

Public Member Functions

 IDropTargetImpl (HWND m_hTargetWnd)
 
virtual ~IDropTargetImpl ()
 
void AddSuportedFormat (FORMATETC &ftetc)
 
virtual bool OnDrop (FORMATETC *pFmtEtc, STGMEDIUM &medium, DWORD *pdwEffect)=0
 
virtual HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
 
virtual ULONG STDMETHODCALLTYPE AddRef ()
 
virtual ULONG STDMETHODCALLTYPE Release ()
 
bool QueryDrop (DWORD grfKeyState, LPDWORD pdwEffect)
 
virtual HRESULT STDMETHODCALLTYPE DragEnter (IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
 
virtual HRESULT STDMETHODCALLTYPE DragOver (DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
 
virtual HRESULT STDMETHODCALLTYPE DragLeave ()
 
virtual HRESULT STDMETHODCALLTYPE Drop (IDataObject __RPC_FAR *pDataObj, DWORD grfKeyState, POINTL pt, DWORD __RPC_FAR *pdwEffect)
 
- Public Member Functions inherited from IDropTarget
HRESULT DragEnter ([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT DragOver ([in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
HRESULT DragLeave ()
 
HRESULT Drop ([in, unique] IDataObject *pDataObj, [in] DWORD grfKeyState, [in] POINTL pt, [in, out] DWORD *pdwEffect)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Protected Attributes

HWND m_hTargetWnd
 

Private Attributes

DWORD m_cRefCount
 
bool m_bAllowDrop
 
IDropTargetHelperm_pDropTargetHelper
 
FormatArray m_formatetc
 
FORMATETC * m_pSupportedFrmt
 

Additional Inherited Members

- Public Types inherited from IDropTarget
typedef IDropTargetLPDROPTARGET
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Attributes inherited from IDropTarget
const DWORD MK_ALT = 0x20
 
const DWORD DROPEFFECT_NONE = 0
 
const DWORD DROPEFFECT_COPY = 1
 
const DWORD DROPEFFECT_MOVE = 2
 
const DWORD DROPEFFECT_LINK = 4
 
const DWORD DROPEFFECT_SCROLL = 0x80000000
 
const DWORD DD_DEFSCROLLINSET = 11
 
const DWORD DD_DEFSCROLLDELAY = 50
 
const DWORD DD_DEFSCROLLINTERVAL = 50
 
const DWORD DD_DEFDRAGDELAY = 200
 
const DWORD DD_DEFDRAGMINDIST = 2
 

Detailed Description

implementation of IDropTarget interface

Definition at line 168 of file dragdropimpl.h.

Constructor & Destructor Documentation

◆ IDropTargetImpl()

IDropTargetImpl::IDropTargetImpl ( HWND  m_hTargetWnd)

Definition at line 331 of file dragdropimpl.cpp.

332 : m_cRefCount(0),
333 m_bAllowDrop(false),
336 m_hTargetWnd(hTargetWnd)
337{
339
340 if (FAILED(CoCreateInstance(CLSID_DragDropHelper, NULL, CLSCTX_INPROC_SERVER,
341 IID_IDropTargetHelper,(LPVOID*)&m_pDropTargetHelper)))
343}
IDropTargetHelper * m_pDropTargetHelper
Definition: dragdropimpl.h:172
FORMATETC * m_pSupportedFrmt
Definition: dragdropimpl.h:175
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define assert(x)
Definition: debug.h:53
#define FAILED(hr)
Definition: intsafe.h:51

◆ ~IDropTargetImpl()

IDropTargetImpl::~IDropTargetImpl ( )
virtual

Definition at line 345 of file dragdropimpl.cpp.

346{
348 {
351 }
352}
ULONG Release()

Member Function Documentation

◆ AddRef()

virtual ULONG STDMETHODCALLTYPE IDropTargetImpl::AddRef ( void  )
inlinevirtual

Implements IUnknown.

Definition at line 192 of file dragdropimpl.h.

192{return ++m_cRefCount;}

Referenced by DesktopShellView::InitDragDrop(), and ShellBrowser::InitDragDrop().

◆ AddSuportedFormat()

void IDropTargetImpl::AddSuportedFormat ( FORMATETC &  ftetc)
inline

Definition at line 184 of file dragdropimpl.h.

184{m_formatetc.push_back(ftetc);}
FormatArray m_formatetc
Definition: dragdropimpl.h:174
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _vector.h:379

Referenced by DesktopShellView::InitDragDrop(), and ShellBrowser::InitDragDrop().

◆ DragEnter()

HRESULT STDMETHODCALLTYPE IDropTargetImpl::DragEnter ( IDataObject __RPC_FAR pDataObj,
DWORD  grfKeyState,
POINTL  pt,
DWORD __RPC_FAR pdwEffect 
)
virtual

Definition at line 424 of file dragdropimpl.cpp.

429{
430 if (pDataObj == NULL)
431 return E_INVALIDARG;
432
434 m_pDropTargetHelper->DragEnter(m_hTargetWnd, pDataObj, (LPPOINT)&pt, *pdwEffect);
435
436 //IEnumFORMATETC* pEnum;
437 //pDataObj->EnumFormatEtc(DATADIR_GET,&pEnum);
438 //FORMATETC ftm;
439 //for()
440 //pEnum->Next(1,&ftm,0);
441 //pEnum->Release();
443
445 {
446 m_bAllowDrop = (pDataObj->QueryGetData(&*it) == S_OK)? true: false;
447
448 if (m_bAllowDrop)
449 {
450 m_pSupportedFrmt = &*it;
451 break;
452 }
453 }
454
455 QueryDrop(grfKeyState, pdwEffect);
456
457 return S_OK;
458}
bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect)
#define E_INVALIDARG
Definition: ddrawi.h:101
#define pt(x, y)
Definition: drawing.c:79
HRESULT DragEnter([in] HWND hwndTarget, [in] IDataObject *pDataObject, [in] POINT *ppt, [in] DWORD dwEffect)
#define S_OK
Definition: intsafe.h:52
iterator end()
Definition: _vector.h:184
iterator begin()
Definition: _vector.h:182
value_type * iterator
Definition: _vector.h:124

◆ DragLeave()

HRESULT STDMETHODCALLTYPE IDropTargetImpl::DragLeave ( void  )
virtual

Implements IDropTarget.

Reimplemented in DesktopDropTarget, and TreeDropTarget.

Definition at line 473 of file dragdropimpl.cpp.

474{
477
478 m_bAllowDrop = false;
480
481 return S_OK;
482}
HRESULT DragLeave()

Referenced by DesktopDropTarget::DragLeave(), and TreeDropTarget::DragLeave().

◆ DragOver()

HRESULT STDMETHODCALLTYPE IDropTargetImpl::DragOver ( DWORD  grfKeyState,
POINTL  pt,
DWORD __RPC_FAR pdwEffect 
)
virtual

Reimplemented in DesktopDropTarget, and TreeDropTarget.

Definition at line 460 of file dragdropimpl.cpp.

464{
466 m_pDropTargetHelper->DragOver((LPPOINT)&pt, *pdwEffect);
467
468 QueryDrop(grfKeyState, pdwEffect);
469
470 return S_OK;
471}
HRESULT DragOver([in] POINT *ppt, [in] DWORD dwEffect)

Referenced by DesktopDropTarget::DragOver(), and TreeDropTarget::DragOver().

◆ Drop()

HRESULT STDMETHODCALLTYPE IDropTargetImpl::Drop ( IDataObject __RPC_FAR pDataObj,
DWORD  grfKeyState,
POINTL  pt,
DWORD __RPC_FAR pdwEffect 
)
virtual

Definition at line 484 of file dragdropimpl.cpp.

488{
489 if (pDataObj == NULL)
490 return E_INVALIDARG;
491
493 m_pDropTargetHelper->Drop(pDataObj, (LPPOINT)&pt, *pdwEffect);
494
495 if (QueryDrop(grfKeyState, pdwEffect))
496 {
498 {
499 STGMEDIUM medium;
500
501 if (pDataObj->GetData(m_pSupportedFrmt, &medium) == S_OK)
502 {
503 if (OnDrop(m_pSupportedFrmt, medium, pdwEffect)) //does derive class wants us to free medium?
504 ReleaseStgMedium(&medium);
505 }
506 }
507 }
508
509 m_bAllowDrop = false;
510 *pdwEffect = DROPEFFECT_NONE;
512
513 return S_OK;
514}
virtual bool OnDrop(FORMATETC *pFmtEtc, STGMEDIUM &medium, DWORD *pdwEffect)=0
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
HRESULT Drop([in] IDataObject *pDataObject, [in] POINT *ppt, [in] DWORD dwEffect)
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929

◆ OnDrop()

virtual bool IDropTargetImpl::OnDrop ( FORMATETC *  pFmtEtc,
STGMEDIUM &  medium,
DWORD pdwEffect 
)
pure virtual

Implemented in DesktopDropTarget, and TreeDropTarget.

Referenced by Drop().

◆ QueryDrop()

bool IDropTargetImpl::QueryDrop ( DWORD  grfKeyState,
LPDWORD  pdwEffect 
)

Definition at line 382 of file dragdropimpl.cpp.

383{
384 DWORD dwOKEffects = *pdwEffect;
385
386 if (!m_bAllowDrop)
387 {
388 *pdwEffect = DROPEFFECT_NONE;
389 return false;
390 }
391
392 //CTRL+SHIFT -- DROPEFFECT_LINK
393 //CTRL -- DROPEFFECT_COPY
394 //SHIFT -- DROPEFFECT_MOVE
395 //no modifier -- DROPEFFECT_MOVE or whatever is allowed by src
396 *pdwEffect = (grfKeyState & MK_CONTROL) ?
397 ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_LINK : DROPEFFECT_COPY ):
398 ( (grfKeyState & MK_SHIFT) ? DROPEFFECT_MOVE : DROPEFFECT_NONE );
399 if (*pdwEffect == 0)
400 {
401 // No modifier keys used by user while dragging.
402 if (DROPEFFECT_COPY & dwOKEffects)
403 *pdwEffect = DROPEFFECT_COPY;
404 else if (DROPEFFECT_MOVE & dwOKEffects)
405 *pdwEffect = DROPEFFECT_MOVE;
406 else if (DROPEFFECT_LINK & dwOKEffects)
407 *pdwEffect = DROPEFFECT_LINK;
408 else
409 {
410 *pdwEffect = DROPEFFECT_NONE;
411 }
412 }
413 else
414 {
415 // Check if the drag source application allows the drop effect desired by user.
416 // The drag source specifies this in DoDragDrop
417 if (!(*pdwEffect & dwOKEffects))
418 *pdwEffect = DROPEFFECT_NONE;
419 }
420
421 return (DROPEFFECT_NONE == *pdwEffect)?false:true;
422}
unsigned long DWORD
Definition: ntddk_ex.h:95
const DWORD DROPEFFECT_LINK
Definition: oleidl.idl:932
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
const DWORD DROPEFFECT_MOVE
Definition: oleidl.idl:931
#define MK_SHIFT
Definition: winuser.h:2372
#define MK_CONTROL
Definition: winuser.h:2373

Referenced by DragEnter(), DragOver(), and Drop().

◆ QueryInterface()

HRESULT STDMETHODCALLTYPE IDropTargetImpl::QueryInterface ( REFIID  riid,
void __RPC_FAR *__RPC_FAR ppvObject 
)
virtual

Definition at line 354 of file dragdropimpl.cpp.

356{
357 *ppvObject = NULL;
358 if (IID_IUnknown==riid || IID_IDropTarget==riid)
359 *ppvObject=this;
360
361 if (*ppvObject != NULL)
362 {
364 return S_OK;
365 }
366
367 return E_NOINTERFACE;
368}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
IUnknown * LPUNKNOWN
Definition: unknwn.idl:40
nsrefcnt AddRef()
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ Release()

ULONG STDMETHODCALLTYPE IDropTargetImpl::Release ( void  )
virtual

Implements IUnknown.

Definition at line 370 of file dragdropimpl.cpp.

371{
372 long nTemp = --m_cRefCount;
373
374 assert(nTemp >= 0);
375
376 if (nTemp == 0)
377 delete this;
378
379 return nTemp;
380}

Referenced by DesktopShellView::InitDragDrop(), ShellBrowser::InitDragDrop(), and ShellBrowser::~ShellBrowser().

Member Data Documentation

◆ m_bAllowDrop

bool IDropTargetImpl::m_bAllowDrop
private

Definition at line 171 of file dragdropimpl.h.

Referenced by DragEnter(), DragLeave(), Drop(), and QueryDrop().

◆ m_cRefCount

DWORD IDropTargetImpl::m_cRefCount
private

Definition at line 170 of file dragdropimpl.h.

Referenced by AddRef(), and Release().

◆ m_formatetc

FormatArray IDropTargetImpl::m_formatetc
private

Definition at line 174 of file dragdropimpl.h.

Referenced by AddSuportedFormat(), and DragEnter().

◆ m_hTargetWnd

◆ m_pDropTargetHelper

IDropTargetHelper* IDropTargetImpl::m_pDropTargetHelper
private

Definition at line 172 of file dragdropimpl.h.

Referenced by DragEnter(), DragLeave(), DragOver(), Drop(), IDropTargetImpl(), and ~IDropTargetImpl().

◆ m_pSupportedFrmt

FORMATETC* IDropTargetImpl::m_pSupportedFrmt
private

Definition at line 175 of file dragdropimpl.h.

Referenced by DragEnter(), DragLeave(), and Drop().


The documentation for this class was generated from the following files: