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 ...@@ -2855,7 +2855,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
case LB_SETCURSEL: case LB_SETCURSEL:
if (IS_MULTISELECT(descr)) return LB_ERR; if (IS_MULTISELECT(descr)) return LB_ERR;
LISTBOX_SetCaretIndex( descr, wParam, FALSE ); LISTBOX_SetCaretIndex( descr, wParam, TRUE );
ret = LISTBOX_SetSelection( descr, wParam, TRUE, FALSE ); ret = LISTBOX_SetSelection( descr, wParam, TRUE, FALSE );
if (ret != LB_ERR) ret = descr->selected_item; if (ret != LB_ERR) ret = descr->selected_item;
return ret; return ret;
......
...@@ -349,7 +349,7 @@ static void test_ownerdraw(void) ...@@ -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.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); 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_nosel = { 0, LB_ERR, 0, 0 };
static const struct listbox_stat test_1 = { 0, LB_ERR, 0, 2 }; static const struct listbox_stat test_1 = { 0, LB_ERR, 0, 2 };
...@@ -429,6 +429,34 @@ static void test_selection(void) ...@@ -429,6 +429,34 @@ static void test_selection(void)
DestroyWindow(hLB); 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) static void test_listbox_height(void)
{ {
HWND hList; HWND hList;
...@@ -1766,7 +1794,8 @@ START_TEST(listbox) ...@@ -1766,7 +1794,8 @@ START_TEST(listbox)
check_item_height(); check_item_height();
test_ownerdraw(); test_ownerdraw();
test_selection(); test_LB_SELITEMRANGE();
test_LB_SETCURSEL();
test_listbox_height(); test_listbox_height();
test_itemfrompoint(); test_itemfrompoint();
test_listbox_item_data(); 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