From f0d6d95ef8952e4afb1b6c88a0d43b85b943d83b Mon Sep 17 00:00:00 2001 From: David Hedberg Date: Mon, 16 Aug 2010 09:17:33 +0200 Subject: [PATCH] explorerframe: Handle changing the selection. --- dlls/explorerframe/nstc.c | 28 ++++++++++++++++++++++++++++ dlls/explorerframe/tests/nstc.c | 9 ++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/explorerframe/nstc.c b/dlls/explorerframe/nstc.c index 6daa4d4759a..a9e667fa6ac 100644 --- a/dlls/explorerframe/nstc.c +++ b/dlls/explorerframe/nstc.c @@ -138,6 +138,13 @@ static HRESULT events_OnAfterExpand(NSTC2Impl *This, IShellItem *psi) return ret; } +static HRESULT events_OnSelectionChanged(NSTC2Impl *This, IShellItemArray *psia) +{ + if(!This->pnstce) return S_OK; + + return INameSpaceTreeControlEvents_OnSelectionChanged(This->pnstce, psia); +} + /************************************************************************* * NamespaceTree helper functions */ @@ -508,6 +515,26 @@ static LRESULT on_tvn_itemexpandedw(NSTC2Impl *This, LPARAM lParam) return TRUE; } +static LRESULT on_tvn_selchangedw(NSTC2Impl *This, LPARAM lParam) +{ + NMTREEVIEWW *nmtv = (NMTREEVIEWW*)lParam; + IShellItemArray *psia; + IShellItem *psi; + HRESULT hr; + TRACE("%p\n", This); + + /* Note: Only supports one selected item. */ + psi = shellitem_from_treeitem(This, nmtv->itemNew.hItem); + hr = SHCreateShellItemArrayFromShellItem(psi, &IID_IShellItemArray, (void**)&psia); + if(SUCCEEDED(hr)) + { + events_OnSelectionChanged(This, psia); + IShellItemArray_Release(psia); + } + + return TRUE; +} + static LRESULT CALLBACK NSTC2_WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { @@ -527,6 +554,7 @@ static LRESULT CALLBACK NSTC2_WndProc(HWND hWnd, UINT uMessage, case TVN_GETDISPINFOW: return on_tvn_getdispinfow(This, lParam); case TVN_ITEMEXPANDINGW: return on_tvn_itemexpandingw(This, lParam); case TVN_ITEMEXPANDEDW: return on_tvn_itemexpandedw(This, lParam); + case TVN_SELCHANGEDW: return on_tvn_selchangedw(This, lParam); default: break; } break; diff --git a/dlls/explorerframe/tests/nstc.c b/dlls/explorerframe/tests/nstc.c index 7e7587a92cc..77d9254bb87 100644 --- a/dlls/explorerframe/tests/nstc.c +++ b/dlls/explorerframe/tests/nstc.c @@ -1251,7 +1251,7 @@ static void test_events(void) ok(hwnd_tv != NULL, "Failed to get hwnd_tv HWND.\n"); if(hwnd_tv) { - HTREEITEM hroot; + HTREEITEM hroot, hitem; /* Test On*Expand */ hroot = (HTREEITEM)SendMessageW(hwnd_tv, TVM_GETNEXTITEM, TVGN_ROOT, 0); @@ -1268,6 +1268,13 @@ static void test_events(void) SendMessage(hwnd_tv, TVM_EXPAND, TVE_EXPAND, (LPARAM)hroot); process_msgs(); ok_no_events(pnstceimpl); + + /* Test OnSelectionChanged */ + hitem = (HTREEITEM)SendMessageW(hwnd_tv, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hroot); + SendMessageW(hwnd_tv, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hitem); + process_msgs(); + ok_event_count(pnstceimpl, OnSelectionChanged, 1); + ok_no_events(pnstceimpl); } else skip("Skipping some tests.\n");