Commit 33a1e827 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tab: Fix selection change when selected item is deleted.

parent 336a68be
......@@ -2916,10 +2916,9 @@ static LRESULT TAB_DeleteItem (TAB_INFO *infoPtr, INT iItem)
Free(oldItems);
/* Readjust the selected index */
if ((iItem == infoPtr->iSelected) && (iItem > 0))
infoPtr->iSelected--;
if (iItem < infoPtr->iSelected)
if (iItem == infoPtr->iSelected)
infoPtr->iSelected = -1;
else if (iItem < infoPtr->iSelected)
infoPtr->iSelected--;
if (infoPtr->uNumItem == 0)
......
......@@ -1176,6 +1176,28 @@ static void test_removeimage(HWND parent_wnd)
DestroyIcon(hicon);
}
static void test_delete_selection(HWND parent_wnd)
{
HWND hTab;
DWORD ret;
hTab = createFilledTabControl(parent_wnd, TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE, 4);
ok(hTab != NULL, "Failed to create tab control\n");
ret = SendMessage(hTab, TCM_SETCURSEL, 3, 0);
expect(0, ret);
ret = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
expect(3, ret);
/* delete selected item - selection goes to -1 */
ret = SendMessage(hTab, TCM_DELETEITEM, 3, 0);
expect(TRUE, ret);
ret = SendMessage(hTab, TCM_GETCURSEL, 0, 0);
expect(-1, ret);
DestroyWindow(hTab);
}
START_TEST(tab)
{
HWND parent_wnd;
......@@ -1218,6 +1240,7 @@ START_TEST(tab)
test_insert_focus(parent_wnd);
test_delete_focus(parent_wnd);
test_delete_selection(parent_wnd);
test_removeimage(parent_wnd);
DestroyWindow(parent_wnd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment