From 4a5e23a2f960dfaa19de6fed481a2f13c69356a7 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 10 May 2009 13:02:57 +0400 Subject: [PATCH] comctl32/listview: Select all items with LVM_SETITEMSTATE is blocked in LVS_SINGLESEL. --- dlls/comctl32/listview.c | 4 ++++ dlls/comctl32/tests/listview.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 1928d4bbc29..7bed09ed359 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -7687,6 +7687,10 @@ static BOOL LISTVIEW_SetItemState(LISTVIEW_INFO *infoPtr, INT nItem, const LVITE if (nItem == -1) { + /* select all isn't allowed in LVS_SINGLESEL */ + if ((lvItem.state & lvItem.stateMask & LVIS_SELECTED) && (infoPtr->dwStyle & LVS_SINGLESEL)) + return FALSE; + /* apply to all items */ for (lvItem.iItem = 0; lvItem.iItem < infoPtr->nItemCount; lvItem.iItem++) if (!LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE)) bResult = FALSE; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index e94bdaaabd0..5987e1eb0c3 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -1496,6 +1496,7 @@ static void test_multiselect(void) BYTE kstate[256]; select_task task; LONG_PTR style; + LVITEMA item; static struct t_select_task task_list[] = { { "using VK_DOWN", 0, VK_DOWN, -1, -1 }, @@ -1605,6 +1606,36 @@ todo_wine todo_wine expect(-1, r); + /* try to select all on LVS_SINGLESEL */ + memset(&item, 0, sizeof(item)); + item.stateMask = LVIS_SELECTED; + r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item); + expect(TRUE, r); + ListView_SetSelectionMark(hwnd, -1); + + item.stateMask = LVIS_SELECTED; + item.state = LVIS_SELECTED; + r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item); + expect(FALSE, r); + + r = ListView_GetSelectedCount(hwnd); + expect(0, r); + r = ListView_GetSelectionMark(hwnd); + expect(-1, r); + + /* try to deselect all on LVS_SINGLESEL */ + item.stateMask = LVIS_SELECTED; + item.state = LVIS_SELECTED; + r = SendMessage(hwnd, LVM_SETITEMSTATE, 0, (LPARAM)&item); + expect(TRUE, r); + + item.stateMask = LVIS_SELECTED; + item.state = 0; + r = SendMessage(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item); + expect(TRUE, r); + r = ListView_GetSelectedCount(hwnd); + expect(0, r); + DestroyWindow(hwnd); }