From: Michael Müller michael@fds-team.de
Signed-off-by: Michael Müller michael@fds-team.de Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38142 --- dlls/user32/listbox.c | 21 +++++++++++++++++---- dlls/user32/tests/listbox.c | 4 ++-- 2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 65a5d24533a..19988ae1247 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -458,18 +458,31 @@ static void LISTBOX_UpdateSize( LB_DESCR *descr ) descr->height = rect.bottom - rect.top; if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !(descr->style & LBS_OWNERDRAWVARIABLE)) { + int height = descr->height; INT remaining; RECT rect;
+ /* The whole point of integral height is to ensure that partial items + * aren't displayed. Native seems to fail to take the horizontal + * scrollbar into account (while successfully taking into account e.g. + * WS_EX_CLIENTEDGE), so it ends up obscuring partial items anyway. + * + * It's not clear if native is trying to work from + * the window rect as opposed to the client rect [and badly + * reimplementing AdjustWindowRect()] or poorly working around the case + * where the horizontal scrollbar is repeatedly toggled (which could + * unnecessarily shrink the scrollbar every time it happens). */ + if (GetWindowLongW( descr->self, GWL_STYLE ) & WS_HSCROLL) + height += GetSystemMetrics( SM_CYHSCROLL ); + GetWindowRect( descr->self, &rect ); if(descr->item_height != 0) - remaining = descr->height % descr->item_height; + remaining = height % descr->item_height; else remaining = 0; - if ((descr->height > descr->item_height) && remaining) + if ((height > descr->item_height) && remaining) { - TRACE("[%p]: changing height %d -> %d\n", - descr->self, descr->height, descr->height - remaining ); + TRACE( "[%p]: changing height %d -> %d\n", descr->self, height, height - remaining ); NtUserSetWindowPos( descr->self, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top - remaining, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE ); diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c index 869255ceb0d..0c5dde29410 100644 --- a/dlls/user32/tests/listbox.c +++ b/dlls/user32/tests/listbox.c @@ -2563,11 +2563,11 @@ static void test_integral_resize(void)
GetWindowRect(listbox, &rect); SetRect(&expect, 100, 100, 299, 260 + (edge_height * 2)); - todo_wine ok(EqualRect(&rect, &expect), "expected %s, got %s\n", wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + ok(EqualRect(&rect, &expect), "expected %s, got %s\n", wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
GetClientRect(listbox, &rect); SetRect(&expect, 0, 0, 199 - (edge_width * 2), 160 - scroll_height); - todo_wine ok(EqualRect(&rect, &expect), "expected %s, got %s\n", wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect)); + ok(EqualRect(&rect, &expect), "expected %s, got %s\n", wine_dbgstr_rect(&expect), wine_dbgstr_rect(&rect));
DestroyWindow(listbox); DestroyWindow(parent);