Commit 6923ec27 authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

explorerframe: Implement HitTest.

parent 193fe3c3
......@@ -422,6 +422,18 @@ static void collapse_all(NSTC2Impl *This, HTREEITEM node)
if(next) collapse_all(This, next);
}
static HTREEITEM treeitem_from_point(NSTC2Impl *This, POINT *pt, UINT *hitflag)
{
TVHITTESTINFO tviht;
tviht.pt.x = pt->x;
tviht.pt.y = pt->y;
tviht.hItem = NULL;
SendMessageW(This->hwnd_tv, TVM_HITTEST, 0, (LPARAM)&tviht);
if(hitflag) *hitflag = tviht.flags;
return tviht.hItem;
}
/*************************************************************************
* NamespaceTree window functions
*/
......@@ -1309,8 +1321,25 @@ static HRESULT WINAPI NSTC2_fnHitTest(INameSpaceTreeControl2* iface,
IShellItem **ppsiOut)
{
NSTC2Impl *This = (NSTC2Impl*)iface;
FIXME("stub, %p (%p, %p)\n", This, ppsiOut, ppt);
return E_NOTIMPL;
HTREEITEM hitem;
TRACE("%p (%p, %p)\n", This, ppsiOut, ppt);
if(!ppt || !ppsiOut)
return E_POINTER;
*ppsiOut = NULL;
hitem = treeitem_from_point(This, ppt, NULL);
if(hitem)
*ppsiOut = shellitem_from_treeitem(This, hitem);
if(*ppsiOut)
{
IShellItem_AddRef(*ppsiOut);
return S_OK;
}
return S_FALSE;
}
static HRESULT WINAPI NSTC2_fnGetItemRect(INameSpaceTreeControl2* iface,
......
......@@ -734,6 +734,7 @@ static void test_basics(void)
HWND hwnd_tv;
RECT rc;
IShellItem *roots[10];
POINT pt;
WCHAR curdirW[MAX_PATH];
WCHAR buf[MAX_PATH];
static const WCHAR testdirW[] = {'t','e','s','t','d','i','r',0};
......@@ -1555,6 +1556,89 @@ static void test_basics(void)
hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
ok(hr == S_OK, "Got (0x%08x)\n", hr);
/* HitTest */
hr = INameSpaceTreeControl_HitTest(pnstc, NULL, NULL);
ok(hr == E_POINTER, "Got 0x%08x\n", hr);
hr = INameSpaceTreeControl_HitTest(pnstc, &pt, NULL);
ok(hr == E_POINTER, "Got 0x%08x\n", hr);
hr = INameSpaceTreeControl_HitTest(pnstc, NULL, &psi);
ok(hr == E_POINTER, "Got 0x%08x\n", hr);
psi = (void*)0xdeadbeef;
hr = INameSpaceTreeControl_HitTest(pnstc, &pt, &psi);
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
ok(psi == NULL, "Got psi %p\n", psi);
hr = INameSpaceTreeControl_AppendRoot(pnstc, psitestdir,
SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
NSTCRS_EXPANDED, NULL);
ok(hr == S_OK, "Got 0x%08x\n", hr);
process_msgs();
pt.x = pt.y = 0;
hr = INameSpaceTreeControl_HitTest(pnstc, &pt, &psi);
ok(hr == S_OK, "Got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
int cmp;
hr = IShellItem_Compare(psi, psitestdir, SICHINT_DISPLAY, &cmp);
ok(hr == S_OK, "Got 0x%08x\n", hr);
ok(!cmp, "Got cmp %d\n", cmp);
IShellItem_Release(psi);
}
pt.y += height - 1;
hr = INameSpaceTreeControl_HitTest(pnstc, &pt, &psi);
ok(hr == S_OK, "Got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
int cmp;
hr = IShellItem_Compare(psi, psitestdir, SICHINT_DISPLAY, &cmp);
ok(hr == S_OK, "Got 0x%08x\n", hr);
ok(!cmp, "Got cmp %d\n", cmp);
IShellItem_Release(psi);
}
pt.y += 1;
hr = INameSpaceTreeControl_HitTest(pnstc, &pt, &psi);
ok(hr == S_OK, "Got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
int cmp;
todo_wine
{
hr = IShellItem_Compare(psi, psitestdir, SICHINT_DISPLAY, &cmp);
ok(hr == S_FALSE, "Got 0x%08x\n", hr);
ok(cmp, "no cmp value.\n");
hr = IShellItem_Compare(psi, psitestdir2, SICHINT_DISPLAY, &cmp);
ok(hr == S_OK, "Got 0x%08x\n", hr);
ok(!cmp, "Got cmp %d\n", cmp);
}
IShellItem_Release(psi);
}
hr = INameSpaceTreeControl_GetItemRect(pnstc, psitestdir2, &rc);
ok(hr == S_OK, "Got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
MapWindowPoints(NULL, hwnd, (POINT*)&rc, 2);
pt.x = rc.left; pt.y = rc.top;
hr = INameSpaceTreeControl_HitTest(pnstc, &pt, &psi);
ok(hr == S_OK, "Got 0x%08x\n", hr);
if(SUCCEEDED(hr))
{
int cmp;
hr = IShellItem_Compare(psi, psitestdir2, SICHINT_DISPLAY, &cmp);
ok(hr == S_OK, "Got 0x%08x\n", hr);
ok(!cmp, "Got cmp %d\n", cmp);
IShellItem_Release(psi);
}
}
hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
ok(hr == S_OK, "Got 0x%08x\n", hr);
IShellItem_Release(psidesktop);
IShellItem_Release(psidesktop2);
IShellItem_Release(psitestdir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment