Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/tests/trackbar.c | 41 +++++++++++++++++++++++++++++++++ dlls/comctl32/trackbar.c | 42 +++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c index 7b601b85b7..7d66df775e 100644 --- a/dlls/comctl32/tests/trackbar.c +++ b/dlls/comctl32/tests/trackbar.c @@ -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 */ diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c index 92c8d9eef0..28ceb699fc 100644 --- a/dlls/comctl32/trackbar.c +++ b/dlls/comctl32/trackbar.c @@ -59,7 +59,7 @@ typedef struct HWND hwndBuddyLA; HWND hwndBuddyRB; INT fLocation; - INT flags; + DWORD flags; BOOL bUnicode; BOOL bFocussed; RECT rcChannel; @@ -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 @@ -1204,6 +1207,8 @@ TRACKBAR_SetPageSize (TRACKBAR_INFO *infoPtr, LONG lPageSize) else infoPtr->lPageSize = TB_DEFAULTPAGESIZE;
+ infoPtr->flags |= TB_USER_PAGE; + return lTemp; }
@@ -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) @@ -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) @@ -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); @@ -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);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/trackbar.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c index 28ceb699fc..762d2e1376 100644 --- a/dlls/comctl32/trackbar.c +++ b/dlls/comctl32/trackbar.c @@ -61,7 +61,6 @@ typedef struct INT fLocation; DWORD flags; BOOL bUnicode; - BOOL bFocussed; RECT rcChannel; RECT rcSelection; RECT rcThumb; @@ -90,6 +89,7 @@ typedef struct
/* Page was set with TBM_SETPAGESIZE */ #define TB_USER_PAGE 0x00000080 +#define TB_IS_FOCUSED 0x00000100
/* helper defines for TRACKBAR_DrawTic */ #define TIC_EDGE 0x20 @@ -999,7 +999,7 @@ TRACKBAR_Refresh (TRACKBAR_INFO *infoPtr, HDC hdcDst) }
/* draw focus rectangle */ - if (infoPtr->bFocussed) { + if (infoPtr->flags & TB_IS_FOCUSED) { DrawFocusRect(hdc, &rcClient); }
@@ -1570,7 +1570,7 @@ static LRESULT TRACKBAR_KillFocus (TRACKBAR_INFO *infoPtr) { TRACE("\n"); - infoPtr->bFocussed = FALSE; + infoPtr->flags &= ~TB_IS_FOCUSED; TRACKBAR_InvalidateAll(infoPtr);
return 0; @@ -1657,7 +1657,7 @@ static LRESULT TRACKBAR_SetFocus (TRACKBAR_INFO *infoPtr) { TRACE("\n"); - infoPtr->bFocussed = TRUE; + infoPtr->flags |= TB_IS_FOCUSED; TRACKBAR_InvalidateAll(infoPtr);
return 0;