X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c96c8649e6edeccbcd6aa40fdfa4da2e6ab5b59..96c9640205933ad0673d5af2c96af0816c50160c:/src/msw/imaglist.cpp diff --git a/src/msw/imaglist.cpp b/src/msw/imaglist.cpp index 087d6dddba..266af3feb0 100644 --- a/src/msw/imaglist.cpp +++ b/src/msw/imaglist.cpp @@ -159,7 +159,7 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) #endif // wxUSE_WXDIB && wxUSE_IMAGE hbmp = GetHbitmapOf(bitmap); - HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); + AutoHBITMAP hbmpMask(GetMaskForImage(bitmap, mask)); int index = ImageList_Add(GetHImageList(), hbmp, hbmpMask); if ( index == -1 ) @@ -167,8 +167,6 @@ int wxImageList::Add(const wxBitmap& bitmap, const wxBitmap& mask) wxLogError(_("Couldn't add an image to the image list.")); } - ::DeleteObject(hbmpMask); - return index; } @@ -237,17 +235,15 @@ bool wxImageList::Replace(int index, #endif // wxUSE_WXDIB && wxUSE_IMAGE hbmp = GetHbitmapOf(bitmap); - HBITMAP hbmpMask = GetMaskForImage(bitmap, mask); + AutoHBITMAP hbmpMask(GetMaskForImage(bitmap, mask)); - bool ok = ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) != 0; - if ( !ok ) + if ( !ImageList_Replace(GetHImageList(), index, hbmp, hbmpMask) ) { wxLogLastError(wxT("ImageList_Replace()")); + return false; } - ::DeleteObject(hbmpMask); - - return ok; + return true; } // Replaces a bitmap and mask from an icon. @@ -303,7 +299,7 @@ bool wxImageList::Draw(int index, if ( solidBackground ) { const wxBrush& brush = dc.GetBackground(); - if ( brush.Ok() ) + if ( brush.IsOk() ) { clr = wxColourToRGB(brush.GetColour()); } @@ -403,7 +399,7 @@ static HBITMAP GetMaskForImage(const wxBitmap& bitmap, const wxBitmap& mask) wxMask *pMask; bool deleteMask = false; - if ( mask.Ok() ) + if ( mask.IsOk() ) { hbmpMask = GetHbitmapOf(mask); pMask = NULL;