From 40dd74e06b51ed783c5a445b27d38f660d68ecf1 Mon Sep 17 00:00:00 2001 From: HomeWorld Date: Mon, 21 Jan 2013 10:01:30 +0200 Subject: [PATCH] Make sure when adding a new source that the list item coresponding to it is visible and selected (also deselect all previous selected items) --- Source/WindowStuff.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/WindowStuff.cpp b/Source/WindowStuff.cpp index c15bf83e..d220009d 100644 --- a/Source/WindowStuff.cpp +++ b/Source/WindowStuff.cpp @@ -711,8 +711,18 @@ LRESULT CALLBACK OBS::ListboxHook(HWND hwnd, UINT message, WPARAM wParam, LPARAM App->scene->AddImageSource(newSourceElement); App->LeaveSceneMutex(); } - + UINT numSources = sources->NumElements(); + + // clear selection/focus for all items before adding the new item + UINT itemState; + for(int i = 0; ibChangingSources = true; @@ -720,7 +730,10 @@ LRESULT CALLBACK OBS::ListboxHook(HWND hwnd, UINT message, WPARAM wParam, LPARAM App->bChangingSources = false; SetFocus(hwnd); - ListView_SetItemState(hwnd, numSources - 1, LVIS_SELECTED, LVIS_SELECTED); + + // make sure the added item is visible and selected/focused + ListView_EnsureVisible(hwnd, numSources - 1, false); + ListView_SetItemState(hwnd, numSources - 1, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); } }