Commit 659b0d70 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

comctl32: Compute border size from client and window rectangles.

Fixes toolbar size when WS_EX_DLGMODALFRAME is used. Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 180f7cf4
...@@ -434,18 +434,23 @@ static void basic_test(void) ...@@ -434,18 +434,23 @@ static void basic_test(void)
DestroyWindow(hToolbar); DestroyWindow(hToolbar);
} }
static void rebuild_toolbar(HWND *hToolbar) static void rebuild_toolbar_ex(HWND *hToolbar, DWORD exstyle)
{ {
if (*hToolbar) if (*hToolbar)
DestroyWindow(*hToolbar); DestroyWindow(*hToolbar);
*hToolbar = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, *hToolbar = CreateWindowExA(exstyle, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE,
hMainWnd, (HMENU)5, GetModuleHandleA(NULL), NULL); 0, 0, 0, 0, hMainWnd, (HMENU)5, GetModuleHandleA(NULL), NULL);
ok(*hToolbar != NULL, "Toolbar creation problem\n"); ok(*hToolbar != NULL, "Toolbar creation problem\n");
ok(SendMessageA(*hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0) == 0, "TB_BUTTONSTRUCTSIZE failed\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, TB_AUTOSIZE, 0, 0) == 0, "TB_AUTOSIZE failed\n");
ok(SendMessageA(*hToolbar, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0)==1, "WM_SETFONT\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) static void rebuild_toolbar_with_buttons(HWND *hToolbar)
{ {
TBBUTTON buttons[5]; TBBUTTON buttons[5];
...@@ -1022,7 +1027,7 @@ static void tbsize_addbutton(tbsize_result_t *tbsr, int left, int top, int right ...@@ -1022,7 +1027,7 @@ static void tbsize_addbutton(tbsize_result_t *tbsr, int left, int top, int right
static tbsize_result_t *tbsize_results; static tbsize_result_t *tbsize_results;
#define tbsize_results_num 28 #define tbsize_results_num 29
static void init_tbsize_results(void) { static void init_tbsize_results(void) {
int fontheight = system_font_height(); int fontheight = system_font_height();
...@@ -1277,6 +1282,9 @@ static void init_tbsize_results(void) { ...@@ -1277,6 +1282,9 @@ static void init_tbsize_results(void) {
tbsize_results[27] = init_tbsize_result(1, 0, 0, 672, 42, 67, 40); tbsize_results[27] = init_tbsize_result(1, 0, 0, 672, 42, 67, 40);
tbsize_addbutton(&tbsize_results[27], 0, 2, 40, 24); 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) { static void free_tbsize_results(void) {
...@@ -1360,6 +1368,7 @@ static void test_sizes(void) ...@@ -1360,6 +1368,7 @@ static void test_sizes(void)
int style; int style;
int i; int i;
int fontheight = system_font_height(); int fontheight = system_font_height();
RECT rect;
init_tbsize_results(); init_tbsize_results();
...@@ -1631,6 +1640,15 @@ static void test_sizes(void) ...@@ -1631,6 +1640,15 @@ static void test_sizes(void)
SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0 ); SendMessageA(hToolbar, TB_AUTOSIZE, 0, 0 );
check_sizes(); 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(); free_tbsize_results();
DestroyWindow(hToolbar); DestroyWindow(hToolbar);
} }
......
...@@ -3069,7 +3069,7 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr) ...@@ -3069,7 +3069,7 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
if (!(infoPtr->dwStyle & CCS_NORESIZE)) if (!(infoPtr->dwStyle & CCS_NORESIZE))
{ {
RECT window_rect, parent_rect; RECT window_rect, client_rect, parent_rect, border;
UINT uPosFlags = SWP_NOZORDER | SWP_NOACTIVATE; UINT uPosFlags = SWP_NOZORDER | SWP_NOACTIVATE;
HWND parent; HWND parent;
INT x, y, cx, cy; INT x, y, cx, cy;
...@@ -3079,6 +3079,13 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr) ...@@ -3079,6 +3079,13 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
if (!parent || !infoPtr->bDoRedraw) if (!parent || !infoPtr->bDoRedraw)
return 0; 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); GetClientRect(parent, &parent_rect);
x = parent_rect.left; x = parent_rect.left;
...@@ -3089,15 +3096,11 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr) ...@@ -3089,15 +3096,11 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_NOMOVEY)
{ {
GetWindowRect(infoPtr->hwndSelf, &window_rect);
MapWindowPoints( 0, parent, (POINT *)&window_rect, 2 ); MapWindowPoints( 0, parent, (POINT *)&window_rect, 2 );
y = window_rect.top; y = window_rect.top;
} }
if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_BOTTOM) if ((infoPtr->dwStyle & CCS_BOTTOM) == CCS_BOTTOM)
{
GetWindowRect(infoPtr->hwndSelf, &window_rect);
y = parent_rect.bottom - ( window_rect.bottom - window_rect.top); y = parent_rect.bottom - ( window_rect.bottom - window_rect.top);
}
if (infoPtr->dwStyle & CCS_NOPARENTALIGN) if (infoPtr->dwStyle & CCS_NOPARENTALIGN)
uPosFlags |= SWP_NOMOVE; uPosFlags |= SWP_NOMOVE;
...@@ -3105,11 +3108,10 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr) ...@@ -3105,11 +3108,10 @@ TOOLBAR_AutoSize (TOOLBAR_INFO *infoPtr)
if (!(infoPtr->dwStyle & CCS_NODIVIDER)) if (!(infoPtr->dwStyle & CCS_NODIVIDER))
cy += GetSystemMetrics(SM_CYEDGE); cy += GetSystemMetrics(SM_CYEDGE);
if (infoPtr->dwStyle & WS_BORDER) x += border.left;
{ y += border.top;
cx += 2 * GetSystemMetrics(SM_CXBORDER); cx += border.right;
cy += 2 * GetSystemMetrics(SM_CYBORDER); cy += border.bottom;
}
SetWindowPos(infoPtr->hwndSelf, NULL, x, y, cx, cy, uPosFlags); SetWindowPos(infoPtr->hwndSelf, NULL, x, y, cx, cy, uPosFlags);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment