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;
WORD numParts;
UINT height;
UINT minHeight; /* at least MIN_PANE_HEIGHT, can be increased by SB_SETMINHEIGHT */
BOOL simple;
HWND hwndToolTip;
HFONT hFont;
@ -119,7 +120,7 @@ STATUSBAR_ComputeHeight(STATUS_INFO *infoPtr)
COMCTL32_GetFontMetrics(infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont, &tm);
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)))
{
@ -128,7 +129,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;
@ -659,40 +660,9 @@ 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 = max(height, MIN_PANE_HEIGHT);
infoPtr->height = STATUSBAR_ComputeHeight(infoPtr);
/* like native, don't resize the control */
return TRUE;
}
@ -962,6 +932,7 @@ STATUSBAR_WMCreate (HWND hwnd, const CREATESTRUCTA *lpCreate)
infoPtr->horizontalBorder = HORZ_BORDER;
infoPtr->verticalBorder = VERT_BORDER;
infoPtr->horizontalGap = HORZ_GAP;
infoPtr->minHeight = MIN_PANE_HEIGHT;
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)
{
LOGFONT lf;
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);
@ -175,6 +175,32 @@ static void test_height(void)
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);
/* test the height formula */
ZeroMemory(&lf, sizeof(lf));
SendMessage(hwndStatus, SB_SETMINHEIGHT, 0, 0);
@ -185,6 +211,7 @@ static void test_height(void)
DestroyWindow(hwndStatus);
DeleteObject(hFont);
DeleteObject(hFontSm);
}
static void test_status_control(void)