X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae090fdb7f4be47466b5728ad37065923b48c8c3..12335fa6aa8db0d0044ff4dbfa9ea056b57b0a66:/src/msw/imaglist.cpp diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 5140135aeb..46cb341d12 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -315,37 +315,41 @@ bool wxImageList::Draw(int index, static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask) { HBITMAP hbmpMask; - wxBitmap *bmpMask = NULL; + wxMask *pMask; + bool deleteMask = FALSE; if ( mask.Ok() ) { hbmpMask = GetHbitmapOf(mask); + pMask = NULL; } else { - wxMask *pMask = bitmap.GetMask(); - if ( pMask ) + pMask = bitmap.GetMask(); + if ( !pMask ) { - hbmpMask = (HBITMAP)pMask->GetMaskBitmap(); - } - else - { - // create a non transparent mask - apparently, this is needed under - // Win9x (it doesn't behave correctly if it's passed 0 mask) - bmpMask = new wxBitmap(bitmap.GetWidth(), bitmap.GetHeight(), 1); + // use the light grey count as transparent: the trouble here is + // that the light grey might have been changed by Windows behind + // our back, so use the standard colour map to get its real value + wxCOLORMAP *cmap = wxGetStdColourMap(); + wxColour col; + wxRGBToColour(col, cmap[wxSTD_COL_BTNFACE].from); - wxMemoryDC dcMem; - dcMem.SelectObject(*bmpMask); - dcMem.Clear(); - dcMem.SelectObject(wxNullBitmap); + pMask = new wxMask(bitmap, col); - hbmpMask = GetHbitmapOf(*bmpMask); + deleteMask = TRUE; } + + hbmpMask = (HBITMAP)pMask->GetMaskBitmap(); } // windows mask convention is opposite to the wxWindows one HBITMAP hbmpMaskInv = wxInvertMask(hbmpMask); - delete bmpMask; + + if ( deleteMask ) + { + delete pMask; + } return hbmpMaskInv; }