comctl32/updown: Reset control width conditionally on UDM_SETBUDDY with NULL buddy handle.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2d7aa09323
commit
030488bc76
|
@ -522,6 +522,7 @@ static void test_updown_pos32(void)
|
||||||
static void test_updown_buddy(void)
|
static void test_updown_buddy(void)
|
||||||
{
|
{
|
||||||
HWND updown, buddyReturn, buddy;
|
HWND updown, buddyReturn, buddy;
|
||||||
|
RECT rect, rect2;
|
||||||
WNDPROC proc;
|
WNDPROC proc;
|
||||||
DWORD style;
|
DWORD style;
|
||||||
|
|
||||||
|
@ -568,8 +569,82 @@ static void test_updown_buddy(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
DestroyWindow(updown);
|
DestroyWindow(updown);
|
||||||
|
|
||||||
DestroyWindow(buddy);
|
DestroyWindow(buddy);
|
||||||
|
|
||||||
|
/* Create with buddy and UDS_HORZ, reset buddy. */
|
||||||
|
updown = create_updown_control(UDS_HORZ, g_edit);
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect);
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect2);
|
||||||
|
ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
|
||||||
|
|
||||||
|
/* Remove UDS_HORZ, reset buddy again. */
|
||||||
|
style = GetWindowLongA(updown, GWL_STYLE);
|
||||||
|
SetWindowLongA(updown, GWL_STYLE, style & ~UDS_HORZ);
|
||||||
|
style = GetWindowLongA(updown, GWL_STYLE);
|
||||||
|
ok(!(style & UDS_HORZ), "Unexpected style.\n");
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == NULL, "Unexpected buddy window.\n");
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect2);
|
||||||
|
ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
|
||||||
|
|
||||||
|
DestroyWindow(updown);
|
||||||
|
|
||||||
|
/* Without UDS_HORZ. */
|
||||||
|
updown = create_updown_control(0, g_edit);
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_GETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect);
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect2);
|
||||||
|
ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
|
||||||
|
|
||||||
|
DestroyWindow(updown);
|
||||||
|
|
||||||
|
/* Create without buddy. */
|
||||||
|
GetClientRect(parent_wnd, &rect);
|
||||||
|
updown = CreateWindowExA(0, UPDOWN_CLASSA, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_HORZ,
|
||||||
|
0, 0, rect.right, rect.bottom, parent_wnd, (HMENU)1, GetModuleHandleA(NULL), NULL);
|
||||||
|
ok(updown != NULL, "Failed to create UpDown control.\n");
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect);
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == NULL, "Unexpected buddy window.\n");
|
||||||
|
GetClientRect(updown, &rect2);
|
||||||
|
|
||||||
|
ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
|
||||||
|
|
||||||
|
style = GetWindowLongA(updown, GWL_STYLE);
|
||||||
|
SetWindowLongA(updown, GWL_STYLE, style & ~UDS_HORZ);
|
||||||
|
|
||||||
|
GetClientRect(updown, &rect2);
|
||||||
|
ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, (WPARAM)g_edit, 0);
|
||||||
|
ok(buddyReturn == NULL, "Unexpected buddy window.\n");
|
||||||
|
GetClientRect(updown, &rect);
|
||||||
|
|
||||||
|
buddyReturn = (HWND)SendMessageA(updown, UDM_SETBUDDY, 0, 0);
|
||||||
|
ok(buddyReturn == g_edit, "Unexpected buddy window.\n");
|
||||||
|
GetClientRect(updown, &rect2);
|
||||||
|
todo_wine
|
||||||
|
ok(EqualRect(&rect, &rect2), "Unexpected window rect.\n");
|
||||||
|
|
||||||
|
DestroyWindow(updown);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_updown_base(void)
|
static void test_updown_base(void)
|
||||||
|
|
|
@ -622,11 +622,11 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
|
||||||
RECT budRect; /* new coord for the buddy */
|
RECT budRect; /* new coord for the buddy */
|
||||||
int x, width; /* new x position and width for the up-down */
|
int x, width; /* new x position and width for the up-down */
|
||||||
WCHAR buddyClass[40];
|
WCHAR buddyClass[40];
|
||||||
HWND ret;
|
HWND old_buddy;
|
||||||
|
|
||||||
TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
|
TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
|
||||||
|
|
||||||
ret = infoPtr->Buddy;
|
old_buddy = infoPtr->Buddy;
|
||||||
|
|
||||||
/* there is already a buddy assigned */
|
/* there is already a buddy assigned */
|
||||||
if (infoPtr->Buddy) RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
|
if (infoPtr->Buddy) RemoveWindowSubclass(infoPtr->Buddy, UPDOWN_Buddy_SubclassProc,
|
||||||
|
@ -663,7 +663,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
|
||||||
x = budRect.right+DEFAULT_XSEP;
|
x = budRect.right+DEFAULT_XSEP;
|
||||||
} else {
|
} else {
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
return ret;
|
return old_buddy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first adjust the buddy to accommodate the up/down */
|
/* first adjust the buddy to accommodate the up/down */
|
||||||
|
@ -692,14 +692,15 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud)
|
||||||
budRect.top - DEFAULT_ADDTOP, width,
|
budRect.top - DEFAULT_ADDTOP, width,
|
||||||
budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
|
budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
|
||||||
SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
|
SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
|
||||||
} else {
|
} else if (!(infoPtr->dwStyle & UDS_HORZ) && old_buddy != NULL) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetWindowRect(infoPtr->Self, &rect);
|
GetWindowRect(infoPtr->Self, &rect);
|
||||||
MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
|
MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
|
||||||
SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
|
SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
|
||||||
SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
|
SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER);
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
return old_buddy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
Loading…
Reference in New Issue