Alex Henrie : user32: Scroll listbox item completely into view on LB_SETCURSEL.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jul 17 08:03:41 CDT 2015


Module: wine
Branch: master
Commit: 5caa651732beb7996ee8397929a0805ae2f45882
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5caa651732beb7996ee8397929a0805ae2f45882

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Thu Jul 16 03:30:30 2015 -0600

user32: Scroll listbox item completely into view on LB_SETCURSEL.

---

 dlls/user32/listbox.c       |  2 +-
 dlls/user32/tests/listbox.c | 33 +++++++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index ed60a19..2902ac9 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -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;
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index d99a82c..79d18e7 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -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();




More information about the wine-cvs mailing list