From ed39e7c039de49834be928f99595e1acdcac1d36 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Tue, 3 Feb 2004 00:08:34 +0000 Subject: [PATCH] Draw disabled toolbar buttons correctly. --- dlls/comctl32/toolbar.c | 72 ++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 8c1c67ea331..e84ea11c300 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -614,39 +614,51 @@ TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect) } -static void -TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, - HDC hdc, INT x, INT y) +static void TOOLBAR_DrawMasked(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, + HDC hdc, INT x, INT y) { HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, 0); - INT cx, cy; - HBITMAP hbmMask; - HDC hdcMask; - - if (!himl) - return; - - ImageList_GetIconSize(himl, &cx, &cy); - - /* create new dc's */ - hdcMask = CreateCompatibleDC (0); - /* create new bitmap */ - hbmMask = CreateBitmap (cx, cy, 1, 1, NULL); - SelectObject (hdcMask, hbmMask); - - /* copy the mask bitmap */ - ImageList_DrawEx(himl, btnPtr->iBitmap, hdcMask, 0, 0, 0, 0, RGB(255, 255, 255), RGB(0, 0, 0), ILD_MASK); - - /* draw the new mask */ - SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); - BitBlt (hdc, x+1, y+1, cx, cy, hdcMask, 0, 0, 0xB8074A); - - SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); - BitBlt (hdc, x, y, cx, cy, hdcMask, 0, 0, 0xB8074A); - - DeleteObject (hbmMask); - DeleteDC (hdcMask); + if (himl) + { + INT cx, cy; + HBITMAP hbmMask, hbmImage; + HDC hdcMask, hdcImage; + + ImageList_GetIconSize(himl, &cx, &cy); + + /* Create src image */ + hdcImage = CreateCompatibleDC(hdc); + hbmImage = CreateBitmap(cx, cy, GetDeviceCaps(hdc,PLANES), + GetDeviceCaps(hdc,BITSPIXEL), NULL); + SelectObject(hdcImage, hbmImage); + ImageList_DrawEx(himl, btnPtr->iBitmap, hdcImage, 0, 0, cx, cy, + RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_NORMAL); + + /* Create Mask */ + hdcMask = CreateCompatibleDC(0); + hbmMask = CreateBitmap(cx, cy, 1, 1, NULL); + SelectObject(hdcMask, hbmMask); + + /* Remove the background and all white pixels */ + SetBkColor(hdcImage, ImageList_GetBkColor(himl)); + BitBlt(hdcMask, 0, 0, cx, cy, hdcImage, 0, 0, SRCCOPY); + SetBkColor(hdcImage, RGB(0xff, 0xff, 0xff)); + BitBlt(hdcMask, 0, 0, cx, cy, hdcImage, 0, 0, NOTSRCERASE); + + /* draw the new mask 'etched' to hdc */ + SetBkColor(hdc, RGB(255, 255, 255)); + SelectObject(hdc, GetSysColorBrush(COLOR_3DHILIGHT)); + BitBlt(hdc, x + 1, y + 1, cx, cy, hdcMask, 0, 0, 0xE20746); + SelectObject(hdc, GetSysColorBrush(COLOR_3DSHADOW)); + BitBlt(hdc, x, y, cx, cy, hdcMask, 0, 0, 0xE20746); + + /* Cleanup */ + DeleteObject(hbmImage); + DeleteDC(hdcImage); + DeleteObject (hbmMask); + DeleteDC(hdcMask); + } } -- 2.11.4.GIT