user32: Only update listbox horizontal scroll info if WS_HSCROLL is set.

This commit is contained in:
Andrew Eikum 2014-04-28 11:16:15 -05:00 committed by Alexandre Julliard
parent 41f5b15523
commit cb1242a8f2
2 changed files with 53 additions and 9 deletions

View File

@ -265,16 +265,13 @@ 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 );
}
}
@ -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;
}

View File

@ -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);