Nikolay Sivov : comctl32/trackbar: Fix tic count calculation.
Alexandre Julliard
julliard at winehq.org
Wed Sep 2 09:31:21 CDT 2009
Module: wine
Branch: master
Commit: 42c83b9dc7b5094384e718926eddd4b297c7bbae
URL: http://source.winehq.org/git/wine.git/?a=commit;h=42c83b9dc7b5094384e718926eddd4b297c7bbae
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Wed Sep 2 15:43:21 2009 +0400
comctl32/trackbar: Fix tic count calculation.
---
dlls/comctl32/tests/trackbar.c | 25 +++++++++++++++++++++----
dlls/comctl32/trackbar.c | 13 +++++++------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c
index 9454a5c..68fdb96 100644
--- a/dlls/comctl32/tests/trackbar.c
+++ b/dlls/comctl32/tests/trackbar.c
@@ -30,6 +30,7 @@
#define PARENT_SEQ_INDEX 0
#define TRACKBAR_SEQ_INDEX 1
+HWND hWndParent;
static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
@@ -846,9 +847,7 @@ static void test_tic_placement(HWND hWndTrackbar){
r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
expect(4, r);
r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
- todo_wine{
- expect(-1, r);
- }
+ expect(-1, r);
/* test TBM_GETTICPIC */
r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
@@ -967,11 +966,27 @@ static void test_ignore_selection(HWND hWndTrackbar){
ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
}
+static void test_initial_state(void)
+{
+ HWND hWnd;
+ DWORD ret;
+
+ hWnd = create_trackbar(0, hWndParent);
+
+ ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
+ expect(2, ret);
+ ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
+ expect(-1, ret);
+ ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
+ expect(-1, ret);
+
+ DestroyWindow(hWnd);
+}
+
START_TEST(trackbar)
{
DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
HWND hWndTrackbar;
- HWND hWndParent;
init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
InitCommonControls();
@@ -1036,5 +1051,7 @@ START_TEST(trackbar)
DestroyWindow(hWndTrackbar);
+ test_initial_state();
+
DestroyWindow(hWndParent);
}
diff --git a/dlls/comctl32/trackbar.c b/dlls/comctl32/trackbar.c
index 849ebcd..3e991ff 100644
--- a/dlls/comctl32/trackbar.c
+++ b/dlls/comctl32/trackbar.c
@@ -151,8 +151,12 @@ static void TRACKBAR_RecalculateTics (TRACKBAR_INFO *infoPtr)
int tic;
unsigned nrTics, i;
- if (infoPtr->uTicFreq && infoPtr->lRangeMax >= infoPtr->lRangeMin)
- nrTics=(infoPtr->lRangeMax - infoPtr->lRangeMin)/infoPtr->uTicFreq;
+ if (infoPtr->uTicFreq && infoPtr->lRangeMax >= infoPtr->lRangeMin) {
+ nrTics=(infoPtr->lRangeMax - infoPtr->lRangeMin)/infoPtr->uTicFreq;
+ /* don't add extra tic if there's no remainder */
+ if ((infoPtr->lRangeMax - infoPtr->lRangeMin) % infoPtr->uTicFreq == 0)
+ nrTics--;
+ }
else {
Free (infoPtr->tics);
infoPtr->tics = NULL;
@@ -1042,10 +1046,7 @@ TRACKBAR_GetNumTics (const TRACKBAR_INFO *infoPtr)
if (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TBS_NOTICKS)
return 0;
- if(infoPtr->uNumTics == 0)
- return 2;
- else
- return infoPtr->uNumTics + 1;
+ return infoPtr->uNumTics + 2;
}
More information about the wine-cvs
mailing list