From: Zhiyi Zhang <zzhang@codeweavers.com> Some applications mistakenly use a very large initial image count. On Windows, there is no limit on how large an imagelist can be. This makes sure that the GDI handle limit will be reached before hitting the imagelist limit. --- dlls/comctl32/imagelist.c | 6 ++++++ dlls/comctl32/tests/imagelist.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index ba340645db8..1d76cec81e7 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -39,6 +39,7 @@ #include "winbase.h" #include "objbase.h" #include "wingdi.h" +#include "ntgdi.h" #include "winuser.h" #include "commctrl.h" #include "comctl32.h" @@ -3663,6 +3664,11 @@ static HRESULT WINAPI ImageListImpl_Initialize(IImageList2 *iface, INT cx, INT c grow = 256; } + /* Some applications mistakenly use a very large initial image count. On Windows, there is no + * limit of how large a imagelist can be. This makes sure that GDI handle limit will be reached + * before hitting the imagelist limit */ + initial = min(initial, GDI_MAX_HANDLE_COUNT); + himl->cx = cx; himl->cy = cy; himl->flags = flags; diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index c2b04f622a4..1921567627f 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -2274,7 +2274,6 @@ static void test_create_destroy(void) ok(ret != -1, "Failed to add an image.\n"); ret = pImageList_GetImageInfo(himl, 0, &info); ok(ret, "got %d\n", ret); - todo_wine ok(info.hbmImage != NULL, "got %p\n", info.hbmImage); DeleteObject(hbm); pImageList_Destroy(himl); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10382