From 1a25f47d5978e2a63874c484bd4650ed1d0fdef7 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 11 Dec 2019 15:17:51 +0300 Subject: [PATCH] comctl32/listbox: Scroll to specified caret index. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/listbox.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index 0d6dcd6a0b8..2b8c2ba0869 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -1462,19 +1462,23 @@ static void LISTBOX_MakeItemVisible( LB_DESCR *descr, INT index, BOOL fully ) */ static LRESULT LISTBOX_SetCaretIndex( LB_DESCR *descr, INT index, BOOL fully_visible ) { - INT oldfocus = descr->focus_item; + BOOL focus_changed = descr->focus_item != index; - TRACE("old focus %d, index %d\n", oldfocus, index); + TRACE("old focus %d, index %d\n", descr->focus_item, index); if (descr->style & LBS_NOSEL) return LB_ERR; if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; - if (index == oldfocus) return LB_OKAY; - LISTBOX_DrawFocusRect( descr, FALSE ); - descr->focus_item = index; + if (focus_changed) + { + LISTBOX_DrawFocusRect( descr, FALSE ); + descr->focus_item = index; + } LISTBOX_MakeItemVisible( descr, index, fully_visible ); - LISTBOX_DrawFocusRect( descr, TRUE ); + + if (focus_changed) + LISTBOX_DrawFocusRect( descr, TRUE ); return LB_OKAY; }