explorerframe: Handle changing the selection.

This commit is contained in:
David Hedberg 2010-08-16 09:17:33 +02:00 committed by Alexandre Julliard
parent 4ad1050eb5
commit f0d6d95ef8
2 changed files with 36 additions and 1 deletions

View File

@ -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;

View File

@ -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");