diff --git a/dlls/user/listbox.c b/dlls/user/listbox.c index 50d4cd3edc6..fb9d1cf26ba 100644 --- a/dlls/user/listbox.c +++ b/dlls/user/listbox.c @@ -2010,11 +2010,16 @@ static LRESULT LISTBOX_HandleLButtonDown( LB_DESCR *descr, DWORD keys, INT x, IN { LISTBOX_MoveCaret( descr, index, FALSE ); - if (descr->style & LBS_MULTIPLESEL) + if (descr->style & LBS_EXTENDEDSEL) { LISTBOX_SetSelection( descr, index, - (!(descr->style & LBS_MULTIPLESEL) || - !descr->items[index].selected), + descr->items[index].selected, + (descr->style & LBS_NOTIFY) != 0 ); + } + else + { + LISTBOX_SetSelection( descr, index, + !descr->items[index].selected, (descr->style & LBS_NOTIFY) != 0 ); } } diff --git a/dlls/user/tests/listbox.c b/dlls/user/tests/listbox.c index f9e821c8694..fb530474ea4 100644 --- a/dlls/user/tests/listbox.c +++ b/dlls/user/tests/listbox.c @@ -181,6 +181,26 @@ START_TEST(listbox) {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, { 1, 1, 1, LB_ERR}, {0,0,0,0}, { 2, 2, 2, LB_ERR}, {0,0,0,0}}; + const struct listbox_test ES = + {{LBS_EXTENDEDSEL}, + { 0, LB_ERR, 0, 0}, {0,0,0,0}, + { 1, 1, 1, 1}, {0,0,0,0}, + { 2, 2, 2, 1}, {0,0,0,0}}; + const struct listbox_test ES_NS = + {{LBS_EXTENDEDSEL | LBS_NOSEL}, + {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, + { 1, 1, 1, LB_ERR}, {0,0,0,0}, + { 2, 2, 2, LB_ERR}, {0,0,0,0}}; + const struct listbox_test EMS = + {{LBS_EXTENDEDSEL | LBS_MULTIPLESEL}, + { 0, LB_ERR, 0, 0}, {0,0,0,0}, + { 1, 1, 1, 1}, {0,0,0,0}, + { 2, 2, 2, 1}, {0,0,0,0}}; + const struct listbox_test EMS_NS = + {{LBS_EXTENDEDSEL | LBS_MULTIPLESEL | LBS_NOSEL}, + {LB_ERR, LB_ERR, 0, LB_ERR}, {0,0,0,0}, + { 1, 1, 1, LB_ERR}, {0,0,0,0}, + { 2, 2, 2, LB_ERR}, {0,0,0,0}}; trace (" Testing single selection...\n"); check (SS); @@ -190,6 +210,14 @@ START_TEST(listbox) check (MS); trace (" ... with NOSEL\n"); check (MS_NS); + trace (" Testing extended selection...\n"); + check (ES); + trace (" ... with NOSEL\n"); + check (ES_NS); + trace (" Testing extended and multiple selection...\n"); + check (EMS); + trace (" ... with NOSEL\n"); + check (EMS_NS); check_item_height(); }