ReactOS 0.4.15-dev-8096-ga0eec98
CSendToZip.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Zip Shell Extension
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: SendTo handler
5 * COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
6 * Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
7 */
8
9#include "precomp.h"
10
13 DWORD *pdwEffect)
14{
15 m_pDataObject = pDataObj;
16
17 FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
18 m_fCanDragDrop = SUCCEEDED(pDataObj->QueryGetData(&etc));
19
21 *pdwEffect &= DROPEFFECT_COPY;
22 else
23 *pdwEffect = DROPEFFECT_NONE;
24
25 return S_OK;
26}
27
29{
31 *pdwEffect &= DROPEFFECT_COPY;
32 else
33 *pdwEffect = DROPEFFECT_NONE;
34
35 return S_OK;
36}
37
39{
42 return S_OK;
43}
44
46CSendToZip::Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt,
47 DWORD *pdwEffect)
48{
49 m_pDataObject = pDataObj;
50
51 if (!pDataObj || !m_fCanDragDrop)
52 {
53 DPRINT1("Drop failed: %d %d\n", !pDataObj, !m_fCanDragDrop);
54 *pdwEffect = 0;
55 DragLeave();
56 return E_FAIL;
57 }
58
59 STGMEDIUM stg;
60 FORMATETC etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
61 HRESULT hr = pDataObj->GetData(&etc, &stg);
63 {
64 *pdwEffect = 0;
65 DragLeave();
66 return E_FAIL;
67 }
68
69 HDROP hDrop = reinterpret_cast<HDROP>(stg.hGlobal);
70 UINT cItems = ::DragQueryFileW(hDrop, -1, NULL, 0);
71
73
74 for (UINT iItem = 0; iItem < cItems; ++iItem)
75 {
77 DragQueryFileW(hDrop, iItem, szPath, _countof(szPath));
78
79 pCreator->DoAddItem(szPath);
80 }
81
83
84 CZipCreator::runThread(pCreator); // pCreator is deleted in runThread
85
86 DragLeave();
87 return hr;
88}
#define CF_HDROP
Definition: constants.h:410
#define DPRINT1
Definition: precomp.h:8
#define STDMETHODIMP
Definition: basetyps.h:43
void Release()
Definition: atlcomcli.h:170
STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
Definition: CSendToZip.cpp:28
STDMETHODIMP DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
Definition: CSendToZip.cpp:12
STDMETHODIMP Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect)
Definition: CSendToZip.cpp:46
BOOL m_fCanDragDrop
Definition: CSendToZip.hpp:19
CComPtr< IDataObject > m_pDataObject
Definition: CSendToZip.hpp:18
STDMETHODIMP DragLeave()
Definition: CSendToZip.cpp:38
static CZipCreator * DoCreate()
Definition: CZipCreator.hpp:20
static BOOL runThread(CZipCreator *pCreator)
virtual void DoAddItem(PCWSTR pszFile)
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:622
#define pt(x, y)
Definition: drawing.c:79
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
HRESULT QueryGetData([in, unique] FORMATETC *pformatetc)
const DWORD DROPEFFECT_NONE
Definition: oleidl.idl:929
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
LPCWSTR szPath
Definition: env.c:37
unsigned int UINT
Definition: ndis.h:50
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180