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); } }