diff --git a/dlls/explorerframe/nstc.c b/dlls/explorerframe/nstc.c index b2d780f9fd6..ca10493e509 100644 --- a/dlls/explorerframe/nstc.c +++ b/dlls/explorerframe/nstc.c @@ -361,6 +361,20 @@ static IShellItem *get_selected_shellitem(NSTC2Impl *This) return shellitem_from_treeitem(This, get_selected_treeitem(This)); } +static void collapse_all(NSTC2Impl *This, HTREEITEM node) +{ + HTREEITEM next; + + /* Collapse this node first, and then first child/next sibling. */ + SendMessageW(This->hwnd_tv, TVM_EXPAND, TVE_COLLAPSE, (LPARAM)node); + + next = (HTREEITEM)SendMessageW(This->hwnd_tv, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)node); + if(next) collapse_all(This, next); + + next = (HTREEITEM)SendMessageW(This->hwnd_tv, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)node); + if(next) collapse_all(This, next); +} + /************************************************************************* * NamespaceTree window functions */ @@ -1143,8 +1157,13 @@ static HRESULT WINAPI NSTC2_fnGetItemRect(INameSpaceTreeControl2* iface, static HRESULT WINAPI NSTC2_fnCollapseAll(INameSpaceTreeControl2* iface) { NSTC2Impl *This = (NSTC2Impl*)iface; - FIXME("stub, %p\n", This); - return E_NOTIMPL; + nstc_root *root; + TRACE("%p\n", This); + + LIST_FOR_EACH_ENTRY(root, &This->roots, nstc_root, entry) + collapse_all(This, root->htreeitem); + + return S_OK; } static HRESULT WINAPI NSTC2_fnSetControlStyle(INameSpaceTreeControl2* iface, diff --git a/dlls/explorerframe/tests/nstc.c b/dlls/explorerframe/tests/nstc.c index 170f1896e98..4ca4320be53 100644 --- a/dlls/explorerframe/tests/nstc.c +++ b/dlls/explorerframe/tests/nstc.c @@ -1077,9 +1077,16 @@ static void test_basics(void) roots[9] = NULL; verify_root_order(pnstc, roots); + /* CollapseAll */ + hr = INameSpaceTreeControl_CollapseAll(pnstc); + ok(hr == S_OK, "Got 0x%08x\n", hr); + hr = INameSpaceTreeControl_RemoveAllRoots(pnstc); ok(hr == S_OK, "Got (0x%08x)\n", hr); + hr = INameSpaceTreeControl_CollapseAll(pnstc); + ok(hr == S_OK, "Got 0x%08x\n", hr); + IShellItem_Release(psidesktop); IShellItem_Release(psidesktop2); IShellItem_Release(psitestdir);