comctl32: Compute border size from client and window rectangles.
Fixes toolbar size when WS_EX_DLGMODALFRAME is used. Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
180f7cf412
commit
659b0d7017
|
@ -434,18 +434,23 @@ static void basic_test(void)
|
|||
DestroyWindow(hToolbar);
|
||||
}
|
||||
|
||||
static void rebuild_toolbar(HWND *hToolbar)
|
||||
static void rebuild_toolbar_ex(HWND *hToolbar, DWORD exstyle)
|
||||
{
|
||||
if (*hToolbar)
|
||||
DestroyWindow(*hToolbar);
|
||||
*hToolbar = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
|
||||
hMainWnd, (HMENU)5, GetModuleHandleA(NULL), NULL);
|
||||
*hToolbar = CreateWindowExA(exstyle, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE,
|
||||
0, 0, 0, 0, hMainWnd, (HMENU)5, GetModuleHandleA(NULL), NULL);
|
||||
ok(*hToolbar != NULL, "Toolbar creation problem\n");
|
||||
ok(SendMessageA(*hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0) == 0, "TB_BUTTONSTRUCTSIZE failed\n");
|
||||
ok(SendMessageA(*hToolbar, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
|
||||
ok(SendMessageA(*hToolbar, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0)==1, "WM_SETFONT\n");
|
||||
}
|
||||
|
||||
static void rebuild_toolbar(HWND *hToolbar)
|
||||
{
|
||||
rebuild_toolbar_ex(hToolbar, 0);
|
||||
}
|
||||
|
||||
static void rebuild_toolbar_with_buttons(HWND *hToolbar)
|
||||
{
|
||||
TBBUTTON buttons[5];
|
||||
|
@ -1022,7 +1027,7 @@ static void tbsize_addbutton(tbsize_result_t *tbsr, int left, int top, int right
|
|||
|
||||
static tbsize_result_t *tbsize_results;
|
||||
|
||||
#define tbsize_results_num 28
|
||||
#define tbsize_results_num 29
|
||||
|
||||
static void init_tbsize_results(void) {
|
||||
int fontheight = system_font_height();
|
||||
|
@ -1277,6 +1282,9 @@ static void init_tbsize_results(void) {
|
|||
|
||||
tbsize_results[27] = init_tbsize_result(1, 0, 0, 672, 42, 67, 40);
|
||||
tbsize_addbutton(&tbsize_results[27], 0, 2, 40, 24);
|
||||
|
||||
tbsize_results[28] = init_tbsize_result(1, 0, 0, 672, 42, 67, 40);
|
||||
tbsize_addbutton(&tbsize_results[28], 0, 2, 23, 24);
|
||||
}
|
||||
|
||||
static void free_tbsize_results(void) {
|
||||
|
@ -1360,6 +1368,7 @@ static void test_sizes(void)
|
|||
int style;
|
||||
int i;
|
||||
int fontheight = system_font_height();
|
||||
RECT rect;
|
||||
|
||||
init_tbsize_results();
|
||||
|
||||
|
@ -1631,6 +1640,15 @@ static void test_sizes(void)
|
|||
SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0 );
|
||||
check_sizes();
|
||||
|
||||
/* Toolbar with borders around client area */
|
||||
rebuild_toolbar_ex(&hToolbar, WS_EX_DLGMODALFRAME);
|
||||
SetWindowLongA(hToolbar, GWL_STYLE, CCS_NODIVIDER | GetWindowLongA(hToolbar, GWL_STYLE));
|
||||
SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)buttons1);
|
||||
check_sizes();
|
||||
GetClientRect(hToolbar, &rect);
|
||||
ok(rect.top == 0, "rect.top = %d\n", rect.top);
|
||||
ok(rect.bottom == 26, "rect.bottom = %d\n", rect.bottom);
|
||||
|
||||
free_tbsize_results();
|
||||
DestroyWindow(hToolbar);
|
||||
}
|
||||
|
|
|
@ -3069,7 +3069,7 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
|
|||
|
||||
if (!(infoPtr->dwStyle & CCS_NORESIZE))
|
||||
{
|
||||
RECT window_rect, parent_rect;
|
||||
RECT window_rect, client_rect, parent_rect, border;
|
||||
UINT uPosFlags = SWP_NOZORDER | SWP_NOACTIVATE;
|
||||
HWND parent;
|
||||
INT x, y, cx, cy;
|
||||
|
@ -3079,6 +3079,13 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
|
|||
if (!parent || !infoPtr->bDoRedraw)
|
||||
return 0;
|
||||
|
||||
GetWindowRect(infoPtr->hwndSelf, &window_rect);
|
||||
GetClientRect(infoPtr->hwndSelf, &client_rect);
|
||||
border = window_rect;
|
||||
MapWindowPoints(0, infoPtr->hwndSelf, (POINT *)&border, 2);
|
||||
border.right -= border.left + client_rect.right - client_rect.left;
|
||||
border.bottom -= border.top + client_rect.bottom - client_rect.top;
|
||||
|
||||
GetClientRect(parent, &parent_rect);
|
||||
|
||||
x = parent_rect.left;
|
||||
|
@ -3089,15 +3096,11 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
|
|||
|
||||
if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_NOMOVEY)
|
||||
{
|
||||
GetWindowRect(infoPtr->hwndSelf, &window_rect);
|
||||
MapWindowPoints( 0, parent, (POINT *)&window_rect, 2 );
|
||||
y = window_rect.top;
|
||||
}
|
||||
if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_BOTTOM)
|
||||
{
|
||||
GetWindowRect(infoPtr->hwndSelf, &window_rect);
|
||||
y = parent_rect.bottom - ( window_rect.bottom - window_rect.top);
|
||||
}
|
||||
|
||||
if (infoPtr->dwStyle & CCS_NOPARENTALIGN)
|
||||
uPosFlags |= SWP_NOMOVE;
|
||||
|
@ -3105,11 +3108,10 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
|
|||
if (!(infoPtr->dwStyle & CCS_NODIVIDER))
|
||||
cy += GetSystemMetrics(SM_CYEDGE);
|
||||
|
||||
if (infoPtr->dwStyle & WS_BORDER)
|
||||
{
|
||||
cx += 2 * GetSystemMetrics(SM_CXBORDER);
|
||||
cy += 2 * GetSystemMetrics(SM_CYBORDER);
|
||||
}
|
||||
x += border.left;
|
||||
y += border.top;
|
||||
cx += border.right;
|
||||
cy += border.bottom;
|
||||
|
||||
SetWindowPos(infoPtr->hwndSelf, NULL, x, y, cx, cy, uPosFlags);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue