LISTVIEW_InsertItemT should accept iItem < 0

Peter Åstrand astrand at cendio.se
Thu Mar 2 04:09:12 CST 2006


Windows accepts LISTVIEW_InsertItem with iItem < 0, when using sorted
lists. The patch below makes Wine behave just like Windows.

Changelog:

dlls/comctl32/listview.c:
comctl32: LISTVIEW_InsertItemT should accept iItem < 0, when using
sorted lists.

Patch:

Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.440
diff -u -r1.440 listview.c
--- dlls/comctl32/listview.c	31 Jan 2006 12:06:30 -0000	1.440
+++ dlls/comctl32/listview.c	2 Mar 2006 10:04:27 -0000
@@ -6211,7 +6211,7 @@
      if (infoPtr->dwStyle & LVS_OWNERDATA) return infoPtr->nItemCount++;

      /* make sure it's an item, and not a subitem; cannot insert a subitem */
-    if (!lpLVItem || lpLVItem->iItem < 0 || lpLVItem->iSubItem) return -1;
+    if (!lpLVItem || lpLVItem->iSubItem) return -1;

      if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return -1;

@@ -6224,6 +6224,8 @@
      is_sorted = (infoPtr->dwStyle & (LVS_SORTASCENDING | LVS_SORTDESCENDING)) &&
  	        !(infoPtr->dwStyle & LVS_OWNERDRAWFIXED) && (LPSTR_TEXTCALLBACKW != lpLVItem->pszText);

+    if (lpLVItem->iItem < 0 && !is_sorted) return -1;
+
      nItem = is_sorted ? infoPtr->nItemCount : min(lpLVItem->iItem, infoPtr->nItemCount);
      TRACE(" inserting at %d, sorted=%d, count=%d, iItem=%d\n", nItem, is_sorted, infoPtr->nItemCount, lpLVItem->iItem);
      nItem = DPA_InsertPtr( infoPtr->hdpaItems, nItem, hdpaSubItems );


-- 
Peter Åstrand		ThinLinc Chief Developer
Cendio			http://www.cendio.se
Teknikringen 3
583 30 Linköping        Phone: +46-13-21 46 00


More information about the wine-patches mailing list