comctl32: imagelist: SetImageCount can be used to decrease image count (with testcase).

This commit is contained in:
Mikołaj Zalewski 2006-09-20 17:42:29 +02:00 committed by Alexandre Julliard
parent 80664defa8
commit 89f537dd57
2 changed files with 11 additions and 2 deletions

View File

@ -2546,11 +2546,12 @@ ImageList_SetImageCount (HIMAGELIST himl, UINT iImageCount)
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;
}

View File

@ -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");