diff --git a/src/msw/toolbar.cpp b/src/msw/toolbar.cpp index 8950c398dc..af6dbc1ca1 100644 --- a/src/msw/toolbar.cpp +++ b/src/msw/toolbar.cpp @@ -1450,21 +1450,51 @@ void wxToolBar::UpdateStretchableSpacersSize() const int newSize = --numSpaces ? sizeSpacer : sizeLastSpacer; if ( newSize != oldSize) { - WinStruct tbbi; - tbbi.dwMask = TBIF_BYINDEX | TBIF_SIZE; - tbbi.cx = newSize; - if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO, - toolIndex, (LPARAM)&tbbi) ) + // For horizontal toolbars we can just update the separator in + // place, but for some unknown reason this just doesn't do anything + // in the vertical case, so we have to delete the separator and it + // back with the correct size then. This has its own problems and + // may mess up toolbars idea of its best size, so do this only when + // necessary. + if ( !IsVertical() ) { - wxLogLastError(wxT("TB_SETBUTTONINFO (separator)")); + // Just update in place. + WinStruct tbbi; + tbbi.dwMask = TBIF_BYINDEX | TBIF_SIZE; + tbbi.cx = newSize; + if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO, + toolIndex, (LPARAM)&tbbi) ) + { + wxLogLastError(wxT("TB_SETBUTTONINFO (separator)")); + } } - else + else // Vertical case, use the workaround. { - // We successfully updated the separator width, move all the - // controls appearing after it by the corresponding amount - // (which may be positive or negative) - offset += newSize - oldSize; + if ( !::SendMessage(GetHwnd(), TB_DELETEBUTTON, toolIndex, 0) ) + { + wxLogLastError(wxT("TB_DELETEBUTTON (separator)")); + } + else + { + TBBUTTON button; + wxZeroMemory(button); + + button.idCommand = tool->GetId(); + button.iBitmap = newSize; // set separator height + button.fsState = TBSTATE_ENABLED | TBSTATE_WRAP; + button.fsStyle = TBSTYLE_SEP; + if ( !::SendMessage(GetHwnd(), TB_INSERTBUTTON, + toolIndex, (LPARAM)&button) ) + { + wxLogLastError(wxT("TB_INSERTBUTTON (separator)")); + } + } } + + // After updating the separator width, move all the + // controls appearing after it by the corresponding amount + // (which may be positive or negative) + offset += newSize - oldSize; } toolIndex++;