X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2e7a64e9e6043d934a117a32d781e01fb907a01e..f8816e49e4bef97dd9b2d706536849239dcfe4a6:/src/msw/bitmap.cpp diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 4f79bc0ddd..00df612886 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -1650,7 +1650,8 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, // Create an empty mask bitmap. // it doesn't seem to work if we mess with the mask at all. - HBITMAP hMonoBitmap = CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL); + AutoHBITMAP + hMonoBitmap(CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL)); ICONINFO iconInfo; wxZeroMemory(iconInfo); @@ -1664,11 +1665,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, iconInfo.hbmMask = hMonoBitmap; iconInfo.hbmColor = hbmp; - HICON hicon = ::CreateIconIndirect(&iconInfo); - - ::DeleteObject(hMonoBitmap); - - return hicon; + return ::CreateIconIndirect(&iconInfo); } wxMask* mask = bmp.GetMask(); @@ -1689,7 +1686,8 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, iconInfo.yHotspot = hotSpotY; } - iconInfo.hbmMask = wxInvertMask((HBITMAP)mask->GetMaskBitmap()); + AutoHBITMAP hbmpMask(wxInvertMask((HBITMAP)mask->GetMaskBitmap())); + iconInfo.hbmMask = hbmpMask; iconInfo.hbmColor = GetHbitmapOf(bmp); // black out the transparent area to preserve background colour, because @@ -1715,9 +1713,6 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, delete mask; } - // delete the inverted mask bitmap we created as well - ::DeleteObject(iconInfo.hbmMask); - return hicon; }