1 /* Unit tests for the track bar control.
3 * Copyright 2007 Keith Stevens
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
28 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
29 #define NUM_MSG_SEQUENCE 2
30 #define PARENT_SEQ_INDEX 0
31 #define TRACKBAR_SEQ_INDEX 1
33 static const DWORD defaultstyle
= WS_VISIBLE
| TBS_TOOLTIPS
| TBS_ENABLESELRANGE
| TBS_FIXEDLENGTH
| TBS_AUTOTICKS
;
34 static HWND hWndParent
;
36 static LRESULT WINAPI
trackbar_no_wmpaint_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
38 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
40 if (message
== WM_PAINT
)
43 return CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
46 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCE
];
48 static const struct message empty_seq
[] = {
52 static const struct message parent_create_trackbar_wnd_seq
[] = {
53 { WM_NOTIFYFORMAT
, sent
},
54 { WM_QUERYUISTATE
, sent
|optional
},
55 { WM_WINDOWPOSCHANGING
, sent
},
56 { WM_NCACTIVATE
, sent
},
57 { PBT_APMRESUMECRITICAL
, sent
},
58 { WM_WINDOWPOSCHANGING
, sent
},
59 { PBT_APMRESUMESTANDBY
, sent
},
60 { WM_IME_SETCONTEXT
, sent
|optional
},
61 { WM_IME_NOTIFY
, sent
|optional
},
62 { WM_CTLCOLORSTATIC
, sent
},
67 static const struct message parent_new_window_test_seq
[] = {
68 { WM_QUERYNEWPALETTE
, sent
|optional
},
69 { WM_WINDOWPOSCHANGING
, sent
|optional
},
70 { WM_NCACTIVATE
, sent
|optional
},
71 { PBT_APMRESUMECRITICAL
, sent
|optional
},
72 { WM_IME_SETCONTEXT
, sent
|defwinproc
|optional
},
73 { WM_IME_NOTIFY
, sent
|defwinproc
|optional
},
74 { WM_SETFOCUS
, sent
|defwinproc
|optional
},
75 { WM_NOTIFYFORMAT
, sent
},
76 { WM_QUERYUISTATE
, sent
|optional
},
80 static const struct message buddy_window_test_seq
[] = {
81 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
82 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
83 { WM_PAINT
, sent
|defwinproc
},
84 { TBM_SETBUDDY
, sent
|wparam
, FALSE
},
85 { WM_PAINT
, sent
|defwinproc
},
86 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
87 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
88 { WM_PAINT
, sent
|defwinproc
},
89 { TBM_SETBUDDY
, sent
|wparam
, TRUE
},
90 { WM_PAINT
, sent
|defwinproc
},
91 { TBM_GETBUDDY
, sent
|wparam
, FALSE
},
92 { TBM_GETBUDDY
, sent
|wparam
, TRUE
},
96 static const struct message parent_buddy_window_test_seq
[] = {
97 { WM_CTLCOLORSTATIC
, sent
},
99 { WM_CTLCOLORSTATIC
, sent
},
101 { WM_CTLCOLORSTATIC
, sent
},
103 { WM_CTLCOLORSTATIC
, sent
},
108 static const struct message line_size_test_seq
[] = {
109 { TBM_SETLINESIZE
, sent
|lparam
, 0, 10},
110 { TBM_SETLINESIZE
, sent
|lparam
, 0, 4},
111 { TBM_GETLINESIZE
, sent
},
115 static const struct message page_size_test_seq
[] = {
116 { TBM_SETPAGESIZE
, sent
|lparam
, 0, 10},
117 { TBM_SETPAGESIZE
, sent
|lparam
, 0, -1},
118 { TBM_GETPAGESIZE
, sent
},
122 static const struct message position_test_seq
[] = {
123 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, -1},
124 { WM_PAINT
, sent
|defwinproc
},
126 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
127 { WM_PAINT
, sent
|defwinproc
},
129 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 5},
130 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 1000},
131 { WM_PAINT
, sent
|defwinproc
},
133 { TBM_SETPOS
, sent
|wparam
|lparam
, FALSE
, 20},
135 { TBM_SETPOS
, sent
|wparam
|lparam
, TRUE
, 20},
140 static const struct message parent_position_test_seq
[] = {
141 { WM_CTLCOLORSTATIC
, sent
},
143 { WM_CTLCOLORSTATIC
, sent
},
145 { WM_CTLCOLORSTATIC
, sent
},
150 static const struct message range_test_seq
[] = {
151 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
152 { WM_PAINT
, sent
|defwinproc
},
153 { TBM_GETRANGEMAX
, sent
},
154 { TBM_GETRANGEMIN
, sent
},
155 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(-1, 1000)},
156 { WM_PAINT
, sent
|defwinproc
},
157 { TBM_GETRANGEMAX
, sent
},
158 { TBM_GETRANGEMIN
, sent
},
159 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(10, 0)},
160 { WM_PAINT
, sent
|defwinproc
},
161 { TBM_GETRANGEMAX
, sent
},
162 { TBM_GETRANGEMIN
, sent
},
163 { TBM_SETRANGE
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0, 10)},
164 { TBM_GETRANGEMAX
, sent
},
165 { TBM_GETRANGEMIN
, sent
},
166 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, 10},
167 { WM_PAINT
, sent
|defwinproc
},
168 { TBM_GETRANGEMAX
, sent
},
169 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, TRUE
, -1},
170 { WM_PAINT
, sent
|defwinproc
},
171 { TBM_GETRANGEMAX
, sent
},
172 { TBM_SETRANGEMAX
, sent
|wparam
|lparam
, FALSE
, 10},
173 { TBM_GETRANGEMAX
, sent
},
174 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 0},
175 { WM_PAINT
, sent
|defwinproc
},
176 { TBM_GETRANGEMIN
, sent
},
177 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, 10},
178 { WM_PAINT
, sent
|defwinproc
},
179 { TBM_GETRANGEMIN
, sent
},
180 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, TRUE
, -10},
181 { WM_PAINT
, sent
|defwinproc
},
182 { TBM_GETRANGEMIN
, sent
},
183 { TBM_SETRANGEMIN
, sent
|wparam
|lparam
, FALSE
, 5},
184 { TBM_GETRANGEMIN
, sent
},
185 { TBM_GETRANGEMAX
, sent
},
186 { TBM_GETRANGEMIN
, sent
},
190 static const struct message parent_range_test_seq
[] = {
191 { WM_CTLCOLORSTATIC
, sent
},
193 { WM_CTLCOLORSTATIC
, sent
},
195 { WM_CTLCOLORSTATIC
, sent
},
197 { WM_CTLCOLORSTATIC
, sent
},
199 { WM_CTLCOLORSTATIC
, sent
},
201 { WM_CTLCOLORSTATIC
, sent
},
203 { WM_CTLCOLORSTATIC
, sent
},
205 { WM_CTLCOLORSTATIC
, sent
},
210 static const struct message selection_test_seq
[] = {
211 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0, 10)},
212 { WM_PAINT
, sent
|defwinproc
},
213 { TBM_GETSELEND
, sent
},
214 { TBM_GETSELSTART
, sent
},
215 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(5, 20)},
216 { WM_PAINT
, sent
|defwinproc
},
217 { TBM_GETSELEND
, sent
},
218 { TBM_GETSELSTART
, sent
},
219 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(5, 10)},
220 { TBM_GETSELEND
, sent
},
221 { TBM_GETSELSTART
, sent
},
222 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
223 { WM_PAINT
, sent
|defwinproc
},
224 { TBM_GETSELEND
, sent
},
225 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 20},
226 { WM_PAINT
, sent
|defwinproc
},
227 { TBM_GETSELEND
, sent
},
228 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 4},
229 { WM_PAINT
, sent
|defwinproc
},
230 { TBM_GETSELEND
, sent
},
231 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
, 2},
232 { TBM_GETSELEND
, sent
},
233 { TBM_GETSELEND
, sent
},
234 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 5},
235 { WM_PAINT
, sent
|defwinproc
},
236 { TBM_GETSELSTART
, sent
},
237 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 0},
238 { WM_PAINT
, sent
|defwinproc
},
239 { TBM_GETSELSTART
, sent
},
240 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 20},
241 { WM_PAINT
, sent
|defwinproc
},
242 { TBM_GETSELSTART
, sent
},
243 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
, 8},
244 { TBM_GETSELSTART
, sent
},
245 { TBM_GETSELSTART
, sent
},
249 static const struct message parent_selection_test_seq
[] = {
250 { WM_CTLCOLORSTATIC
, sent
},
252 { WM_CTLCOLORSTATIC
, sent
},
254 { WM_CTLCOLORSTATIC
, sent
},
256 { WM_CTLCOLORSTATIC
, sent
},
258 { WM_CTLCOLORSTATIC
, sent
},
260 { WM_CTLCOLORSTATIC
, sent
},
262 { WM_CTLCOLORSTATIC
, sent
},
264 { WM_CTLCOLORSTATIC
, sent
},
269 static const struct message tic_settings_test_seq
[] = {
270 { TBM_SETTIC
, sent
|lparam
, 0, 0},
271 { TBM_SETTIC
, sent
|lparam
, 0, 5},
272 { TBM_SETTIC
, sent
|lparam
, 0, 10},
273 { TBM_SETTIC
, sent
|lparam
, 0, 20},
274 { TBM_SETRANGE
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
275 { WM_PAINT
, sent
|defwinproc
},
276 { TBM_SETTICFREQ
, sent
|wparam
, 2},
277 { WM_PAINT
, sent
|defwinproc
},
278 { TBM_GETNUMTICS
, sent
},
279 { TBM_SETTICFREQ
, sent
|wparam
, 5},
280 { WM_PAINT
, sent
|defwinproc
},
281 { TBM_GETNUMTICS
, sent
},
282 { TBM_SETTICFREQ
, sent
|wparam
, 15},
283 { WM_PAINT
, sent
|defwinproc
},
284 { TBM_GETNUMTICS
, sent
},
285 { TBM_GETNUMTICS
, sent
},
289 static const struct message parent_tic_settings_test_seq
[] = {
290 { WM_CTLCOLORSTATIC
, sent
},
292 { WM_CTLCOLORSTATIC
, sent
},
294 { WM_CTLCOLORSTATIC
, sent
},
296 { WM_CTLCOLORSTATIC
, sent
},
301 static const struct message thumb_length_test_seq
[] = {
302 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 15, 0},
303 { WM_PAINT
, sent
|defwinproc
},
304 { TBM_GETTHUMBLENGTH
, sent
},
305 { TBM_SETTHUMBLENGTH
, sent
|wparam
|lparam
, 20, 0},
306 { WM_PAINT
, sent
|defwinproc
},
307 { TBM_GETTHUMBLENGTH
, sent
},
308 { TBM_GETTHUMBLENGTH
, sent
},
310 { WM_PAINT
, sent
|defwinproc
},
311 { TBM_GETTHUMBLENGTH
, sent
},
313 { WM_PAINT
, sent
|defwinproc
},
314 { TBM_GETTHUMBLENGTH
, sent
},
318 static const struct message parent_thumb_length_test_seq
[] = {
319 { WM_CTLCOLORSTATIC
, sent
},
321 { WM_CTLCOLORSTATIC
, sent
},
323 { WM_CTLCOLORSTATIC
, sent
},
325 { WM_CTLCOLORSTATIC
, sent
},
330 static const struct message tic_placement_test_seq
[] = {
331 { TBM_GETPTICS
, sent
},
332 { TBM_GETTIC
, sent
|wparam
, 0},
333 { TBM_GETTIC
, sent
|wparam
, 2},
334 { TBM_GETTIC
, sent
|wparam
, 4},
335 { TBM_GETTICPOS
, sent
|wparam
, 0},
336 { TBM_GETTICPOS
, sent
|wparam
, 2},
340 static const struct message tool_tips_test_seq
[] = {
341 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_TOP
},
342 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_LEFT
},
343 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_BOTTOM
},
344 { TBM_SETTIPSIDE
, sent
|wparam
, TBTS_RIGHT
},
345 { TBM_SETTOOLTIPS
, sent
},
346 { TBM_GETTOOLTIPS
, sent
},
347 { TBM_SETTOOLTIPS
, sent
},
348 { TBM_GETTOOLTIPS
, sent
},
349 { TBM_SETTOOLTIPS
, sent
},
350 { TBM_GETTOOLTIPS
, sent
},
351 { TBM_GETTOOLTIPS
, sent
},
355 static const struct message unicode_test_seq
[] = {
356 { TBM_SETUNICODEFORMAT
, sent
|wparam
, TRUE
},
357 { TBM_SETUNICODEFORMAT
, sent
|wparam
, FALSE
},
358 { TBM_GETUNICODEFORMAT
, sent
},
362 static const struct message ignore_selection_test_seq
[] = {
363 { TBM_SETSEL
, sent
|wparam
|lparam
, TRUE
, MAKELONG(0,10)},
364 { TBM_GETSELEND
, sent
},
365 { TBM_GETSELSTART
, sent
},
366 { TBM_SETSEL
, sent
|wparam
|lparam
, FALSE
, MAKELONG(0,10)},
367 { TBM_GETSELEND
, sent
},
368 { TBM_GETSELSTART
, sent
},
369 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
,0},
370 { TBM_GETSELEND
, sent
},
371 { TBM_SETSELEND
, sent
|wparam
|lparam
, TRUE
, 10},
372 { TBM_GETSELEND
, sent
},
373 { TBM_SETSELEND
, sent
|wparam
|lparam
, FALSE
,0},
374 { TBM_GETSELEND
, sent
},
375 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
,0},
376 { TBM_GETSELSTART
, sent
},
377 { TBM_SETSELSTART
, sent
|wparam
|lparam
, TRUE
, 10},
378 { TBM_GETSELSTART
, sent
},
379 { TBM_SETSELSTART
, sent
|wparam
|lparam
, FALSE
,0},
380 { TBM_GETSELSTART
, sent
},
384 static LRESULT WINAPI
parent_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
385 static LONG defwndproc_counter
= 0;
389 /* log system messages, except for painting */
390 if (message
< WM_USER
&&
391 message
!= WM_PAINT
&&
392 message
!= WM_ERASEBKGND
&&
393 message
!= WM_NCPAINT
&&
394 message
!= WM_NCHITTEST
&&
395 message
!= WM_GETTEXT
&&
396 message
!= WM_GETICON
&&
397 message
!= WM_DEVICECHANGE
)
399 msg
.message
= message
;
400 msg
.flags
= sent
|wparam
|lparam
;
401 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
405 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
408 defwndproc_counter
++;
409 ret
= DefWindowProcA(hwnd
, message
, wParam
, lParam
);
410 defwndproc_counter
--;
415 static BOOL
register_parent_wnd_class(void){
419 cls
.lpfnWndProc
= parent_wnd_proc
;
422 cls
.hInstance
= GetModuleHandleA(NULL
);
424 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
425 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
426 cls
.lpszMenuName
= NULL
;
427 cls
.lpszClassName
= "Trackbar test parent class";
428 return RegisterClassA(&cls
);
431 static HWND
create_parent_window(void){
432 if (!register_parent_wnd_class())
435 return CreateWindowA("Trackbar test parent class", "Trackbar test parent window",
436 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_VISIBLE
,
437 0, 0, 100, 100, GetDesktopWindow(), NULL
, GetModuleHandleA(NULL
), NULL
);
440 static LRESULT WINAPI
trackbar_subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
){
441 WNDPROC oldproc
= (WNDPROC
)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
442 static LONG defwndproc_counter
= 0;
443 struct message msg
= { 0 };
446 msg
.message
= message
;
447 msg
.flags
= sent
|wparam
|lparam
;
448 if (defwndproc_counter
) msg
.flags
|= defwinproc
;
451 add_message(sequences
, TRACKBAR_SEQ_INDEX
, &msg
);
453 defwndproc_counter
++;
454 ret
= CallWindowProcA(oldproc
, hwnd
, message
, wParam
, lParam
);
455 defwndproc_counter
--;
460 static HWND
create_trackbar(DWORD style
, HWND parent
){
465 GetClientRect(parent
, &rect
);
466 hWndTrack
= CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", style
,
467 rect
.right
, rect
.bottom
, 100, 50,
468 parent
, NULL
, GetModuleHandleA(NULL
), NULL
);
470 if (!hWndTrack
) return NULL
;
472 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrack
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_subclass_proc
);
473 SetWindowLongPtrA(hWndTrack
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
478 static HWND
create_trackbar2(DWORD style
, HWND parent
)
481 GetClientRect(parent
, &rect
);
482 return CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", style
,
483 rect
.right
, rect
.bottom
, 100, 50,
484 parent
, NULL
, GetModuleHandleA(NULL
), NULL
);
487 /* test functions for setters, getters, and sequences */
489 static void test_trackbar_buddy(void)
491 HWND hWndLeftBuddy
, hWndTrackbar
;
493 HWND hWndCurrentBuddy
;
496 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
497 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
499 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
501 hWndLeftBuddy
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, 0, 0, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
502 ok(hWndLeftBuddy
!= NULL
, "Expected non NULL value\n");
504 if (hWndLeftBuddy
!= NULL
){
505 hWndCurrentBuddy
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
506 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
507 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
508 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, FALSE
, (LPARAM
) hWndLeftBuddy
);
509 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
511 skip ("left buddy control not present?\n");
513 hWndRightBuddy
= CreateWindowA(STATUSCLASSNAMEA
, NULL
, 0, 0, 0, 300, 20, NULL
, NULL
, NULL
, NULL
);
515 ok(hWndRightBuddy
!= NULL
, "expected non NULL value\n");
517 /* test TBM_SETBUDDY */
518 if (hWndRightBuddy
!= NULL
){
519 hWndCurrentBuddy
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
, 0);
520 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
521 ok(rTest
== hWndCurrentBuddy
, "Expected hWndCurrentBuddy\n");
522 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_SETBUDDY
, TRUE
, (LPARAM
) hWndRightBuddy
);
523 ok(rTest
== hWndRightBuddy
, "Expected hWndRightbuddy\n");
525 skip("Right buddy control not present?\n");
527 /* test TBM_GETBUDDY */
528 if (hWndLeftBuddy
!= NULL
){
529 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, FALSE
, 0);
530 ok(rTest
== hWndLeftBuddy
, "Expected hWndLeftBuddy\n");
531 DestroyWindow(hWndLeftBuddy
);
533 if (hWndRightBuddy
!= NULL
){
534 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETBUDDY
, TRUE
,0);
535 ok(rTest
== hWndRightBuddy
, "Expected hWndRightBuddy\n");
536 DestroyWindow(hWndRightBuddy
);
539 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, buddy_window_test_seq
, "buddy test sequence", TRUE
);
540 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_buddy_window_test_seq
, "parent buddy test seq", TRUE
);
542 DestroyWindow(hWndTrackbar
);
545 static void test_line_size(void)
550 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
551 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
553 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
555 /* test TBM_SETLINESIZE */
556 r
= SendMessageA(hWndTrackbar
, TBM_SETLINESIZE
, 0, 10);
558 r
= SendMessageA(hWndTrackbar
, TBM_SETLINESIZE
, 0, 4);
561 /* test TBM_GETLINESIZE */
562 r
= SendMessageA(hWndTrackbar
, TBM_GETLINESIZE
, 0,0);
565 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, line_size_test_seq
, "linesize test sequence", FALSE
);
566 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent line test sequence", FALSE
);
568 DestroyWindow(hWndTrackbar
);
572 static void test_page_size(void)
577 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
578 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
580 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
581 ok(r
== 20, "Unexpected page size %d.\n", r
);
583 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, 0, MAKELPARAM(0, 65));
585 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
586 ok(r
== 13, "Unexpected page size %d.\n", r
);
588 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, 0, 10);
590 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
591 ok(r
== 11, "Unexpected page size %d.\n", r
);
593 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, 0, 50);
595 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
596 ok(r
== 8, "Unexpected page size %d.\n", r
);
598 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 10);
599 ok(r
== 8, "Unexpected page size %d.\n", r
);
601 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, 0, MAKELPARAM(0, 30));
603 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
604 ok(r
== 10, "Unexpected page size %d.\n", r
);
606 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, 0, 5);
608 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
609 ok(r
== 10, "Unexpected page size %d.\n", r
);
611 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, 0, 40);
613 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
614 ok(r
== 10, "Unexpected page size %d.\n", r
);
616 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
617 ok(r
== 10, "Unexpected page size %d.\n", r
);
619 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
620 ok(r
== 7, "Unexpected page size %d.\n", r
);
622 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, 0, 100);
624 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
625 ok(r
== 19, "Unexpected page size %d.\n", r
);
627 DestroyWindow(hWndTrackbar
);
629 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
630 ok(hWndTrackbar
!= NULL
, "Failed to create trackbar window.\n");
632 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
634 /* test TBM_SETPAGESIZE */
635 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 10);
637 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
640 /* test TBM_GETPAGESIZE */
641 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0,0);
644 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, page_size_test_seq
, "page size test sequence", FALSE
);
645 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent page size test sequence", FALSE
);
647 /* check for zero page size */
648 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, 0);
650 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
652 /* revert to default */
653 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -1);
655 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
658 r
= SendMessageA(hWndTrackbar
, TBM_SETPAGESIZE
, 0, -2);
660 r
= SendMessageA(hWndTrackbar
, TBM_GETPAGESIZE
, 0, 0);
663 DestroyWindow(hWndTrackbar
);
666 static void test_position(void)
673 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
674 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
676 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
678 /* test TBM_SETPOS */
679 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, -1);
680 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
682 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
683 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
685 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 5);
686 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 1000);
687 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
689 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 20);
690 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
692 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 20);
694 /* test TBM_GETPOS */
695 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0,0);
698 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, position_test_seq
, "position test sequence", TRUE
);
699 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_position_test_seq
, "parent position test sequence", TRUE
);
701 DestroyWindow(hWndTrackbar
);
703 hWndTrackbar
= create_trackbar2(defaultstyle
, hWndParent
);
704 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
706 /* subclassing procedure blocks WM_PAINT */
707 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_no_wmpaint_proc
);
708 SetWindowLongPtrA(hWndTrackbar
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
711 SetRectEmpty(&rect2
);
713 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
715 /* without repaint */
716 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 25);
717 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
718 ok(r
== 25, "got %d\n", r
);
719 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
720 ok(rect
.left
== rect2
.left
, "got %d\n", rect
.left
);
723 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 30);
724 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
725 ok(r
== 30, "got %d\n", r
);
726 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
727 ok(rect
.left
!= rect2
.left
, "got %d, expected %d\n", rect2
.left
, rect
.left
);
729 /* now move it with keys */
730 SendMessageA(hWndTrackbar
, WM_KEYDOWN
, VK_END
, 0);
731 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
732 ok(r
== 100, "got %d\n", r
);
733 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
734 ok(rect
.left
!= rect2
.left
, "got %d, expected %d\n", rect
.left
, rect2
.left
);
736 DestroyWindow(hWndTrackbar
);
739 static void test_range(void)
745 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
746 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
748 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
750 /* test TBM_SETRANGE */
751 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
752 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
754 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
756 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-1, 1000));
757 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
759 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
761 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 0));
762 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
764 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
766 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(0,10));
767 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
769 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
772 /*test TBM_SETRANGEMAX */
773 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 10);
774 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
776 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, -1);
777 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
779 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
780 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
783 /* testing TBM_SETRANGEMIN */
784 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
785 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
787 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 10);
788 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
790 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, -10);
791 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
793 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
794 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
797 /* test TBM_GETRANGEMAX */
798 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0,0);
801 /* test TBM_GETRANGEMIN */
802 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0,0);
805 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, range_test_seq
, "range test sequence", TRUE
);
806 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_range_test_seq
, "parent range test sequence", TRUE
);
808 /* TBM_SETRANGE updates thumb visual position (rectangle) if needed */
809 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-10, 0));
810 ok(r
== 0, "got %d\n", r
);
811 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 0);
813 RedrawWindow(hWndTrackbar
, NULL
, 0, RDW_UPDATENOW
);
814 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
816 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(-10, 10));
817 ok(r
== 0, "got %d\n", r
);
818 RedrawWindow(hWndTrackbar
, NULL
, 0, RDW_UPDATENOW
);
820 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect2
);
821 ok(!EqualRect(&rect1
, &rect2
), "thumb rectangle not updated\n");
823 /* change range back, don't force repaint */
824 r
= SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(-10, 0));
825 ok(r
== 0, "got %d\n", r
);
827 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
828 ok(EqualRect(&rect1
, &rect2
), "thumb rectangle not updated\n");
830 /* test position update on range change */
832 /* set to [20, 50], position at 30, reduce range to [20,25] */
833 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
834 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
835 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
836 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 25);
837 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
838 ok(r
== 25, "Unexpected position %d\n", r
);
840 /* set to [20, 50], position at 30, flip max to 10 */
841 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
842 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
843 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
844 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
845 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
846 ok(r
== 20, "Unexpected position %d\n", r
);
848 /* set to [20, 50], position at 30, flip min to 70 */
849 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 20);
850 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 50);
851 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 30);
852 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 70);
853 r
= SendMessageA(hWndTrackbar
, TBM_GETPOS
, 0, 0);
854 ok(r
== 70, "Unexpected position %d\n", r
);
856 DestroyWindow(hWndTrackbar
);
859 static void test_selection(void)
864 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
865 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
867 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
868 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
870 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
872 /* test TBM_SETSEL */
873 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
874 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
876 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
878 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(5, 20));
879 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
881 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
883 SendMessageA(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(5, 10));
884 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
886 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
889 /* test TBM_SETSELEND */
890 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
891 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
893 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 20);
894 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
896 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 4);
897 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
899 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 2);
900 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
903 /* test TBM_GETSELEND */
904 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
907 /* testing TBM_SETSELSTART */
908 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 5);
909 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
911 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
912 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
914 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 20);
915 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
917 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 8);
918 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
921 /* test TBM_GETSELSTART */
922 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
925 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, selection_test_seq
, "selection test sequence", TRUE
);
926 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_selection_test_seq
, "parent selection test sequence", TRUE
);
928 DestroyWindow(hWndTrackbar
);
931 static void test_thumb_length(void)
936 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
937 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
939 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
941 /* testing TBM_SETTHUMBLENGTH */
942 SendMessageA(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 15, 0);
943 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
945 SendMessageA(hWndTrackbar
, TBM_SETTHUMBLENGTH
, 20, 0);
946 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
949 /* test TBM_GETTHUMBLENGTH */
950 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
953 r
= SendMessageA(hWndTrackbar
, WM_SIZE
, 0,0);
955 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
957 r
= SendMessageA(hWndTrackbar
, WM_SIZE
, 0, MAKELPARAM(50, 50) );
959 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0,0);
962 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, thumb_length_test_seq
, "thumb length test sequence", TRUE
);
963 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_thumb_length_test_seq
, "parent thumb length test sequence", TRUE
);
965 DestroyWindow(hWndTrackbar
);
967 /* Fixed thumb length does not depend on window size. */
968 hWndTrackbar
= CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", WS_VISIBLE
| TBS_ENABLESELRANGE
969 | TBS_FIXEDLENGTH
, 0, 0, 0, 0, hWndParent
, NULL
, GetModuleHandleA(NULL
), NULL
);
971 r
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0, 0);
973 DestroyWindow(hWndTrackbar
);
975 hWndTrackbar
= CreateWindowA(TRACKBAR_CLASSA
, "Trackbar Control", WS_VISIBLE
| TBS_ENABLESELRANGE
976 | TBS_FIXEDLENGTH
, 0, 0, 200, 200, hWndParent
, NULL
, GetModuleHandleA(NULL
), NULL
);
978 r2
= SendMessageA(hWndTrackbar
, TBM_GETTHUMBLENGTH
, 0, 0);
979 ok(r2
== r
, "Unexpected thumb length %d.\n", r
);
981 DestroyWindow(hWndTrackbar
);
984 static void test_tic_settings(void)
989 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
990 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
992 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, FALSE
, 5);
993 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, FALSE
, 10);
995 /* testing TBM_SETTIC */
996 /* Set tics at 5 and 10 */
997 /* 0 and 20 are out of range and should not be set */
998 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMAX
, 0, 0);
1000 r
= SendMessageA(hWndTrackbar
, TBM_GETRANGEMIN
, 0, 0);
1003 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1004 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 0);
1005 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
1006 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 5);
1007 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
1008 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 10);
1009 ok(r
== TRUE
, "Expected TRUE, got %d\n", r
);
1011 r
= SendMessageA(hWndTrackbar
, TBM_SETTIC
, 0, 20);
1012 ok(r
== FALSE
, "Expected FALSE, got %d\n", r
);
1014 /* test TBM_SETTICFREQ */
1015 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(0, 10));
1016 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 2, 0);
1017 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1019 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 5, 0);
1020 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1022 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 15, 0);
1023 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1026 /* test TBM_GETNUMTICS */
1027 /* since TIC FREQ is 15, there should be only 2 tics now */
1028 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1031 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_settings_test_seq
, "tic settings test sequence", TRUE
);
1032 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_tic_settings_test_seq
, "parent tic settings test sequence", TRUE
);
1034 /* range [0,0], freq = 1 */
1035 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 0);
1036 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
1037 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1038 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1040 /* range [0,1], freq = 1 */
1041 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 1);
1042 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
1043 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1044 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1046 /* range [0,2], freq = 1 */
1047 SendMessageA(hWndTrackbar
, TBM_SETRANGEMAX
, TRUE
, 2);
1048 SendMessageA(hWndTrackbar
, TBM_SETRANGEMIN
, TRUE
, 0);
1049 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1050 r
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1053 DestroyWindow(hWndTrackbar
);
1055 /* Test to show that TBM_SETTICFREQ updates thumb */
1056 for (i
= 0; i
< 2; i
++)
1058 DWORD style
= i
? defaultstyle
: defaultstyle
& ~TBS_AUTOTICKS
;
1062 hWndTrackbar
= create_trackbar2(style
, hWndParent
);
1063 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1065 oldproc
= (WNDPROC
)SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)trackbar_no_wmpaint_proc
);
1066 SetWindowLongPtrA(hWndTrackbar
, GWLP_USERDATA
, (LONG_PTR
)oldproc
);
1068 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1069 SendMessageA(hWndTrackbar
, TBM_SETPOS
, FALSE
, 0);
1070 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1071 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1072 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1074 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1075 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, FALSE
, MAKELONG(-100, 100));
1076 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1077 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1078 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1079 /* Old position is also 0, but thumb position will be different after range change */
1080 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1081 SendMessageA(hWndTrackbar
, TBM_SETPOS
, TRUE
, 0);
1082 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1083 ok(EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1084 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1085 /* Previous frequency is also 1, yet thumb is updated */
1086 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect
);
1087 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1088 SendMessageA(hWndTrackbar
, TBM_GETTHUMBRECT
, 0, (LPARAM
)&rect1
);
1089 ok(!EqualRect(&rect
, &rect1
), "Unexpected thumb rectangle %s, previous %s\n",
1090 wine_dbgstr_rect(&rect1
), wine_dbgstr_rect(&rect
));
1092 SetWindowLongPtrA(hWndTrackbar
, GWLP_WNDPROC
, (LONG_PTR
)oldproc
);
1094 DestroyWindow(hWndTrackbar
);
1098 static void test_tic_placement(void)
1105 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1106 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1108 SendMessageA(hWndTrackbar
, TBM_SETRANGE
, TRUE
, MAKELONG(1, 6));
1109 SendMessageA(hWndTrackbar
, TBM_SETTICFREQ
, 1, 0);
1111 numtics
= SendMessageA(hWndTrackbar
, TBM_GETNUMTICS
, 0, 0);
1112 ok(numtics
== 6, "Expected 6, got %d\n", numtics
);
1114 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1115 /* test TBM_GETPTICS */
1116 rPTics
= (DWORD
*) SendMessageA(hWndTrackbar
, TBM_GETPTICS
, 0,0);
1117 expect(2, rPTics
[0]);
1118 expect(3, rPTics
[1]);
1119 expect(4, rPTics
[2]);
1120 expect(5, rPTics
[3]);
1122 /* test TBM_GETTIC */
1123 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 0,0);
1125 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 2,0);
1127 r
= SendMessageA(hWndTrackbar
, TBM_GETTIC
, 4,0);
1130 /* test TBM_GETTICPIC */
1131 r
= SendMessageA(hWndTrackbar
, TBM_GETTICPOS
, 0, 0);
1132 ok(r
> 0, "Expected r > 0, got %d\n", r
);
1133 r
= SendMessageA(hWndTrackbar
, TBM_GETTICPOS
, 2, 0);
1134 ok(r
> 0, "Expected r > 0, got %d\n", r
);
1136 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tic_placement_test_seq
, "get tic placement test sequence", FALSE
);
1137 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent get tic placement test sequence", FALSE
);
1139 DestroyWindow(hWndTrackbar
);
1142 static void test_tool_tips(void)
1144 HWND hWndTooltip
, hWndTrackbar
;
1148 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1149 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1151 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1153 /* testing TBM_SETTIPSIDE */
1154 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_TOP
, 0);
1155 expect(TBTS_TOP
, r
);
1156 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_LEFT
, 0);
1157 expect(TBTS_TOP
, r
);
1158 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_BOTTOM
, 0);
1159 expect(TBTS_LEFT
, r
);
1160 r
= SendMessageA(hWndTrackbar
, TBM_SETTIPSIDE
, TBTS_RIGHT
, 0);
1161 expect(TBTS_BOTTOM
, r
);
1163 /* testing TBM_SETTOOLTIPS */
1164 hWndTooltip
= CreateWindowExA(WS_EX_TOPMOST
, TOOLTIPS_CLASSA
, NULL
, 0,
1165 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
1166 NULL
, NULL
, NULL
, NULL
);
1168 ok(hWndTooltip
!= NULL
, "Expected non NULL value\n");
1169 if (hWndTooltip
!= NULL
){
1170 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 0);
1171 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1172 ok(rTest
== hWndTooltip
, "Expected hWndToolTip, got\n");
1173 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, 0, 0);
1174 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1175 ok(rTest
== NULL
, "Expected NULL\n");
1176 SendMessageA(hWndTrackbar
, TBM_SETTOOLTIPS
, (LPARAM
) hWndTooltip
, 5);
1177 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1178 ok(rTest
== hWndTooltip
, "Expected hWndTooltip, got\n");
1180 skip("tool tip control not present?\n");
1182 /* test TBM_GETTOOLTIPS */
1183 rTest
= (HWND
) SendMessageA(hWndTrackbar
, TBM_GETTOOLTIPS
, 0,0);
1184 ok(rTest
== hWndTooltip
, "Expected hWndTooltip\n");
1186 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, tool_tips_test_seq
, "tool tips test sequence", FALSE
);
1187 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent tool tips test sequence", FALSE
);
1189 DestroyWindow(hWndTrackbar
);
1193 static void test_unicode(void)
1198 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1199 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1201 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1203 /* testing TBM_SETUNICODEFORMAT */
1204 r
= SendMessageA(hWndTrackbar
, TBM_SETUNICODEFORMAT
, TRUE
, 0);
1205 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
1206 r
= SendMessageA(hWndTrackbar
, TBM_SETUNICODEFORMAT
, FALSE
, 0);
1207 ok(r
== TRUE
, "Expected TRUE, got %d\n",r
);
1209 /* test TBM_GETUNICODEFORMAT */
1210 r
= SendMessageA(hWndTrackbar
, TBM_GETUNICODEFORMAT
, 0,0);
1211 ok(r
== FALSE
, "Expected FALSE, got %d\n",r
);
1213 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, unicode_test_seq
, "unicode test sequence", FALSE
);
1214 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent unicode test sequence", FALSE
);
1216 DestroyWindow(hWndTrackbar
);
1219 static void test_ignore_selection(void)
1224 hWndTrackbar
= create_trackbar(0, hWndParent
);
1225 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1227 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1228 /* test TBM_SETSEL ensure that it is ignored */
1229 SendMessageA(hWndTrackbar
, TBM_SETSEL
, TRUE
, MAKELONG(0,10));
1230 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1232 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1234 SendMessageA(hWndTrackbar
, TBM_SETSEL
, FALSE
, MAKELONG(0,10));
1235 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1237 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1240 /* test TBM_SETSELEND, ensure that it is ignored */
1241 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 0);
1242 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1244 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, TRUE
, 10);
1245 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1247 SendMessageA(hWndTrackbar
, TBM_SETSELEND
, FALSE
, 0);
1248 r
= SendMessageA(hWndTrackbar
, TBM_GETSELEND
, 0,0);
1251 /* test TBM_SETSELSTART, ensure that it is ignored */
1252 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 0);
1253 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1255 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, TRUE
, 10);
1256 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1258 SendMessageA(hWndTrackbar
, TBM_SETSELSTART
, FALSE
, 0);
1259 r
= SendMessageA(hWndTrackbar
, TBM_GETSELSTART
, 0,0);
1262 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, ignore_selection_test_seq
, "ignore selection setting test sequence", FALSE
);
1263 ok_sequence(sequences
, PARENT_SEQ_INDEX
, empty_seq
, "parent ignore selection setting test sequence", FALSE
);
1265 DestroyWindow(hWndTrackbar
);
1268 static void test_initial_state(void)
1273 hWnd
= create_trackbar(0, hWndParent
);
1275 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1277 ret
= SendMessageA(hWnd
, TBM_GETTIC
, 0, 0);
1279 ret
= SendMessageA(hWnd
, TBM_GETTICPOS
, 0, 0);
1281 ret
= SendMessageA(hWnd
, TBM_GETRANGEMIN
, 0, 0);
1283 ret
= SendMessageA(hWnd
, TBM_GETRANGEMAX
, 0, 0);
1286 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 200);
1289 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1292 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 10);
1295 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1298 DestroyWindow(hWnd
);
1301 static void test_TBS_AUTOTICKS(void)
1306 hWnd
= create_trackbar(TBS_AUTOTICKS
, hWndParent
);
1308 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1310 ret
= SendMessageA(hWnd
, TBM_GETTIC
, 0, 0);
1312 ret
= SendMessageA(hWnd
, TBM_GETTICPOS
, 0, 0);
1314 ret
= SendMessageA(hWnd
, TBM_GETRANGEMIN
, 0, 0);
1316 ret
= SendMessageA(hWnd
, TBM_GETRANGEMAX
, 0, 0);
1319 /* TBM_SETRANGEMAX rebuilds tics */
1320 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 200);
1322 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1325 /* TBM_SETRANGEMIN rebuilds tics */
1326 ret
= SendMessageA(hWnd
, TBM_SETRANGEMAX
, TRUE
, 100);
1328 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 10);
1330 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1333 ret
= SendMessageA(hWnd
, TBM_SETRANGEMIN
, TRUE
, 0);
1336 /* TBM_SETRANGE rebuilds tics */
1337 ret
= SendMessageA(hWnd
, TBM_SETRANGE
, TRUE
, MAKELONG(10, 200));
1339 ret
= SendMessageA(hWnd
, TBM_GETNUMTICS
, 0, 0);
1342 DestroyWindow(hWnd
);
1345 static void test_create(void)
1349 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1351 hWndTrackbar
= create_trackbar(defaultstyle
, hWndParent
);
1352 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1353 ok_sequence(sequences
, TRACKBAR_SEQ_INDEX
, empty_seq
, "create Trackbar Window", FALSE
);
1354 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_create_trackbar_wnd_seq
, "parent trackbar window", TRUE
);
1356 DestroyWindow(hWndTrackbar
);
1359 flush_sequences(sequences
, NUM_MSG_SEQUENCE
);
1360 hWndTrackbar
= create_trackbar(0, hWndParent
);
1361 ok(hWndTrackbar
!= NULL
, "Expected non NULL value\n");
1362 ok_sequence(sequences
, PARENT_SEQ_INDEX
, parent_new_window_test_seq
, "new trackbar window test sequence", TRUE
);
1363 DestroyWindow(hWndTrackbar
);
1366 START_TEST(trackbar
)
1371 LoadLibraryA("comctl32.dll");
1373 init_msg_sequences(sequences
, NUM_MSG_SEQUENCE
);
1375 /* create parent window */
1376 hWndParent
= create_parent_window();
1377 ok(hWndParent
!= NULL
, "Failed to create parent Window!\n");
1380 skip("parent window not present\n");
1385 test_trackbar_buddy();
1391 test_thumb_length();
1392 test_tic_settings();
1393 test_tic_placement();
1396 test_TBS_AUTOTICKS();
1397 test_ignore_selection();
1398 test_initial_state();
1400 if (!load_v6_module(&cookie
, &ctxt
))
1403 test_trackbar_buddy();
1409 test_thumb_length();
1410 test_tic_settings();
1411 test_tic_placement();
1414 test_TBS_AUTOTICKS();
1415 test_ignore_selection();
1416 test_initial_state();
1418 unload_v6_module(cookie
, ctxt
);
1420 DestroyWindow(hWndParent
);