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.
This commit is contained in:
Artur Wieczorek
2021-03-13 22:50:33 +01:00
parent f6194cb797
commit 2af825c6a6

View File

@@ -256,13 +256,9 @@ public:
virtual void SetBitmapMargins(wxCoord x, wxCoord y) wxOVERRIDE virtual void SetBitmapMargins(wxCoord x, wxCoord y) wxOVERRIDE
{ {
RECT& margin = m_data.margin; ::SetRect(&m_data.margin, x, y, x, y);
::SetRect(&margin, x, y, x, y);
if ( !::SendMessage(m_hwndBtn, BCM_SETTEXTMARGIN, 0, (LPARAM)&margin) ) UpdateImageInfo();
{
wxLogDebug("SendMessage(BCM_SETTEXTMARGIN) failed");
}
} }
virtual wxDirection GetBitmapPosition() const wxOVERRIDE virtual wxDirection GetBitmapPosition() const wxOVERRIDE