Commit 5caa6517 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

user32: Scroll listbox item completely into view on LB_SETCURSEL.

parent f6125536
......@@ -2855,7 +2855,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
case LB_SETCURSEL:
if (IS_MULTISELECT(descr)) return LB_ERR;
LISTBOX_SetCaretIndex( descr, wParam, FALSE );
LISTBOX_SetCaretIndex( descr, wParam, TRUE );
ret = LISTBOX_SetSelection( descr, wParam, TRUE, FALSE );
if (ret != LB_ERR) ret = descr->selected_item;
return ret;
......
......@@ -349,7 +349,7 @@ static void test_ownerdraw(void)
ok(exp.caret == got.caret, "expected caret %d, got %d\n", exp.caret, got.caret); \
ok(exp.selcount == got.selcount, "expected selcount %d, got %d\n", exp.selcount, got.selcount);
static void test_selection(void)
static void test_LB_SELITEMRANGE(void)
{
static const struct listbox_stat test_nosel = { 0, LB_ERR, 0, 0 };
static const struct listbox_stat test_1 = { 0, LB_ERR, 0, 2 };
......@@ -429,6 +429,34 @@ static void test_selection(void)
DestroyWindow(hLB);
}
static void test_LB_SETCURSEL(void)
{
HWND parent, hLB;
INT ret;
trace("testing LB_SETCURSEL\n");
parent = create_parent();
assert(parent);
hLB = create_listbox(LBS_NOINTEGRALHEIGHT | WS_CHILD, parent);
assert(hLB);
SendMessageA(hLB, LB_SETITEMHEIGHT, 0, 32);
ret = SendMessageA(hLB, LB_SETCURSEL, 2, 0);
ok(ret == 2, "LB_SETCURSEL returned %d instead of 2\n", ret);
ret = GetScrollPos(hLB, SB_VERT);
ok(ret == 0, "expected vscroll 0, got %d\n", ret);
ret = SendMessageA(hLB, LB_SETCURSEL, 3, 0);
ok(ret == 3, "LB_SETCURSEL returned %d instead of 3\n", ret);
ret = GetScrollPos(hLB, SB_VERT);
ok(ret == 1, "expected vscroll 1, got %d\n", ret);
DestroyWindow(hLB);
}
static void test_listbox_height(void)
{
HWND hList;
......@@ -1766,7 +1794,8 @@ START_TEST(listbox)
check_item_height();
test_ownerdraw();
test_selection();
test_LB_SELITEMRANGE();
test_LB_SETCURSEL();
test_listbox_height();
test_itemfrompoint();
test_listbox_item_data();
......
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