comctl32: statusbar: Test and fix SB_SETMINHEIGHT.

The minimal height should be saved so that it survives WM_SIZE or WM_SETFONT.
This commit is contained in:
Mikołaj Zalewski 2008-07-22 21:29:19 +02:00 committed by Alexandre Julliard
parent a289bab122
commit 72d4318c8c
2 changed files with 35 additions and 37 deletions

View File

@ -72,6 +72,7 @@ typedef struct
HWND Notify; HWND Notify;
WORD numParts; WORD numParts;
UINT height; UINT height;
UINT minHeight; /* at least MIN_PANE_HEIGHT, can be increased by SB_SETMINHEIGHT */
BOOL simple; BOOL simple;
HWND hwndToolTip; HWND hwndToolTip;
HFONT hFont; HFONT hFont;
@ -119,7 +120,7 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
COMCTL32_GetFontMetrics(infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont, &tm); COMCTL32_GetFontMetrics(infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont, &tm);
margin = (tm.tmInternalLeading ? tm.tmInternalLeading : 2); margin = (tm.tmInternalLeading ? tm.tmInternalLeading : 2);
height = max(tm.tmHeight + margin + 2*GetSystemMetrics(SM_CYBORDER), MIN_PANE_HEIGHT) + infoPtr->verticalBorder; height = max(tm.tmHeight + margin + 2*GetSystemMetrics(SM_CYBORDER), infoPtr->minHeight) + infoPtr->verticalBorder;
if ((theme = GetWindowTheme(infoPtr->Self))) if ((theme = GetWindowTheme(infoPtr->Self)))
{ {
@ -128,7 +129,7 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
HDC hdc = GetDC(infoPtr->Self); HDC hdc = GetDC(infoPtr->Self);
RECT r; RECT r;
memset (&r, 0, sizeof (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))) if (SUCCEEDED(GetThemeBackgroundExtent(theme, hdc, SP_PANE, 0, &r, &r)))
{ {
height = r.bottom - r.top; height = r.bottom - r.top;
@ -659,40 +660,9 @@ STATUSBAR_SetIcon (STATUS_INFO *infoPtr, INT nPart, HICON hIcon)
static BOOL static BOOL
STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height) STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height)
{ {
infoPtr->minHeight = max(height, MIN_PANE_HEIGHT);
TRACE("(height=%d)\n", height); infoPtr->height = STATUSBAR_ComputeHeight(infoPtr);
if (IsWindowVisible (infoPtr->Self)) { /* like native, don't resize the control */
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);
}
}
return TRUE; return TRUE;
} }
@ -962,6 +932,7 @@ STATUSBAR_WMCreate (HWND hwnd, const CREATESTRUCTA *lpCreate)
infoPtr->horizontalBorder = HORZ_BORDER; infoPtr->horizontalBorder = HORZ_BORDER;
infoPtr->verticalBorder = VERT_BORDER; infoPtr->verticalBorder = VERT_BORDER;
infoPtr->horizontalGap = HORZ_GAP; infoPtr->horizontalGap = HORZ_GAP;
infoPtr->minHeight = MIN_PANE_HEIGHT;
STATUSBAR_NotifyFormat(infoPtr, infoPtr->Notify, NF_REQUERY); STATUSBAR_NotifyFormat(infoPtr, infoPtr->Notify, NF_REQUERY);

View File

@ -151,7 +151,7 @@ static int CALLBACK check_height_family_enumproc(ENUMLOGFONTEX *enumlf, NEWTEXTM
static void test_height(void) static void test_height(void)
{ {
LOGFONT lf; LOGFONT lf;
HFONT hFont; HFONT hFont, hFontSm;
RECT rc1, rc2; RECT rc1, rc2;
HWND hwndStatus = CreateWindow(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE, HWND hwndStatus = CreateWindow(SUBCLASS_NAME, NULL, WS_CHILD|WS_VISIBLE,
0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL); 0, 0, 300, 20, g_hMainWnd, NULL, NULL, NULL);
@ -175,6 +175,32 @@ static void test_height(void)
GetClientRect(hwndStatus, &rc2); GetClientRect(hwndStatus, &rc2);
todo_wine expect_rect(0, 0, 672, 42, 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);
/* test the height formula */ /* test the height formula */
ZeroMemory(&lf, sizeof(lf)); ZeroMemory(&lf, sizeof(lf));
SendMessage(hwndStatus, SB_SETMINHEIGHT, 0, 0); SendMessage(hwndStatus, SB_SETMINHEIGHT, 0, 0);
@ -185,6 +211,7 @@ static void test_height(void)
DestroyWindow(hwndStatus); DestroyWindow(hwndStatus);
DeleteObject(hFont); DeleteObject(hFont);
DeleteObject(hFontSm);
} }
static void test_status_control(void) static void test_status_control(void)