Commit 175e7146 authored by Joachim Priesner's avatar Joachim Priesner Committed by Alexandre Julliard

user32: Hide horizontal Listbox scroll bar if no horizontal extent is set.

parent 109d4b91
......@@ -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)
info.fMask |= SIF_DISABLENOSCROLL;
SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
}
if (descr->horz_pos > extent - descr->width)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment