ReactOS  0.4.15-dev-985-gd905dd5
CMyDocsDropHandler Class Reference

#include <CMyDocsDropHandler.hpp>

Inheritance diagram for CMyDocsDropHandler:
Collaboration diagram for CMyDocsDropHandler:

Public Member Functions

 CMyDocsDropHandler ()
 
 ~CMyDocsDropHandler ()
 
STDMETHODIMP DragEnter (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
STDMETHODIMP DragOver (DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
STDMETHODIMP DragLeave ()
 
STDMETHODIMP Drop (IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect)
 
STDMETHODIMP GetClassID (CLSID *lpClassId)
 
STDMETHODIMP GetCurFile (LPOLESTR *ppszFileName)
 
STDMETHODIMP IsDirty ()
 
STDMETHODIMP Load (LPCOLESTR pszFileName, DWORD dwMode)
 
STDMETHODIMP Save (LPCOLESTR pszFileName, BOOL fRemember)
 
STDMETHODIMP SaveCompleted (LPCOLESTR pszFileName)
 
- 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 ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Additional Inherited Members

- Public Types inherited from IDropTarget
typedef IDropTargetLPDROPTARGET
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IPersistFile
typedef IPersistFileLPPERSISTFILE
 
- Public Types inherited from IPersist
typedef IPersistLPPERSIST
 
- 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 12 of file CMyDocsDropHandler.hpp.

Constructor & Destructor Documentation

◆ CMyDocsDropHandler()

CMyDocsDropHandler::CMyDocsDropHandler ( )

Definition at line 14 of file CMyDocsDropHandler.cpp.

15 {
17 }
LONG g_ModuleRefCnt
Definition: ACPPage.cpp:13
#define InterlockedIncrement
Definition: armddk.h:53

◆ ~CMyDocsDropHandler()

CMyDocsDropHandler::~CMyDocsDropHandler ( )

Definition at line 19 of file CMyDocsDropHandler.cpp.

20 {
22 }
LONG g_ModuleRefCnt
Definition: ACPPage.cpp:13
#define InterlockedDecrement
Definition: armddk.h:52

Member Function Documentation

◆ DragEnter()

STDMETHODIMP CMyDocsDropHandler::DragEnter ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)

Implements IDropTarget.

Definition at line 26 of file CMyDocsDropHandler.cpp.

28 {
29  TRACE("(%p)\n", this);
30 
31  *pdwEffect &= DROPEFFECT_COPY; // Copy only
32 
33  return S_OK;
34 }
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ DragLeave()

STDMETHODIMP CMyDocsDropHandler::DragLeave ( void  )

Implements IDropTarget.

Definition at line 46 of file CMyDocsDropHandler.cpp.

47 {
48  TRACE("(%p)\n", this);
49  return S_OK;
50 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

Referenced by Drop().

◆ DragOver()

STDMETHODIMP CMyDocsDropHandler::DragOver ( DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)

Implements IDropTarget.

Definition at line 37 of file CMyDocsDropHandler.cpp.

38 {
39  TRACE("(%p)\n", this);
40 
41  *pdwEffect &= DROPEFFECT_COPY; // Copy only
42 
43  return S_OK;
44 }
const DWORD DROPEFFECT_COPY
Definition: oleidl.idl:930
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ Drop()

STDMETHODIMP CMyDocsDropHandler::Drop ( IDataObject pDataObject,
DWORD  dwKeyState,
POINTL  pt,
DWORD pdwEffect 
)

Implements IDropTarget.

Definition at line 53 of file CMyDocsDropHandler.cpp.

55 {
56  TRACE("(%p)\n", this);
57 
58  if (!pDataObject)
59  {
60  ERR("pDataObject is NULL\n");
61  *pdwEffect = 0;
62  DragLeave();
63  return E_POINTER;
64  }
65 
66  CComPtr<IShellFolder> pDesktop;
67  HRESULT hr = SHGetDesktopFolder(&pDesktop);
69  return hr;
70 
71  // get the clipboard format
72  if (g_cfHIDA == 0)
74 
75  // Retrieve an HIDA (handle of IDA)
76  STGMEDIUM medium;
77  FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
78  hr = pDataObject->GetData(&fmt, &medium);
80  {
81  *pdwEffect = 0;
82  DragLeave();
83  return E_FAIL;
84  }
85 
86  // lock HIDA
87  LPIDA pida = reinterpret_cast<LPIDA>(GlobalLock(medium.hGlobal));
88  UINT iItem, cItems = pida->cidl;
89 
90  // get the path of "My Documents"
91  WCHAR szzDir[MAX_PATH + 1];
93  szzDir[lstrlenW(szzDir) + 1] = 0; // ends with double NULs
94 
95  // for all source items
96  CStringW strSrcList;
97  WCHAR szSrc[MAX_PATH];
98  PCIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(pida);
99  for (iItem = 0; iItem < cItems; ++iItem)
100  {
101  // query source pidl
102  PCITEMID_CHILD pidlChild = HIDA_GetPIDLItem(pida, iItem);
103  CComHeapPtr<ITEMIDLIST> pidl(ILCombine(pidlParent, pidlChild));
104 
105  // can get path?
106  szSrc[0] = 0;
107  if (!SHGetPathFromIDListW(pidl, szSrc))
108  {
109  // try to retrieve path from desktop
110  STRRET strret;
111  hr = pDesktop->GetDisplayNameOf(pidl, SHGDN_INFOLDER, &strret);
112  if (FAILED_UNEXPECTEDLY(hr))
113  break;
114  hr = StrRetToBufW(&strret, pidl, szSrc, _countof(szSrc));
115  if (FAILED_UNEXPECTEDLY(hr))
116  break;
117  if (!PathFileExistsW(szSrc))
118  break;
119  }
120 
121  if (iItem > 0)
122  strSrcList += L'|'; // separator is '|'
123  strSrcList += szSrc;
124  }
125 
126  // unlock HIDA
127  GlobalUnlock(medium.hGlobal);
128 
129  if (iItem != cItems)
130  {
131  // source not found
132  CStringW strText;
133  strText.Format(IDS_NOSRCFILEFOUND, szSrc[0] ? szSrc : L"(null)");
134  MessageBoxW(NULL, strText, NULL, MB_ICONERROR);
135 
136  *pdwEffect = 0;
137  DragLeave();
138  return E_FAIL;
139  }
140 
141  strSrcList += L"||"; // double separators
142 
143  // lock the buffer
144  LPWSTR pszzSrcList = strSrcList.GetBuffer();
145 
146  // convert every separator to a NUL
147  INT cch = strSrcList.GetLength();
148  for (INT i = 0; i < cch; ++i)
149  {
150  if (pszzSrcList[i] == L'|')
151  pszzSrcList[i] = L'\0';
152  }
153 
154  // copy them
155  SHFILEOPSTRUCTW fileop = { NULL };
156  fileop.wFunc = FO_COPY;
157  fileop.pFrom = pszzSrcList;
158  fileop.pTo = szzDir;
160  int res = SHFileOperationW(&fileop);
161  if (res)
162  {
163  ERR("SHFileOperationW failed with 0x%x\n", res);
164  hr = E_FAIL;
165  }
166 
167  // unlock buffer
168  strSrcList.ReleaseBuffer();
169 
170  DragLeave();
171  return hr;
172 }
int GetLength() const
Definition: atlsimpstr.h:356
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:477
HRESULT hr
Definition: shlfolder.c:183
STDMETHODIMP DragLeave()
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define FO_COPY
Definition: shellapi.h:134
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:543
#define FOF_ALLOWUNDO
Definition: shellapi.h:144
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:716
#define IDS_NOSRCFILEFOUND
Definition: resource.h:13
FILEOP_FLAGS fFlags
Definition: shellapi.h:357
static CLIPFORMAT g_cfHIDA
#define lstrlenW
Definition: compat.h:498
#define E_FAIL
Definition: ddrawi.h:102
int32_t INT
Definition: typedefs.h:58
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1918
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
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:201
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1756
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define FOF_FILESONLY
Definition: shellapi.h:145
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define MAX_PATH
Definition: compat.h:34
UINT cidl
Definition: shlobj.h:499
LPCWSTR pFrom
Definition: shellapi.h:355
static const WCHAR L[]
Definition: oid.c:1250
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define MB_ICONERROR
Definition: winuser.h:781
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:538
#define ERR(fmt,...)
Definition: debug.h:110
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2709
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define CSIDL_PERSONAL
Definition: shlobj.h:2017
GLuint res
Definition: glext.h:9613
#define FOF_MULTIDESTFILES
Definition: shellapi.h:138
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_POINTER
Definition: winerror.h:2365
#define FOF_NOCONFIRMMKDIR
Definition: shellapi.h:147
Definition: dsound.c:943
Definition: shlobj.h:498

◆ GetClassID()

STDMETHODIMP CMyDocsDropHandler::GetClassID ( CLSID lpClassId)

Implements IPersist.

Definition at line 205 of file CMyDocsDropHandler.cpp.

206 {
207  TRACE("(%p)\n", this);
208 
209  if (!lpClassId)
210  {
211  ERR("lpClassId is NULL\n");
212  return E_POINTER;
213  }
214 
215  *lpClassId = CLSID_MyDocsDropHandler;
216 
217  return S_OK;
218 }
#define TRACE(s)
Definition: solgame.cpp:4
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:59
#define E_POINTER
Definition: winerror.h:2365

◆ GetCurFile()

STDMETHODIMP CMyDocsDropHandler::GetCurFile ( LPOLESTR ppszFileName)

Implements IPersistFile.

Definition at line 175 of file CMyDocsDropHandler.cpp.

176 {
177  FIXME("(%p)\n", this);
178  return E_NOTIMPL;
179 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ IsDirty()

STDMETHODIMP CMyDocsDropHandler::IsDirty ( void  )

Implements IPersistFile.

Definition at line 181 of file CMyDocsDropHandler.cpp.

182 {
183  FIXME("(%p)\n", this);
184  return E_NOTIMPL;
185 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Load()

STDMETHODIMP CMyDocsDropHandler::Load ( LPCOLESTR  pszFileName,
DWORD  dwMode 
)

Implements IPersistFile.

Definition at line 187 of file CMyDocsDropHandler.cpp.

188 {
189  return S_OK;
190 }
#define S_OK
Definition: intsafe.h:59

◆ Save()

STDMETHODIMP CMyDocsDropHandler::Save ( LPCOLESTR  pszFileName,
BOOL  fRemember 
)

Implements IPersistFile.

Definition at line 192 of file CMyDocsDropHandler.cpp.

193 {
194  FIXME("(%p)\n", this);
195  return E_NOTIMPL;
196 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ SaveCompleted()

STDMETHODIMP CMyDocsDropHandler::SaveCompleted ( LPCOLESTR  pszFileName)

Implements IPersistFile.

Definition at line 198 of file CMyDocsDropHandler.cpp.

199 {
200  FIXME("(%p)\n", this);
201  return E_NOTIMPL;
202 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

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