Commit 3f266610 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

comctl32/listbox: Fix scrolling for multi-column listboxes.

parent 470ea0d5
...@@ -275,28 +275,27 @@ static LRESULT LISTBOX_SetTopItem( LB_DESCR *descr, INT index, BOOL scroll ) ...@@ -275,28 +275,27 @@ static LRESULT LISTBOX_SetTopItem( LB_DESCR *descr, INT index, BOOL scroll )
if (descr->top_item == index) return LB_OKAY; if (descr->top_item == index) return LB_OKAY;
if (scroll) if (scroll)
{ {
INT diff; INT dx = 0, dy = 0;
if (descr->style & LBS_MULTICOLUMN) if (descr->style & LBS_MULTICOLUMN)
diff = (descr->top_item - index) / descr->page_size * descr->column_width; dx = (descr->top_item - index) / descr->page_size * descr->column_width;
else if (descr->style & LBS_OWNERDRAWVARIABLE) else if (descr->style & LBS_OWNERDRAWVARIABLE)
{ {
INT i; INT i;
diff = 0;
if (index > descr->top_item) if (index > descr->top_item)
{ {
for (i = index - 1; i >= descr->top_item; i--) for (i = index - 1; i >= descr->top_item; i--)
diff -= descr->items[i].height; dy -= descr->items[i].height;
} }
else else
{ {
for (i = index; i < descr->top_item; i++) for (i = index; i < descr->top_item; i++)
diff += descr->items[i].height; dy += descr->items[i].height;
} }
} }
else else
diff = (descr->top_item - index) * descr->item_height; dy = (descr->top_item - index) * descr->item_height;
ScrollWindowEx( descr->self, 0, diff, NULL, NULL, 0, NULL, ScrollWindowEx( descr->self, dx, dy, NULL, NULL, 0, NULL,
SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN );
} }
else else
......
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