From d9fc8e993a3de81c03bd1b91c5fca15839c1f7d1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 30 Nov 2011 00:52:34 +0000 Subject: [PATCH] Make wxMSW status bar slightly less tall by default. The status bar in wxMSW applications was too big under Windows 7 because it used EDIT_HEIGHT_FROM_CHAR_HEIGHT() to calculate the height which was simply unwarranted here. Instead, make the status bar tall enough to accommodate simple text contents by default and fix SetMinHeight() to actually work for the cases when a taller toolbar is needed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69867 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/statusbar.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index 7bfb81bc9d..48960afe22 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -405,7 +405,18 @@ const wxStatusBar::MSWMetrics& wxStatusBar::MSWGetMetrics() void wxStatusBar::SetMinHeight(int height) { - SendMessage(GetHwnd(), SB_SETMINHEIGHT, height + 2*GetBorderY(), 0); + // It looks like we need to count the border twice to really make the + // controls taking exactly height pixels fully fit in the status bar: + // at least under Windows 7 the checkbox in the custom status bar of the + // statbar sample gets truncated otherwise. + height += 4*GetBorderY(); + + // We need to set the size and not the size to reflect the height because + // wxFrame uses our size and not the minimal size as it assumes that the + // size of a status bar never changes anyhow. + SetSize(-1, height); + + SendMessage(GetHwnd(), SB_SETMINHEIGHT, height, 0); // we have to send a (dummy) WM_SIZE to redraw it now SendMessage(GetHwnd(), WM_SIZE, 0, 0); @@ -475,11 +486,10 @@ wxSize wxStatusBar::DoGetBestSize() const width = 2*DEFAULT_FIELD_WIDTH; } - // calculate height - int height; - wxGetCharSize(GetHWND(), NULL, &height, GetFont()); - height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(height); - height += borders.vert; + // calculate height: by default it should be just big enough to show text + // (see SetMinHeight() for the explanation of 4 factor) + int height = GetCharHeight(); + height += 4*borders.vert; wxSize best(width, height); CacheBestSize(best); -- 2.45.2