ReactOS 0.4.15-dev-8207-gd73a838
CDataObject.cpp File Reference
#include "precomp.h"
Include dependency graph for CDataObject.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (fontext)
 
HRESULT _CDataObject_CreateInstance (PCIDLIST_ABSOLUTE folder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, LPVOID *ppvOut)
 

Function Documentation

◆ _CDataObject_CreateInstance()

HRESULT _CDataObject_CreateInstance ( PCIDLIST_ABSOLUTE  folder,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 38 of file CDataObject.cpp.

40{
41 HRESULT hr = CIDLData_CreateFromIDArray(folder, cidl, apidl, (IDataObject**)ppvOut);
43 return hr;
44
45 // Now that we have an IDataObject with the shell itemid list (CFSTR_SHELLIDLIST, aka HIDA) format
46 // we will augment this IDataObject with the CF_HDROP format. (Full filepaths)
47 // This enabled the objects for the 'copy' and drag to copy actions
48
50
51 // First we allocate room for the DROPFILES structure
52 data.AllocateBytes(sizeof(DROPFILES));
53 UINT offset = sizeof(DROPFILES);
54
55 // Then we walk all files
56 for (UINT n = 0; n < cidl; ++n)
57 {
58 const FontPidlEntry* fontEntry = _FontFromIL(apidl[n]);
59 if (fontEntry)
60 {
61 CStringW File = g_FontCache->Filename(g_FontCache->Find(fontEntry), true);
62 if (!File.IsEmpty())
63 {
64 // Now append the path (+ nullterminator) to the buffer
65 UINT len = offset + (File.GetLength() + 1) * sizeof(WCHAR);
66 data.ReallocateBytes(len);
67 if (!data)
68 {
69 ERR("Unable to allocate memory for the CF_HDROP\n");
70 return hr;
71 }
72 BYTE* dataPtr = data;
74 offset = len;
75 }
76 else
77 {
78 ERR("No file found for %S\n", fontEntry->Name);
79 }
80 }
81 }
82
83 // Append the final nullterminator (double null terminated list)
84 data.ReallocateBytes(offset + sizeof(UNICODE_NULL));
87 offset += sizeof(UNICODE_NULL);
88
89 // Fill in the required fields
90 DROPFILES* pDrop = (DROPFILES*)(BYTE*)data;
91 pDrop->fWide = 1;
92 pDrop->pFiles = sizeof(DROPFILES);
93 // Zero out the rest
94 pDrop->pt.x = pDrop->pt.y = 0;
95 pDrop-> fNC = NULL;
96
99
100 return hr;
101}
CFontCache * g_FontCache
Definition: CFontCache.cpp:12
#define CF_HDROP
Definition: constants.h:410
#define ERR(fmt,...)
Definition: debug.h:113
CStringW Filename(CFontInfo *info, bool alwaysFullPath=false)
Definition: CFontCache.cpp:164
CFontInfo * Find(const FontPidlEntry *fontEntry)
Definition: CFontCache.cpp:145
Definition: File.h:16
#define NULL
Definition: types.h:112
static HRESULT WINAPI DataObject_SetData(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
Definition: view.c:203
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
const FontPidlEntry * _FontFromIL(LPCITEMIDLIST pidl)
Definition: fontpidl.cpp:32
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
unsigned int UINT
Definition: ndis.h:50
#define UNICODE_NULL
wchar_t * STRSAFE_LPWSTR
Definition: ntstrsafe.h:53
const WCHAR * str
HRESULT WINAPI CIDLData_CreateFromIDArray(PCIDLIST_ABSOLUTE pidlFolder, UINT cpidlFiles, PCUIDLIST_RELATIVE_ARRAY lppidlFiles, LPDATAOBJECT *ppdataObject)
Definition: shellord.c:2213
HRESULT hr
Definition: shlfolder.c:183
struct _DROPFILES DROPFILES
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
WCHAR Name[1]
Definition: fontpidl.hpp:17
DWORD pFiles
Definition: shlobj.h:2300
BOOL fWide
Definition: shlobj.h:2303
POINT pt
Definition: shlobj.h:2301
Definition: fci.c:116
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CFontExt::GetUIObjectOf().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( fontext  )