From f2519fdcda334167b44899e188f3d9400a83ea13 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 29 Oct 2007 18:47:09 -0700 Subject: [PATCH] comctl32: Set tab focus correctly. --- dlls/comctl32/tab.c | 9 ++++----- dlls/comctl32/tests/tab.c | 20 +++++--------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/dlls/comctl32/tab.c b/dlls/comctl32/tab.c index 2db8cfee281..5f9e2957f8c 100644 --- a/dlls/comctl32/tab.c +++ b/dlls/comctl32/tab.c @@ -2325,11 +2325,6 @@ static void TAB_Refresh (TAB_INFO *infoPtr, HDC hdc) /* Then, draw the selected item */ TAB_DrawItem (infoPtr, hdc, infoPtr->iSelected); - - /* If we haven't set the current focus yet, set it now. - * Only happens when we first paint the tab controls */ - if (infoPtr->uFocus == -1) - TAB_SetCurFocus(infoPtr, infoPtr->iSelected); } SelectObject (hdc, hOldFont); @@ -2637,6 +2632,10 @@ TAB_InsertItemT (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode) TRACE("[%p]: added item %d %s\n", infoPtr->hwnd, iItem, debugstr_w(item->pszText)); + /* If we haven't set the current focus yet, set it now. */ + if (infoPtr->uFocus == -1) + TAB_SetCurFocus(infoPtr, iItem); + return iItem; } diff --git a/dlls/comctl32/tests/tab.c b/dlls/comctl32/tests/tab.c index 32de6bc3f05..94893767452 100644 --- a/dlls/comctl32/tests/tab.c +++ b/dlls/comctl32/tests/tab.c @@ -876,9 +876,7 @@ static void test_insert_focus(HWND parent_wnd) expect(1, nTabsRetrieved); r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); - todo_wine { - expect(0, r); - } + expect(0, r); tcNewTab.iImage = 2; r = SendMessage(hTab, TCM_INSERTITEM, 2, (LPARAM) &tcNewTab); @@ -888,9 +886,7 @@ static void test_insert_focus(HWND parent_wnd) expect(2, nTabsRetrieved); r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); - todo_wine { - expect(0, r); - } + expect(0, r); r = SendMessage(hTab, TCM_SETCURFOCUS, -1, 0); expect(0, r); @@ -903,9 +899,7 @@ static void test_insert_focus(HWND parent_wnd) expect(2, r); r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); - todo_wine { - expect(2, r); - } + expect(2, r); ok_sequence(sequences, TAB_SEQ_INDEX, insert_focus_seq, "insert_focus test sequence", TRUE); ok_sequence(sequences, PARENT_SEQ_INDEX, empty_sequence, "insert_focus parent test sequence", FALSE); @@ -930,9 +924,7 @@ static void test_delete_focus(HWND parent_wnd) expect(2, nTabsRetrieved); r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); - todo_wine { - expect(0, r); - } + expect(0, r); r = SendMessage(hTab, TCM_DELETEITEM, 1, 0); expect(1, r); @@ -941,9 +933,7 @@ static void test_delete_focus(HWND parent_wnd) expect(1, nTabsRetrieved); r = SendMessage(hTab, TCM_GETCURFOCUS, 0, 0); - todo_wine { - expect(0, r); - } + expect(0, r); r = SendMessage(hTab, TCM_SETCURFOCUS, -1, 0); expect(0, r);