Nikolay Sivov : comctl32/trackbar: Fix TBM_SETRANGEMAX handling when new limit is less than current min boundary.
Alexandre Julliard
julliard at winehq.org
Tue Feb 28 03:45:55 CST 2017
Module: wine
Branch: oldstable
Commit: 29f4ac427f75a8513795dce719f79623f136511e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=29f4ac427f75a8513795dce719f79623f136511e
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Jan 12 17:22:25 2017 +0300
comctl32/trackbar: Fix TBM_SETRANGEMAX handling when new limit is less than current min boundary.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit bb1d68ede06c8b517ea16246e376a4a4e52bf1c5)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/comctl32/tests/trackbar.c | 26 ++++++++++++++++++++++++++
dlls/comctl32/trackbar.c | 5 +++--
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c
index 80d5906..381bfb8 100644
--- a/dlls/comctl32/tests/trackbar.c
+++ b/dlls/comctl32/tests/trackbar.c
@@ -775,6 +775,32 @@ static void test_range(void)
SendMessageA(hWndTrackbar, TBM_GETTHUMBRECT, 0, (LPARAM)&rect1);
ok(EqualRect(&rect1, &rect2), "thumb rectangle not updated\n");
+ /* test position update on range change */
+
+ /* set to [20, 50], position at 30, reduce range to [20,25] */
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 20);
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 50);
+ SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 30);
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 25);
+ r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
+ ok(r == 25, "Unexpected position %d\n", r);
+
+ /* set to [20, 50], position at 30, flip max to 10 */
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 20);
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 50);
+ SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 30);
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
+ r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
+ ok(r == 20, "Unexpected position %d\n", r);
+
+ /* set to [20, 50], position at 30, flip min to 70 */
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 20);
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 50);
+ SendMessageA(hWndTrackbar, TBM_SETPOS, FALSE, 30);
+ SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 70);
+ r = SendMessageA(hWndTrackbar, TBM_GETPOS, 0, 0);
+ ok(r == 70, "Unexpected position %d\n", r);
+
DestroyWindow(hWndTrackbar);
}
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c
index 0e52212..b26d743 100644
--- a/dlls/comctl32/trackbar.c
+++ b/dlls/comctl32/trackbar.c
@@ -1279,10 +1279,11 @@ static inline LRESULT
TRACKBAR_SetRangeMax (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG lMax)
{
BOOL changed = infoPtr->lRangeMax != lMax;
+ LONG rightmost = max(lMax, infoPtr->lRangeMin);
infoPtr->lRangeMax = lMax;
- if (infoPtr->lPos > infoPtr->lRangeMax) {
- infoPtr->lPos = infoPtr->lRangeMax;
+ if (infoPtr->lPos > rightmost) {
+ infoPtr->lPos = rightmost;
infoPtr->flags |= TB_THUMBPOSCHANGED;
}
More information about the wine-cvs
mailing list