mirror of
https://github.com/reactos/reactos.git
synced 2025-06-17 18:45:19 +00:00
[SDK][SHELL32] Augment the internally used IDataObject with some extra formats
This is needed because our code seems to use CF_HDROP a lot, instead of HIDA...
This commit is contained in:
parent
f9d3c2c608
commit
c31327114b
10 changed files with 58 additions and 15 deletions
|
@ -143,7 +143,7 @@ private:
|
||||||
public:
|
public:
|
||||||
CIDLDataObj();
|
CIDLDataObj();
|
||||||
~CIDLDataObj();
|
~CIDLDataObj();
|
||||||
HRESULT WINAPI Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx);
|
HRESULT WINAPI Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx, BOOL bAddAdditionalFormats);
|
||||||
|
|
||||||
// *** IDataObject methods ***
|
// *** IDataObject methods ***
|
||||||
virtual HRESULT WINAPI GetData(LPFORMATETC pformatetcIn, STGMEDIUM *pmedium);
|
virtual HRESULT WINAPI GetData(LPFORMATETC pformatetcIn, STGMEDIUM *pmedium);
|
||||||
|
@ -187,7 +187,7 @@ CIDLDataObj::~CIDLDataObj()
|
||||||
m_Storage.RemoveAll();
|
m_Storage.RemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx)
|
HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx, BOOL bAddAdditionalFormats)
|
||||||
{
|
{
|
||||||
HGLOBAL hida = RenderSHELLIDLIST((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
|
HGLOBAL hida = RenderSHELLIDLIST((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
|
||||||
if (!hida)
|
if (!hida)
|
||||||
|
@ -198,12 +198,33 @@ HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl
|
||||||
|
|
||||||
m_cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
|
m_cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
|
||||||
|
|
||||||
FORMATETC HIDAFormat = { (CLIPFORMAT)m_cfShellIDList, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
|
FORMATETC Format = { (CLIPFORMAT)m_cfShellIDList, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
|
||||||
STGMEDIUM medium = {0};
|
STGMEDIUM medium = {0};
|
||||||
medium.tymed = TYMED_HGLOBAL;
|
medium.tymed = TYMED_HGLOBAL;
|
||||||
medium.hGlobal = hida;
|
medium.hGlobal = hida;
|
||||||
|
HRESULT hr = SetData(&Format, &medium, TRUE);
|
||||||
|
if (!FAILED_UNEXPECTEDLY(hr) && bAddAdditionalFormats)
|
||||||
|
{
|
||||||
|
Format.cfFormat = CF_HDROP;
|
||||||
|
medium.hGlobal = RenderHDROP((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
|
||||||
|
hr = SetData(&Format, &medium, TRUE);
|
||||||
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
|
return hr;
|
||||||
|
|
||||||
return SetData(&HIDAFormat, &medium, TRUE);
|
Format.cfFormat = RegisterClipboardFormatA(CFSTR_FILENAMEA);
|
||||||
|
medium.hGlobal = RenderFILENAMEA((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
|
||||||
|
hr = SetData(&Format, &medium, TRUE);
|
||||||
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
|
return hr;
|
||||||
|
|
||||||
|
Format.cfFormat = RegisterClipboardFormatW(CFSTR_FILENAMEW);
|
||||||
|
medium.hGlobal = RenderFILENAMEW((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
|
||||||
|
hr = SetData(&Format, &medium, TRUE);
|
||||||
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,11 +376,11 @@ HRESULT WINAPI CIDLDataObj::EndOperation(HRESULT hResult, IBindCtx *pbcReserved,
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* IDataObject_Constructor
|
* IDataObject_Constructor
|
||||||
*/
|
*/
|
||||||
HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, IDataObject **dataObject)
|
HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject)
|
||||||
{
|
{
|
||||||
if (!dataObject)
|
if (!dataObject)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
return ShellObjectCreatorInit<CIDLDataObj>(hwndOwner, pMyPidl, apidl, cidl, IID_PPV_ARG(IDataObject, dataObject));
|
return ShellObjectCreatorInit<CIDLDataObj>(hwndOwner, pMyPidl, apidl, cidl, bExtendedObject, IID_PPV_ARG(IDataObject, dataObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -373,7 +394,7 @@ HRESULT WINAPI SHCreateDataObject(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUIT
|
||||||
{
|
{
|
||||||
if (pdtInner)
|
if (pdtInner)
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return CIDLData_CreateFromIDArray(pidlFolder, cidl, apidl, (IDataObject **)ppv);
|
return IDataObject_Constructor(NULL, pidlFolder, apidl, cidl, TRUE, (IDataObject **)ppv);
|
||||||
}
|
}
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,7 +459,7 @@ HRESULT WINAPI CControlPanelFolder::GetUIObjectOf(HWND hwndOwner,
|
||||||
else
|
else
|
||||||
hr = m_regFolder->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, &pObj);
|
hr = m_regFolder->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, &pObj);
|
||||||
} else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1)) {
|
} else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1)) {
|
||||||
hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj);
|
hr = IDataObject_Constructor(hwndOwner, pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
|
||||||
} else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW)) && (cidl == 1)) {
|
} else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW)) && (cidl == 1)) {
|
||||||
if (_ILGetCPanelPointer(apidl[0]))
|
if (_ILGetCPanelPointer(apidl[0]))
|
||||||
hr = CCPLExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
|
hr = CCPLExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
|
||||||
|
|
|
@ -636,7 +636,7 @@ HRESULT WINAPI CDesktopFolder::GetUIObjectOf(
|
||||||
}
|
}
|
||||||
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
|
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
|
||||||
{
|
{
|
||||||
hr = IDataObject_Constructor( hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj);
|
hr = IDataObject_Constructor( hwndOwner, pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
|
||||||
}
|
}
|
||||||
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
|
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
|
||||||
{
|
{
|
||||||
|
|
|
@ -784,7 +784,7 @@ HRESULT WINAPI CDrivesFolder::GetUIObjectOf(HWND hwndOwner,
|
||||||
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
|
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
|
||||||
{
|
{
|
||||||
hr = IDataObject_Constructor (hwndOwner,
|
hr = IDataObject_Constructor (hwndOwner,
|
||||||
pidlRoot, apidl, cidl, (IDataObject **)&pObj);
|
pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
|
||||||
}
|
}
|
||||||
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
|
else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1064,7 +1064,7 @@ HRESULT WINAPI CFSFolder::GetUIObjectOf(HWND hwndOwner,
|
||||||
{
|
{
|
||||||
if (cidl >= 1)
|
if (cidl >= 1)
|
||||||
{
|
{
|
||||||
hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj);
|
hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -427,7 +427,7 @@ HRESULT WINAPI CNetFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CH
|
||||||
else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1))
|
else if (IsEqualIID(riid, IID_IDataObject) && (cidl >= 1))
|
||||||
{
|
{
|
||||||
IDataObject * pDo = NULL;
|
IDataObject * pDo = NULL;
|
||||||
hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, &pDo);
|
hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, TRUE, &pDo);
|
||||||
pObj = pDo;
|
pObj = pDo;
|
||||||
}
|
}
|
||||||
else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW)) && (cidl == 1))
|
else if ((IsEqualIID(riid, IID_IExtractIconA) || IsEqualIID(riid, IID_IExtractIconW)) && (cidl == 1))
|
||||||
|
|
|
@ -533,7 +533,7 @@ HRESULT WINAPI CRegFolder::GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CH
|
||||||
}
|
}
|
||||||
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
|
else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
|
||||||
{
|
{
|
||||||
hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, (IDataObject **)&pObj);
|
hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,7 @@ DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLS
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Class constructors
|
* Class constructors
|
||||||
*/
|
*/
|
||||||
HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, PCUITEMID_CHILD_ARRAY apidl, UINT cidl, IDataObject **dataObject);
|
HRESULT IDataObject_Constructor(HWND hwndOwner, LPCITEMIDLIST pMyPidl, PCUITEMID_CHILD_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject);
|
||||||
HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **enumerator);
|
HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **enumerator);
|
||||||
|
|
||||||
LPCLASSFACTORY IClassFactory_Constructor(REFCLSID);
|
LPCLASSFACTORY IClassFactory_Constructor(REFCLSID);
|
||||||
|
|
|
@ -1791,7 +1791,7 @@ HRESULT WINAPI CIDLData_CreateFromIDArray(
|
||||||
pdump (pidlFolder);
|
pdump (pidlFolder);
|
||||||
for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
|
for (i=0; i<cpidlFiles; i++) pdump (lppidlFiles[i]);
|
||||||
}
|
}
|
||||||
hResult = IDataObject_Constructor(hwnd, pidlFolder, lppidlFiles, cpidlFiles, ppdataObject);
|
hResult = IDataObject_Constructor(hwnd, pidlFolder, lppidlFiles, cpidlFiles, FALSE, ppdataObject);
|
||||||
return hResult;
|
return hResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,6 +378,28 @@ HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4
|
||||||
return hResult;
|
return hResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T, class T1, class T2, class T3, class T4, class T5>
|
||||||
|
HRESULT inline ShellObjectCreatorInit(T1 initArg1, T2 initArg2, T3 initArg3, T4 initArg4, T5 initArg5, REFIID riid, void ** ppv)
|
||||||
|
{
|
||||||
|
_CComObject<T> *pobj;
|
||||||
|
HRESULT hResult;
|
||||||
|
|
||||||
|
hResult = _CComObject<T>::CreateInstance(&pobj);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
return hResult;
|
||||||
|
|
||||||
|
pobj->AddRef(); /* CreateInstance returns object with 0 ref count */
|
||||||
|
|
||||||
|
hResult = pobj->Initialize(initArg1, initArg2, initArg3, initArg4, initArg5);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hResult))
|
||||||
|
hResult = pobj->QueryInterface(riid, reinterpret_cast<void **>(ppv));
|
||||||
|
|
||||||
|
pobj->Release(); /* In case of failure the object will be released */
|
||||||
|
|
||||||
|
return hResult;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT inline SHSetStrRet(LPSTRRET pStrRet, LPCSTR pstrValue)
|
HRESULT inline SHSetStrRet(LPSTRRET pStrRet, LPCSTR pstrValue)
|
||||||
{
|
{
|
||||||
pStrRet->uType = STRRET_CSTR;
|
pStrRet->uType = STRRET_CSTR;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue