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"
27 #define expect(expected, got) ok(got == expected, "Expected %d, got %d\n", expected, got)
28 #define NUM_MSG_SEQUENCE 2
29 #define PARENT_SEQ_INDEX 0
30 #define TRACKBAR_SEQ_INDEX 1
32 static HWND hWndParent;
34 static struct msg_sequence *sequences[NUM_MSG_SEQUENCE];
36 static const struct message create_trackbar_wnd_seq[] = {
40 static const struct message parent_empty_test_seq[] = {
44 static const struct message parent_create_trackbar_wnd_seq[] = {
45 { WM_NOTIFYFORMAT, sent},
46 { WM_QUERYUISTATE, sent|optional},
47 { WM_WINDOWPOSCHANGING, sent},
48 { WM_NCACTIVATE, sent},
49 { PBT_APMRESUMECRITICAL, sent},
50 { WM_WINDOWPOSCHANGING, sent},
51 { PBT_APMRESUMESTANDBY, sent},
52 { WM_IME_SETCONTEXT, sent|optional},
53 { WM_IME_NOTIFY, sent|optional},
54 { WM_CTLCOLORSTATIC, sent},
59 static const struct message parent_new_window_test_seq[] = {
60 { WM_QUERYNEWPALETTE, sent|optional },
61 { WM_WINDOWPOSCHANGING, sent|optional},
62 { WM_NCACTIVATE, sent|optional},
63 { PBT_APMRESUMECRITICAL, sent|optional},
64 { WM_IME_SETCONTEXT, sent|defwinproc|optional},
65 { WM_IME_NOTIFY, sent|defwinproc|optional},
66 { WM_SETFOCUS, sent|defwinproc|optional},
67 { WM_NOTIFYFORMAT, sent},
68 { WM_QUERYUISTATE, sent|optional},
72 static const struct message buddy_window_test_seq[] = {
73 { TBM_GETBUDDY, sent|wparam, TRUE},
74 { TBM_SETBUDDY, sent|wparam, FALSE},
75 { WM_PAINT, sent|defwinproc},
76 { TBM_SETBUDDY, sent|wparam, FALSE},
77 { WM_PAINT, sent|defwinproc},
78 { TBM_GETBUDDY, sent|wparam, TRUE},
79 { TBM_SETBUDDY, sent|wparam, TRUE},
80 { WM_PAINT, sent|defwinproc},
81 { TBM_SETBUDDY, sent|wparam, TRUE},
82 { WM_PAINT, sent|defwinproc},
83 { TBM_GETBUDDY, sent|wparam, FALSE},
84 { TBM_GETBUDDY, sent|wparam, TRUE},
88 static const struct message parent_buddy_window_test_seq[] = {
89 { WM_CTLCOLORSTATIC, sent},
91 { WM_CTLCOLORSTATIC, sent},
93 { WM_CTLCOLORSTATIC, sent},
95 { WM_CTLCOLORSTATIC, sent},
100 static const struct message line_size_test_seq[] = {
101 { TBM_SETLINESIZE, sent|lparam, 0, 10},
102 { TBM_SETLINESIZE, sent|lparam, 0, 4},
103 { TBM_GETLINESIZE, sent},
107 static const struct message page_size_test_seq[] = {
108 { TBM_SETPAGESIZE, sent|lparam, 0, 10},
109 { TBM_SETPAGESIZE, sent|lparam, 0, -1},
110 { TBM_GETPAGESIZE, sent},
114 static const struct message position_test_seq[] = {
115 { TBM_SETPOS, sent|wparam|lparam, TRUE, -1},
116 { WM_PAINT, sent|defwinproc},
118 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
119 { WM_PAINT, sent|defwinproc},
121 { TBM_SETPOS, sent|wparam|lparam, TRUE, 5},
122 { TBM_SETPOS, sent|wparam|lparam, TRUE, 1000},
123 { WM_PAINT, sent|defwinproc},
125 { TBM_SETPOS, sent|wparam|lparam, FALSE, 20},
127 { TBM_SETPOS, sent|wparam|lparam, TRUE, 20},
132 static const struct message parent_position_test_seq[] = {
133 { WM_CTLCOLORSTATIC, sent},
135 { WM_CTLCOLORSTATIC, sent},
137 { WM_CTLCOLORSTATIC, sent},
142 static const struct message range_test_seq[] = {
143 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
144 { WM_PAINT, sent|defwinproc},
145 { TBM_GETRANGEMAX, sent},
146 { TBM_GETRANGEMIN, sent},
147 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(-1, 1000)},
148 { WM_PAINT, sent|defwinproc},
149 { TBM_GETRANGEMAX, sent},
150 { TBM_GETRANGEMIN, sent},
151 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(10, 0)},
152 { WM_PAINT, sent|defwinproc},
153 { TBM_GETRANGEMAX, sent},
154 { TBM_GETRANGEMIN, sent},
155 { TBM_SETRANGE, sent|wparam|lparam, FALSE, MAKELONG(0, 10)},
156 { TBM_GETRANGEMAX, sent},
157 { TBM_GETRANGEMIN, sent},
158 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, 10},
159 { WM_PAINT, sent|defwinproc},
160 { TBM_GETRANGEMAX, sent},
161 { TBM_SETRANGEMAX, sent|wparam|lparam, TRUE, -1},
162 { WM_PAINT, sent|defwinproc},
163 { TBM_GETRANGEMAX, sent},
164 { TBM_SETRANGEMAX, sent|wparam|lparam, FALSE, 10},
165 { TBM_GETRANGEMAX, sent},
166 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 0},
167 { WM_PAINT, sent|defwinproc},
168 { TBM_GETRANGEMIN, sent},
169 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, 10},
170 { WM_PAINT, sent|defwinproc},
171 { TBM_GETRANGEMIN, sent},
172 { TBM_SETRANGEMIN, sent|wparam|lparam, TRUE, -10},
173 { WM_PAINT, sent|defwinproc},
174 { TBM_GETRANGEMIN, sent},
175 { TBM_SETRANGEMIN, sent|wparam|lparam, FALSE, 5},
176 { TBM_GETRANGEMIN, sent},
177 { TBM_GETRANGEMAX, sent},
178 { TBM_GETRANGEMIN, sent},
182 static const struct message parent_range_test_seq[] = {
183 { WM_CTLCOLORSTATIC, sent},
185 { WM_CTLCOLORSTATIC, sent},
187 { WM_CTLCOLORSTATIC, sent},
189 { WM_CTLCOLORSTATIC, sent},
191 { WM_CTLCOLORSTATIC, sent},
193 { WM_CTLCOLORSTATIC, sent},
195 { WM_CTLCOLORSTATIC, sent},
197 { WM_CTLCOLORSTATIC, sent},
202 static const struct message selection_test_seq[] = {
203 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0, 10)},
204 { WM_PAINT, sent|defwinproc},
205 { TBM_GETSELEND, sent},
206 { TBM_GETSELSTART, sent},
207 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(5, 20)},
208 { WM_PAINT, sent|defwinproc},
209 { TBM_GETSELEND, sent},
210 { TBM_GETSELSTART, sent},
211 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(5, 10)},
212 { TBM_GETSELEND, sent},
213 { TBM_GETSELSTART, sent},
214 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
215 { WM_PAINT, sent|defwinproc},
216 { TBM_GETSELEND, sent},
217 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 20},
218 { WM_PAINT, sent|defwinproc},
219 { TBM_GETSELEND, sent},
220 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 4},
221 { WM_PAINT, sent|defwinproc},
222 { TBM_GETSELEND, sent},
223 { TBM_SETSELEND, sent|wparam|lparam, FALSE, 2},
224 { TBM_GETSELEND, sent},
225 { TBM_GETSELEND, sent},
226 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 5},
227 { WM_PAINT, sent|defwinproc},
228 { TBM_GETSELSTART, sent},
229 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 0},
230 { WM_PAINT, sent|defwinproc},
231 { TBM_GETSELSTART, sent},
232 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 20},
233 { WM_PAINT, sent|defwinproc},
234 { TBM_GETSELSTART, sent},
235 { TBM_SETSELSTART, sent|wparam|lparam, FALSE, 8},
236 { TBM_GETSELSTART, sent},
237 { TBM_GETSELSTART, sent},
241 static const struct message parent_selection_test_seq[] = {
242 { WM_CTLCOLORSTATIC, sent},
244 { WM_CTLCOLORSTATIC, sent},
246 { WM_CTLCOLORSTATIC, sent},
248 { WM_CTLCOLORSTATIC, sent},
250 { WM_CTLCOLORSTATIC, sent},
252 { WM_CTLCOLORSTATIC, sent},
254 { WM_CTLCOLORSTATIC, sent},
256 { WM_CTLCOLORSTATIC, sent},
261 static const struct message tic_settings_test_seq[] = {
262 { TBM_SETTIC, sent|lparam, 0, 0},
263 { TBM_SETTIC, sent|lparam, 0, 5},
264 { TBM_SETTIC, sent|lparam, 0, 10},
265 { TBM_SETTIC, sent|lparam, 0, 20},
266 { TBM_SETRANGE, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
267 { WM_PAINT, sent|defwinproc},
268 { TBM_SETTICFREQ, sent|wparam, 2},
269 { WM_PAINT, sent|defwinproc},
270 { TBM_GETNUMTICS, sent},
271 { TBM_SETTICFREQ, sent|wparam, 5},
272 { WM_PAINT, sent|defwinproc},
273 { TBM_GETNUMTICS, sent},
274 { TBM_SETTICFREQ, sent|wparam, 15},
275 { WM_PAINT, sent|defwinproc},
276 { TBM_GETNUMTICS, sent},
277 { TBM_GETNUMTICS, sent},
281 static const struct message parent_tic_settings_test_seq[] = {
282 { WM_CTLCOLORSTATIC, sent},
284 { WM_CTLCOLORSTATIC, sent},
286 { WM_CTLCOLORSTATIC, sent},
288 { WM_CTLCOLORSTATIC, sent},
293 static const struct message thumb_length_test_seq[] = {
294 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 15, 0},
295 { WM_PAINT, sent|defwinproc},
296 { TBM_GETTHUMBLENGTH, sent},
297 { TBM_SETTHUMBLENGTH, sent|wparam|lparam, 20, 0},
298 { WM_PAINT, sent|defwinproc},
299 { TBM_GETTHUMBLENGTH, sent},
300 { TBM_GETTHUMBLENGTH, sent},
302 { WM_PAINT, sent|defwinproc},
303 { TBM_GETTHUMBLENGTH, sent},
305 { WM_PAINT, sent|defwinproc},
306 { TBM_GETTHUMBLENGTH, sent},
310 static const struct message parent_thumb_length_test_seq[] = {
311 { WM_CTLCOLORSTATIC, sent},
313 { WM_CTLCOLORSTATIC, sent},
315 { WM_CTLCOLORSTATIC, sent},
317 { WM_CTLCOLORSTATIC, sent},
322 static const struct message tic_placement_test_seq[] = {
323 { TBM_GETPTICS, sent},
324 { TBM_GETTIC, sent|wparam, 0},
325 { TBM_GETTIC, sent|wparam, 2},
326 { TBM_GETTIC, sent|wparam, 4},
327 { TBM_GETTICPOS, sent|wparam, 0},
328 { TBM_GETTICPOS, sent|wparam, 2},
332 static const struct message tool_tips_test_seq[] = {
333 { TBM_SETTIPSIDE, sent|wparam, TBTS_TOP},
334 { TBM_SETTIPSIDE, sent|wparam, TBTS_LEFT},
335 { TBM_SETTIPSIDE, sent|wparam, TBTS_BOTTOM},
336 { TBM_SETTIPSIDE, sent|wparam, TBTS_RIGHT},
337 { TBM_SETTOOLTIPS, sent},
338 { TBM_GETTOOLTIPS, sent},
339 { TBM_SETTOOLTIPS, sent},
340 { TBM_GETTOOLTIPS, sent},
341 { TBM_SETTOOLTIPS, sent},
342 { TBM_GETTOOLTIPS, sent},
343 { TBM_GETTOOLTIPS, sent},
347 static const struct message unicode_test_seq[] = {
348 { TBM_SETUNICODEFORMAT, sent|wparam, TRUE},
349 { TBM_SETUNICODEFORMAT, sent|wparam, FALSE},
350 { TBM_GETUNICODEFORMAT, sent},
354 static const struct message ignore_selection_test_seq[] = {
355 { TBM_SETSEL, sent|wparam|lparam, TRUE, MAKELONG(0,10)},
356 { TBM_GETSELEND, sent},
357 { TBM_GETSELSTART, sent},
358 { TBM_SETSEL, sent|wparam|lparam, FALSE, MAKELONG(0,10)},
359 { TBM_GETSELEND, sent},
360 { TBM_GETSELSTART, sent},
361 { TBM_SETSELEND, sent|wparam|lparam, TRUE,0},
362 { TBM_GETSELEND, sent},
363 { TBM_SETSELEND, sent|wparam|lparam, TRUE, 10},
364 { TBM_GETSELEND, sent},
365 { TBM_SETSELEND, sent|wparam|lparam, FALSE,0},
366 { TBM_GETSELEND, sent},
367 { TBM_SETSELSTART, sent|wparam|lparam, TRUE,0},
368 { TBM_GETSELSTART, sent},
369 { TBM_SETSELSTART, sent|wparam|lparam, TRUE, 10},
370 { TBM_GETSELSTART, sent},
371 { TBM_SETSELSTART, sent|wparam|lparam, FALSE,0},
372 { TBM_GETSELSTART, sent},
376 static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
377 static LONG defwndproc_counter = 0;
381 /* log system messages, except for painting */
382 if (message < WM_USER &&
383 message != WM_PAINT &&
384 message != WM_ERASEBKGND &&
385 message != WM_NCPAINT &&
386 message != WM_NCHITTEST &&
387 message != WM_GETTEXT &&
388 message != WM_GETICON &&
389 message != WM_DEVICECHANGE)
391 trace("parent: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
393 msg.message = message;
394 msg.flags = sent|wparam|lparam;
395 if (defwndproc_counter) msg.flags |= defwinproc;
398 add_message(sequences, PARENT_SEQ_INDEX, &msg);
401 defwndproc_counter++;
402 ret = DefWindowProcA(hwnd, message, wParam, lParam);
403 defwndproc_counter--;
408 static BOOL register_parent_wnd_class(void){
412 cls.lpfnWndProc = parent_wnd_proc;
415 cls.hInstance = GetModuleHandleA(NULL);
417 cls.hCursor = LoadCursorA(0, IDC_ARROW);
418 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
419 cls.lpszMenuName = NULL;
420 cls.lpszClassName = "Trackbar test parent class";
421 return RegisterClassA(&cls);
424 static HWND create_parent_window(void){
425 if (!register_parent_wnd_class())
428 return CreateWindowEx(0, "Trackbar test parent class",
429 "Trackbar test parent window",
430 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
431 WS_MAXIMIZEBOX | WS_VISIBLE,
433 GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL);
436 static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
437 WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
438 static LONG defwndproc_counter = 0;
442 trace("trackbar: %p, %04x, %08lx, %08lx\n", hwnd, message, wParam, lParam);
444 msg.message = message;
445 msg.flags = sent|wparam|lparam;
446 if (defwndproc_counter) msg.flags |= defwinproc;
449 add_message(sequences, TRACKBAR_SEQ_INDEX, &msg);
451 defwndproc_counter++;
452 ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam);
453 defwndproc_counter--;
458 static HWND create_trackbar(DWORD style, HWND parent){
463 GetClientRect(parent, &rect);
464 hWndTrack = CreateWindowEx(
465 0, TRACKBAR_CLASS,"Trackbar Control", style,
466 rect.right,rect.bottom, 100, 50,
467 parent, NULL,GetModuleHandleA(NULL) ,NULL);
469 if (!hWndTrack) return NULL;
471 oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc);
472 SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc);
477 /* test functions for setters, getters, and sequences */
479 static void test_trackbar_buddy(HWND hWndTrackbar){
482 HWND hWndCurrentBuddy;
485 flush_sequences(sequences, NUM_MSG_SEQUENCE);
487 hWndLeftBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
488 0,0,300,20, NULL, NULL, NULL, NULL);
489 ok(hWndLeftBuddy != NULL, "Expected non NULL value\n");
491 if (hWndLeftBuddy != NULL){
492 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
493 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
494 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
495 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, FALSE, (LPARAM) hWndLeftBuddy);
496 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
498 skip ("left buddy control not present?\n");
500 hWndRightBuddy = CreateWindowEx(0, STATUSCLASSNAME, NULL, 0,
501 0,0,300,20,NULL,NULL, NULL, NULL);
503 ok(hWndRightBuddy != NULL, "expected non NULL value\n");
505 /* test TBM_SETBUDDY */
506 if (hWndRightBuddy != NULL){
507 hWndCurrentBuddy = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE, 0);
508 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
509 ok(rTest == hWndCurrentBuddy, "Expected hWndCurrentBuddy\n");
510 rTest = (HWND) SendMessage(hWndTrackbar, TBM_SETBUDDY, TRUE, (LPARAM) hWndRightBuddy);
511 ok(rTest == hWndRightBuddy, "Expected hWndRightbuddy\n");
513 skip("Right buddy control not present?\n");
515 /* test TBM_GETBUDDY */
516 if (hWndLeftBuddy != NULL){
517 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, FALSE, 0);
518 ok(rTest == hWndLeftBuddy, "Expected hWndLeftBuddy\n");
519 DestroyWindow(hWndLeftBuddy);
521 if (hWndRightBuddy != NULL){
522 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETBUDDY, TRUE,0);
523 ok(rTest == hWndRightBuddy, "Expected hWndRightBuddy\n");
524 DestroyWindow(hWndRightBuddy);
527 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, buddy_window_test_seq, "buddy test sequence", TRUE);
528 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_buddy_window_test_seq, "parent buddy test seq", TRUE);
532 static void test_line_size(HWND hWndTrackbar){
535 flush_sequences(sequences, NUM_MSG_SEQUENCE);
537 /* test TBM_SETLINESIZE */
538 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 10);
540 r = SendMessage(hWndTrackbar, TBM_SETLINESIZE, 0, 4);
543 /* test TBM_GETLINESIZE */
544 r = SendMessage(hWndTrackbar, TBM_GETLINESIZE, 0,0);
547 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, line_size_test_seq, "linesize test sequence", FALSE);
548 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent line test sequence", FALSE);
552 static void test_page_size(HWND hWndTrackbar){
555 flush_sequences(sequences, NUM_MSG_SEQUENCE);
557 /* test TBM_SETPAGESIZE */
558 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 10);
560 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
563 /* test TBM_GETPAGESIZE */
564 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0,0);
567 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, page_size_test_seq, "page size test sequence", FALSE);
568 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent page size test sequence", FALSE);
570 /* check for zero page size */
571 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, 0);
573 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
575 /* revert to default */
576 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -1);
578 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
581 r = SendMessage(hWndTrackbar, TBM_SETPAGESIZE, 0, -2);
583 r = SendMessage(hWndTrackbar, TBM_GETPAGESIZE, 0, 0);
587 static void test_position(HWND hWndTrackbar){
590 flush_sequences(sequences, NUM_MSG_SEQUENCE);
591 /* test TBM_SETPOS */
592 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, -1);
593 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0, 0);
595 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
596 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
598 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 5);
599 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 1000);
600 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
602 SendMessage(hWndTrackbar, TBM_SETPOS, FALSE, 20);
603 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
605 SendMessage(hWndTrackbar, TBM_SETPOS, TRUE, 20);
607 /* test TBM_GETPOS */
608 r = SendMessage(hWndTrackbar, TBM_GETPOS, 0,0);
611 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, position_test_seq, "position test sequence", TRUE);
612 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_position_test_seq, "parent position test sequence", TRUE);
615 static void test_range(HWND hWndTrackbar){
618 flush_sequences(sequences, NUM_MSG_SEQUENCE);
619 /* test TBM_SETRANGE */
620 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
621 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
623 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
625 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(-1, 1000));
626 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
628 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
630 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(10, 0));
631 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
633 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
635 SendMessage(hWndTrackbar, TBM_SETRANGE, FALSE, MAKELONG(0,10));
636 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
638 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
641 /*test TBM_SETRANGEMAX */
642 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 10);
643 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
645 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, -1);
646 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
648 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, FALSE, 10);
649 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
652 /* testing TBM_SETRANGEMIN */
653 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
654 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
656 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 10);
657 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
659 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, -10);
660 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
662 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, FALSE, 5);
663 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
666 /* test TBM_GETRANGEMAX */
667 r = SendMessage(hWndTrackbar, TBM_GETRANGEMAX, 0,0);
670 /* test TBM_GETRANGEMIN */
671 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0,0);
674 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, range_test_seq, "range test sequence", TRUE);
675 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_range_test_seq, "parent range test sequence", TRUE);
678 static void test_selection(HWND hWndTrackbar){
681 flush_sequences(sequences, NUM_MSG_SEQUENCE);
682 /* test TBM_SETSEL */
683 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
684 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
686 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
688 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(5, 20));
689 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
691 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
693 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(5, 10));
694 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
696 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
699 /* test TBM_SETSELEND */
700 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
701 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
703 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 20);
704 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
706 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 4);
707 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
709 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 2);
710 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
713 /* test TBM_GETSELEND */
714 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
717 /* testing TBM_SETSELSTART */
718 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 5);
719 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
721 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
722 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
724 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 20);
725 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
727 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 8);
728 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
731 /* test TBM_GETSELSTART */
732 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
735 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, selection_test_seq, "selection test sequence", TRUE);
736 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_selection_test_seq, "parent selection test seqence", TRUE);
739 static void test_thumb_length(HWND hWndTrackbar){
742 flush_sequences(sequences, NUM_MSG_SEQUENCE);
743 /* testing TBM_SETTHUMBLENGTH */
744 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 15, 0);
745 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
747 SendMessage(hWndTrackbar, TBM_SETTHUMBLENGTH, 20, 0);
748 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
751 /* test TBM_GETTHUMBLENGTH */
752 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
755 r = SendMessage(hWndTrackbar, WM_SIZE, 0,0);
757 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
759 r = SendMessage(hWndTrackbar, WM_SIZE, 0, MAKELPARAM(50, 50) );
761 r = SendMessage(hWndTrackbar, TBM_GETTHUMBLENGTH, 0,0);
764 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, thumb_length_test_seq, "thumb length test sequence", TRUE);
765 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_thumb_length_test_seq, "parent thumb length test sequence", TRUE);
768 static void test_tic_settings(HWND hWndTrackbar){
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_GETRANGEMAX, 0, 0);
776 r = SendMessage(hWndTrackbar, TBM_GETRANGEMIN, 0, 0);
779 flush_sequences(sequences, NUM_MSG_SEQUENCE);
780 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 0);
781 ok(r == FALSE, "Expected FALSE, got %d\n", r);
782 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 5);
783 ok(r == TRUE, "Expected TRUE, got %d\n", r);
784 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 10);
785 ok(r == TRUE, "Expected TRUE, got %d\n", r);
787 r = SendMessage(hWndTrackbar, TBM_SETTIC, 0, 20);
788 ok(r == FALSE, "Expected False, got %d\n", r);
790 /* test TBM_SETTICFREQ */
791 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(0, 10));
792 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 2, 0);
793 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
795 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 5, 0);
796 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
798 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 15, 0);
799 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
802 /* test TBM_GETNUMTICS */
803 /* since TIC FREQ is 15, there should be only 2 tics now */
804 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
807 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_settings_test_seq, "tic settings test sequence", TRUE);
808 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_tic_settings_test_seq, "parent tic settings test sequence", TRUE);
810 /* range [0,0], freq = 1 */
811 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 0);
812 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
813 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
814 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
816 /* range [0,1], freq = 1 */
817 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 1);
818 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
819 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
820 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
822 /* range [0,2], freq = 1 */
823 SendMessage(hWndTrackbar, TBM_SETRANGEMAX, TRUE, 2);
824 SendMessage(hWndTrackbar, TBM_SETRANGEMIN, TRUE, 0);
825 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
826 r = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
830 static void test_tic_placement(HWND hWndTrackbar){
835 SendMessage(hWndTrackbar, TBM_SETRANGE, TRUE, MAKELONG(1, 6));
836 SendMessage(hWndTrackbar, TBM_SETTICFREQ, 1, 0);
838 numtics = SendMessage(hWndTrackbar, TBM_GETNUMTICS, 0, 0);
839 ok(numtics == 6, "Expected 6, got %d\n", numtics);
841 flush_sequences(sequences, NUM_MSG_SEQUENCE);
842 /* test TBM_GETPTICS */
843 rPTics = (DWORD *) SendMessage(hWndTrackbar, TBM_GETPTICS, 0,0);
844 expect(2, rPTics[0]);
845 expect(3, rPTics[1]);
846 expect(4, rPTics[2]);
847 expect(5, rPTics[3]);
849 /* test TBM_GETTIC */
850 r = SendMessage(hWndTrackbar, TBM_GETTIC, 0,0);
852 r = SendMessage(hWndTrackbar, TBM_GETTIC, 2,0);
854 r = SendMessage(hWndTrackbar, TBM_GETTIC, 4,0);
857 /* test TBM_GETTICPIC */
858 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 0, 0);
859 ok(r > 0, "Expected r > 0, got %d\n", r);
860 r = SendMessage(hWndTrackbar, TBM_GETTICPOS, 2, 0);
861 ok(r > 0, "Expected r > 0, got %d\n", r);
863 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tic_placement_test_seq, "get tic placement test sequence", FALSE);
864 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent get tic placement test sequence", FALSE);
868 static void test_tool_tips(HWND hWndTrackbar){
873 flush_sequences(sequences, NUM_MSG_SEQUENCE);
874 /* testing TBM_SETTIPSIDE */
875 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_TOP, 0);
877 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_LEFT, 0);
879 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_BOTTOM, 0);
880 expect(TBTS_LEFT, r);
881 r = SendMessage(hWndTrackbar, TBM_SETTIPSIDE, TBTS_RIGHT, 0);
882 expect(TBTS_BOTTOM, r);
884 /* testing TBM_SETTOOLTIPS */
885 hWndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, 0,
886 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
887 NULL, NULL, NULL, NULL);
889 ok(hWndTooltip != NULL, "Expected non NULL value\n");
890 if (hWndTooltip != NULL){
891 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 0);
892 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
893 ok(rTest == hWndTooltip, "Expected hWndToolTip, got\n");
894 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, 0, 0);
895 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
896 ok(rTest == NULL, "Expected NULL\n");
897 SendMessage(hWndTrackbar, TBM_SETTOOLTIPS, (LPARAM) hWndTooltip, 5);
898 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
899 ok(rTest == hWndTooltip, "Expected hWndTooltip, got\n");
901 skip("tool tip control not present?\n");
903 /* test TBM_GETTOOLTIPS */
904 rTest = (HWND) SendMessage(hWndTrackbar, TBM_GETTOOLTIPS, 0,0);
905 ok(rTest == hWndTooltip, "Expected hWndTooltip\n");
907 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, tool_tips_test_seq, "tool tips test sequence", FALSE);
908 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent tool tips test sequence", FALSE);
912 static void test_unicode(HWND hWndTrackbar){
915 flush_sequences(sequences, NUM_MSG_SEQUENCE);
916 /* testing TBM_SETUNICODEFORMAT */
917 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, TRUE, 0);
918 ok(r == FALSE, "Expected FALSE, got %d\n",r);
919 r = SendMessage(hWndTrackbar, TBM_SETUNICODEFORMAT, FALSE, 0);
920 ok(r == TRUE, "Expected TRUE, got %d\n",r);
922 /* test TBM_GETUNICODEFORMAT */
923 r = SendMessage(hWndTrackbar, TBM_GETUNICODEFORMAT, 0,0);
924 ok(r == FALSE, "Expected FALSE, got %d\n",r);
926 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, unicode_test_seq, "unicode test sequence", FALSE);
927 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent unicode test sequence", FALSE);
930 static void test_ignore_selection(HWND hWndTrackbar){
933 flush_sequences(sequences, NUM_MSG_SEQUENCE);
934 /* test TBM_SETSEL ensure that it is ignored */
935 SendMessage(hWndTrackbar, TBM_SETSEL, TRUE, MAKELONG(0,10));
936 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
938 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
940 SendMessage(hWndTrackbar, TBM_SETSEL, FALSE, MAKELONG(0,10));
941 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
943 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
946 /* test TBM_SETSELEND, ensure that it is ignored */
947 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 0);
948 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
950 SendMessage(hWndTrackbar, TBM_SETSELEND, TRUE, 10);
951 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
953 SendMessage(hWndTrackbar, TBM_SETSELEND, FALSE, 0);
954 r = SendMessage(hWndTrackbar, TBM_GETSELEND, 0,0);
957 /* test TBM_SETSELSTART, ensure that it is ignored */
958 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 0);
959 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
961 SendMessage(hWndTrackbar, TBM_SETSELSTART, TRUE, 10);
962 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
964 SendMessage(hWndTrackbar, TBM_SETSELSTART, FALSE, 0);
965 r = SendMessage(hWndTrackbar, TBM_GETSELSTART, 0,0);
968 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, ignore_selection_test_seq, "ignore selection setting test sequence", FALSE);
969 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_empty_test_seq, "parent ignore selection setting test sequence", FALSE);
972 static void test_initial_state(void)
977 hWnd = create_trackbar(0, hWndParent);
979 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
981 ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
983 ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
985 ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
987 ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
990 ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
993 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
996 ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
999 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1002 DestroyWindow(hWnd);
1005 static void test_TBS_AUTOTICKS(void)
1010 hWnd = create_trackbar(TBS_AUTOTICKS, hWndParent);
1012 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1014 ret = SendMessage(hWnd, TBM_GETTIC, 0, 0);
1016 ret = SendMessage(hWnd, TBM_GETTICPOS, 0, 0);
1018 ret = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
1020 ret = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
1023 /* TBM_SETRANGEMAX rebuilds tics */
1024 ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 200);
1026 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1029 /* TBM_SETRANGEMIN rebuilds tics */
1030 ret = SendMessage(hWnd, TBM_SETRANGEMAX, TRUE, 100);
1032 ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 10);
1034 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1037 ret = SendMessage(hWnd, TBM_SETRANGEMIN, TRUE, 0);
1040 /* TBM_SETRANGE rebuilds tics */
1041 ret = SendMessage(hWnd, TBM_SETRANGE, TRUE, MAKELONG(10, 200));
1043 ret = SendMessage(hWnd, TBM_GETNUMTICS, 0, 0);
1046 DestroyWindow(hWnd);
1049 START_TEST(trackbar)
1051 DWORD style = WS_VISIBLE | TBS_TOOLTIPS | TBS_ENABLESELRANGE | TBS_FIXEDLENGTH | TBS_AUTOTICKS;
1054 init_msg_sequences(sequences, NUM_MSG_SEQUENCE);
1055 InitCommonControls();
1057 /* create parent window */
1058 hWndParent = create_parent_window();
1059 ok(hWndParent != NULL, "Failed to create parent Window!\n");
1062 skip("parent window not present\n");
1066 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1068 /* create trackbar with set styles */
1069 hWndTrackbar = create_trackbar(style, hWndParent);
1071 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1074 skip("trackbar control not present?\n");
1078 ok_sequence(sequences, TRACKBAR_SEQ_INDEX, create_trackbar_wnd_seq, "create Trackbar Window", FALSE);
1079 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_create_trackbar_wnd_seq, "parent trackbar window", TRUE);
1080 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1082 /* TEST OF ALL SETTER and GETTER MESSAGES with required styles turned on*/
1083 test_trackbar_buddy(hWndTrackbar);
1084 test_line_size(hWndTrackbar);
1085 test_page_size(hWndTrackbar);
1086 test_position(hWndTrackbar);
1087 test_range(hWndTrackbar);
1088 test_selection(hWndTrackbar);
1089 test_thumb_length(hWndTrackbar);
1090 test_tic_settings(hWndTrackbar);
1091 test_tic_placement(hWndTrackbar);
1092 test_tool_tips(hWndTrackbar);
1093 test_unicode(hWndTrackbar);
1094 test_TBS_AUTOTICKS();
1096 flush_sequences(sequences, NUM_MSG_SEQUENCE);
1097 DestroyWindow(hWndTrackbar);
1099 /* test getters and setters without styles set */
1100 hWndTrackbar = create_trackbar(0, hWndParent);
1102 ok(hWndTrackbar != NULL, "Expected non NULL value\n");
1105 skip("trackbar control not present?\n");
1109 ok_sequence(sequences, PARENT_SEQ_INDEX, parent_new_window_test_seq, "new trackbar window test sequence", TRUE);
1111 test_ignore_selection(hWndTrackbar);
1113 DestroyWindow(hWndTrackbar);
1115 test_initial_state();
1117 DestroyWindow(hWndParent);