From f88fbcc2b3c7dd17c9c6130f71db77e357def28b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 24 Feb 2014 20:54:54 +0000 Subject: [PATCH] Add helper Set32bppHDIB() method to wxMSW wxBitmapRefData. No real changes, just add a helper to allow replacing the HBITMAP stored in wxBitmapRefData without changing anything else, this is going to be used in another place soon. See #12762. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76006 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/bitmap.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index d02cad9420..1c91e4101e 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -74,6 +74,11 @@ public: #if wxUSE_WXDIB // Takes ownership of the given DIB. bool AssignDIB(wxDIB& dib); + + // Also takes ownership of the given DIB, but doesn't change any other + // fields (which are supposed to be already set), and just updates + // m_hasAlpha because 32 bit DIBs always do have it. + void Set32bppHDIB(HBITMAP hdib); #endif // wxUSE_WXDIB @@ -310,6 +315,15 @@ bool wxBitmapRefData::AssignDIB(wxDIB& dib) return true; } +void wxBitmapRefData::Set32bppHDIB(HBITMAP hdib) +{ + Free(); + + m_isDIB = true; + m_hasAlpha = true; + m_hBitmap = hdib; +} + #endif // wxUSE_WXDIB // ---------------------------------------------------------------------------- @@ -424,11 +438,7 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon, { HBITMAP hdib = 0; if ( CheckAlpha(iconInfo.hbmColor, &hdib) ) - { - refData->m_hasAlpha = true; - ::DeleteObject(refData->m_hBitmap); - refData->m_hBitmap = hdib; - } + refData->Set32bppHDIB(hdib); } break; #endif // wxUSE_WXDIB