[PATCH 1/4] explorerframe: Implement GetItemRect.

David Hedberg david.hedberg at gmail.com
Thu Aug 19 01:17:53 CDT 2010


---
 dlls/explorerframe/nstc.c       |   20 +++++++++++-
 dlls/explorerframe/tests/nstc.c |   61 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/dlls/explorerframe/nstc.c b/dlls/explorerframe/nstc.c
index 4269b73..2a68d95 100644
--- a/dlls/explorerframe/nstc.c
+++ b/dlls/explorerframe/nstc.c
@@ -1318,8 +1318,24 @@ static HRESULT WINAPI NSTC2_fnGetItemRect(INameSpaceTreeControl2* iface,
                                           RECT *prect)
 {
     NSTC2Impl *This = (NSTC2Impl*)iface;
-    FIXME("stub, %p (%p, %p)\n", This, psi, prect);
-    return E_NOTIMPL;
+    HTREEITEM hitem;
+    TRACE("%p (%p, %p)\n", This, psi, prect);
+
+    if(!psi || !prect)
+        return E_POINTER;
+
+    hitem = treeitem_from_shellitem(This, psi);
+    if(hitem)
+    {
+        *(HTREEITEM*)prect = hitem;
+        if(SendMessageW(This->hwnd_tv, TVM_GETITEMRECT, FALSE, (LPARAM)prect))
+        {
+            MapWindowPoints(This->hwnd_tv, HWND_DESKTOP, (POINT*)prect, 2);
+            return S_OK;
+        }
+    }
+
+    return E_INVALIDARG;
 }
 
 static HRESULT WINAPI NSTC2_fnCollapseAll(INameSpaceTreeControl2* iface)
diff --git a/dlls/explorerframe/tests/nstc.c b/dlls/explorerframe/tests/nstc.c
index d05db8e..363b982 100644
--- a/dlls/explorerframe/tests/nstc.c
+++ b/dlls/explorerframe/tests/nstc.c
@@ -730,7 +730,8 @@ static void test_basics(void)
     LPITEMIDLIST pidl_desktop;
     NSTCITEMSTATE istate;
     HRESULT hr;
-    UINT i, res;
+    UINT i, res, height;
+    HWND hwnd_tv;
     RECT rc;
     IShellItem *roots[10];
     WCHAR curdirW[MAX_PATH];
@@ -1496,6 +1497,64 @@ static void test_basics(void)
     hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
     ok(hr == S_OK, "Got (0x%08x)\n", hr);
 
+    /* GetItemRect */
+    rc.top = rc.left = rc.bottom = rc.right = 0;
+    if(0)
+    {
+        /* Crashes under win 7 */
+        hr = INameSpaceTreeControl_GetItemRect(pnstc, NULL, NULL);
+        hr = INameSpaceTreeControl_GetItemRect(pnstc, psitestdir, NULL);
+        hr = INameSpaceTreeControl_GetItemRect(pnstc, NULL, &rc);
+    }
+
+    hr = INameSpaceTreeControl_GetItemRect(pnstc, psitestdir, &rc);
+    ok(hr == E_INVALIDARG, "Got 0x%08x\n", hr);
+
+    hr = INameSpaceTreeControl_AppendRoot(pnstc, psitestdir,
+                                          SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,
+                                          NSTCRS_EXPANDED, NULL);
+    ok(hr == S_OK, "Got 0x%08x\n", hr);
+    process_msgs();
+
+    hr = INameSpaceTreeControl_GetItemRect(pnstc, psitestdir, &rc);
+    ok(hr == S_OK, "Got 0x%08x\n", hr);
+    ok(rc.top != rc.bottom, "Got 0 height.\n");
+    ok(rc.left != rc.bottom, "Got 0 width.\n");
+
+    height = 0;
+    hwnd_tv = get_treeview_hwnd(pnstc);
+    if(hwnd_tv)
+    {
+        HTREEITEM hroot = (HTREEITEM)SendMessageW(hwnd_tv, TVM_GETNEXTITEM, TVGN_ROOT, 0);
+        ok(hroot != NULL, "Failed to get root.\n");
+        if(hroot)
+        {
+            RECT tv_rc;
+            BOOL bret;
+
+            *(HTREEITEM*)&tv_rc = hroot;
+            bret = SendMessageW(hwnd_tv, TVM_GETITEMRECT, FALSE, (LPARAM)&tv_rc);
+            ok(bret, "TVM_GETITEMRECT failed.\n");
+
+            /* The NamespaceTreeControl returns screen coordinates. */
+            MapWindowPoints(NULL, hwnd, (POINT*)&rc, 2);
+            ok(rc.left == tv_rc.left, "Differed, got %d and %d\n", rc.left, tv_rc.left);
+            ok(rc.top == tv_rc.top, "Differed, got %d and %d\n", rc.top, tv_rc.top);
+            ok(rc.right == tv_rc.right, "Differed, got %d and %d\n", rc.right, tv_rc.right);
+            ok(rc.bottom == tv_rc.bottom, "Differed, got %d and %d\n", rc.bottom, tv_rc.bottom);
+
+            /* Save the height and compare to that of other items.
+               Observed values: 18, 19, 21 */
+            height = rc.bottom - rc.top;
+            trace("height: %d\n", height);
+        }
+    }
+    else
+        win_skip("Skipping some GetItemRect tests.\n");
+
+    hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
+    ok(hr == S_OK, "Got (0x%08x)\n", hr);
+
     IShellItem_Release(psidesktop);
     IShellItem_Release(psidesktop2);
     IShellItem_Release(psitestdir);
-- 
1.7.2




More information about the wine-patches mailing list