[MYDOCS] Simplify HIDA usage

This commit is contained in:
Mark Jansen 2021-07-25 01:08:35 +02:00
parent e5ea6041c9
commit eba16dc9e9
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -9,8 +9,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mydocs); WINE_DEFAULT_DEBUG_CHANNEL(mydocs);
static CLIPFORMAT g_cfHIDA = 0;
CMyDocsDropHandler::CMyDocsDropHandler() CMyDocsDropHandler::CMyDocsDropHandler()
{ {
InterlockedIncrement(&g_ModuleRefCnt); InterlockedIncrement(&g_ModuleRefCnt);
@ -68,23 +66,15 @@ CMyDocsDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState,
if (FAILED_UNEXPECTEDLY(hr)) if (FAILED_UNEXPECTEDLY(hr))
return hr; return hr;
// get the clipboard format
if (g_cfHIDA == 0)
g_cfHIDA = ::RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
// Retrieve an HIDA (handle of IDA) // Retrieve an HIDA (handle of IDA)
STGMEDIUM medium; CDataObjectHIDA pida(pDataObject);
FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; if (FAILED_UNEXPECTEDLY(pida.hr()))
hr = pDataObject->GetData(&fmt, &medium);
if (FAILED_UNEXPECTEDLY(hr))
{ {
*pdwEffect = 0; *pdwEffect = 0;
DragLeave(); DragLeave();
return E_FAIL; return pida.hr();
} }
// lock HIDA
LPIDA pida = reinterpret_cast<LPIDA>(GlobalLock(medium.hGlobal));
UINT iItem, cItems = pida->cidl; UINT iItem, cItems = pida->cidl;
// get the path of "My Documents" // get the path of "My Documents"
@ -123,9 +113,6 @@ CMyDocsDropHandler::Drop(IDataObject *pDataObject, DWORD dwKeyState,
strSrcList += szSrc; strSrcList += szSrc;
} }
// unlock HIDA
GlobalUnlock(medium.hGlobal);
if (iItem != cItems) if (iItem != cItems)
{ {
// source not found // source not found