LISTVIEW_SetItemCount without LVS_OWNERDATA take 3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With a lot of help from Dimi, and his insistence that I be more careful about error handling :-) This version supersedes the previous versions.

Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.338
diff -u -r1.338 listview.c
--- dlls/comctl32/listview.c	24 Jan 2003 00:54:59 -0000	1.338
+++ dlls/comctl32/listview.c	3 Feb 2003 16:50:05 -0000
@@ -6657,13 +6659,28 @@
     }
     else
     {
-	/* According to MSDN for non-LVS_OWNERDATA this is just
-	 * a performance issue. The control allocates its internal
-	 * data structures for the number of items specified. It
-	 * cuts down on the number of memory allocations. Therefore
-	 * we will just issue a WARN here
-	 */
-	WARN("for non-ownerdata performance option not implemented.\n");
+        HDPA hdpaSubItems;
+        ITEM_INFO *lpItem;
+        INT i;
+        INT nOldCount = infoPtr->nItemCount;
+
+        /* From the description in MSDN, it does not appear this function can
+         * be used to decrease the number of items.
+         */
+        if (nItems <= nOldCount) return TRUE;
+        
+        for (i=nOldCount; i<nItems; i++)
+        {
+            if ( !(lpItem = (ITEM_INFO *)COMCTL32_Alloc(sizeof(ITEM_INFO))) ) goto fail;
+            if ( !(hdpaSubItems = DPA_Create(8)) ) goto fail;
+            if ( !DPA_SetPtr(hdpaSubItems, 0, lpItem) ) goto fail;
+            if ( DPA_InsertPtr( infoPtr->hdpaItems, i, hdpaSubItems ) < 0) goto fail;
+            infoPtr->nItemCount++;
+        }
+fail:
+	COMCTL32_Free(lpItem);
+	DPA_Destroy(hdpaSubItems );
+	return FALSE;
     }
 
     return TRUE;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux