diff --git a/include/wx/msw/toolbar.h b/include/wx/msw/toolbar.h index dfd59adc8f..772e99aa12 100644 --- a/include/wx/msw/toolbar.h +++ b/include/wx/msw/toolbar.h @@ -136,6 +136,8 @@ protected: // get the Windows toolbar style of this control long GetMSWToolbarStyle() const; + // set native toolbar padding + void MSWSetPadding(WXWORD padding); // the big bitmap containing all bitmaps of the toolbar buttons WXHBITMAP m_hBitmap; diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 4f781c9afc..fa97401829 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -377,6 +377,15 @@ bool wxToolBar::Create(wxWindow *parent, return true; } +void wxToolBar::MSWSetPadding(WXWORD padding) +{ + DWORD curPadding = ::SendMessage(GetHwnd(), TB_GETPADDING, 0, 0); + // Preserve orthogonal padding + DWORD newPadding = IsVertical() ? MAKELPARAM(LOWORD(curPadding), padding) + : MAKELPARAM(padding, HIWORD(curPadding)); + ::SendMessage(GetHwnd(), TB_SETPADDING, 0, newPadding); +} + bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size) { if ( !MSWCreateControl(TOOLBARCLASSNAME, wxEmptyString, pos, size) ) @@ -389,6 +398,19 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size) ::SendMessage(GetHwnd(), TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS); #endif + // Retrieve or apply/restore tool packing value. + if ( m_toolPacking <= 0 ) + { + // Retrieve packing value if it hasn't been yet set with SetToolPacking. + DWORD padding = ::SendMessage(GetHwnd(), TB_GETPADDING, 0, 0); + m_toolPacking = IsVertical() ? HIWORD(padding) : LOWORD(padding); + } + else + { + // Apply packing value if it has been already set with SetToolPacking. + MSWSetPadding(m_toolPacking); + } + return true; }