diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 56e2563c171..c01d816c468 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -7989,12 +7989,8 @@ static BOOL LISTVIEW_IsItemVisible(const LISTVIEW_INFO *infoPtr, INT nItem) static BOOL LISTVIEW_RedrawItems(const LISTVIEW_INFO *infoPtr, INT nFirst, INT nLast) { INT i; - - if (nLast < nFirst || min(nFirst, nLast) < 0 || - max(nFirst, nLast) >= infoPtr->nItemCount) - return FALSE; - - for (i = nFirst; i <= nLast; i++) + + for (i = max(nFirst, 0); i <= min(nLast, infoPtr->nItemCount - 1); i++) LISTVIEW_InvalidateItem(infoPtr, i); return TRUE; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 6d21b054360..f49767309c3 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -5529,6 +5529,43 @@ static void test_LVM_SETITEMTEXT(void) DestroyWindow(hwnd); } +static void test_LVM_REDRAWITEMS(void) +{ + HWND list; + DWORD ret; + + list = create_listview_control(LVS_ICON); + ok(list != NULL, "failed to create listview window\n"); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 0); + expect(TRUE, ret); + + insert_item(list, 0); + + ret = SendMessageA(list, LVM_REDRAWITEMS, -1, 0); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, -1); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 0); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 1); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 0, 2); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 1, 0); + expect(TRUE, ret); + + ret = SendMessageA(list, LVM_REDRAWITEMS, 2, 3); + expect(TRUE, ret); + + DestroyWindow(list); +} + static void test_imagelists(void) { HWND hwnd, header; @@ -5903,6 +5940,7 @@ START_TEST(listview) test_createdragimage(); test_dispinfo(); test_LVM_SETITEMTEXT(); + test_LVM_REDRAWITEMS(); test_imagelists(); test_deleteitem(); test_insertitem();