From 051418ac00ba05d029cc963c664e5b2046e17f2a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 26 Aug 2021 22:24:13 +0100 Subject: [PATCH] Fix recent wxMSW buttons with bitmaps appearance regression Revert both 53eff92ea7 (Call AdjustForBitmapMargins() only once in wxAnyButton, 2021-04-24), which was completely wrong and was due to not reading the code attentively enough, and the subsequent 5d508b6e6 (Fix regression in sizes of buttons with bitmaps in wxMSW, 2021-07-08) which fixed the problem introduced by the first commit partly, but not completely. Closes #13130. --- src/msw/anybutton.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index b329f2796a..9310e33f1a 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -589,6 +589,9 @@ wxSize wxAnyButton::DoGetBestSize() const SIZE idealSize = { 0, 0 }; if ( ::SendMessage(GetHwnd(), BCM_GETIDEALSIZE, 0, (LPARAM)&idealSize) ) size.Set(idealSize.cx, idealSize.cy); + + if ( m_imageData ) + AdjustForBitmapMargins(size); } // If we failed to set the size using BCM_GETIDEALSIZE above, determine it @@ -618,10 +621,10 @@ wxSize wxAnyButton::DoGetBestSize() const size = wxMSWButton::ComputeBestFittingSize(self, flags); } } - } - if ( m_imageData ) - AdjustForBitmapSize(size); + if ( m_imageData ) + AdjustForBitmapSize(size); + } return wxMSWButton::IncreaseToStdSizeAndCache(self, size); }