[3/5] comctl32/listview: Select all items with LVM_SETITEMSTATE is blocked in LVS_SINGLESEL

Nikolay Sivov bunglehead at gmail.com
Mon May 11 03:01:09 CDT 2009


Changelog:
    - Select all items with LVM_SETITEMSTATE is blocked in LVS_SINGLESEL (with tests)

>From 70682fba2c6a87efd0018a55c82b8faf2dbf9b37 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun, 10 May 2009 13:02:57 +0400
Subject: 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(+), 0 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 1928d4b..7bed09e 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 e94bdaa..5987e1e 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);
 }
 
-- 
1.5.6.5





More information about the wine-patches mailing list