]> git.saurik.com Git - wxWidgets.git/commitdiff
use TB_GETMAXSIZE in GetBestSize() (patch 1050045)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Nov 2004 23:12:44 +0000 (23:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Nov 2004 23:12:44 +0000 (23:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30434 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/tbar95.cpp

index 1d667c258d340706ae705aecc69313e22b521c9a..c5d3aaa39e9bb9a4dd0cc1ef445dcf62000e27e8 100644 (file)
     #define TB_HITTEST              (WM_USER + 69)
 #endif
 
+#ifndef TB_GETMAXSIZE
+    #define TB_GETMAXSIZE           (WM_USER + 83)
+#endif
+
 // these values correspond to those used by comctl32.dll
 #define DEFAULTBITMAPX   16
 #define DEFAULTBITMAPY   15
@@ -338,11 +342,31 @@ wxToolBar::~wxToolBar()
 
 wxSize wxToolBar::DoGetBestSize() const
 {
-    wxSize sizeBest = GetToolSize();
-    sizeBest.x *= GetToolsCount();
+    wxSize sizeBest;
+
+    SIZE size;
+    if ( !::SendMessage(GetHwnd(), TB_GETMAXSIZE, 0, (LPARAM)&size) )
+    {
+        // maybe an old (< 0x400) Windows version? try to approximate the
+        // toolbar size ourselves
+        sizeBest = GetToolSize();
+        sizeBest.x *= GetToolsCount();
+
+        // reverse horz and vertical components if necessary
+        if ( HasFlag(wxTB_VERTICAL) )
+        {
+            int t = sizeBest.x;
+            sizeBest.x = sizeBest.y;
+            sizeBest.y = t;
+        }
+    }
+    else
+    {
+        sizeBest.x = size.cx;
+        sizeBest.y = size.cy;
+    }
 
-    // reverse horz and vertical components if necessary
-    return HasFlag(wxTB_VERTICAL) ? wxSize(sizeBest.y, sizeBest.x) : sizeBest;
+    return sizeBest;
 }
 
 WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const