From 194f7c3d1fccc87b5110db64184f93ccd8640d85 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Feb 2014 01:15:50 +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/branches/WX_3_0_BRANCH@75769 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 c292bb77de..5ff927e656 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 )