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 )