This is needed for the linked bug, although it doesn't fix it yet.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43465 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/comctl32/listbox.c | 7 +++++++ dlls/comctl32/tests/listbox.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)
diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index 2137ef86e0..a9d1db458b 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -91,6 +91,7 @@ typedef struct HFONT font; /* Current font */ LCID locale; /* Current locale for string comparisons */ HEADCOMBO *lphc; /* ComboLBox */ + BOOL got_wm_size; /* Did we get already a WM_SIZE? */ } LB_DESCR;
@@ -200,6 +201,10 @@ static void LISTBOX_UpdateScroll( LB_DESCR *descr ) the programmer use it for his/her own purposes. */
if (descr->style & LBS_NOREDRAW) return; + + /* When height is 0 don't update scrollbar during CreateWindowEx, that is until we receive our first WM_SIZE */ + if (!descr->got_wm_size && descr->height == 0) return; + info.cbSize = sizeof(info);
if (descr->style & LBS_MULTICOLUMN) @@ -2502,6 +2507,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) descr->font = 0; descr->locale = GetUserDefaultLCID(); descr->lphc = lphc; + descr->got_wm_size = FALSE;
if( lphc ) { @@ -2887,6 +2893,7 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam,
case WM_SIZE: LISTBOX_UpdateSize( descr ); + descr->got_wm_size = TRUE; return 0; case WM_GETFONT: return (LRESULT)descr->font; diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index c9d13a8d67..e3a3b42c2f 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -2176,6 +2176,40 @@ static void test_WM_MEASUREITEM(void) DestroyWindow(parent); }
+static void test_WS_VSCROLL(void) +{ + HWND parent, listbox; + UINT style; + + parent = create_parent(); + + /* Listbox must always have WS_VSCROLL after creating when height 0 was specified */ + listbox = CreateWindowA("LISTBOX", "TestList", (LBS_STANDARD & ~LBS_SORT) | WS_CHILD | WS_VSCROLL, 0, 0, 100, 0, parent, NULL, NULL, 0); + style = GetWindowLongW(listbox, GWL_STYLE); + ok((style & WS_VSCROLL) != 0, "Listbox must have WS_VSCROLL\n"); + SendMessageA(listbox, WM_SIZE, SIZE_RESTORED, 0); + style = GetWindowLongW(listbox, GWL_STYLE); + ok((style & WS_VSCROLL) == 0, "Listbox must not have WS_VSCROLL\n"); + DestroyWindow(listbox); + + /* Listbox must not have WS_VSCROLL after creating when height > 0 was specified */ + listbox = CreateWindowA("LISTBOX", "TestList", (LBS_STANDARD & ~LBS_SORT) | WS_CHILD | WS_VSCROLL, 0, 0, 100, 100, parent, NULL, NULL, 0); + style = GetWindowLongW(listbox, GWL_STYLE); + ok((style & WS_VSCROLL) == 0, "Listbox must not have WS_VSCROLL\n"); + DestroyWindow(listbox); + + /* Adding elements must change WS_VSCROLL flag */ + listbox = CreateWindowA("LISTBOX", "TestList", (LBS_STANDARD & ~LBS_SORT) | WS_CHILD | WS_VSCROLL, 0, 0, 100, 0, parent, NULL, NULL, 0); + SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"test1"); + style = GetWindowLongW(listbox, GWL_STYLE); + ok((style & WS_VSCROLL) == 0, "Listbox must not have WS_VSCROLL\n"); + SendMessageA(listbox, LB_ADDSTRING, 0, (LPARAM)"test1"); + style = GetWindowLongW(listbox, GWL_STYLE); + ok((style & WS_VSCROLL) != 0, "Listbox must have WS_VSCROLL\n"); + + DestroyWindow(parent); +} + START_TEST(listbox) { ULONG_PTR ctx_cookie; @@ -2202,6 +2236,7 @@ START_TEST(listbox) test_extents(); test_WM_MEASUREITEM(); test_LB_SETSEL(); + test_WS_VSCROLL();
unload_v6_module(ctx_cookie, hCtx); }