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

Alexandre Julliard julliard at wine.codeweavers.com
Wed Oct 7 10:00:49 CDT 2015


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

Author: Joachim Priesner <joachim.priesner at web.de>
Date:   Mon Sep 28 11:20:45 2015 +0200

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

Signed-off-by: Joachim Priesner <joachim.priesner at web.de>

---

 dlls/user32/listbox.c       |  18 +++++++-
 dlls/user32/tests/listbox.c | 103 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+), 1 deletion(-)

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




More information about the wine-cvs mailing list