From: Kun Yang <yangkun@uniontech.com> Logs: When CreateDIBSection does not return a valid hbitmap, the source image is lost that only masked icon is shown in imagelist. Signed-off-by: Kun Yang <yangkun@uniontech.com> --- dlls/comctl32/imagelist.c | 9 +++++++++ dlls/comctl32/tests/imagelist.c | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index ab65bca7c07..5788bf22a53 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -3089,6 +3089,15 @@ static HBITMAP ImageList_CreateImage(HDC hdc, HIMAGELIST himl, UINT count) } } hbmNewBitmap = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, NULL, 0, 0); + if(!hbmNewBitmap) + { + UINT newImageCount = 1; + /*if CreateDIBSection failed, allocate for 1 image only.*/ + bmi->bmiHeader.biHeight = newImageCount * himl->cy; + hbmNewBitmap = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, NULL, 0, 0); + /*the max image count is set to 1, expand when exceeded.*/ + himl->cMaxImage = newImageCount; + } } else /*if (ilc == ILC_COLORDDB)*/ { diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 01dd0481705..38cf6c3de4a 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -2284,7 +2284,6 @@ static void test_create_destroy(void) ret = pImageList_AddMasked(himl, hbm, RGB(0, 0, 0)); ret = pImageList_GetImageInfo(himl, 0, &info); ok(ret, "got %d\n", ret); - todo_wine ok(info.hbmImage != NULL, "got %p\n", info.hbmImage); ok(info.hbmMask != NULL, "got %p\n", info.hbmMask); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10059