diff --git a/docs/changes.txt b/docs/changes.txt index 85fd4a59a6..e6d48f2285 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -171,6 +171,8 @@ wxMSW: spin button's client size. - Fixed IMPLEMENT_APP() to be compatible with the -WU flag of Borland C++ compiler (Matthias Bohm). +- Correct size calculation for toolbars containing controls under pre-XP + systems (Gerald Giese) wxGTK: diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index d0e246b8a3..de1fef7b7b 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -363,8 +363,25 @@ wxSize wxToolBar::DoGetBestSize() const sizeBest.y = t; } } - else + else // TB_GETMAXSIZE succeeded { + // but it could still return an incorrect result due to what appears to + // be a bug in old comctl32.dll versions which don't handle controls in + // the toolbar correctly, so work around it (see SF patch 1902358) + if ( !IsVertical() && wxApp::GetComCtl32Version() < 600 ) + { + // calculate the toolbar width in alternative way + RECT rcFirst, rcLast; + if ( ::SendMessage(GetHwnd(), TB_GETITEMRECT, 0, (LPARAM)&rcFirst) + && ::SendMessage(GetHwnd(), TB_GETITEMRECT, + GetToolsCount() - 1, (LPARAM)&rcLast) ) + { + const int widthAlt = rcLast.right - rcFirst.left; + if ( widthAlt > size.cx ) + size.cx = widthAlt; + } + } + sizeBest.x = size.cx; sizeBest.y = size.cy; }