mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
[FONTEXT] Simplify HIDA usage
This commit is contained in:
parent
fa0f5cc4be
commit
54c09f856c
|
@ -505,10 +505,9 @@ STDMETHODIMP CFontExt::DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINT
|
||||||
{
|
{
|
||||||
*pdwEffect = DROPEFFECT_NONE;
|
*pdwEffect = DROPEFFECT_NONE;
|
||||||
|
|
||||||
CComHeapPtr<CIDA> cida;
|
CDataObjectHIDA cida(pDataObj);
|
||||||
HRESULT hr = _GetCidlFromDataObject(pDataObj, &cida);
|
if (FAILED_UNEXPECTEDLY(cida.hr()))
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
return cida.hr();
|
||||||
return hr;
|
|
||||||
|
|
||||||
*pdwEffect = DROPEFFECT_COPY;
|
*pdwEffect = DROPEFFECT_COPY;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -528,10 +527,9 @@ STDMETHODIMP CFontExt::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt,
|
||||||
{
|
{
|
||||||
*pdwEffect = DROPEFFECT_NONE;
|
*pdwEffect = DROPEFFECT_NONE;
|
||||||
|
|
||||||
CComHeapPtr<CIDA> cida;
|
CDataObjectHIDA cida(pDataObj);
|
||||||
HRESULT hr = _GetCidlFromDataObject(pDataObj, &cida);
|
if (!cida)
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
return E_UNEXPECTED;
|
||||||
return hr;
|
|
||||||
|
|
||||||
PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(cida);
|
PCUIDLIST_ABSOLUTE pidlParent = HIDA_GetPIDLFolder(cida);
|
||||||
if (!pidlParent)
|
if (!pidlParent)
|
||||||
|
|
|
@ -2,45 +2,13 @@
|
||||||
* PROJECT: ReactOS Font Shell Extension
|
* PROJECT: ReactOS Font Shell Extension
|
||||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: CFontMenu implementation
|
* PURPOSE: CFontMenu implementation
|
||||||
* COPYRIGHT: Copyright 2019,2020 Mark Jansen <mark.jansen@reactos.org>
|
* COPYRIGHT: Copyright 2019-2021 Mark Jansen <mark.jansen@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(fontext);
|
WINE_DEFAULT_DEBUG_CHANNEL(fontext);
|
||||||
|
|
||||||
static CLIPFORMAT g_cfHIDA;
|
|
||||||
|
|
||||||
HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida)
|
|
||||||
{
|
|
||||||
if (g_cfHIDA == NULL)
|
|
||||||
{
|
|
||||||
g_cfHIDA = (CLIPFORMAT)RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
FORMATETC fmt = { g_cfHIDA, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
|
|
||||||
STGMEDIUM medium;
|
|
||||||
|
|
||||||
HRESULT hr = pDataObject->GetData(&fmt, &medium);
|
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
LPVOID lpSrc = GlobalLock(medium.hGlobal);
|
|
||||||
SIZE_T cbSize = GlobalSize(medium.hGlobal);
|
|
||||||
|
|
||||||
*ppcida = (CIDA *)::CoTaskMemAlloc(cbSize);
|
|
||||||
if (*ppcida)
|
|
||||||
{
|
|
||||||
memcpy(*ppcida, lpSrc, cbSize);
|
|
||||||
hr = S_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hr = E_FAIL;
|
|
||||||
}
|
|
||||||
ReleaseStgMedium(&medium);
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* DFM_TO_STR(UINT uMsg)
|
const char* DFM_TO_STR(UINT uMsg)
|
||||||
{
|
{
|
||||||
|
@ -111,10 +79,10 @@ static HRESULT CALLBACK FontFolderMenuCallback(IShellFolder *psf, HWND hwnd, IDa
|
||||||
// Preview is the only item we handle
|
// Preview is the only item we handle
|
||||||
if (wParam == 0)
|
if (wParam == 0)
|
||||||
{
|
{
|
||||||
CComHeapPtr<CIDA> cida;
|
CDataObjectHIDA cida(pdtobj);
|
||||||
HRESULT hr = _GetCidlFromDataObject(pdtobj, &cida);
|
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
if (FAILED_UNEXPECTEDLY(cida.hr()))
|
||||||
return hr;
|
return cida.hr();
|
||||||
|
|
||||||
for (UINT n = 0; n < cida->cidl; ++n)
|
for (UINT n = 0; n < cida->cidl; ++n)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,8 +36,6 @@ HRESULT _CFontMenu_CreateInstance(HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY ap
|
||||||
HRESULT _CDataObject_CreateInstance(PCIDLIST_ABSOLUTE folder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
|
HRESULT _CDataObject_CreateInstance(PCIDLIST_ABSOLUTE folder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
|
||||||
REFIID riid, LPVOID* ppvOut);
|
REFIID riid, LPVOID* ppvOut);
|
||||||
|
|
||||||
HRESULT _GetCidlFromDataObject(IDataObject *pDataObject, CIDA** ppcida);
|
|
||||||
|
|
||||||
inline BOOL IsFontDotExt(LPCWSTR pchDotExt)
|
inline BOOL IsFontDotExt(LPCWSTR pchDotExt)
|
||||||
{
|
{
|
||||||
static const LPCWSTR array[] =
|
static const LPCWSTR array[] =
|
||||||
|
|
Loading…
Reference in a new issue