shell32: Simplify drag drop helper object creation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-12-01 07:33:18 +03:00 committed by Alexandre Julliard
parent 794efcceee
commit 8e7a041154
2 changed files with 56 additions and 39 deletions

View File

@ -52,42 +52,11 @@ typedef struct {
LONG ref;
} IDropTargetHelperImpl;
static const IDropTargetHelperVtbl vt_IDropTargetHelper;
static inline IDropTargetHelperImpl *impl_from_IDropTargetHelper(IDropTargetHelper *iface)
{
return CONTAINING_RECORD(iface, IDropTargetHelperImpl, IDropTargetHelper_iface);
}
/**************************************************************************
* IDropTargetHelper_Constructor
*/
HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
{
IDropTargetHelperImpl *dth;
TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
if (!ppv)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
dth = LocalAlloc (LMEM_ZEROINIT, sizeof (IDropTargetHelperImpl));
if (!dth) return E_OUTOFMEMORY;
dth->ref = 0;
dth->IDropTargetHelper_iface.lpVtbl = &vt_IDropTargetHelper;
if (FAILED (IDropTargetHelper_QueryInterface (&dth->IDropTargetHelper_iface, riid, ppv))) {
LocalFree(dth);
return E_NOINTERFACE;
}
TRACE ("--(%p)\n", dth);
return S_OK;
}
/**************************************************************************
* IDropTargetHelper_fnQueryInterface
*/
@ -179,12 +148,39 @@ static HRESULT WINAPI IDropTargetHelper_fnShow (IDropTargetHelper * iface, BOOL
static const IDropTargetHelperVtbl vt_IDropTargetHelper =
{
IDropTargetHelper_fnQueryInterface,
IDropTargetHelper_fnAddRef,
IDropTargetHelper_fnRelease,
IDropTargetHelper_fnDragEnter,
IDropTargetHelper_fnDragLeave,
IDropTargetHelper_fnDragOver,
IDropTargetHelper_fnDrop,
IDropTargetHelper_fnShow
IDropTargetHelper_fnQueryInterface,
IDropTargetHelper_fnAddRef,
IDropTargetHelper_fnRelease,
IDropTargetHelper_fnDragEnter,
IDropTargetHelper_fnDragLeave,
IDropTargetHelper_fnDragOver,
IDropTargetHelper_fnDrop,
IDropTargetHelper_fnShow
};
/**************************************************************************
* IDropTargetHelper_Constructor
*/
HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
{
IDropTargetHelperImpl *dth;
HRESULT hr;
TRACE ("outer=%p %s %p\n", pUnkOuter, shdebugstr_guid (riid), ppv);
if (!ppv)
return E_POINTER;
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
dth = LocalAlloc (LMEM_ZEROINIT, sizeof (IDropTargetHelperImpl));
if (!dth) return E_OUTOFMEMORY;
dth->IDropTargetHelper_iface.lpVtbl = &vt_IDropTargetHelper;
dth->ref = 1;
hr = IDropTargetHelper_QueryInterface (&dth->IDropTargetHelper_iface, riid, ppv);
IDropTargetHelper_Release (&dth->IDropTargetHelper_iface);
return hr;
}

View File

@ -890,12 +890,33 @@ static void test_SHCreateSessionKey(void)
RegCloseKey(hkey2);
}
static void test_dragdrophelper(void)
{
IDropTargetHelper *target;
HRESULT hr;
hr = CoCreateInstance(&CLSID_DragDropHelper, NULL, CLSCTX_INPROC_SERVER, &IID_IDropTargetHelper, (void **)&target);
ok(hr == S_OK, "Failed to create IDropTargetHelper, %#x\n", hr);
IDropTargetHelper_Release(target);
}
START_TEST(shellole)
{
HRESULT hr;
init();
hr = CoInitialize(NULL);
ok(hr == S_OK, "CoInitialize failed (0x%08x)\n", hr);
if (hr != S_OK)
return;
test_SHPropStg_functions();
test_SHCreateQueryCancelAutoPlayMoniker();
test_DragQueryFile();
test_SHCreateSessionKey();
test_dragdrophelper();
CoUninitialize();
}