listview: Allow LVIF_STATE flag in subitems.

Duane Clark fpga at pacbell.net
Sat Jan 6 17:55:45 CST 2007


When setting subitems, that LVIF_STATE flag is valid. However, the 
behavior is not particularly useful, and I have to wonder whether any 
applications actually use this feature. The application of interest to 
me, beersmith, sets the LVIF_STATE flag for subitems, but does not 
actually set the state. Instead, they obviously simply did not bother to 
remove the LVIF_STATE flag from the LVITEM structure when setting the 
subitems. And in Windows, this is okay.

The Wine listview code is full of assumptions which assume that the 
state applies only to the main item. It will require a lot of changes to 
remove that assumption. I think that until an application is found that 
depends on that behavior, it would be best to leave the code as is, with 
the exception of allowing the LVIF_STATE flag on subitems.

So the attached patch allows the LVIF_STATE flag when setting subitems, 
but does not actually do anything with the flag. Also included is a 
basic test, with a todo_wine for the ability to read back the state of 
subitems.

Changelog: Allow LVIF_STATE flag in subitems.
-------------- next part --------------
Subject: [PATCH] Allow LVIF_STATE in subitems, but it is not yet used.

---

 dlls/comctl32/listview.c       |    8 ++++++--
 dlls/comctl32/tests/listview.c |   27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

e1b66d679bcaee456292c593a1e6b3b9c0618533
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 6340c87..11e02ee 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -3506,8 +3506,12 @@ static BOOL set_sub_item(LISTVIEW_INFO *
     if (lpLVItem->iSubItem >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
    
     /* First do some sanity checks */
-    if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE)) return FALSE;
-    if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE))) return TRUE;
+    /* The LVIF_STATE flag is valid for subitems, but does not appear to be
+       particularly useful. We currently do not actually do anything with
+       the flag on subitems.
+    */
+    if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE | LVIF_STATE)) return FALSE;
+    if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE | LVIF_STATE))) return TRUE;
    
     /* get the subitem structure, and create it if not there */
     hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 127208c..9d14e39 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -313,6 +313,33 @@ static void test_items(void)
     ok(r != 0, "ret %d\n", r);
     ok(item.lParam == lparamTest, "got lParam %lx, expected %lx\n", item.lParam, lparamTest);
 
+    /**** Some tests of state highlighting ****/
+    memset (&item, 0xaa, sizeof (item));
+    item.mask = LVIF_STATE;
+    item.iItem = 0;
+    item.iSubItem = 0;
+    item.state = LVIS_SELECTED;
+    item.stateMask = LVIS_SELECTED | LVIS_DROPHILITED;
+    r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
+    ok(r != 0, "ret %d\n", r);
+    item.iSubItem = 1;
+    item.state = LVIS_DROPHILITED;
+    r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM) &item);
+    ok(r != 0, "ret %d\n", r);
+
+    memset (&item, 0xaa, sizeof (item));
+    item.mask = LVIF_STATE;
+    item.iItem = 0;
+    item.iSubItem = 0;
+    item.stateMask = -1;
+    r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
+    ok(r != 0, "ret %d\n", r);
+    ok(item.state == LVIS_SELECTED, "got state %x, expected %x\n", item.state, LVIS_SELECTED);
+    item.iSubItem = 1;
+    r = SendMessage(hwnd, LVM_GETITEM, 0, (LPARAM) &item);
+    ok(r != 0, "ret %d\n", r);
+    todo_wine ok(item.state == LVIS_DROPHILITED, "got state %x, expected %x\n", item.state, LVIS_DROPHILITED);
+
     DestroyWindow(hwnd);
 }
 
-- 
1.1.4


More information about the wine-patches mailing list