X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0c589ad076cb531a3ef7808aaedadc03c8286942..c6e62f74fcac5b62889b59e7ce7a41d0ce884d7b:/src/msw/imaglist.cpp diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index a4e2fe629d..642fc9290c 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -37,13 +37,11 @@ #include "wx/msw/imaglist.h" #include "wx/msw/private.h" -#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) +#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) #include #endif -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject) -#endif wxImageList::wxImageList(void) { @@ -91,13 +89,36 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) HBITMAP hBitmap2 = 0; if ( mask.Ok() ) hBitmap2 = (HBITMAP) mask.GetHBITMAP(); + else if (bitmap.GetMask()) + hBitmap2 = (HBITMAP) bitmap.GetMask()->GetMaskBitmap(); + + HBITMAP hBitmapI=0; + if(hBitmap2!=0) { + // Microsoft imagelist masks are inverted from wxWindows mask standard (white is mask color) + BITMAP bm; + ::GetObject(hBitmap2,sizeof(BITMAP),(LPVOID)&bm); + int w=bm.bmWidth; + int h=bm.bmHeight; + HDC hdc = ::CreateCompatibleDC(NULL); + HDC hdci = ::CreateCompatibleDC(NULL); + hBitmapI = ::CreateCompatibleBitmap(hdci, w, h); + ::SelectObject(hdc, hBitmap2); + ::SelectObject(hdci, hBitmapI); + ::BitBlt(hdci, 0, 0, w, h, hdc, 0, 0, NOTSRCCOPY); + ::DeleteDC(hdc); + ::DeleteDC(hdci); + } - int index = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmap2); + int index = ImageList_Add((HIMAGELIST) GetHIMAGELIST(), hBitmap1, hBitmapI); if ( index == -1 ) { wxLogError(_("Couldn't add an image to the image list.")); } + // Clean up inverted mask + if(hBitmapI!=0) + ::DeleteObject(hBitmapI); + return index; }