From a4c9d96aca1a6298d75d0c80fc31b0935173af9c Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 14 Nov 2007 12:38:35 +0100 Subject: [PATCH] comctl32: Fixed handling of monochrome icons in image lists. --- dlls/comctl32/imagelist.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index ee1ef0e0fa5..c604abc5da2 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -2291,8 +2291,6 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon) return -1; } - if (ii.hbmColor == 0) - ERR("no color!\n"); ret = GetObjectW (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); if (!ret) { ERR("couldn't get mask bitmap info\n"); @@ -2317,18 +2315,32 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT nIndex, HICON hIcon) if (hdcImage == 0) ERR("invalid hdcImage!\n"); + imagelist_point_from_index(himl, nIndex, &pt); + SetTextColor(himl->hdcImage, RGB(0,0,0)); SetBkColor (himl->hdcImage, RGB(255,255,255)); - hbmOldSrc = SelectObject (hdcImage, ii.hbmColor); - imagelist_point_from_index(himl, nIndex, &pt); - StretchBlt (himl->hdcImage, pt.x, pt.y, himl->cx, himl->cy, - hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); - - if (himl->hbmMask) { - SelectObject (hdcImage, ii.hbmMask); - StretchBlt (himl->hdcMask, pt.x, pt.y, himl->cx, himl->cy, - hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + if (ii.hbmColor) + { + hbmOldSrc = SelectObject (hdcImage, ii.hbmColor); + StretchBlt (himl->hdcImage, pt.x, pt.y, himl->cx, himl->cy, + hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + if (himl->hbmMask) + { + SelectObject (hdcImage, ii.hbmMask); + StretchBlt (himl->hdcMask, pt.x, pt.y, himl->cx, himl->cy, + hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); + } + } + else + { + UINT height = bmp.bmHeight / 2; + hbmOldSrc = SelectObject (hdcImage, ii.hbmMask); + StretchBlt (himl->hdcImage, pt.x, pt.y, himl->cx, himl->cy, + hdcImage, 0, height, bmp.bmWidth, height, SRCCOPY); + if (himl->hbmMask) + StretchBlt (himl->hdcMask, pt.x, pt.y, himl->cx, himl->cy, + hdcImage, 0, 0, bmp.bmWidth, height, SRCCOPY); } SelectObject (hdcImage, hbmOldSrc);