Andrew Eikum : user32: Only update listbox horizontal scroll info if WS_HSCROLL is set.
Alexandre Julliard
julliard at winehq.org
Mon Apr 28 13:27:00 CDT 2014
Module: wine
Branch: master
Commit: cb1242a8f286f00faece961616d613149166325a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb1242a8f286f00faece961616d613149166325a
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Mon Apr 28 11:16:15 2014 -0500
user32: Only update listbox horizontal scroll info if WS_HSCROLL is set.
---
dlls/user32/listbox.c | 20 +++++++++++---------
dlls/user32/tests/listbox.c | 42 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index d17797b..4853c3f 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -265,17 +265,14 @@ static void LISTBOX_UpdateScroll( LB_DESCR *descr )
if (descr->style & WS_VSCROLL)
SetScrollInfo( descr->self, SB_VERT, &info, TRUE );
- if (descr->horz_extent)
+ if (descr->style & WS_HSCROLL)
{
- info.nMin = 0;
- info.nMax = descr->horz_extent - 1;
info.nPos = descr->horz_pos;
info.nPage = descr->width;
- info.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
+ info.fMask = SIF_POS | SIF_PAGE;
if (descr->style & LBS_DISABLENOSCROLL)
info.fMask |= SIF_DISABLENOSCROLL;
- if (descr->style & WS_HSCROLL)
- SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
+ SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
}
}
}
@@ -1241,14 +1238,19 @@ static LRESULT LISTBOX_SetHorizontalExtent( LB_DESCR *descr, INT extent )
{
if (descr->style & LBS_MULTICOLUMN)
return LB_OKAY;
- if (extent <= 0) extent = 1;
if (extent == descr->horz_extent) return LB_OKAY;
TRACE("[%p]: new horz extent = %d\n", descr->self, extent );
descr->horz_extent = extent;
+ if (descr->style & WS_HSCROLL) {
+ SCROLLINFO info;
+ info.cbSize = sizeof(info);
+ info.nMin = 0;
+ info.nMax = descr->horz_extent ? descr->horz_extent - 1 : 0;
+ info.fMask = SIF_RANGE;
+ SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
+ }
if (descr->horz_pos > extent - descr->width)
LISTBOX_SetHorizontalPos( descr, extent - descr->width );
- else
- LISTBOX_UpdateScroll( descr );
return LB_OKAY;
}
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index ebcb5e9..d99a82c 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -1621,6 +1621,8 @@ static void test_extents(void)
{
HWND listbox, parent;
DWORD res;
+ SCROLLINFO sinfo;
+ BOOL br;
parent = create_parent();
@@ -1629,11 +1631,25 @@ static void test_extents(void)
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 == 100, "got wrong max: %u\n", sinfo.nMax);
+
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 == 100, "got wrong max: %u\n", sinfo.nMax);
+
DestroyWindow(listbox);
@@ -1642,11 +1658,37 @@ static void test_extents(void)
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 == 100, "got wrong max: %u\n", sinfo.nMax);
+
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);
+
+ 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);
+
DestroyWindow(listbox);
DestroyWindow(parent);
More information about the wine-cvs
mailing list