From 2af825c6a665bb362051ab6b3778ea1543e498b2 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 13 Mar 2021 22:50:33 +0100 Subject: [PATCH] Fix setting image margin in wxButton (wxMSW) When button images are stored in the image list (BUTTON_IMAGELIST) their margins should be set with BCM_SETIMAGELIST message. BCM_SETTEXTMARGIN sets the margins around the text label and not the image. See #13130. --- src/msw/anybutton.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/msw/anybutton.cpp b/src/msw/anybutton.cpp index 6b61baa630..b7a018041c 100644 --- a/src/msw/anybutton.cpp +++ b/src/msw/anybutton.cpp @@ -256,13 +256,9 @@ public: virtual void SetBitmapMargins(wxCoord x, wxCoord y) wxOVERRIDE { - RECT& margin = m_data.margin; - ::SetRect(&margin, x, y, x, y); + ::SetRect(&m_data.margin, x, y, x, y); - if ( !::SendMessage(m_hwndBtn, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin) ) - { - wxLogDebug("SendMessage(BCM_SETTEXTMARGIN) failed"); - } + UpdateImageInfo(); } virtual wxDirection GetBitmapPosition() const wxOVERRIDE