comctl32/tests: Fix a failing test for some platforms.
[wine] / dlls / comctl32 / tests / trackbar.c
1 /* Unit tests for the track bar control.
2  *
3  * Copyright 2007 Keith Stevens
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <assert.h>
21 #include <windows.h>
22 #include <commctrl.h>
23 #include <stdio.h>
24
25 #include "wine/test.h"
26 #include "msg.h"
27
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
32
33
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
35
36 static const struct message create_parent_wnd_seq[] = {
37     { WM_GETMINMAXINFO, sent },
38     { WM_NCCREATE, sent },
39     { WM_NCCALCSIZE, sent|wparam, 0 },
40     { WM_CREATE, sent },
41     { WM_SHOWWINDOW, sent|wparam, 1 },
42     { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
43     { WM_QUERYNEWPALETTE, sent|optional },
44     { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
45     { WM_ACTIVATEAPP, sent|wparam, 1 },
46     { WM_NCACTIVATE, sent|wparam, 1 },
47     { WM_ACTIVATE, sent|wparam, 1 },
48     { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
49     { WM_IME_NOTIFY, sent|defwinproc|optional },
50     { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
51     /* Win9x adds SWP_NOZORDER below */
52     { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
53     { WM_NCCALCSIZE, sent|wparam|optional, 1 },
54     { WM_SIZE, sent },
55     { WM_MOVE, sent },
56     { 0 }
57 };
58
59 static const struct message create_trackbar_wnd_seq[] = {
60     {0}
61 };
62
63 static const struct message parent_empty_test_seq[] = {
64     {0}
65 };
66
67 static const struct message parent_create_trackbar_wnd_seq[] = {
68     { WM_NOTIFYFORMAT, sent},
69     { WM_QUERYUISTATE, sent|optional},
70     { WM_WINDOWPOSCHANGING, sent},
71     { WM_NCACTIVATE, sent},
72     { PBT_APMRESUMECRITICAL, sent},
73     { WM_WINDOWPOSCHANGING, sent},
74     { PBT_APMRESUMESTANDBY, sent},
75     { WM_IME_SETCONTEXT, sent|optional},
76     { WM_IME_NOTIFY, sent|optional},
77     { WM_CTLCOLORSTATIC, sent},
78     { WM_NOTIFY, sent},
79     {0}
80 };
81
82 static const struct message parent_new_window_test_seq[] = {
83     { WM_QUERYNEWPALETTE, sent|optional },
84     { WM_WINDOWPOSCHANGING, sent},
85     { WM_NCACTIVATE, sent},
86     { PBT_APMRESUMECRITICAL, sent},
87     { WM_IME_SETCONTEXT, sent|defwinproc|optional},
88     { WM_IME_NOTIFY, sent|defwinproc|optional},
89     { WM_SETFOCUS, sent|defwinproc},
90     { WM_NOTIFYFORMAT, sent},
91     { WM_QUERYUISTATE, sent|optional},
92     {0}
93 };
94
95 static const struct message buddy_window_test_seq[] = {
96     { TBM_GETBUDDY, sent|wparam, TRUE},
97     { TBM_SETBUDDY, sent|wparam, FALSE},
98     { WM_PAINT, sent|defwinproc},
99     { TBM_SETBUDDY, sent|wparam, FALSE},
100     { WM_PAINT, sent|defwinproc},
101     { TBM_GETBUDDY, sent|wparam, TRUE},
102     { TBM_SETBUDDY, sent|wparam, TRUE},
103     { WM_PAINT, sent|defwinproc},
104     { TBM_SETBUDDY, sent|wparam, TRUE},
105     { WM_PAINT, sent|defwinproc},
106     { TBM_GETBUDDY, sent|wparam, FALSE},
107     { TBM_GETBUDDY, sent|wparam, TRUE},
108     {0}
109 };
110
111 static const struct message parent_buddy_window_test_seq[] = {
112     { WM_CTLCOLORSTATIC, sent},
113     { WM_NOTIFY, sent},
114     { WM_CTLCOLORSTATIC, sent},
115     { WM_NOTIFY, sent},
116     { WM_CTLCOLORSTATIC, sent},
117     { WM_NOTIFY, sent},
118     { WM_CTLCOLORSTATIC, sent},
119     { WM_NOTIFY, sent},
120     {0}
121 };
122
123 static const struct message line_size_test_seq[] = {
124     { TBM_SETLINESIZE, sent|lparam, 0, 10},
125     { TBM_SETLINESIZE, sent|lparam, 0, 4},
126     { TBM_GETLINESIZE, sent},
127     {0}
128 };
129
130 static const struct message page_size_test_seq[] = {
131     { TBM_SETPAGESIZE, sent|lparam, 0, 10},
132     { TBM_SETPAGESIZE, sent|lparam, 0, -1},
133     { TBM_GETPAGESIZE, sent},
134     {0}
135 };
136
137 static const struct message position_test_seq[] = {
138     { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
139     { WM_PAINT, sent|defwinproc},
140     { TBM_GETPOS, sent},
141     { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
142     { WM_PAINT, sent|defwinproc},
143     { TBM_GETPOS, sent},
144     { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
145     { WM_PAINT, sent|defwinproc},
146     { TBM_GETPOS, sent},
147     { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
148     { TBM_GETPOS, sent},
149     { TBM_GETPOS, sent},
150     {0}
151 };
152
153 static const struct message parent_position_test_seq[] = {
154     { WM_CTLCOLORSTATIC, sent},
155     { WM_NOTIFY, sent},
156     { WM_CTLCOLORSTATIC, sent},
157     { WM_NOTIFY, sent},
158     { WM_CTLCOLORSTATIC, sent},
159     { WM_NOTIFY, sent},
160     {0}
161 };
162
163 static const struct message range_test_seq[] = {
164     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
165     { WM_PAINT, sent|defwinproc},
166     { TBM_GETRANGEMAX, sent},
167     { TBM_GETRANGEMIN, sent},
168     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
169     { WM_PAINT, sent|defwinproc},
170     { TBM_GETRANGEMAX, sent},
171     { TBM_GETRANGEMIN, sent},
172     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
173     { WM_PAINT, sent|defwinproc},
174     { TBM_GETRANGEMAX, sent},
175     { TBM_GETRANGEMIN, sent},
176     { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
177     { TBM_GETRANGEMAX, sent},
178     { TBM_GETRANGEMIN, sent},
179     { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
180     { WM_PAINT, sent|defwinproc},
181     { TBM_GETRANGEMAX, sent},
182     { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
183     { WM_PAINT, sent|defwinproc},
184     { TBM_GETRANGEMAX, sent},
185     { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
186     { TBM_GETRANGEMAX, sent},
187     { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
188     { WM_PAINT, sent|defwinproc},
189     { TBM_GETRANGEMIN, sent},
190     { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
191     { WM_PAINT, sent|defwinproc},
192     { TBM_GETRANGEMIN, sent},
193     { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
194     { WM_PAINT, sent|defwinproc},
195     { TBM_GETRANGEMIN, sent},
196     { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
197     { TBM_GETRANGEMIN, sent},
198     { TBM_GETRANGEMAX, sent},
199     { TBM_GETRANGEMIN, sent},
200     {0}
201 };
202
203 static const struct message parent_range_test_seq[] = {
204     { WM_CTLCOLORSTATIC, sent},
205     { WM_NOTIFY, sent},
206     { WM_CTLCOLORSTATIC, sent},
207     { WM_NOTIFY, sent},
208     { WM_CTLCOLORSTATIC, sent},
209     { WM_NOTIFY, sent},
210     { WM_CTLCOLORSTATIC, sent},
211     { WM_NOTIFY, sent},
212     { WM_CTLCOLORSTATIC, sent},
213     { WM_NOTIFY, sent},
214     { WM_CTLCOLORSTATIC, sent},
215     { WM_NOTIFY, sent},
216     { WM_CTLCOLORSTATIC, sent},
217     { WM_NOTIFY, sent},
218     { WM_CTLCOLORSTATIC, sent},
219     { WM_NOTIFY, sent},
220     {0}
221 };
222
223 static const struct message selection_test_seq[] = {
224     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
225     { WM_PAINT, sent|defwinproc},
226     { TBM_GETSELEND, sent},
227     { TBM_GETSELSTART, sent},
228     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
229     { WM_PAINT, sent|defwinproc},
230     { TBM_GETSELEND, sent},
231     { TBM_GETSELSTART, sent},
232     { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
233     { TBM_GETSELEND, sent},
234     { TBM_GETSELSTART, sent},
235     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
236     { WM_PAINT, sent|defwinproc},
237     { TBM_GETSELEND, sent},
238     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
239     { WM_PAINT, sent|defwinproc},
240     { TBM_GETSELEND, sent},
241     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
242     { WM_PAINT, sent|defwinproc},
243     { TBM_GETSELEND, sent},
244     { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
245     { TBM_GETSELEND, sent},
246     { TBM_GETSELEND, sent},
247     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
248     { WM_PAINT, sent|defwinproc},
249     { TBM_GETSELSTART, sent},
250     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
251     { WM_PAINT, sent|defwinproc},
252     { TBM_GETSELSTART, sent},
253     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
254     { WM_PAINT, sent|defwinproc},
255     { TBM_GETSELSTART, sent},
256     { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
257     { TBM_GETSELSTART, sent},
258     { TBM_GETSELSTART, sent},
259     {0}
260 };
261
262 static const struct message parent_selection_test_seq[] = {
263     { WM_CTLCOLORSTATIC, sent},
264     { WM_NOTIFY, sent},
265     { WM_CTLCOLORSTATIC, sent},
266     { WM_NOTIFY, sent},
267     { WM_CTLCOLORSTATIC, sent},
268     { WM_NOTIFY, sent},
269     { WM_CTLCOLORSTATIC, sent},
270     { WM_NOTIFY, sent},
271     { WM_CTLCOLORSTATIC, sent},
272     { WM_NOTIFY, sent},
273     { WM_CTLCOLORSTATIC, sent},
274     { WM_NOTIFY, sent},
275     { WM_CTLCOLORSTATIC, sent},
276     { WM_NOTIFY, sent},
277     { WM_CTLCOLORSTATIC, sent},
278     { WM_NOTIFY, sent},
279     {0}
280 };
281
282 static const struct message tic_settings_test_seq[] = {
283     { TBM_SETTIC, sent|lparam, 0, 0},
284     { TBM_SETTIC, sent|lparam, 0, 5},
285     { TBM_SETTIC, sent|lparam, 0, 10},
286     { TBM_SETTIC, sent|lparam, 0, 20},
287     { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
288     { WM_PAINT, sent|defwinproc},
289     { TBM_SETTICFREQ, sent|wparam, 2},
290     { WM_PAINT, sent|defwinproc},
291     { TBM_GETNUMTICS, sent},
292     { TBM_SETTICFREQ, sent|wparam, 5},
293     { WM_PAINT, sent|defwinproc},
294     { TBM_GETNUMTICS, sent},
295     { TBM_SETTICFREQ, sent|wparam, 15},
296     { WM_PAINT, sent|defwinproc},
297     { TBM_GETNUMTICS, sent},
298     { TBM_GETNUMTICS, sent},
299     {0}
300 };
301
302 static const struct message parent_tic_settings_test_seq[] = {
303     { WM_CTLCOLORSTATIC, sent},
304     { WM_NOTIFY, sent},
305     { WM_CTLCOLORSTATIC, sent},
306     { WM_NOTIFY, sent},
307     { WM_CTLCOLORSTATIC, sent},
308     { WM_NOTIFY, sent},
309     { WM_CTLCOLORSTATIC, sent},
310     { WM_NOTIFY, sent},
311     {0}
312 };
313
314 static const struct message thumb_length_test_seq[] = {
315     { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
316     { WM_PAINT, sent|defwinproc},
317     { TBM_GETTHUMBLENGTH, sent},
318     { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
319     { WM_PAINT, sent|defwinproc},
320     { TBM_GETTHUMBLENGTH, sent},
321     { TBM_GETTHUMBLENGTH, sent},
322     {0}
323 };
324
325 static const struct message parent_thumb_length_test_seq[] = {
326     { WM_CTLCOLORSTATIC, sent},
327     { WM_NOTIFY, sent},
328     { WM_CTLCOLORSTATIC, sent},
329     { WM_NOTIFY, sent},
330     {0}
331 };
332
333 static const struct message tic_placement_test_seq[] = {
334     { TBM_GETPTICS, sent},
335     { TBM_GETTIC, sent|wparam, 0},
336     { TBM_GETTIC, sent|wparam, 2},
337     { TBM_GETTIC, sent|wparam, 4},
338     { TBM_GETTICPOS, sent|wparam, 0},
339     { TBM_GETTICPOS, sent|wparam, 2},
340     {0}
341 };
342
343 static const struct message tool_tips_test_seq[] = {
344     { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
345     { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
346     { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
347     { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
348     { TBM_SETTOOLTIPS, sent},
349     { TBM_GETTOOLTIPS, sent},
350     { TBM_SETTOOLTIPS, sent},
351     { TBM_GETTOOLTIPS, sent},
352     { TBM_SETTOOLTIPS, sent},
353     { TBM_GETTOOLTIPS, sent},
354     { TBM_GETTOOLTIPS, sent},
355     {0}
356 };
357
358 static const struct message unicode_test_seq[] = {
359     { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
360     { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
361     { TBM_GETUNICODEFORMAT, sent},
362     {0}
363 };
364
365 static const struct message ignore_selection_test_seq[] = {
366     { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
367     { TBM_GETSELEND, sent},
368     { TBM_GETSELSTART, sent},
369     { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
370     { TBM_GETSELEND, sent},
371     { TBM_GETSELSTART, sent},
372     { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
373     { TBM_GETSELEND, sent},
374     { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
375     { TBM_GETSELEND, sent},
376     { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
377     { TBM_GETSELEND, sent},
378     { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
379     { TBM_GETSELSTART, sent},
380     { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
381     { TBM_GETSELSTART, sent},
382     { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
383     { TBM_GETSELSTART, sent},
384     {0}
385 };
386
387 struct subclass_info
388 {
389     WNDPROC oldproc;
390 };
391
392 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
393     static long defwndproc_counter = 0;
394     LRESULT ret;
395     struct message msg;
396
397     /* log system messages, except for painting */
398     if (message < WM_USER &&
399         message != WM_PAINT &&
400         message != WM_ERASEBKGND &&
401         message != WM_NCPAINT &&
402         message != WM_NCHITTEST &&
403         message != WM_GETTEXT &&
404         message != WM_GETICON &&
405         message != WM_DEVICECHANGE)
406     {
407         trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
408
409         msg.message = message;
410         msg.flags = sent|wparam|lparam;
411         if (defwndproc_counter) msg.flags |= defwinproc;
412         msg.wParam = wParam;
413         msg.lParam = lParam;
414         add_message(sequences, PARENT_SEQ_INDEX, &msg);
415     }
416
417     defwndproc_counter++;
418     ret = DefWindowProcA(hwnd, message, wParam, lParam);
419     defwndproc_counter--;
420
421     return ret;
422 }
423
424 static BOOL register_parent_wnd_class(void){
425     WNDCLASSA cls;
426
427     cls.style = 0;
428     cls.lpfnWndProc = parent_wnd_proc;
429     cls.cbClsExtra = 0;
430     cls.cbWndExtra = 0;
431     cls.hInstance = GetModuleHandleA(NULL);
432     cls.hIcon = 0;
433     cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
434     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
435     cls.lpszMenuName = NULL;
436     cls.lpszClassName = "Trackbar test parent class";
437     return RegisterClassA(&cls);
438 }
439
440 static HWND create_parent_window(void){
441     if (!register_parent_wnd_class())
442         return NULL;
443
444     return CreateWindowEx(0, "Trackbar test parent class",
445         "Trackbar test parent window",
446         WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
447         WS_MAXIMIZEBOX | WS_VISIBLE,
448         0, 0, 100, 100,
449         GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
450 }
451
452 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
453     struct subclass_info *info = (struct subclass_info *) GetWindowLongPtrA(hwnd, GWLP_USERDATA);
454     static long defwndproc_counter = 0;
455     LRESULT ret;
456     struct message msg;
457
458     trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
459
460     msg.message = message;
461     msg.flags = sent|wparam|lparam;
462     if (defwndproc_counter) msg.flags |= defwinproc;
463     msg.wParam = wParam;
464     msg.lParam = lParam;
465     add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
466
467     defwndproc_counter++;
468     ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam);
469     defwndproc_counter--;
470
471     return ret;
472 }
473
474 static HWND create_trackbar(DWORD style, HWND parent){
475     struct subclass_info *info;
476     HWND hWndTrack;
477     RECT rect;
478
479     info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info));
480     if (!info)
481         return NULL;
482
483     GetClientRect(parent, &rect);
484     hWndTrack = CreateWindowEx(
485       0, TRACKBAR_CLASS,"Trackbar Control", style,
486       rect.right,rect.bottom, 100, 50,
487       parent, NULL,GetModuleHandleA(NULL) ,NULL);
488
489     if (!hWndTrack)
490     {
491         HeapFree(GetProcessHeap(), 0, info);
492         return NULL;
493     }
494
495     info->oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
496
497     SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)info);
498
499     return hWndTrack;
500 }
501
502 /* test functions for setters, getters, and sequences */
503
504 static void test_trackbar_buddy(HWND hWndTrackbar){
505     HWND hWndLeftBuddy;
506     HWND hWndRightBuddy;
507     HWND hWndCurrentBuddy;
508     HWND rTest;
509
510     flush_sequences(sequences, NUM_MSG_SEQUENCE);
511
512     hWndLeftBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
513         0,0,300,20, NULL, NULL, NULL, NULL);
514     ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
515
516     if (hWndLeftBuddy != NULL){
517         hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
518         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
519         ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
520         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
521         ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
522     } else
523         skip ("left buddy control not present?\n");
524
525     hWndRightBuddy = (HWND) CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
526         0,0,300,20,NULL,NULL, NULL, NULL);
527
528     ok(hWndRightBuddy != NULL, "expected non NULL value\n");
529
530     /* test TBM_SETBUDDY */
531     if (hWndRightBuddy != NULL){
532         hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
533         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
534         ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
535         rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
536         ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
537      } else
538        skip("Right buddy control not present?\n");
539
540     /* test TBM_GETBUDDY */
541     if (hWndLeftBuddy != NULL){
542         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
543         ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
544         DestroyWindow(hWndLeftBuddy);
545     }
546     if (hWndRightBuddy != NULL){
547         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
548         ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
549         DestroyWindow(hWndRightBuddy);
550     }
551
552     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
553     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
554
555 }
556
557 static void test_line_size(HWND hWndTrackbar){
558     int r;
559
560     flush_sequences(sequences, NUM_MSG_SEQUENCE);
561
562     /* test TBM_SETLINESIZE */
563     r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
564     r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
565     expect(10, r);
566
567     /* test TBM_GETLINESIZE */
568     r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
569     expect(4, r);
570
571     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
572     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent line test sequence", FALSE);
573 }
574
575
576 static void test_page_size(HWND hWndTrackbar){
577     int r;
578
579     flush_sequences(sequences, NUM_MSG_SEQUENCE);
580
581     /* test TBM_SETPAGESIZE */
582     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
583     expect(20, r);
584     r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
585     expect(10, r);
586
587     /* test TBM_GETPAGESIZE */
588     r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
589     todo_wine{
590         expect(20, r);
591     }
592
593     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
594     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
595 }
596
597 static void test_position(HWND hWndTrackbar){
598     int r;
599
600     flush_sequences(sequences, NUM_MSG_SEQUENCE);
601     /* test TBM_SETPOS */
602     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
603     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
604     expect(0, r);
605     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
606     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
607     expect(5, r);
608     SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
609     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
610     expect(100, r);
611     SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
612     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
613     expect(20, r);
614
615     /* test TBM_GETPOS */
616     r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
617     expect(20, r);
618
619     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
620     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
621 }
622
623 static void test_range(HWND hWndTrackbar){
624     int r;
625
626     flush_sequences(sequences, NUM_MSG_SEQUENCE);
627     /* test TBM_SETRANGE */
628     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
629     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
630     expect(10, r);
631     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
632     expect(0, r);
633     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
634     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
635     expect(1000, r);
636     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
637     expect(-1, r);
638     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
639     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
640     expect(0, r);
641     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
642     expect(10, r);
643     SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
644     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
645     expect(10, r);
646     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
647     expect(0, r);
648
649     /*test TBM_SETRANGEMAX */
650     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
651     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
652     expect(10, r);
653     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
654     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
655     expect(-1, r);
656     SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
657     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
658     expect(10, r);
659
660     /* testing TBM_SETRANGEMIN */
661     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
662     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
663     expect(0, r);
664     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
665     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
666     expect(10, r);
667     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
668     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
669     expect(-10, r);
670     SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
671     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
672     expect(5, r);
673
674     /* test TBM_GETRANGEMAX */
675     r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
676     expect(10, r);
677
678     /* test TBM_GETRANGEMIN */
679     r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
680     expect(5, r);
681
682     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
683     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
684 }
685
686 static void test_selection(HWND hWndTrackbar){
687     int r;
688
689     flush_sequences(sequences, NUM_MSG_SEQUENCE);
690     /* test TBM_SETSEL */
691     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
692     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
693     expect(10, r);
694     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
695     expect(5, r);
696     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
697     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
698     expect(10, r);
699     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
700     expect(5, r);
701     SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
702     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
703     expect(10, r);
704     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
705     expect(5, r);
706
707     /* test TBM_SETSELEND */
708     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
709     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
710     expect(10, r);
711     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
712     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
713     expect(10, r);
714     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
715     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
716     expect(4, r);
717     SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
718     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
719     expect(2, r);
720
721     /* test TBM_GETSELEND */
722     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
723     expect(2, r);
724
725     /* testing TBM_SETSELSTART */
726     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
727     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
728     expect(5, r);
729     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
730     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
731     expect(5, r);
732     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
733     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
734     expect(20, r);
735     SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
736     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
737     expect(8, r);
738
739     /* test TBM_GETSELSTART */
740     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
741     expect(8, r);
742
743     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
744     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
745 }
746
747 static void test_thumb_length(HWND hWndTrackbar){
748     int r;
749
750     flush_sequences(sequences, NUM_MSG_SEQUENCE);
751     /* testing TBM_SETTHUMBLENGTH */
752     SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
753     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
754     expect(15, r);
755     SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
756     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
757     expect(20, r);
758
759     /* test TBM_GETTHUMBLENGTH */
760     r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
761     expect(20, r);
762
763     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
764     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb lenth test sequence", TRUE);
765 }
766
767 static void test_tic_settings(HWND hWndTrackbar){
768     int r;
769
770     flush_sequences(sequences, NUM_MSG_SEQUENCE);
771     /* testing TBM_SETTIC */
772     /* Set tics at 5 and 10 */
773     /* 0 and 20 are out of range and should not be set */
774     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
775     ok(r == FALSE, "Expected FALSE, got %d\n", r);
776     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
777     todo_wine{
778         ok(r == TRUE, "Expected TRUE, got %d\n", r);
779         r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
780         ok(r == TRUE, "Expected TRUE, got %d\n", r);
781     }
782     r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
783     ok(r == FALSE, "Expected False, got %d\n", r);
784
785     /* test TBM_SETTICFREQ */
786     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
787     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
788     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
789     expect(6, r);
790     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
791     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
792     expect(3, r);
793     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
794     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
795     expect(2, r);
796
797     /* test TBM_GETNUMTICS */
798     /* since TIC FREQ is 15, there should be only 2 tics now */
799     r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0,0);
800     expect(2, r);
801
802     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
803     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
804 }
805
806 static void test_tic_placement(HWND hWndTrackbar){
807     int r;
808     DWORD *rPTics;
809     DWORD numtics;
810
811     SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
812     SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
813
814     numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
815     ok(numtics == 6, "Expected 6, got %d\n", numtics);
816
817     flush_sequences(sequences, NUM_MSG_SEQUENCE);
818     /* test TBM_GETPTICS */
819     rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
820     expect(2, rPTics[0]);
821     expect(3, rPTics[1]);
822     expect(4, rPTics[2]);
823     expect(5, rPTics[3]);
824
825     /* test TBM_GETTIC */
826     r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
827     expect(2, r);
828     r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
829     expect(4, r);
830     r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
831     todo_wine{
832         expect(-1, r);
833     }
834
835     /* test TBM_GETTICPIC */
836     r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
837     ok(r > 0, "Expected r > 0, got %d\n", r);
838     r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
839     ok(r > 0, "Expected r > 0, got %d\n", r);
840
841     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
842     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent get tic placement test sequence", FALSE);
843 }
844
845
846 static void test_tool_tips(HWND hWndTrackbar){
847     int r;
848     HWND hWndTooltip;
849     HWND rTest;
850
851     flush_sequences(sequences, NUM_MSG_SEQUENCE);
852     /* testing TBM_SETTIPSIDE */
853     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
854     todo_wine{
855         expect(0, r);
856     }
857     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
858     expect(0, r);
859     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
860     expect(1, r);
861     r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
862     expect(2, r);
863
864     /* testing TBM_SETTOOLTIPS */
865     hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
866       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
867       NULL, NULL, NULL, NULL);
868
869     ok(hWndTooltip != NULL, "Expected non NULL value\n");
870     if (hWndTooltip != NULL){
871         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
872         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
873         ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
874         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) NULL, 0);
875         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
876         ok(rTest == NULL, "Expected NULL\n");
877         SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
878         rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
879         ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
880     } else
881         skip("tool tip control not present?\n");
882
883     /* test TBM_GETTOOLTIPS */
884     rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
885     ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
886
887     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
888     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent tool tips test sequence", FALSE);
889 }
890
891
892 static void test_unicode(HWND hWndTrackbar){
893     int r;
894
895     flush_sequences(sequences, NUM_MSG_SEQUENCE);
896     /* testing TBM_SETUNICODEFORMAT */
897     r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
898     ok(r == FALSE, "Expected FALSE, got %d\n",r);
899     r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
900     ok(r == TRUE, "Expected TRUE, got %d\n",r);
901
902     /* test TBM_GETUNICODEFORMAT */
903     r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
904     ok(r == FALSE, "Expected FALSE, got %d\n",r);
905
906     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
907     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent unicode test sequence", FALSE);
908 }
909
910 static void test_ignore_selection(HWND hWndTrackbar){
911     int r;
912
913     flush_sequences(sequences, NUM_MSG_SEQUENCE);
914     /* test TBM_SETSEL  ensure that it is ignored */
915     SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
916     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
917     expect(0, r);
918     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
919     expect(0, r);
920     SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
921     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
922     expect(0, r);
923     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
924     expect(0, r);
925
926     /* test TBM_SETSELEND, ensure that it is ignored */
927     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
928     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
929     expect(0, r);
930     SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
931     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
932     expect(0,r);
933     SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
934     r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
935     expect(0, r);
936
937     /* test TBM_SETSELSTART, ensure that it is ignored */
938     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
939     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
940     expect(0, r);
941     SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
942     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
943     expect(0,r);
944     SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
945     r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
946     expect(0, r);
947
948     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
949     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
950 }
951
952 START_TEST(trackbar)
953 {
954     DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
955     HWND hWndTrackbar;
956     HWND hWndParent;
957
958     init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
959     InitCommonControls();
960
961     flush_sequences(sequences, NUM_MSG_SEQUENCE);
962
963     /* create parent window */
964     hWndParent = create_parent_window();
965     ok(hWndParent != NULL, "Failed to create parent Window!\n");
966
967     if(!hWndParent){
968         skip("parent window not present\n");
969         return;
970     }
971
972     ok_sequence(sequences, PARENT_SEQ_INDEX, create_parent_wnd_seq, "create Parent Window", TRUE);
973     flush_sequences(sequences, NUM_MSG_SEQUENCE);
974
975     /* create trackbar with set styles */
976     hWndTrackbar = create_trackbar(style, hWndParent);
977
978     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
979
980     if (!hWndTrackbar){
981         skip("trackbar control not present?\n");
982         return;
983     }
984
985     ok_sequence(sequences, TRACKBAR_SEQ_INDEX, create_trackbar_wnd_seq, "create Trackbar Window", FALSE);
986     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
987     flush_sequences(sequences, NUM_MSG_SEQUENCE);
988
989     /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
990     test_trackbar_buddy(hWndTrackbar);
991     test_line_size(hWndTrackbar);
992     test_page_size(hWndTrackbar);
993     test_position(hWndTrackbar);
994     test_range(hWndTrackbar);
995     test_selection(hWndTrackbar);
996     test_thumb_length(hWndTrackbar);
997     test_tic_settings(hWndTrackbar);
998     test_tic_placement(hWndTrackbar);
999     test_tool_tips(hWndTrackbar);
1000     test_unicode(hWndTrackbar);
1001
1002     flush_sequences(sequences, NUM_MSG_SEQUENCE);
1003     DestroyWindow(hWndTrackbar);
1004
1005     /* test getters and setters without styles set */
1006     hWndTrackbar = create_trackbar(0, hWndParent);
1007
1008     ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1009
1010     if (!hWndTrackbar){
1011         skip("trackbar control not present?\n");
1012         return;
1013     }
1014
1015     ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1016
1017     test_ignore_selection(hWndTrackbar);
1018
1019     DestroyWindow(hWndTrackbar);
1020
1021     DestroyWindow(hWndParent);
1022 }