Hi,
I was wondering about the status of this patch I sent over a month ago. Anything I can do to improve it and get it reviewed?
Joachim
Am Samstag, 25. Juli 2015 schrieb Joachim Priesner:
According to https://msdn.microsoft.com/en-us/library/ms997541.aspx , a horizontal scroll bar is shown iff the WS_HSCROLL style is set and
a) the LBS_MULTICOLUMN style is set and there are too many items or b) the LBS_MULTICOLUMN style is not set and a horizontal extent is specified.
Before this patch, the default scroll info min=0, max=100 would be set even if no horizontal extent was specified. This led to WS_HSCROLL list boxes that were less than 100 pixels wide to erroneously have a horizontal scroll bar.
Try 2 because I noted a minor formatting error in the first iteration of the patch.
dlls/user32/listbox.c | 20 ++++++++- dlls/user32/tests/listbox.c | 103 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 2902ac9..f4d890b 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -265,7 +265,7 @@ static void LISTBOX_UpdateScroll( LB_DESCR *descr ) if (descr->style & WS_VSCROLL) SetScrollInfo( descr->self, SB_VERT, &info, TRUE );
if (descr->style & WS_HSCROLL)
if ((descr->style & WS_HSCROLL) && descr->horz_extent) { info.nPos = descr->horz_pos; info.nPage = descr->width;
@@ -274,6 +274,20 @@ static void LISTBOX_UpdateScroll( LB_DESCR *descr ) info.fMask |= SIF_DISABLENOSCROLL; SetScrollInfo( descr->self, SB_HORZ, &info, TRUE ); }
else
{
if (descr->style & LBS_DISABLENOSCROLL)
{
info.nMin = 0;
info.nMax = 0;
info.fMask = SIF_RANGE | SIF_DISABLENOSCROLL;
SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
}
else
{
ShowScrollBar( descr->self, SB_HORZ, FALSE );
}
}}
}
@@ -1248,6 +1262,8 @@ static LRESULT LISTBOX_SetHorizontalExtent( LB_DESCR *descr, INT extent ) info.nMin = 0; info.nMax = descr->horz_extent ? descr->horz_extent - 1 : 0; info.fMask = SIF_RANGE;
if (descr->style & LBS_DISABLENOSCROLL)
} if (descr->horz_pos > extent - descr->width)info.fMask |= SIF_DISABLENOSCROLL; SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
@@ -2537,6 +2553,8 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) } }
- LISTBOX_UpdateScroll(descr);
- TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height); return TRUE;
} diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c index 79d18e7..9380457 100644 --- a/dlls/user32/tests/listbox.c +++ b/dlls/user32/tests/listbox.c @@ -1665,7 +1665,10 @@ static void test_extents(void) ok(br == TRUE, "GetScrollInfo failed\n"); ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin); ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
"List box should not have a horizontal scroll bar\n");
/* horizontal extent < width */ SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 64, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
@@ -1677,6 +1680,23 @@ static void test_extents(void) ok(br == TRUE, "GetScrollInfo failed\n"); ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin); ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
"List box should not have a horizontal scroll bar\n");
/* horizontal extent > width */
SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 184, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
ok(res == 184, "Got wrong horizontal extent: %u\n", res);
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_RANGE;
br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
ok(br == TRUE, "GetScrollInfo failed\n");
ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
"List box should not have a horizontal scroll bar\n");
DestroyWindow(listbox);
@@ -1692,7 +1712,71 @@ static void test_extents(void) ok(br == TRUE, "GetScrollInfo failed\n"); ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin); ok(sinfo.nMax == 100, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
"List box should not have a horizontal scroll bar\n");
/* horizontal extent < width */
SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 64, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
ok(res == 64, "Got wrong horizontal extent: %u\n", res);
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_RANGE;
br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
ok(br == TRUE, "GetScrollInfo failed\n");
ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
ok(sinfo.nMax == 63, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
"List box should not have a horizontal scroll bar\n");
/* horizontal extent > width */
SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 184, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
ok(res == 184, "Got wrong horizontal extent: %u\n", res);
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_RANGE;
br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
ok(br == TRUE, "GetScrollInfo failed\n");
ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
ok(sinfo.nMax == 183, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
"List box should have a horizontal scroll bar\n");
SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 0, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
ok(res == 0, "Got wrong horizontal extent: %u\n", res);
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_RANGE;
br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
ok(br == TRUE, "GetScrollInfo failed\n");
ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
ok(sinfo.nMax == 0, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) == 0,
"List box should not have a horizontal scroll bar\n");
DestroyWindow(listbox);
listbox = create_listbox(WS_CHILD | WS_VISIBLE | WS_HSCROLL | LBS_DISABLENOSCROLL, parent);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
ok(res == 0, "Got wrong initial horizontal extent: %u\n", res);
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_RANGE;
br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
ok(br == TRUE, "GetScrollInfo failed\n");
ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
ok(sinfo.nMax == 0, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
"List box should have a horizontal scroll bar\n");
/* horizontal extent < width */ SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 64, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
@@ -1704,6 +1788,23 @@ static void test_extents(void) ok(br == TRUE, "GetScrollInfo failed\n"); ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin); ok(sinfo.nMax == 63, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
"List box should have a horizontal scroll bar\n");
/* horizontal extent > width */
SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 184, 0);
res = SendMessageA(listbox, LB_GETHORIZONTALEXTENT, 0, 0);
ok(res == 184, "Got wrong horizontal extent: %u\n", res);
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_RANGE;
br = GetScrollInfo(listbox, SB_HORZ, &sinfo);
ok(br == TRUE, "GetScrollInfo failed\n");
ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin);
ok(sinfo.nMax == 183, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
"List box should have a horizontal scroll bar\n");
SendMessageA(listbox, LB_SETHORIZONTALEXTENT, 0, 0);
@@ -1716,6 +1817,8 @@ static void test_extents(void) ok(br == TRUE, "GetScrollInfo failed\n"); ok(sinfo.nMin == 0, "got wrong min: %u\n", sinfo.nMin); ok(sinfo.nMax == 0, "got wrong max: %u\n", sinfo.nMax);
ok((GetWindowLongA(listbox, GWL_STYLE) & WS_HSCROLL) != 0,
"List box should have a horizontal scroll bar\n");
DestroyWindow(listbox);