comctl32[2/6]: imagelist: SetImageCount can be used to decrease image count (with testcase)

Mikołaj Zalewski mikolaj at zalewski.pl
Wed Sep 20 10:42:29 CDT 2006


-------------- next part --------------
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index cc3078e..faf5371 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -2546,11 +2546,12 @@ ImageList_SetImageCount (HIMAGELIST himl
 
     if (!is_valid(himl))
 	return FALSE;
-    if (himl->cCurImage >= iImageCount)
-	return FALSE;
+    if (iImageCount < 0)
+        return FALSE;
     if (himl->cMaxImage > iImageCount)
     {
         himl->cCurImage = iImageCount;
+        /* TODO: shrink the bitmap when cMaxImage-cCurImage>cGrow ? */
 	return TRUE;
     }
 
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c
index 0ecb03a..6278adc 100644
--- a/dlls/comctl32/tests/imagelist.c
+++ b/dlls/comctl32/tests/imagelist.c
@@ -327,6 +327,14 @@ static BOOL DoTest1(void)
     /* remove one extra */
     ok(!ImageList_Remove(himl,0),"removed nonexistent icon\n");
 
+    /* check SetImageCount/GetImageCount */
+    ok(ImageList_SetImageCount(himl, 3), "couldn't increase image count\n");
+    ok(ImageList_GetImageCount(himl) == 3, "invalid image count after increase\n");
+    ok(ImageList_SetImageCount(himl, 1), "couldn't decrease image count\n");
+    ok(ImageList_GetImageCount(himl) == 1, "invalid image count after decrease to 1\n");
+    ok(ImageList_SetImageCount(himl, 0), "couldn't decrease image count\n");
+    ok(ImageList_GetImageCount(himl) == 0, "invalid image count after decrease to 0\n");
+
     /* destroy it */
     ok(ImageList_Destroy(himl),"destroy imagelist failed\n");
 
-- 
1.4.1


More information about the wine-patches mailing list