Skip to content

Commit

Permalink
comctl32/trackbar: Don't update page size if it was explicitly set.
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Sivov <[email protected]>
Signed-off-by: Alexandre Julliard <[email protected]>
  • Loading branch information
nsivov authored and julliard committed May 7, 2018
1 parent e95d0c6 commit 6dc3c6b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 16 deletions.
41 changes: 41 additions & 0 deletions dlls/comctl32/tests/trackbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,47 @@ static void test_page_size(void)
hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
ok(hWndTrackbar != NULL, "Expected non NULL value\n");

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 20, "Unexpected page size %d.\n", r);

SendMessageA(hWndTrackbar, TBM_SETRANGE, 0, MAKELPARAM(0, 65));

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 13, "Unexpected page size %d.\n", r);

SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, 0, 10);

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 11, "Unexpected page size %d.\n", r);

SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, 0, 50);

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 8, "Unexpected page size %d.\n", r);

r = SendMessageA(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
ok(r == 8, "Unexpected page size %d.\n", r);

SendMessageA(hWndTrackbar, TBM_SETRANGE, 0, MAKELPARAM(0, 30));

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 10, "Unexpected page size %d.\n", r);

SendMessageA(hWndTrackbar, TBM_SETRANGEMIN, 0, 5);

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 10, "Unexpected page size %d.\n", r);

SendMessageA(hWndTrackbar, TBM_SETRANGEMAX, 0, 40);

r = SendMessageA(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
ok(r == 10, "Unexpected page size %d.\n", r);

DestroyWindow(hWndTrackbar);

hWndTrackbar = create_trackbar(defaultstyle, hWndParent);
ok(hWndTrackbar != NULL, "Failed to create trackbar window.\n");

flush_sequences(sequences, NUM_MSG_SEQUENCE);

/* test TBM_SETPAGESIZE */
Expand Down
42 changes: 26 additions & 16 deletions dlls/comctl32/trackbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct
HWND hwndBuddyLA;
HWND hwndBuddyRB;
INT fLocation;
INT flags;
DWORD flags;
BOOL bUnicode;
BOOL bFocussed;
RECT rcChannel;
Expand All @@ -78,15 +78,18 @@ typedef struct
/* Used by TRACKBAR_Refresh to find out which parts of the control
need to be recalculated */

#define TB_THUMBPOSCHANGED 1
#define TB_THUMBSIZECHANGED 2
#define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBSIZECHANGED)
#define TB_SELECTIONCHANGED 4
#define TB_DRAG_MODE 8 /* we're dragging the slider */
#define TB_AUTO_PAGE_LEFT 16
#define TB_AUTO_PAGE_RIGHT 32
#define TB_AUTO_PAGE (TB_AUTO_PAGE_LEFT | TB_AUTO_PAGE_RIGHT)
#define TB_THUMB_HOT 64 /* mouse hovers above thumb */
#define TB_THUMBPOSCHANGED 0x00000001
#define TB_THUMBSIZECHANGED 0x00000002
#define TB_THUMBCHANGED (TB_THUMBPOSCHANGED | TB_THUMBSIZECHANGED)
#define TB_SELECTIONCHANGED 0x00000004
#define TB_DRAG_MODE 0x00000008 /* we're dragging the slider */
#define TB_AUTO_PAGE_LEFT 0x00000010
#define TB_AUTO_PAGE_RIGHT 0x00000020
#define TB_AUTO_PAGE (TB_AUTO_PAGE_LEFT | TB_AUTO_PAGE_RIGHT)
#define TB_THUMB_HOT 0x00000040 /* mouse hovers above thumb */

/* Page was set with TBM_SETPAGESIZE */
#define TB_USER_PAGE 0x00000080

/* helper defines for TRACKBAR_DrawTic */
#define TIC_EDGE 0x20
Expand Down Expand Up @@ -1204,6 +1207,8 @@ TRACKBAR_SetPageSize (TRACKBAR_INFO *infoPtr, LONG lPageSize)
else
infoPtr->lPageSize = TB_DEFAULTPAGESIZE;

infoPtr->flags |= TB_USER_PAGE;

return lTemp;
}

Expand All @@ -1229,6 +1234,14 @@ TRACKBAR_SetPos (TRACKBAR_INFO *infoPtr, BOOL fPosition, LONG lPosition)
return 0;
}

static void TRACKBAR_UpdatePageSize(TRACKBAR_INFO *infoPtr)
{
if (infoPtr->flags & TB_USER_PAGE)
return;

infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
}

static inline LRESULT
TRACKBAR_SetRange (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG range)
Expand All @@ -1246,8 +1259,7 @@ TRACKBAR_SetRange (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG range)
if (infoPtr->lPos > infoPtr->lRangeMax)
infoPtr->lPos = infoPtr->lRangeMax;

infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
TRACKBAR_UpdatePageSize(infoPtr);

if (changed) {
if (infoPtr->dwStyle & TBS_AUTOTICKS)
Expand All @@ -1273,8 +1285,7 @@ TRACKBAR_SetRangeMax (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG lMax)
infoPtr->flags |= TB_THUMBPOSCHANGED;
}

infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
TRACKBAR_UpdatePageSize(infoPtr);

if (changed && (infoPtr->dwStyle & TBS_AUTOTICKS))
TRACKBAR_RecalculateTics (infoPtr);
Expand All @@ -1296,8 +1307,7 @@ TRACKBAR_SetRangeMin (TRACKBAR_INFO *infoPtr, BOOL redraw, LONG lMin)
infoPtr->flags |= TB_THUMBPOSCHANGED;
}

infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
TRACKBAR_UpdatePageSize(infoPtr);

if (changed && (infoPtr->dwStyle & TBS_AUTOTICKS))
TRACKBAR_RecalculateTics (infoPtr);
Expand Down

0 comments on commit 6dc3c6b

Please sign in to comment.