From 08247522368bca387f23f526ebd4e0232e1b1038 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 19 Jan 2014 13:15:57 +0000 Subject: [PATCH] Fix appearance of tools with alpha bitmaps in wxMSW wxToolBar. Recent changes broke the handling of tools with alpha bitmaps as drawing them on the global toolbar bitmap changes its underlying HBITMAP now, but the code in wxToolBar didn't expect this. Fix it by updating the HBITMAP used after every DrawBitmap() call, just in case it changed (it doesn't cost anything to reset it if it did not). Closes #15876. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75649 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/toolbar.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index a45adb5418..48a2f3afed 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -748,8 +748,7 @@ bool wxToolBar::Realize() dcAllButtons.Clear(); } - m_hBitmap = bitmap.GetHBITMAP(); - HBITMAP hBitmap = (HBITMAP)m_hBitmap; + HBITMAP hBitmap = GetHbitmapOf(bitmap); #ifdef wxREMAP_BUTTON_COLOURS if ( remapValue == Remap_Bg ) @@ -789,6 +788,12 @@ bool wxToolBar::Realize() // notice the last parameter: do use mask dcAllButtons.DrawBitmap(bmp, x + xOffset, yOffset, true); + + // Handle of the bitmap could have changed inside + // DrawBitmap() call if it had to convert it from DDB to + // DIB internally, as is necessary if the bitmap being + // drawn had alpha channel. + hBitmap = GetHbitmapOf(bitmap); } else { @@ -861,6 +866,8 @@ bool wxToolBar::Realize() } #endif // wxREMAP_BUTTON_COLOURS + m_hBitmap = hBitmap; + bool addBitmap = true; if ( oldToolBarBitmap )