Nikolay Sivov : comctl32/trackbar: Do not consider window size when initializing fixed length thumb.

Alexandre Julliard julliard at winehq.org
Mon Jun 3 16:07:15 CDT 2019


Module: wine
Branch: master
Commit: d5f8eb333c5c000a3ea986ea532c0ba030ebad88
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d5f8eb333c5c000a3ea986ea532c0ba030ebad88

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Jun  3 13:10:04 2019 +0300

comctl32/trackbar: Do not consider window size when initializing fixed length thumb.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47143
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/tests/trackbar.c | 18 +++++++++++++++++-
 dlls/comctl32/trackbar.c       | 19 +++++++++++--------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c
index 7f17e9e4b..eb54644 100644
--- a/dlls/comctl32/tests/trackbar.c
+++ b/dlls/comctl32/tests/trackbar.c
@@ -931,7 +931,7 @@ static void test_selection(void)
 static void test_thumb_length(void)
 {
     HWND hWndTrackbar;
-    int r;
+    int r, r2;
 
     hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
@@ -963,6 +963,22 @@ static void test_thumb_length(void)
     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb length test sequence", TRUE);
 
     DestroyWindow(hWndTrackbar);
+
+    /* Fixed thumb length does not depend on window size. */
+    hWndTrackbar = CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", WS_VISIBLE | TBS_ENABLESELRANGE
+            | TBS_FIXEDLENGTH, 0, 0, 0, 0, hWndParent, NULL, GetModuleHandleA(NULL), NULL);
+
+    r = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0, 0);
+
+    DestroyWindow(hWndTrackbar);
+
+    hWndTrackbar = CreateWindowA(TRACKBAR_CLASSA, "Trackbar Control", WS_VISIBLE | TBS_ENABLESELRANGE
+            | TBS_FIXEDLENGTH, 0, 0, 200, 200, hWndParent, NULL, GetModuleHandleA(NULL), NULL);
+
+    r2 = SendMessageA(hWndTrackbar, TBM_GETTHUMBLENGTH, 0, 0);
+    ok(r2 == r, "Unexpected thumb length %d.\n", r);
+
+    DestroyWindow(hWndTrackbar);
 }
 
 static void test_tic_settings(void)
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c
index c3b9b27..de3f93e 100644
--- a/dlls/comctl32/trackbar.c
+++ b/dlls/comctl32/trackbar.c
@@ -1481,15 +1481,18 @@ TRACKBAR_InitializeThumb (TRACKBAR_INFO *infoPtr)
 
     infoPtr->uThumbLen = get_scaled_metric(infoPtr, infoPtr->dwStyle & TBS_ENABLESELRANGE ? 23 : 21);
 
-    GetClientRect(infoPtr->hwndSelf,&rect);
-    if (infoPtr->dwStyle & TBS_VERT)
-        client_size = rect.right - rect.left;
-    else
-        client_size = rect.bottom - rect.top;
+    if (!(infoPtr->dwStyle & TBS_FIXEDLENGTH))
+    {
+        GetClientRect(infoPtr->hwndSelf, &rect);
+        if (infoPtr->dwStyle & TBS_VERT)
+            client_size = rect.right - rect.left;
+        else
+            client_size = rect.bottom - rect.top;
 
-    if (client_size < infoPtr->uThumbLen)
-        infoPtr->uThumbLen = client_size > get_scaled_metric(infoPtr, 9) ?
-            client_size - get_scaled_metric(infoPtr, 5) : get_scaled_metric(infoPtr, 4);
+        if (client_size < infoPtr->uThumbLen)
+            infoPtr->uThumbLen = client_size > get_scaled_metric(infoPtr, 9) ?
+                client_size - get_scaled_metric(infoPtr, 5) : get_scaled_metric(infoPtr, 4);
+    }
 
     TRACKBAR_CalcChannel (infoPtr);
     TRACKBAR_UpdateThumb (infoPtr);




More information about the wine-cvs mailing list