[PATCH] comctl32: statusbar: test and fix SB_SETMINHEIGHT

Mikołaj Zalewski mikolaj at zalewski.pl
Wed Jul 16 13:52:36 CDT 2008


---
 dlls/comctl32/status.c       |   41 +++++------------------------------------
 dlls/comctl32/tests/status.c |   33 ++++++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 39 deletions(-)

diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index d2b9c0d..bbab393 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -72,6 +72,7 @@ typedef struct
     HWND              Notify;
     WORD              numParts;
     UINT              height;
+    UINT              minHeight;        /* minimum height set by SB_SETMINHEIGHT */
     BOOL              simple;
     HWND              hwndToolTip;
     HFONT             hFont;
@@ -116,7 +117,7 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
     TEXTMETRICW tm;
     
     COMCTL32_GetFontMetrics(infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont, &tm);
-    height = tm.tmHeight + tm.tmInternalLeading + 2 + infoPtr->verticalBorder;
+    height = max(tm.tmHeight + tm.tmInternalLeading + 2, infoPtr->minHeight) + infoPtr->verticalBorder;
 
     if ((theme = GetWindowTheme(infoPtr->Self)))
     {
@@ -125,7 +126,7 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
         HDC hdc = GetDC(infoPtr->Self);
         RECT r;
         memset (&r, 0, sizeof (r));
-        r.bottom = tm.tmHeight;
+        r.bottom = max(infoPtr->minHeight, tm.tmHeight);
         if (SUCCEEDED(GetThemeBackgroundExtent(theme, hdc, SP_PANE, 0, &r, &r)))
         {
             height = r.bottom - r.top;
@@ -656,40 +657,8 @@ STATUSBAR_SetIcon (STATUS_INFO *infoPtr, INT nPart, HICON hIcon)
 static BOOL
 STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height)
 {
-
-    TRACE("(height=%d)\n", height);
-    if (IsWindowVisible (infoPtr->Self)) {
-	INT  width, x, y;
-	RECT parent_rect;
-        HTHEME theme;
-
-	infoPtr->height = height + infoPtr->verticalBorder;
-        
-        if ((theme = GetWindowTheme (infoPtr->Self)))
-        {
-            /* Determine bar height from theme such that the content area is
-             * 'height' pixels large */
-            HDC hdc = GetDC (infoPtr->Self);
-            RECT r;
-            memset (&r, 0, sizeof (r));
-            r.bottom = height;
-            if (SUCCEEDED(GetThemeBackgroundExtent (theme, hdc, SP_PANE, 0, &r, &r)))
-            {
-                infoPtr->height = r.bottom - r.top;
-            }
-            ReleaseDC (infoPtr->Self, hdc);
-        }
-        
-        if (GetClientRect (infoPtr->Notify, &parent_rect))
-        {
-            width = parent_rect.right - parent_rect.left;
-            x = parent_rect.left;
-            y = parent_rect.bottom - infoPtr->height;
-            MoveWindow (infoPtr->Self, x, y, width, infoPtr->height, TRUE);
-            STATUSBAR_SetPartBounds (infoPtr);
-        }
-    }
-
+    infoPtr->minHeight = height;
+    infoPtr->height = STATUSBAR_ComputeHeight(infoPtr);
     return TRUE;
 }
 
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c
index 7aabf62..961a305 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -106,9 +106,9 @@ static void test_create()
     DestroyWindow(hwnd);
 }
 
-static void test_setfont()
+static void test_height()
 {
-    HFONT hFont;
+    HFONT hFont, hFontSm;
     RECT rc1, rc2;
     HWND hwndStatus = CreateWindow(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
         0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
@@ -131,8 +131,35 @@ static void test_setfont()
     GetClientRect(hwndStatus, &rc2);
     todo_wine expect_rect(0, 0, 672, 42, rc2);
 
+    /* minheight < fontsize - no effects*/
+    SendMessage(hwndStatus, SB_SETMINHEIGHT, 12, 0);
+    SendMessage(hwndStatus, WM_SIZE, 0, 0);
+    GetClientRect(hwndStatus, &rc2);
+    todo_wine expect_rect(0, 0, 672, 42, rc2);
+
+    /* minheight > fontsize - has an effect after WM_SIZE */
+    SendMessage(hwndStatus, SB_SETMINHEIGHT, 60, 0);
+    GetClientRect(hwndStatus, &rc2);
+    todo_wine expect_rect(0, 0, 672, 42, rc2);
+    SendMessage(hwndStatus, WM_SIZE, 0, 0);
+    GetClientRect(hwndStatus, &rc2);
+    expect_rect(0, 0, 672, 62, rc2);
+
+    /* font changed to smaller than minheight - has an effect */
+    SendMessage(hwndStatus, SB_SETMINHEIGHT, 30, 0);
+    expect_rect(0, 0, 672, 62, rc2);
+    SendMessage(hwndStatus, WM_SIZE, 0, 0);
+    GetClientRect(hwndStatus, &rc2);
+    todo_wine expect_rect(0, 0, 672, 42, rc2);
+    hFontSm = CreateFont(9, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET,
+        OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Tahoma");
+    SendMessage(hwndStatus, WM_SETFONT, (WPARAM)hFontSm, TRUE);
+    GetClientRect(hwndStatus, &rc2);
+    expect_rect(0, 0, 672, 32, rc2);
+
     DestroyWindow(hwndStatus);
     DeleteObject(hFont);
+    DeleteObject(hFontSm);
 }
 
 static void test_status_control(void)
@@ -294,5 +321,5 @@ START_TEST(status)
 
     test_status_control();
     test_create();
-    test_setfont();
+    test_height();
 }
-- 
1.5.4


--------------080805020507010007050203--



More information about the wine-patches mailing list