ReactOS 0.4.16-dev-1946-g52006dd
CFSDropTarget Class Reference

#include <CFSDropTarget.h>

Inheritance diagram for CFSDropTarget:
Collaboration diagram for CFSDropTarget:

Public Member Functions

 CFSDropTarget ()
 
 ~CFSDropTarget ()
 
HRESULT Initialize (LPWSTR PathTarget)
 
STDMETHOD() DragEnter (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
 
STDMETHOD() DragOver (DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
 
STDMETHOD() DragLeave () override
 
STDMETHOD() Drop (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override
 
STDMETHOD() SetSite (IUnknown *pUnkSite) override
 
STDMETHOD() GetSite (REFIID riid, void **ppvSite) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
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 ()
 
- Public Member Functions inherited from IObjectWithSite
HRESULT SetSite ([in] IUnknown *pUnkSite)
 
HRESULT GetSite ([in] REFIID riid, [out, iid_is(riid)] PVOID *ppvSite)
 

Private Member Functions

BOOL _QueryDrop (DWORD dwKeyState, LPDWORD pdwEffect)
 
HRESULT _DoDrop (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
HRESULT _CopyItems (IShellFolder *pSFFrom, UINT cidl, LPCITEMIDLIST *apidl, BOOL bCopy)
 
BOOL _GetUniqueFileName (LPCWSTR pwszBasePath, LPCWSTR pwszExt, LPWSTR pwszTarget, BOOL bShortcut)
 
HRESULT _GetEffectFromMenu (IDataObject *pDataObject, POINTL pt, DWORD *pdwEffect, DWORD dwAvailableEffects)
 
HRESULT _RepositionItems (IShellFolderView *psfv, IDataObject *pDataObject, POINTL pt)
 

Static Private Member Functions

static DWORD WINAPI _DoDropThreadProc (LPVOID lpParameter)
 

Private Attributes

UINT m_cfShellIDList
 
BOOL m_fAcceptFmt
 
LPWSTR m_sPathTarget
 
HWND m_hwndSite
 
DWORD m_grfKeyState
 
DWORD m_dwDefaultEffect
 
DWORD m_AllowedEffects
 
CComPtr< IUnknownm_site
 

Additional Inherited Members

- Public Types inherited from IDropTarget
typedef IDropTargetLPDROPTARGET
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IObjectWithSite
typedef IObjectWithSiteLPOBJECTWITHSITE
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 
- 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

Definition at line 29 of file CFSDropTarget.h.

Constructor & Destructor Documentation

◆ CFSDropTarget()

CFSDropTarget::CFSDropTarget ( )

Definition at line 148 of file CFSDropTarget.cpp.

148 :
153 m_grfKeyState(0),
155{
156}
DWORD m_AllowedEffects
Definition: CFSDropTarget.h:41
LPWSTR m_sPathTarget
Definition: CFSDropTarget.h:37
UINT m_cfShellIDList
Definition: CFSDropTarget.h:35
DWORD m_grfKeyState
Definition: CFSDropTarget.h:39
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117

◆ ~CFSDropTarget()

CFSDropTarget::~CFSDropTarget ( )

Definition at line 170 of file CFSDropTarget.cpp.

171{
173}
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370

Member Function Documentation

◆ _CopyItems()

HRESULT CFSDropTarget::_CopyItems ( IShellFolder pSFFrom,
UINT  cidl,
LPCITEMIDLIST apidl,
BOOL  bCopy 
)
private

Definition at line 78 of file CFSDropTarget.cpp.

80{
82 WCHAR wszDstPath[MAX_PATH + 1] = {0};
83 PWCHAR pwszSrcPathsList = (PWCHAR) HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) * cidl + 1);
84 if (!pwszSrcPathsList)
85 return E_OUTOFMEMORY;
86
87 PWCHAR pwszListPos = pwszSrcPathsList;
88 STRRET strretFrom;
90 BOOL bRenameOnCollision = FALSE;
91
92 /* Build a double null terminated list of C strings from source paths */
93 for (UINT i = 0; i < cidl; i++)
94 {
95 ret = pSFFrom->GetDisplayNameOf(apidl[i], SHGDN_FORPARSING, &strretFrom);
96 if (FAILED(ret))
97 goto cleanup;
98
99 ret = StrRetToBufW(&strretFrom, NULL, pwszListPos, MAX_PATH);
100 if (FAILED(ret))
101 goto cleanup;
102
103 pwszListPos += lstrlenW(pwszListPos) + 1;
104 }
105 /* Append the final null. */
106 *pwszListPos = L'\0';
107
108 /* Build a double null terminated target (this path) */
110 if (FAILED(ret))
111 goto cleanup;
112
113 wszDstPath[lstrlenW(wszDstPath) + 1] = UNICODE_NULL;
114
115 /* Set bRenameOnCollision to TRUE if necesssary */
116 if (bCopy)
117 {
118 WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
119 GetFullPathNameW(pwszSrcPathsList, _countof(szPath1), szPath1, NULL);
120 GetFullPathNameW(wszDstPath, _countof(szPath2), szPath2, NULL);
121 PathRemoveFileSpecW(szPath1);
122 if (_wcsicmp(szPath1, szPath2) == 0)
123 bRenameOnCollision = TRUE;
124 }
125
126 ZeroMemory(&fop, sizeof(fop));
127 fop.hwnd = m_hwndSite;
128 fop.wFunc = bCopy ? FO_COPY : FO_MOVE;
129 fop.pFrom = pwszSrcPathsList;
130 fop.pTo = wszDstPath;
132 if (bRenameOnCollision)
134
135 ret = S_OK;
136
137 if (SHFileOperationW(&fop))
138 {
139 ERR("SHFileOperationW failed\n");
140 ret = E_FAIL;
141 }
142
143cleanup:
144 HeapFree(GetProcessHeap(), 0, pwszSrcPathsList);
145 return ret;
146}
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
static void cleanup(void)
Definition: main.c:1335
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1145
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define ZeroMemory
Definition: minwinbase.h:31
unsigned int UINT
Definition: ndis.h:50
#define UNICODE_NULL
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define FOF_ALLOWUNDO
Definition: shellapi.h:147
#define FO_COPY
Definition: shellapi.h:137
#define FOF_RENAMEONCOLLISION
Definition: shellapi.h:144
#define FOF_NOCONFIRMMKDIR
Definition: shellapi.h:150
#define FO_MOVE
Definition: shellapi.h:136
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:2200
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LPCWSTR pFrom
Definition: shellapi.h:369
FILEOP_FLAGS fFlags
Definition: shellapi.h:371
uint16_t * PWCHAR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _DoDrop().

◆ _DoDrop()

HRESULT CFSDropTarget::_DoDrop ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
private

Definition at line 556 of file CFSDropTarget.cpp.

558{
559 TRACE("(%p) performing drop, effect %u\n", this, *pdwEffect);
560 FORMATETC fmt;
561 FORMATETC fmt2;
562 STGMEDIUM medium;
563
564 InitFormatEtc (fmt, m_cfShellIDList, TYMED_HGLOBAL);
565 InitFormatEtc (fmt2, CF_HDROP, TYMED_HGLOBAL);
566
567 HRESULT hr;
568 bool bCopy = TRUE;
569 bool bLinking = FALSE;
570
571 /* Figure out what drop operation we're doing */
572 if (pdwEffect)
573 {
574 TRACE("Current drop effect flag %i\n", *pdwEffect);
575 if ((*pdwEffect & DROPEFFECT_MOVE) == DROPEFFECT_MOVE)
576 bCopy = FALSE;
577 if ((*pdwEffect & DROPEFFECT_LINK) == DROPEFFECT_LINK)
578 bLinking = TRUE;
579 }
580
581 if (SUCCEEDED(hr = pDataObject->QueryGetData(&fmt)))
582 {
583 hr = pDataObject->GetData(&fmt, &medium);
584 TRACE("CFSTR_SHELLIDLIST\n");
585 if (FAILED(hr))
586 {
587 ERR("CFSTR_SHELLIDLIST failed\n");
588 }
589 /* lock the handle */
590 LPIDA lpcida = (LPIDA)GlobalLock(medium.hGlobal);
591 if (!lpcida)
592 {
593 ReleaseStgMedium(&medium);
594 return E_FAIL;
595 }
596
597 /* convert the data into pidl */
598 LPITEMIDLIST pidl;
599 LPITEMIDLIST *apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
600 if (!apidl)
601 {
602 ReleaseStgMedium(&medium);
603 return E_FAIL;
604 }
605
606 CComPtr<IShellFolder> psfDesktop;
607 CComPtr<IShellFolder> psfFrom = NULL;
608
609 /* Grab the desktop shell folder */
610 hr = SHGetDesktopFolder(&psfDesktop);
611 if (FAILED(hr))
612 {
613 ERR("SHGetDesktopFolder failed\n");
614 SHFree(pidl);
615 _ILFreeaPidl(apidl, lpcida->cidl);
616 ReleaseStgMedium(&medium);
617 return E_FAIL;
618 }
619
620 /* Find source folder, this is where the clipboard data was copied from */
621 if (_ILIsDesktop(pidl))
622 {
623 /* use desktop shell folder */
624 psfFrom = psfDesktop;
625 }
626 else
627 {
628 hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &psfFrom));
629 if (FAILED(hr))
630 {
631 ERR("no IShellFolder\n");
632 SHFree(pidl);
633 _ILFreeaPidl(apidl, lpcida->cidl);
634 ReleaseStgMedium(&medium);
635 return E_FAIL;
636 }
637 }
638
639 if (bLinking)
640 {
641 WCHAR wszNewLnk[MAX_PATH];
642
643 TRACE("target path = %s\n", debugstr_w(m_sPathTarget));
644
645 /* We need to create a link for each pidl in the copied items, so step through the pidls from the clipboard */
646 for (UINT i = 0; i < lpcida->cidl; i++)
647 {
648 SFGAOF att = SHGetAttributes(psfFrom, apidl[i], SFGAO_FOLDER | SFGAO_STREAM | SFGAO_FILESYSTEM);
649 CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlFull;
650 hr = SHILCombine(pidl, apidl[i], &pidlFull);
651
652 WCHAR targetName[MAX_PATH];
653 if (SUCCEEDED(hr))
654 {
655 // If the target is a file, we use SHGDN_FORPARSING because "NeverShowExt" will hide the ".lnk" extension.
656 // If the target is a virtual item, we ask for the friendly name because SHGDN_FORPARSING will return a GUID.
657 BOOL UseParsing = (att & (SFGAO_FILESYSTEM | SFGAO_FOLDER)) == SFGAO_FILESYSTEM;
658 DWORD ShgdnFor = UseParsing ? SHGDN_FORPARSING : SHGDN_FOREDITING;
659 hr = DisplayNameOfW(psfFrom, apidl[i], ShgdnFor | SHGDN_INFOLDER, targetName, _countof(targetName));
660 }
662 {
664 break;
665 }
667
668 WCHAR wszCombined[MAX_PATH + _countof(targetName)];
669 PathCombineW(wszCombined, m_sPathTarget, targetName);
670
671 // Check to see if the source is a link
672 BOOL fSourceIsLink = FALSE;
673 if (!_wcsicmp(PathFindExtensionW(targetName), L".lnk") && (att & (SFGAO_FOLDER | SFGAO_STREAM)) != SFGAO_FOLDER)
674 {
675 fSourceIsLink = TRUE;
676 PathRemoveExtensionW(wszCombined);
677 }
678
679 // Create a pathname to save the new link.
680 _GetUniqueFileName(wszCombined, L".lnk", wszNewLnk, TRUE);
681
682 CComPtr<IPersistFile> ppf;
683 if (fSourceIsLink)
684 {
685 PWSTR pwszTargetFull;
686 hr = SHGetNameFromIDList(pidlFull, SIGDN_DESKTOPABSOLUTEPARSING, &pwszTargetFull);
688 {
691 SHFree(pwszTargetFull);
692 }
693 }
694 else
695 {
696 CComPtr<IShellLinkW> pLink;
697 hr = CShellLink::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IShellLinkW, &pLink));
699 {
700 hr = pLink->SetIDList(pidlFull);
702 hr = pLink->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf));
703
704 PWSTR pwszPath, pSep;
705 if ((att & SFGAO_FILESYSTEM) && SUCCEEDED(SHGetNameFromIDList(pidlFull, SIGDN_FILESYSPATH, &pwszPath)))
706 {
707 if ((pSep = PathFindFileNameW(pwszPath)) > pwszPath)
708 {
709 pSep[-1] = UNICODE_NULL;
710 pLink->SetWorkingDirectory(pwszPath);
711 }
712 SHFree(pwszPath);
713 }
714 }
715 }
716 if (SUCCEEDED(hr))
717 hr = ppf->Save(wszNewLnk, !fSourceIsLink);
719 {
721 break;
722 }
724 }
725 }
726 else
727 {
728 hr = _CopyItems(psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl, bCopy);
729 }
730
731 SHFree(pidl);
732 _ILFreeaPidl(apidl, lpcida->cidl);
733 ReleaseStgMedium(&medium);
734 }
735 else if (SUCCEEDED(hr = pDataObject->QueryGetData(&fmt2)))
736 {
737 FORMATETC fmt2;
738 InitFormatEtc (fmt2, CF_HDROP, TYMED_HGLOBAL);
739 if (SUCCEEDED(hr = pDataObject->GetData(&fmt2, &medium)) /* && SUCCEEDED(pDataObject->GetData(&fmt2, &medium))*/)
740 {
741 WCHAR wszTargetPath[MAX_PATH + 1];
742 LPWSTR pszSrcList;
743
744 wcscpy(wszTargetPath, m_sPathTarget);
745 //Double NULL terminate.
746 wszTargetPath[wcslen(wszTargetPath) + 1] = '\0';
747
748 LPDROPFILES lpdf = (LPDROPFILES) GlobalLock(medium.hGlobal);
749 if (!lpdf)
750 {
751 ERR("Error locking global\n");
752 return E_FAIL;
753 }
754 pszSrcList = (LPWSTR) (((byte*) lpdf) + lpdf->pFiles);
755 ERR("Source file (just the first) = %s, target path = %s, bCopy: %d\n", debugstr_w(pszSrcList), debugstr_w(wszTargetPath), bCopy);
756
758 ZeroMemory(&op, sizeof(op));
759 op.pFrom = pszSrcList;
760 op.pTo = wszTargetPath;
761 op.hwnd = m_hwndSite;
762 op.wFunc = bCopy ? FO_COPY : FO_MOVE;
764 int res = SHFileOperationW(&op);
765 if (res)
766 {
767 ERR("SHFileOperationW failed with 0x%x\n", res);
768 hr = E_FAIL;
769 }
770
771 return hr;
772 }
773 ERR("Error calling GetData\n");
774 hr = E_FAIL;
775 }
776 else
777 {
778 ERR("No viable drop format\n");
779 hr = E_FAIL;
780 }
781 return hr;
782}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
static void SHELL_StripIllegalFsNameCharacters(_Inout_ LPWSTR Buf)
static HRESULT WINAPI DisplayNameOfW(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
Definition: CFindFolder.cpp:15
#define CF_HDROP
Definition: constants.h:410
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
HRESULT _CopyItems(IShellFolder *pSFFrom, UINT cidl, LPCITEMIDLIST *apidl, BOOL bCopy)
BOOL _GetUniqueFileName(LPCWSTR pwszBasePath, LPCWSTR pwszExt, LPWSTR pwszTarget, BOOL bShortcut)
wcscpy
UINT op
Definition: effect.c:236
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1946
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1701
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:448
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
HRESULT QueryGetData([in, unique] FORMATETC *pformatetc)
const DWORD DROPEFFECT_LINK
Definition: oleidl.idl:932
const DWORD DROPEFFECT_MOVE
Definition: oleidl.idl:931
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define debugstr_w
Definition: kernel32.h:32
#define PathCombineW
Definition: pathcch.h:318
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST *pidl, const CIDA *cida)
Definition: pidl.c:2648
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1604
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2608
#define SHELL_ErrorBox
Definition: shellutils.h:126
HRESULT hr
Definition: shlfolder.c:183
struct CIDA * LPIDA
#define SHCNE_CREATE
Definition: shlobj.h:1896
#define SHCNF_PATHW
Definition: shlobj.h:1931
struct _DROPFILES * LPDROPFILES
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define TRACE(s)
Definition: solgame.cpp:4
Definition: shlobj.h:580
UINT cidl
Definition: shlobj.h:580
Definition: dsound.c:943
uint16_t * PWSTR
Definition: typedefs.h:56
#define IID_PPV_ARG(Itype, ppType)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by Drop().

◆ _DoDropThreadProc()

DWORD WINAPI CFSDropTarget::_DoDropThreadProc ( LPVOID  lpParameter)
staticprivate

Definition at line 784 of file CFSDropTarget.cpp.

785{
786 _DoDropData *data = static_cast<_DoDropData*>(lpParameter);
787 CComPtr<IDataObject> pDataObject;
789
790 if (SUCCEEDED(hr))
791 {
792 CComPtr<IAsyncOperation> pAsyncOperation;
793 hr = data->This->_DoDrop(pDataObject, data->dwKeyState, data->pt, &data->pdwEffect);
794 if (SUCCEEDED(pDataObject->QueryInterface(IID_PPV_ARG(IAsyncOperation, &pAsyncOperation))))
795 {
796 pAsyncOperation->EndOperation(hr, NULL, data->pdwEffect);
797 }
798 }
799 //Release the CFSFolder and data object holds in the copying thread.
800 data->This->Release();
801 //Release the parameter from the heap.
803 return 0;
804}
HRESULT WINAPI CoGetInterfaceAndReleaseStream(LPSTREAM pStm, REFIID riid, LPVOID *ppv)
Definition: marshal.c:2144
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
ULONG Release()

Referenced by Drop().

◆ _GetEffectFromMenu()

HRESULT CFSDropTarget::_GetEffectFromMenu ( IDataObject pDataObject,
POINTL  pt,
DWORD pdwEffect,
DWORD  dwAvailableEffects 
)
private

Definition at line 235 of file CFSDropTarget.cpp.

236{
238 if (!hmenu)
239 return E_OUTOFMEMORY;
241
242 SHELL_LimitDropEffectToItemAttributes(pDataObject, &dwAvailableEffects);
243 if ((dwAvailableEffects & DROPEFFECT_COPY) == 0)
245 if ((dwAvailableEffects & DROPEFFECT_MOVE) == 0)
247 if ((dwAvailableEffects & DROPEFFECT_LINK) == 0 && (dwAvailableEffects & (DROPEFFECT_COPY | DROPEFFECT_MOVE)))
249
251 if (*pdwEffect & dwAvailableEffects & DROPEFFECT_COPY)
253 else if (*pdwEffect & dwAvailableEffects & DROPEFFECT_MOVE)
255 else if (dwAvailableEffects & DROPEFFECT_LINK)
257
258 CRegKeyHandleArray keys;
259 HDCIA hDCIA = DCIA_Create();
260 HDCMA hDCMA = DCMA_Create();
261 CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlFolder(SHELL32_CreateSimpleIDListFromPath(m_sPathTarget, FILE_ATTRIBUTE_DIRECTORY));
262 if (hDCMA && hDCIA && pidlFolder)
263 {
264 AddPidlClassKeysToArray(pidlFolder, keys, keys);
265 for (UINT i = 0; i < keys; ++i)
266 DCIA_AddShellExSubkey(hDCIA, keys[i], L"DragDropHandlers");
267
269 DCMA_InsertMenuItems(hDCMA, hDCIA, pidlFolder, pDataObject, keys, keys, &qcmi, 0, m_site);
270 }
271
272 /* We shouldn't use the site window here because the menu should work even when we don't have a site */
273 HWND hwndDummy = CreateWindowEx(0,
274 WC_STATIC,
275 NULL,
277 pt.x,
278 pt.y,
279 1,
280 1,
281 NULL,
282 NULL,
283 NULL,
284 NULL);
285
286 SetForegroundWindow(hwndDummy); // Required for aborting by pressing Esc when dragging from Explorer to desktop
287 UINT uCommand = TrackPopupMenu(hpopupmenu,
289 pt.x, pt.y, 0, hwndDummy, NULL);
290
291 DestroyWindow(hwndDummy);
292
293 HRESULT hr = S_FALSE; // S_FALSE means we did not handle the command
295 IDM_LINKHERE < DROPIDM_EXTFIRST && DROPIDM_EXTFIRST > 0);
296 if (uCommand >= DROPIDM_EXTFIRST && uCommand <= DROPIDM_EXTLAST)
297 {
298 CMINVOKECOMMANDINFO ici = { sizeof(ici), 0, m_hwndSite, MAKEINTRESOURCEA(uCommand - DROPIDM_EXTFIRST) };
299 ici.nShow = SW_SHOW;
301 ici.fMask |= CMIC_MASK_SHIFT_DOWN;
303 ici.fMask |= CMIC_MASK_CONTROL_DOWN;
304 DCMA_InvokeCommand(hDCMA, &ici);
305 hr = S_OK;
306 *pdwEffect = DROPEFFECT_NONE;
307 }
308 else if (uCommand == 0)
309 {
310 hr = S_OK;
311 *pdwEffect = DROPEFFECT_NONE;
312 }
313 else if (uCommand == IDM_COPYHERE)
314 *pdwEffect = DROPEFFECT_COPY;
315 else if (uCommand == IDM_MOVEHERE)
316 *pdwEffect = DROPEFFECT_MOVE;
317 else if (uCommand == IDM_LINKHERE)
318 *pdwEffect = DROPEFFECT_LINK;
319 else
321
322 DCMA_Destroy(hDCMA);
323 DCIA_Destroy(hDCIA);
325 return hr;
326}
UINT DCMA_InsertMenuItems(_In_ HDCMA hDCMA, _In_ HDCIA hDCIA, _In_opt_ LPCITEMIDLIST pidlFolder, _In_opt_ IDataObject *pDO, _In_opt_ HKEY *pKeys, _In_opt_ UINT nKeys, _In_ QCMINFO *pQCMI, _In_opt_ UINT fCmf, _In_opt_ IUnknown *pUnkSite)
void DCMA_Destroy(HDCMA hDCMA)
HRESULT DCMA_InvokeCommand(HDCMA hDCMA, CMINVOKECOMMANDINFO *pICI)
static HRESULT SHELL_LimitDropEffectToItemAttributes(_In_ IDataObject *pDataObject, _Inout_ PDWORD pdwEffect)
static void GetDefaultCopyMoveEffect()
#define DROPIDM_EXTFIRST
Definition: CFSDropTarget.h:26
#define DROPIDM_EXTLAST
Definition: CFSDropTarget.h:27
#define shell32_hInstance
CComPtr< IUnknown > m_site
Definition: CFSDropTarget.h:42
const UINT * keys
Definition: locale.c:416
#define DCMA_Create()
Definition: precomp.h:189
void DCIA_AddShellExSubkey(HDCIA hDCIA, HKEY hProgId, PCWSTR pszSubkey)
Definition: utils.cpp:1848
#define DCIA_Destroy(hDCIA)
Definition: utils.h:125
#define DCIA_Create()
Definition: utils.h:124
#define pt(x, y)
Definition: drawing.c:79
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
#define C_ASSERT(e)
Definition: intsafe.h:73
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
static HMENU hpopupmenu
Definition: msg.c:17339
static HMENU hmenu
Definition: win.c:66
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_BORDER
Definition: pedump.c:625
#define WS_DISABLED
Definition: pedump.c:621
#define SS_LEFT
Definition: pedump.c:692
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LPITEMIDLIST SHELL32_CreateSimpleIDListFromPath(LPCWSTR pszPath, DWORD dwAttributes)
Definition: pidl.c:1189
#define WC_STATIC
Definition: commctrl.h:4687
void AddPidlClassKeysToArray(LPCITEMIDLIST pidl, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:504
#define IDM_DRAGFILE
Definition: shresdef.h:918
#define IDM_MOVEHERE
Definition: shresdef.h:920
#define IDM_LINKHERE
Definition: shresdef.h:921
#define IDM_COPYHERE
Definition: shresdef.h:919
Definition: dsa.c:45
#define S_FALSE
Definition: winerror.h:3451
#define E_UNEXPECTED
Definition: winerror.h:3528
#define CreateWindowEx
Definition: winuser.h:5866
#define MK_SHIFT
Definition: winuser.h:2405
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define TPM_RIGHTBUTTON
Definition: winuser.h:2416
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define TPM_NONOTIFY
Definition: winuser.h:2422
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MK_CONTROL
Definition: winuser.h:2406
#define TPM_LEFTALIGN
Definition: winuser.h:2413
#define TPM_LEFTBUTTON
Definition: winuser.h:2415
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define SW_SHOW
Definition: winuser.h:786
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define TPM_RETURNCMD
Definition: winuser.h:2423
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by Drop().

◆ _GetUniqueFileName()

BOOL CFSDropTarget::_GetUniqueFileName ( LPCWSTR  pwszBasePath,
LPCWSTR  pwszExt,
LPWSTR  pwszTarget,
BOOL  bShortcut 
)
private

Definition at line 176 of file CFSDropTarget.cpp.

177{
178 WCHAR wszLink[40];
179
180 if (!bShortcut)
181 {
182 if (!LoadStringW(shell32_hInstance, IDS_LNK_FILE, wszLink, _countof(wszLink)))
183 wszLink[0] = L'\0';
184 }
185
186 if (!bShortcut)
187 swprintf(pwszTarget, L"%s%s%s", wszLink, pwszBasePath, pwszExt);
188 else
189 swprintf(pwszTarget, L"%s%s", pwszBasePath, pwszExt);
190
191 for (UINT i = 2; PathFileExistsW(pwszTarget); ++i)
192 {
193 if (!bShortcut)
194 swprintf(pwszTarget, L"%s%s (%u)%s", wszLink, pwszBasePath, i, pwszExt);
195 else
196 swprintf(pwszTarget, L"%s (%u)%s", pwszBasePath, i, pwszExt);
197 }
198
199 return TRUE;
200}
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2607
INT WINAPI DECLSPEC_HOTPATCH LoadStringW(HINSTANCE instance, UINT resource_id, LPWSTR buffer, INT buflen)
Definition: string.c:1220
#define swprintf
Definition: precomp.h:40
#define IDS_LNK_FILE
Definition: shresdef.h:178

Referenced by _DoDrop().

◆ _QueryDrop()

BOOL CFSDropTarget::_QueryDrop ( DWORD  dwKeyState,
LPDWORD  pdwEffect 
)
private

Definition at line 205 of file CFSDropTarget.cpp.

206{
207 /* TODO Windows does different drop effects if dragging across drives.
208 i.e., it will copy instead of move if the directories are on different disks. */
210
211 DWORD dwEffect = m_dwDefaultEffect;
212
213 *pdwEffect = DROPEFFECT_NONE;
214
215 if (m_fAcceptFmt) { /* Does our interpretation of the keystate ... */
216 *pdwEffect = KeyStateToDropEffect(dwKeyState);
217
218 // Transform disallowed move to a copy
219 if ((*pdwEffect & D_MOVE) && (m_AllowedEffects & (D_MOVE | D_COPY)) == D_COPY)
220 *pdwEffect = D_COPY;
221
222 *pdwEffect &= m_AllowedEffects;
223
224 if (*pdwEffect == DROPEFFECT_NONE)
225 *pdwEffect = dwEffect;
226
227 /* ... matches the desired effect ? */
228 if (dwEffect & *pdwEffect) {
229 return TRUE;
230 }
231 }
232 return FALSE;
233}
#define D_COPY
#define D_MOVE
DWORD m_dwDefaultEffect
Definition: CFSDropTarget.h:40
#define KeyStateToDropEffect(kst)
Definition: shell32_main.h:134

Referenced by DragOver(), and Drop().

◆ _RepositionItems()

HRESULT CFSDropTarget::_RepositionItems ( IShellFolderView *  psfv,
IDataObject pDataObject,
POINTL  pt 
)
private

Definition at line 328 of file CFSDropTarget.cpp.

329{
330 CComPtr<IFolderView> pfv;
331 POINT ptDrag;
334 return hr;
335
336 hr = psfv->GetDragPoint(&ptDrag);
338 return hr;
339
340 PIDLIST_ABSOLUTE pidlFolder;
341 PUITEMID_CHILD *apidl;
342 UINT cidl;
343 hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
345 return hr;
346
347 CComHeapPtr<POINT> apt;
348 if (!apt.Allocate(cidl))
349 {
350 SHFree(pidlFolder);
351 _ILFreeaPidl(apidl, cidl);
352 return E_OUTOFMEMORY;
353 }
354
355 for (UINT i = 0; i<cidl; i++)
356 {
357 pfv->GetItemPosition(apidl[i], &apt[i]);
358 apt[i].x += pt.x - ptDrag.x;
359 apt[i].y += pt.y - ptDrag.y;
360 }
361
362 pfv->SelectAndPositionItems(cidl, apidl, apt, SVSI_SELECT);
363
364 SHFree(pidlFolder);
365 _ILFreeaPidl(apidl, cidl);
366 return S_OK;
367}
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:510
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48

Referenced by Drop().

◆ DragEnter()

HRESULT WINAPI CFSDropTarget::DragEnter ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
override

Implements IDropTarget.

Definition at line 369 of file CFSDropTarget.cpp.

371{
372 TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
373
374 const BOOL bAnyKeyMod = dwKeyState & (MK_SHIFT | MK_CONTROL);
375 m_AllowedEffects = *pdwEffect;
376
377 if (*pdwEffect == DROPEFFECT_NONE)
378 return S_OK;
379
380 FORMATETC fmt;
381 FORMATETC fmt2;
383
384 InitFormatEtc (fmt, m_cfShellIDList, TYMED_HGLOBAL);
385 InitFormatEtc (fmt2, CF_HDROP, TYMED_HGLOBAL);
386
387 if (SUCCEEDED(pDataObject->QueryGetData(&fmt)))
389 else if (SUCCEEDED(pDataObject->QueryGetData(&fmt2)))
391
392 m_grfKeyState = dwKeyState;
393
394 SHELL_LimitDropEffectToItemAttributes(pDataObject, pdwEffect);
395 m_AllowedEffects = *pdwEffect;
397 switch (*pdwEffect & (D_COPY | D_MOVE | D_LINK))
398 {
399 case D_COPY | D_MOVE:
400 if (dwKeyState & MK_CONTROL)
402 else
404 break;
405 case D_COPY | D_MOVE | D_LINK:
406 if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT | MK_CONTROL))
408 else if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == MK_CONTROL)
410 else
412 break;
413 case D_COPY | D_LINK:
414 if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT | MK_CONTROL))
416 else
418 break;
419 case D_MOVE | D_LINK:
420 if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT | MK_CONTROL))
422 else
424 break;
425 }
426
427 STGMEDIUM medium;
428 if (SUCCEEDED(pDataObject->GetData(&fmt2, &medium)))
429 {
430 WCHAR wstrFirstFile[MAX_PATH];
431 if (DragQueryFileW((HDROP)medium.hGlobal, 0, wstrFirstFile, _countof(wstrFirstFile)))
432 {
433 if (!PathIsSameDrive(wstrFirstFile, m_sPathTarget) && m_dwDefaultEffect != D_LINK)
434 {
436 }
437
438 if (!bAnyKeyMod && PathIsDriveRoot(wstrFirstFile) && (m_AllowedEffects & DROPEFFECT_LINK))
439 {
440 m_dwDefaultEffect = DROPEFFECT_LINK; // Don't copy a drive by default
441 }
442 }
443 ReleaseStgMedium(&medium);
444 }
445
446 if (!m_fAcceptFmt)
448 else
449 *pdwEffect = m_dwDefaultEffect;
450 *pdwEffect &= m_AllowedEffects;
451
452 return S_OK;
453}
static bool PathIsDriveRoot(LPCWSTR Path)
#define D_LINK
static bool PathIsSameDrive(LPCWSTR Path1, LPCWSTR Path2)
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:666

◆ DragLeave()

HRESULT WINAPI CFSDropTarget::DragLeave ( void  )
override

Implements IDropTarget.

Definition at line 470 of file CFSDropTarget.cpp.

471{
472 TRACE("(%p)\n", this);
473
475
476 return S_OK;
477}

◆ DragOver()

HRESULT WINAPI CFSDropTarget::DragOver ( DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
override

Implements IDropTarget.

Definition at line 455 of file CFSDropTarget.cpp.

457{
458 TRACE("(%p)\n", this);
459
460 if (!pdwEffect)
461 return E_INVALIDARG;
462
463 m_grfKeyState = dwKeyState;
464
465 _QueryDrop(dwKeyState, pdwEffect);
466
467 return S_OK;
468}
BOOL _QueryDrop(DWORD dwKeyState, LPDWORD pdwEffect)
#define E_INVALIDARG
Definition: ddrawi.h:101

◆ Drop()

HRESULT WINAPI CFSDropTarget::Drop ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)
override

Implements IDropTarget.

Definition at line 479 of file CFSDropTarget.cpp.

481{
482 TRACE("(%p) object dropped, effect %u\n", this, *pdwEffect);
483
484 if (!pdwEffect)
485 return E_INVALIDARG;
486
488
489 DWORD dwAvailableEffects = *pdwEffect;
490
491 _QueryDrop(dwKeyState, pdwEffect);
492
493 TRACE("pdwEffect: 0x%x, m_dwDefaultEffect: 0x%x, dwAvailableEffects: 0x%x\n", *pdwEffect, m_dwDefaultEffect, dwAvailableEffects);
494
496 {
497 HRESULT hr = _GetEffectFromMenu(pDataObject, pt, pdwEffect, dwAvailableEffects);
498 if (FAILED_UNEXPECTEDLY(hr) || hr == S_OK)
499 return hr;
500 }
501
502 if (*pdwEffect == DROPEFFECT_MOVE && m_site)
503 {
504 CComPtr<IShellFolderView> psfv;
505 HRESULT hr = IUnknown_QueryService(m_site, SID_SFolderView, IID_PPV_ARG(IShellFolderView, &psfv));
506 if (SUCCEEDED(hr) && psfv->IsDropOnSource(this) == S_OK)
507 {
508 _RepositionItems(psfv, pDataObject, pt);
509 return S_OK;
510 }
511 }
512
513 BOOL fIsOpAsync = FALSE;
514 CComPtr<IAsyncOperation> pAsyncOperation;
515
516 if (SUCCEEDED(pDataObject->QueryInterface(IID_PPV_ARG(IAsyncOperation, &pAsyncOperation))))
517 {
518 if (SUCCEEDED(pAsyncOperation->GetAsyncMode(&fIsOpAsync)) && fIsOpAsync)
519 {
520 _DoDropData *data = static_cast<_DoDropData*>(HeapAlloc(GetProcessHeap(), 0, sizeof(_DoDropData)));
521 data->This = this;
522 // Need to maintain this class in case the window is closed or the class exists temporarily (when dropping onto a folder).
523 pDataObject->AddRef();
524 pAsyncOperation->StartOperation(NULL);
526 this->AddRef();
527 data->dwKeyState = dwKeyState;
528 data->pt = pt;
529 // Need to dereference as pdweffect gets freed.
530 data->pdwEffect = *pdwEffect;
532 return S_OK;
533 }
534 }
535 return this->_DoDrop(pDataObject, dwKeyState, pt, pdwEffect);
536}
static DWORD WINAPI _DoDropThreadProc(LPVOID lpParameter)
HRESULT _GetEffectFromMenu(IDataObject *pDataObject, POINTL pt, DWORD *pdwEffect, DWORD dwAvailableEffects)
HRESULT _DoDrop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
HRESULT _RepositionItems(IShellFolderView *psfv, IDataObject *pDataObject, POINTL pt)
HRESULT WINAPI CoMarshalInterThreadInterfaceInStream(REFIID riid, LPUNKNOWN pUnk, LPSTREAM *ppStm)
Definition: marshal.c:2100
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1501
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1336
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE pfnThreadProc, VOID *pData, DWORD dwFlags, LPTHREAD_START_ROUTINE pfnCallback)
Definition: thread.c:356
ULONG AddRef()
const GUID IID_IDataObject
@ CTF_PROCESS_REF
Definition: shlwapi.h:73
@ CTF_COINIT
Definition: shlwapi.h:75
DWORD dwKeyState
Definition: CFSDropTarget.h:81
CFSDropTarget * This
Definition: CFSDropTarget.h:79
#define MK_RBUTTON
Definition: winuser.h:2404

◆ GetSite()

HRESULT WINAPI CFSDropTarget::GetSite ( REFIID  riid,
void **  ppvSite 
)
override

Definition at line 548 of file CFSDropTarget.cpp.

549{
550 if (!m_site)
551 return E_FAIL;
552
553 return m_site->QueryInterface(riid, ppvSite);
554}
REFIID riid
Definition: atlbase.h:39

◆ Initialize()

HRESULT CFSDropTarget::Initialize ( LPWSTR  PathTarget)

Definition at line 158 of file CFSDropTarget.cpp.

159{
160 if (!PathTarget)
161 return E_UNEXPECTED;
162
164 if (!m_cfShellIDList)
165 return E_FAIL;
166
167 return SHStrDupW(PathTarget, &m_sPathTarget);
168}
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:2018
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:558
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)

◆ SetSite()

HRESULT WINAPI CFSDropTarget::SetSite ( IUnknown pUnkSite)
override

Implements IObjectWithSite.

Definition at line 540 of file CFSDropTarget.cpp.

541{
542 m_site = pUnkSite;
543 return S_OK;
544}

Member Data Documentation

◆ m_AllowedEffects

DWORD CFSDropTarget::m_AllowedEffects
private

Definition at line 41 of file CFSDropTarget.h.

Referenced by _QueryDrop(), and DragEnter().

◆ m_cfShellIDList

UINT CFSDropTarget::m_cfShellIDList
private

Definition at line 35 of file CFSDropTarget.h.

Referenced by _DoDrop(), DragEnter(), and Initialize().

◆ m_dwDefaultEffect

DWORD CFSDropTarget::m_dwDefaultEffect
private

Definition at line 40 of file CFSDropTarget.h.

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

◆ m_fAcceptFmt

BOOL CFSDropTarget::m_fAcceptFmt
private

Definition at line 36 of file CFSDropTarget.h.

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

◆ m_grfKeyState

DWORD CFSDropTarget::m_grfKeyState
private

Definition at line 39 of file CFSDropTarget.h.

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

◆ m_hwndSite

HWND CFSDropTarget::m_hwndSite
private

Definition at line 38 of file CFSDropTarget.h.

Referenced by _CopyItems(), _DoDrop(), _GetEffectFromMenu(), and Drop().

◆ m_site

CComPtr<IUnknown> CFSDropTarget::m_site
private

Definition at line 42 of file CFSDropTarget.h.

Referenced by _GetEffectFromMenu(), Drop(), GetSite(), and SetSite().

◆ m_sPathTarget

LPWSTR CFSDropTarget::m_sPathTarget
private

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