David Hedberg : explorerframe: Implement EnsureItemVisible.

Alexandre Julliard julliard at winehq.org
Thu Aug 19 11:44:04 CDT 2010


Module: wine
Branch: master
Commit: e5ab57f2c6805029cc0b56ae7fae0b35f8633c22
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e5ab57f2c6805029cc0b56ae7fae0b35f8633c22

Author: David Hedberg <david.hedberg at gmail.com>
Date:   Thu Aug 19 08:17:55 2010 +0200

explorerframe: Implement EnsureItemVisible.

---

 dlls/explorerframe/nstc.c       |   14 +++++++-
 dlls/explorerframe/tests/nstc.c |   64 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/dlls/explorerframe/nstc.c b/dlls/explorerframe/nstc.c
index b77297e..02633b0 100644
--- a/dlls/explorerframe/nstc.c
+++ b/dlls/explorerframe/nstc.c
@@ -1259,8 +1259,18 @@ static HRESULT WINAPI NSTC2_fnEnsureItemVisible(INameSpaceTreeControl2* iface,
                                                 IShellItem *psi)
 {
     NSTC2Impl *This = (NSTC2Impl*)iface;
-    FIXME("stub, %p (%p)\n", This, psi);
-    return E_NOTIMPL;
+    HTREEITEM hitem;
+
+    TRACE("%p (%p)\n", This, psi);
+
+    hitem = treeitem_from_shellitem(This, psi);
+    if(hitem)
+    {
+        SendMessageW(This->hwnd_tv, TVM_ENSUREVISIBLE, 0, (WPARAM)hitem);
+        return S_OK;
+    }
+
+    return E_INVALIDARG;
 }
 
 static HRESULT WINAPI NSTC2_fnSetTheme(INameSpaceTreeControl2* iface,
diff --git a/dlls/explorerframe/tests/nstc.c b/dlls/explorerframe/tests/nstc.c
index 9d4d0b4..cb6ed44 100644
--- a/dlls/explorerframe/tests/nstc.c
+++ b/dlls/explorerframe/tests/nstc.c
@@ -35,6 +35,7 @@ static HWND hwnd;
 static HRESULT (WINAPI *pSHCreateShellItem)(LPCITEMIDLIST,IShellFolder*,LPCITEMIDLIST,IShellItem**);
 static HRESULT (WINAPI *pSHGetIDListFromObject)(IUnknown*, PIDLIST_ABSOLUTE*);
 static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**);
+static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *);
 
 #define NUM_MSG_SEQUENCES 1
 #define TREEVIEW_SEQ_INDEX 0
@@ -53,6 +54,7 @@ static void init_function_pointers(void)
     pSHCreateShellItem = (void*)GetProcAddress(hmod, "SHCreateShellItem");
     pSHGetIDListFromObject = (void*)GetProcAddress(hmod, "SHGetIDListFromObject");
     pSHCreateItemFromParsingName = (void*)GetProcAddress(hmod, "SHCreateItemFromParsingName");
+    pSHGetSpecialFolderLocation = (void*)GetProcAddress(hmod, "SHGetSpecialFolderLocation");
 }
 
 /*******************************************************
@@ -1672,6 +1674,7 @@ static void test_events(void)
     IShellItem *psidesktop;
     IOleWindow *pow;
     LPITEMIDLIST pidl_desktop;
+    LPITEMIDLIST pidl_drives;
     NSTCITEMSTATE itemstate;
     IShellItem *psi;
     DWORD cookie1, cookie2;
@@ -2195,6 +2198,67 @@ static void test_events(void)
     ok_event_count(pnstceimpl, OnItemDeleted, 1);
     ok_no_events(pnstceimpl);
 
+    /* EnsureItemVisible */
+    if(0)
+    {
+        /* Crashes on Windows 7 */
+        hr = INameSpaceTreeControl_EnsureItemVisible(pnstc, NULL);
+    }
+
+    hr = INameSpaceTreeControl_EnsureItemVisible(pnstc, psidesktop);
+    ok(hr == E_INVALIDARG || hr == E_FAIL, "Got (0x%08x)\n", hr);
+    ok_no_events(pnstceimpl);
+
+    hr = pSHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidl_drives);
+    ok(hr == S_OK, "Got (0x%08x)\n", hr);
+    if(SUCCEEDED(hr))
+    {
+        hr = pSHCreateShellItem(NULL, NULL, pidl_drives, &psi);
+        ok(hr == S_OK, "Got (0x%08x)\n", hr);
+        if(SUCCEEDED(hr))
+        {
+            hr = INameSpaceTreeControl_AppendRoot(pnstc, psi, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, 0, NULL);
+            ok(hr == S_OK, "Got (0x%08x)\n", hr);
+            process_msgs();
+            ok_event_count_broken(pnstceimpl, OnItemAdded, 1, 0 /* Vista */);
+            ok_no_events(pnstceimpl);
+
+            hr = INameSpaceTreeControl_EnsureItemVisible(pnstc, psidesktop);
+            ok(hr == E_INVALIDARG, "Got (0x%08x)\n", hr);
+            ok_no_events(pnstceimpl);
+
+            hr = INameSpaceTreeControl_EnsureItemVisible(pnstc, psi);
+            ok(hr == S_OK, "Got (0x%08x)\n", hr);
+            ok_no_events(pnstceimpl);
+
+            hr = INameSpaceTreeControl_AppendRoot(pnstc, psidesktop, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, 0, NULL);
+            ok(hr == S_OK, "Got (0x%08x)\n", hr);
+            process_msgs();
+            ok_event_count_broken(pnstceimpl, OnItemAdded, 1, 0 /* Vista */);
+            ok_no_events(pnstceimpl);
+
+            hr = INameSpaceTreeControl_EnsureItemVisible(pnstc, psidesktop);
+            ok(hr == S_OK, "Got (0x%08x)\n", hr);
+            ok_no_events(pnstceimpl);
+
+            hr = INameSpaceTreeControl_EnsureItemVisible(pnstc, psi);
+            ok(hr == S_OK, "Got (0x%08x)\n", hr);
+            ok_no_events(pnstceimpl);
+
+        }
+        else
+            skip("Failed to create shellitem.\n");
+
+        ILFree(pidl_drives);
+    }
+    else
+        skip("Failed to get pidl for CSIDL_DRIVES.\n");
+
+    hr = INameSpaceTreeControl_RemoveAllRoots(pnstc);
+    ok(hr == S_OK, "Got (0x%08x)\n", hr);
+    ok_event_count(pnstceimpl, OnItemDeleted, 2);
+    ok_no_events(pnstceimpl);
+
     hr = INameSpaceTreeControl_QueryInterface(pnstc, &IID_IOleWindow, (void**)&pow);
     ok(hr == S_OK, "Got 0x%08x\n", hr);
     if(SUCCEEDED(hr))




More information about the wine-cvs mailing list