ReactOS 0.4.17-dev-470-gf9e3448
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 (IDataObject *pDO, 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 157 of file CFSDropTarget.cpp.

157 :
162 m_grfKeyState(0),
164{
165}
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 179 of file CFSDropTarget.cpp.

180{
182}
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370

Member Function Documentation

◆ _CopyItems()

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

Definition at line 87 of file CFSDropTarget.cpp.

89{
91 WCHAR wszDstPath[MAX_PATH + 1] = {0};
92 PWCHAR pwszSrcPathsList = (PWCHAR) HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) * cidl + 1);
93 if (!pwszSrcPathsList)
94 return E_OUTOFMEMORY;
95
96 PWCHAR pwszListPos = pwszSrcPathsList;
97 STRRET strretFrom;
99 BOOL bRenameOnCollision = FALSE;
100
101 /* Build a double null terminated list of C strings from source paths */
102 for (UINT i = 0; i < cidl; i++)
103 {
104 ret = pSFFrom->GetDisplayNameOf(apidl[i], SHGDN_FORPARSING, &strretFrom);
105 if (FAILED(ret))
106 goto cleanup;
107
108 ret = StrRetToBufW(&strretFrom, NULL, pwszListPos, MAX_PATH);
109 if (FAILED(ret))
110 goto cleanup;
111
112 pwszListPos += lstrlenW(pwszListPos) + 1;
113 }
114 /* Append the final null. */
115 *pwszListPos = L'\0';
116
117 /* Build a double null terminated target (this path) */
119 if (FAILED(ret))
120 goto cleanup;
121
122 wszDstPath[lstrlenW(wszDstPath) + 1] = UNICODE_NULL;
123
124 /* Set bRenameOnCollision to TRUE if necesssary */
125 if (bCopy)
126 {
127 WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
128 GetFullPathNameW(pwszSrcPathsList, _countof(szPath1), szPath1, NULL);
129 GetFullPathNameW(wszDstPath, _countof(szPath2), szPath2, NULL);
130 PathRemoveFileSpecW(szPath1);
131 if (_wcsicmp(szPath1, szPath2) == 0)
132 bRenameOnCollision = TRUE;
133 }
134
135 ZeroMemory(&fop, sizeof(fop));
136 fop.hwnd = m_hwndSite;
137 fop.wFunc = bCopy ? FO_COPY : FO_MOVE;
138 fop.pFrom = pwszSrcPathsList;
139 fop.pTo = wszDstPath;
140 fop.fFlags = GetDefaultFileOpFlags(pDO);
141 if (bRenameOnCollision)
143
144 ret = S_OK;
145
146 if (SHFileOperationW(&fop))
147 {
148 ERR("SHFileOperationW failed\n");
149 ret = E_FAIL;
150 }
151
152cleanup:
153 HeapFree(GetProcessHeap(), 0, pwszSrcPathsList);
154 return ret;
155}
static DWORD GetDefaultFileOpFlags(IDataObject *pDO, DWORD fDefault=FOF_ALLOWUNDO|FOF_NOCONFIRMMKDIR)
#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:1121
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:248
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
unsigned int UINT
Definition: sysinfo.c:13
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
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
#define FO_COPY
Definition: shellapi.h:137
#define FOF_RENAMEONCOLLISION
Definition: shellapi.h:144
#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

Referenced by _DoDrop().

◆ _DoDrop()

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

Definition at line 565 of file CFSDropTarget.cpp.

567{
568 TRACE("(%p) performing drop, effect %u\n", this, *pdwEffect);
569 FORMATETC fmt;
570 FORMATETC fmt2;
571 STGMEDIUM medium;
572
573 InitFormatEtc (fmt, m_cfShellIDList, TYMED_HGLOBAL);
574 InitFormatEtc (fmt2, CF_HDROP, TYMED_HGLOBAL);
575
576 HRESULT hr;
577 bool bCopy = TRUE;
578 bool bLinking = FALSE;
579
580 /* Figure out what drop operation we're doing */
581 if (pdwEffect)
582 {
583 TRACE("Current drop effect flag %i\n", *pdwEffect);
584 if ((*pdwEffect & DROPEFFECT_MOVE) == DROPEFFECT_MOVE)
585 bCopy = FALSE;
586 if ((*pdwEffect & DROPEFFECT_LINK) == DROPEFFECT_LINK)
587 bLinking = TRUE;
588 }
589
590 if (SUCCEEDED(hr = pDataObject->QueryGetData(&fmt)))
591 {
592 hr = pDataObject->GetData(&fmt, &medium);
593 TRACE("CFSTR_SHELLIDLIST\n");
594 if (FAILED(hr))
595 {
596 ERR("CFSTR_SHELLIDLIST failed\n");
597 }
598 /* lock the handle */
599 LPIDA lpcida = (LPIDA)GlobalLock(medium.hGlobal);
600 if (!lpcida)
601 {
602 ReleaseStgMedium(&medium);
603 return E_FAIL;
604 }
605
606 /* convert the data into pidl */
607 LPITEMIDLIST pidl;
608 LPITEMIDLIST *apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
609 if (!apidl)
610 {
611 ReleaseStgMedium(&medium);
612 return E_FAIL;
613 }
614
615 CComPtr<IShellFolder> psfDesktop;
616 CComPtr<IShellFolder> psfFrom = NULL;
617
618 /* Grab the desktop shell folder */
619 hr = SHGetDesktopFolder(&psfDesktop);
620 if (FAILED(hr))
621 {
622 ERR("SHGetDesktopFolder failed\n");
623 SHFree(pidl);
624 _ILFreeaPidl(apidl, lpcida->cidl);
625 ReleaseStgMedium(&medium);
626 return E_FAIL;
627 }
628
629 /* Find source folder, this is where the clipboard data was copied from */
630 if (_ILIsDesktop(pidl))
631 {
632 /* use desktop shell folder */
633 psfFrom = psfDesktop;
634 }
635 else
636 {
637 hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &psfFrom));
638 if (FAILED(hr))
639 {
640 ERR("no IShellFolder\n");
641 SHFree(pidl);
642 _ILFreeaPidl(apidl, lpcida->cidl);
643 ReleaseStgMedium(&medium);
644 return E_FAIL;
645 }
646 }
647
648 if (bLinking)
649 {
650 WCHAR wszNewLnk[MAX_PATH];
651
652 TRACE("target path = %s\n", debugstr_w(m_sPathTarget));
653
654 /* We need to create a link for each pidl in the copied items, so step through the pidls from the clipboard */
655 for (UINT i = 0; i < lpcida->cidl; i++)
656 {
657 SFGAOF att = SHGetAttributes(psfFrom, apidl[i], SFGAO_FOLDER | SFGAO_STREAM | SFGAO_FILESYSTEM);
658 CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlFull;
659 hr = SHILCombine(pidl, apidl[i], &pidlFull);
660
661 WCHAR targetName[MAX_PATH];
662 if (SUCCEEDED(hr))
663 {
664 // If the target is a file, we use SHGDN_FORPARSING because "NeverShowExt" will hide the ".lnk" extension.
665 // If the target is a virtual item, we ask for the friendly name because SHGDN_FORPARSING will return a GUID.
666 BOOL UseParsing = (att & (SFGAO_FILESYSTEM | SFGAO_FOLDER)) == SFGAO_FILESYSTEM;
667 DWORD ShgdnFor = UseParsing ? SHGDN_FORPARSING : SHGDN_FOREDITING;
668 hr = DisplayNameOfW(psfFrom, apidl[i], ShgdnFor | SHGDN_INFOLDER, targetName, _countof(targetName));
669 }
671 {
673 break;
674 }
676
677 WCHAR wszCombined[MAX_PATH + _countof(targetName)];
678 PathCombineW(wszCombined, m_sPathTarget, targetName);
679
680 // Check to see if the source is a link
681 BOOL fSourceIsLink = FALSE;
682 if (!_wcsicmp(PathFindExtensionW(targetName), L".lnk") && (att & (SFGAO_FOLDER | SFGAO_STREAM)) != SFGAO_FOLDER)
683 {
684 fSourceIsLink = TRUE;
685 PathRemoveExtensionW(wszCombined);
686 }
687
688 // Create a pathname to save the new link.
689 _GetUniqueFileName(wszCombined, L".lnk", wszNewLnk, TRUE);
690
691 CComPtr<IPersistFile> ppf;
692 if (fSourceIsLink)
693 {
694 PWSTR pwszTargetFull;
695 hr = SHGetNameFromIDList(pidlFull, SIGDN_DESKTOPABSOLUTEPARSING, &pwszTargetFull);
697 {
700 SHFree(pwszTargetFull);
701 }
702 }
703 else
704 {
705 CComPtr<IShellLinkW> pLink;
706 hr = CShellLink::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IShellLinkW, &pLink));
708 {
709 hr = pLink->SetIDList(pidlFull);
711 hr = pLink->QueryInterface(IID_PPV_ARG(IPersistFile, &ppf));
712
713 PWSTR pwszPath, pSep;
714 if ((att & SFGAO_FILESYSTEM) && SUCCEEDED(SHGetNameFromIDList(pidlFull, SIGDN_FILESYSPATH, &pwszPath)))
715 {
716 if ((pSep = PathFindFileNameW(pwszPath)) > pwszPath)
717 {
718 pSep[-1] = UNICODE_NULL;
719 pLink->SetWorkingDirectory(pwszPath);
720 }
721 SHFree(pwszPath);
722 }
723 }
724 }
725 if (SUCCEEDED(hr))
726 hr = ppf->Save(wszNewLnk, !fSourceIsLink);
728 {
730 break;
731 }
733 }
734 }
735 else
736 {
737 hr = _CopyItems(pDataObject, psfFrom, lpcida->cidl, (LPCITEMIDLIST*)apidl, bCopy);
738 }
739
740 SHFree(pidl);
741 _ILFreeaPidl(apidl, lpcida->cidl);
742 ReleaseStgMedium(&medium);
743 }
744 else if (SUCCEEDED(hr = pDataObject->QueryGetData(&fmt2)))
745 {
746 FORMATETC fmt2;
747 InitFormatEtc (fmt2, CF_HDROP, TYMED_HGLOBAL);
748 if (SUCCEEDED(hr = pDataObject->GetData(&fmt2, &medium)) /* && SUCCEEDED(pDataObject->GetData(&fmt2, &medium))*/)
749 {
750 WCHAR wszTargetPath[MAX_PATH + 1];
751 LPWSTR pszSrcList;
752
753 wcscpy(wszTargetPath, m_sPathTarget);
754 //Double NULL terminate.
755 wszTargetPath[wcslen(wszTargetPath) + 1] = '\0';
756
757 LPDROPFILES lpdf = (LPDROPFILES) GlobalLock(medium.hGlobal);
758 if (!lpdf)
759 {
760 ERR("Error locking global\n");
761 return E_FAIL;
762 }
763 pszSrcList = (LPWSTR) (((byte*) lpdf) + lpdf->pFiles);
764 ERR("Source file (just the first) = %s, target path = %s, bCopy: %d\n", debugstr_w(pszSrcList), debugstr_w(wszTargetPath), bCopy);
765
767 ZeroMemory(&op, sizeof(op));
768 op.pFrom = pszSrcList;
769 op.pTo = wszTargetPath;
770 op.hwnd = m_hwndSite;
771 op.wFunc = bCopy ? FO_COPY : FO_MOVE;
772 op.fFlags = GetDefaultFileOpFlags(pDataObject);
773 int res = SHFileOperationW(&op);
774 if (res)
775 {
776 ERR("SHFileOperationW failed with 0x%x\n", res);
777 hr = E_FAIL;
778 }
779
780 return hr;
781 }
782 ERR("Error calling GetData\n");
783 hr = E_FAIL;
784 }
785 else
786 {
787 ERR("No viable drop format\n");
788 hr = E_FAIL;
789 }
790 return hr;
791}
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(IDataObject *pDO, IShellFolder *pSFFrom, UINT cidl, LPCITEMIDLIST *apidl, BOOL bCopy)
BOOL _GetUniqueFileName(LPCWSTR pwszBasePath, LPCWSTR pwszExt, LPWSTR pwszTarget, BOOL bShortcut)
HRESULT hr
Definition: delayimp.cpp:582
UINT op
Definition: effect.c:236
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1922
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1250
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2014
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:510
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
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
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:2654
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1610
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2614
wcscpy
#define SHELL_ErrorBox
Definition: shellutils.h:126
struct CIDA * LPIDA
#define SHCNE_CREATE
Definition: shlobj.h:1907
#define SHCNF_PATHW
Definition: shlobj.h:1942
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:582
UINT cidl
Definition: shlobj.h:582
Definition: dsound.c:943
uint16_t * PWSTR
Definition: typedefs.h:56
uint16_t * LPWSTR
Definition: typedefs.h:56
#define IID_PPV_ARG(Itype, ppType)

Referenced by Drop().

◆ _DoDropThreadProc()

DWORD WINAPI CFSDropTarget::_DoDropThreadProc ( LPVOID  lpParameter)
staticprivate

Definition at line 793 of file CFSDropTarget.cpp.

794{
795 _DoDropData *data = static_cast<_DoDropData*>(lpParameter);
796 CComPtr<IDataObject> pDataObject;
798
799 if (SUCCEEDED(hr))
800 {
801 CComPtr<IAsyncOperation> pAsyncOperation;
802 hr = data->This->_DoDrop(pDataObject, data->dwKeyState, data->pt, &data->pdwEffect);
803 if (SUCCEEDED(pDataObject->QueryInterface(IID_PPV_ARG(IAsyncOperation, &pAsyncOperation))))
804 {
805 pAsyncOperation->EndOperation(hr, NULL, data->pdwEffect);
806 }
807 }
808 //Release the CFSFolder and data object holds in the copying thread.
809 data->This->Release();
810 //Release the parameter from the heap.
812 return 0;
813}
HRESULT WINAPI CoGetInterfaceAndReleaseStream(IStream *stream, REFIID riid, void **obj)
Definition: marshal.c:139
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 244 of file CFSDropTarget.cpp.

245{
247 if (!hmenu)
248 return E_OUTOFMEMORY;
250
251 SHELL_LimitDropEffectToItemAttributes(pDataObject, &dwAvailableEffects);
252 if ((dwAvailableEffects & DROPEFFECT_COPY) == 0)
254 if ((dwAvailableEffects & DROPEFFECT_MOVE) == 0)
256 if ((dwAvailableEffects & DROPEFFECT_LINK) == 0 && (dwAvailableEffects & (DROPEFFECT_COPY | DROPEFFECT_MOVE)))
258
260 if (*pdwEffect & dwAvailableEffects & DROPEFFECT_COPY)
262 else if (*pdwEffect & dwAvailableEffects & DROPEFFECT_MOVE)
264 else if (dwAvailableEffects & DROPEFFECT_LINK)
266
268 HDCIA hDCIA = DCIA_Create();
269 HDCMA hDCMA = DCMA_Create();
270 CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlFolder(SHELL32_CreateSimpleIDListFromPath(m_sPathTarget, FILE_ATTRIBUTE_DIRECTORY));
271 if (hDCMA && hDCIA && pidlFolder)
272 {
273 AddPidlClassKeysToArray(pidlFolder, keys, keys);
274 for (UINT i = 0; i < keys; ++i)
275 DCIA_AddShellExSubkey(hDCIA, keys[i], L"DragDropHandlers");
276
278 DCMA_InsertMenuItems(hDCMA, hDCIA, pidlFolder, pDataObject, keys, keys, &qcmi, 0, m_site);
279 }
280
281 /* We shouldn't use the site window here because the menu should work even when we don't have a site */
282 HWND hwndDummy = CreateWindowEx(0,
283 WC_STATIC,
284 NULL,
286 pt.x,
287 pt.y,
288 1,
289 1,
290 NULL,
291 NULL,
292 NULL,
293 NULL);
294
295 SetForegroundWindow(hwndDummy); // Required for aborting by pressing Esc when dragging from Explorer to desktop
296 UINT uCommand = TrackPopupMenu(hpopupmenu,
298 pt.x, pt.y, 0, hwndDummy, NULL);
299
300 DestroyWindow(hwndDummy);
301
302 HRESULT hr = S_FALSE; // S_FALSE means we did not handle the command
304 IDM_LINKHERE < DROPIDM_EXTFIRST && DROPIDM_EXTFIRST > 0);
305 if (uCommand >= DROPIDM_EXTFIRST && uCommand <= DROPIDM_EXTLAST)
306 {
307 CMINVOKECOMMANDINFO ici = { sizeof(ici), 0, m_hwndSite, MAKEINTRESOURCEA(uCommand - DROPIDM_EXTFIRST) };
308 ici.nShow = SW_SHOW;
310 ici.fMask |= CMIC_MASK_SHIFT_DOWN;
312 ici.fMask |= CMIC_MASK_CONTROL_DOWN;
313 DCMA_InvokeCommand(hDCMA, &ici);
314 hr = S_OK;
315 *pdwEffect = DROPEFFECT_NONE;
316 }
317 else if (uCommand == 0)
318 {
319 hr = S_OK;
320 *pdwEffect = DROPEFFECT_NONE;
321 }
322 else if (uCommand == IDM_COPYHERE)
323 *pdwEffect = DROPEFFECT_COPY;
324 else if (uCommand == IDM_MOVEHERE)
325 *pdwEffect = DROPEFFECT_MOVE;
326 else if (uCommand == IDM_LINKHERE)
327 *pdwEffect = DROPEFFECT_LINK;
328 else
330
331 DCMA_Destroy(hDCMA);
332 DCIA_Destroy(hDCIA);
334 return hr;
335}
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:418
#define DCMA_Create()
Definition: precomp.h:191
void DCIA_AddShellExSubkey(HDCIA hDCIA, HKEY hProgId, PCWSTR pszSubkey)
Definition: utils.cpp:1910
#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:19998
static HMENU hmenu
Definition: win.c:78
#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:1195
#define WC_STATIC
Definition: commctrl.h:4687
void AddPidlClassKeysToArray(LPCITEMIDLIST pidl, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:536
#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:5921
#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 185 of file CFSDropTarget.cpp.

186{
187 WCHAR wszLink[40];
188
189 if (!bShortcut)
190 {
191 if (!LoadStringW(shell32_hInstance, IDS_LNK_FILE, wszLink, _countof(wszLink)))
192 wszLink[0] = L'\0';
193 }
194
195 if (!bShortcut)
196 _swprintf(pwszTarget, L"%s%s%s", wszLink, pwszBasePath, pwszExt);
197 else
198 _swprintf(pwszTarget, L"%s%s", pwszBasePath, pwszExt);
199
200 for (UINT i = 2; PathFileExistsW(pwszTarget); ++i)
201 {
202 if (!bShortcut)
203 _swprintf(pwszTarget, L"%s%s (%u)%s", wszLink, pwszBasePath, i, pwszExt);
204 else
205 _swprintf(pwszTarget, L"%s (%u)%s", pwszBasePath, i, pwszExt);
206 }
207
208 return TRUE;
209}
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2583
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
#define LoadStringW
Definition: utils.h:64
#define IDS_LNK_FILE
Definition: shresdef.h:178

Referenced by _DoDrop().

◆ _QueryDrop()

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

Definition at line 214 of file CFSDropTarget.cpp.

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

Referenced by DragOver(), and Drop().

◆ _RepositionItems()

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

Definition at line 337 of file CFSDropTarget.cpp.

338{
339 CComPtr<IFolderView> pfv;
340 POINT ptDrag;
343 return hr;
344
345 hr = psfv->GetDragPoint(&ptDrag);
347 return hr;
348
349 PIDLIST_ABSOLUTE pidlFolder;
350 PUITEMID_CHILD *apidl;
351 UINT cidl;
352 hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
354 return hr;
355
356 CComHeapPtr<POINT> apt;
357 if (!apt.Allocate(cidl))
358 {
359 SHFree(pidlFolder);
360 _ILFreeaPidl(apidl, cidl);
361 return E_OUTOFMEMORY;
362 }
363
364 for (UINT i = 0; i<cidl; i++)
365 {
366 pfv->GetItemPosition(apidl[i], &apt[i]);
367 apt[i].x += pt.x - ptDrag.x;
368 apt[i].y += pt.y - ptDrag.y;
369 }
370
371 pfv->SelectAndPositionItems(cidl, apidl, apt, SVSI_SELECT);
372
373 SHFree(pidlFolder);
374 _ILFreeaPidl(apidl, cidl);
375 return S_OK;
376}
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:542
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 378 of file CFSDropTarget.cpp.

380{
381 TRACE("(%p)->(DataObject=%p)\n", this, pDataObject);
382
383 const BOOL bAnyKeyMod = dwKeyState & (MK_SHIFT | MK_CONTROL);
384 m_AllowedEffects = *pdwEffect;
385
386 if (*pdwEffect == DROPEFFECT_NONE)
387 return S_OK;
388
389 FORMATETC fmt;
390 FORMATETC fmt2;
392
393 InitFormatEtc (fmt, m_cfShellIDList, TYMED_HGLOBAL);
394 InitFormatEtc (fmt2, CF_HDROP, TYMED_HGLOBAL);
395
396 if (SUCCEEDED(pDataObject->QueryGetData(&fmt)))
398 else if (SUCCEEDED(pDataObject->QueryGetData(&fmt2)))
400
401 m_grfKeyState = dwKeyState;
402
403 SHELL_LimitDropEffectToItemAttributes(pDataObject, pdwEffect);
404 m_AllowedEffects = *pdwEffect;
406 switch (*pdwEffect & (D_COPY | D_MOVE | D_LINK))
407 {
408 case D_COPY | D_MOVE:
409 if (dwKeyState & MK_CONTROL)
411 else
413 break;
414 case D_COPY | D_MOVE | D_LINK:
415 if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT | MK_CONTROL))
417 else if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == MK_CONTROL)
419 else
421 break;
422 case D_COPY | D_LINK:
423 if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT | MK_CONTROL))
425 else
427 break;
428 case D_MOVE | D_LINK:
429 if ((dwKeyState & (MK_SHIFT | MK_CONTROL)) == (MK_SHIFT | MK_CONTROL))
431 else
433 break;
434 }
435
436 STGMEDIUM medium;
437 if (SUCCEEDED(pDataObject->GetData(&fmt2, &medium)))
438 {
439 WCHAR wstrFirstFile[MAX_PATH];
440 if (DragQueryFileW((HDROP)medium.hGlobal, 0, wstrFirstFile, _countof(wstrFirstFile)))
441 {
442 if (!PathIsSameDrive(wstrFirstFile, m_sPathTarget) && m_dwDefaultEffect != D_LINK)
443 {
445 }
446
447 if (!bAnyKeyMod && PathIsDriveRoot(wstrFirstFile) && (m_AllowedEffects & DROPEFFECT_LINK))
448 {
449 m_dwDefaultEffect = DROPEFFECT_LINK; // Don't copy a drive by default
450 }
451 }
452 ReleaseStgMedium(&medium);
453 }
454
455 if (!m_fAcceptFmt)
457 else
458 *pdwEffect = m_dwDefaultEffect;
459 *pdwEffect &= m_AllowedEffects;
460
461 return S_OK;
462}
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 ( )
override

Implements IDropTarget.

Definition at line 479 of file CFSDropTarget.cpp.

480{
481 TRACE("(%p)\n", this);
482
484
485 return S_OK;
486}

◆ DragOver()

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

Implements IDropTarget.

Definition at line 464 of file CFSDropTarget.cpp.

466{
467 TRACE("(%p)\n", this);
468
469 if (!pdwEffect)
470 return E_INVALIDARG;
471
472 m_grfKeyState = dwKeyState;
473
474 _QueryDrop(dwKeyState, pdwEffect);
475
476 return S_OK;
477}
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 488 of file CFSDropTarget.cpp.

490{
491 TRACE("(%p) object dropped, effect %u\n", this, *pdwEffect);
492
493 if (!pdwEffect)
494 return E_INVALIDARG;
495
497
498 DWORD dwAvailableEffects = *pdwEffect;
499
500 _QueryDrop(dwKeyState, pdwEffect);
501
502 TRACE("pdwEffect: 0x%x, m_dwDefaultEffect: 0x%x, dwAvailableEffects: 0x%x\n", *pdwEffect, m_dwDefaultEffect, dwAvailableEffects);
503
505 {
506 HRESULT hr = _GetEffectFromMenu(pDataObject, pt, pdwEffect, dwAvailableEffects);
507 if (FAILED_UNEXPECTEDLY(hr) || hr == S_OK)
508 return hr;
509 }
510
511 if (*pdwEffect == DROPEFFECT_MOVE && m_site)
512 {
513 CComPtr<IShellFolderView> psfv;
514 HRESULT hr = IUnknown_QueryService(m_site, SID_SFolderView, IID_PPV_ARG(IShellFolderView, &psfv));
515 if (SUCCEEDED(hr) && psfv->IsDropOnSource(this) == S_OK)
516 {
517 _RepositionItems(psfv, pDataObject, pt);
518 return S_OK;
519 }
520 }
521
522 BOOL fIsOpAsync = FALSE;
523 CComPtr<IAsyncOperation> pAsyncOperation;
524
525 if (SUCCEEDED(pDataObject->QueryInterface(IID_PPV_ARG(IAsyncOperation, &pAsyncOperation))))
526 {
527 if (SUCCEEDED(pAsyncOperation->GetAsyncMode(&fIsOpAsync)) && fIsOpAsync)
528 {
529 _DoDropData *data = static_cast<_DoDropData*>(HeapAlloc(GetProcessHeap(), 0, sizeof(_DoDropData)));
530 data->This = this;
531 // Need to maintain this class in case the window is closed or the class exists temporarily (when dropping onto a folder).
532 pDataObject->AddRef();
533 pAsyncOperation->StartOperation(NULL);
535 this->AddRef();
536 data->dwKeyState = dwKeyState;
537 data->pt = pt;
538 // Need to dereference as pdweffect gets freed.
539 data->pdwEffect = *pdwEffect;
541 return S_OK;
542 }
543 }
544 return this->_DoDrop(pDataObject, dwKeyState, pt, pdwEffect);
545}
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, IUnknown *unk, IStream **stream)
Definition: marshal.c:154
HRESULT WINAPI IUnknown_QueryService(IUnknown *obj, REFGUID sid, REFIID iid, void **out)
Definition: main.c:181
BOOL WINAPI SHCreateThread(LPTHREAD_START_ROUTINE thread_proc, void *data, DWORD flags, LPTHREAD_START_ROUTINE callback)
Definition: main.c:1628
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:988
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 557 of file CFSDropTarget.cpp.

558{
559 if (!m_site)
560 return E_FAIL;
561
562 return m_site->QueryInterface(riid, ppvSite);
563}
REFIID riid
Definition: atlbase.h:39

◆ Initialize()

HRESULT CFSDropTarget::Initialize ( LPWSTR  PathTarget)

Definition at line 167 of file CFSDropTarget.cpp.

168{
169 if (!PathTarget)
170 return E_UNEXPECTED;
171
173 if (!m_cfShellIDList)
174 return E_FAIL;
175
176 return SHStrDupW(PathTarget, &m_sPathTarget);
177}
HRESULT WINAPI SHStrDupW(const WCHAR *src, WCHAR **dest)
Definition: main.c:1692
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:560
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)

◆ SetSite()

HRESULT WINAPI CFSDropTarget::SetSite ( IUnknown pUnkSite)
override

Implements IObjectWithSite.

Definition at line 549 of file CFSDropTarget.cpp.

550{
551 m_site = pUnkSite;
552 return S_OK;
553}

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: