ReactOS 0.4.15-dev-7958-gcd0bb1a
win.c
Go to the documentation of this file.
1/*
2 * Unit tests for window handling
3 *
4 * Copyright 2002 Bill Medland
5 * Copyright 2002 Alexandre Julliard
6 * Copyright 2003 Dmitry Timoshkov
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#include "precomp.h"
24
25#ifndef SPI_GETDESKWALLPAPER
26#define SPI_GETDESKWALLPAPER 0x0073
27#endif
28
29#ifndef WM_SYSTIMER
30#define WM_SYSTIMER 0x0118
31#endif
32
33#define LONG_PTR INT_PTR
34#define ULONG_PTR UINT_PTR
35
36void dump_region(HRGN hrgn);
37
38static HWND (WINAPI *pGetAncestor)(HWND,UINT);
39static BOOL (WINAPI *pGetWindowInfo)(HWND,WINDOWINFO*);
40static UINT (WINAPI *pGetWindowModuleFileNameA)(HWND,LPSTR,UINT);
41static BOOL (WINAPI *pGetLayeredWindowAttributes)(HWND,COLORREF*,BYTE*,DWORD*);
42static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
43static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
44static BOOL (WINAPI *pUpdateLayeredWindowIndirect)(HWND,const UPDATELAYEREDWINDOWINFO*);
45static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
46static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
47static int (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
48static BOOL (WINAPI *pGetGUIThreadInfo)(DWORD, GUITHREADINFO*);
49static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout );
50static BOOL (WINAPI *pSetProcessDefaultLayout)( DWORD layout );
51static BOOL (WINAPI *pFlashWindow)( HWND hwnd, BOOL bInvert );
52static BOOL (WINAPI *pFlashWindowEx)( PFLASHWINFO pfwi );
53static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
54static DWORD (WINAPI *pGetLayout)(HDC hdc);
55static BOOL (WINAPI *pMirrorRgn)(HWND hwnd, HRGN hrgn);
56
62static HHOOK hhook;
64
65static const char* szAWRClass = "Winsize";
66static HMENU hmenu;
68
70
71#define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
72
73static void dump_minmax_info( const MINMAXINFO *minmax )
74{
75 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
76 minmax->ptReserved.x, minmax->ptReserved.y,
77 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
78 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
79 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
80 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
81}
82
83/* try to make sure pending X events have been processed before continuing */
84static void flush_events( BOOL remove_messages )
85{
86 MSG msg;
87 int diff = 200;
88 int min_timeout = 100;
89 DWORD time = GetTickCount() + diff;
90
91 while (diff > 0)
92 {
93 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
94 if (remove_messages)
95 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
96 diff = time - GetTickCount();
97 min_timeout = 50;
98 }
99}
100
102{
103 DWORD end_time = GetTickCount() + timeout;
104 MSG msg;
105
106 do {
108 return TRUE;
109 while(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
111 timeout = end_time - GetTickCount();
112 }while(timeout > 0);
113
114 return FALSE;
115}
116
117/* check the values returned by the various parent/owner functions on a given window */
118static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
119 HWND gw_owner, HWND ga_root, HWND ga_root_owner )
120{
121 HWND res;
122
123 if (pGetAncestor)
124 {
125 res = pGetAncestor( hwnd, GA_PARENT );
126 ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent );
127 }
129 ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res, gwl_parent );
130 res = GetParent( hwnd );
131 ok( res == get_parent, "Wrong result for GetParent %p expected %p\n", res, get_parent );
133 ok( res == gw_owner, "Wrong result for GW_OWNER %p expected %p\n", res, gw_owner );
134 if (pGetAncestor)
135 {
136 res = pGetAncestor( hwnd, GA_ROOT );
137 ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p\n", res, ga_root );
138 res = pGetAncestor( hwnd, GA_ROOTOWNER );
139 ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p\n", res, ga_root_owner );
140 }
141}
142
143#define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
144static void check_wnd_state_(const char *file, int line,
145 HWND active, HWND foreground, HWND focus, HWND capture)
146{
147 ok_(file, line)(active == GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
148 /* only check foreground if it belongs to the current thread */
149 /* foreground can be moved to a different app pretty much at any time */
150 if (foreground && GetForegroundWindow() &&
153 ok_(file, line)(foreground == GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
154 ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus());
155 ok_(file, line)(capture == GetCapture(), "GetCapture() = %p\n", GetCapture());
156}
157
158/* same as above but without capture test */
159#define check_active_state(a,b,c) check_active_state_(__FILE__,__LINE__,a,b,c)
160static void check_active_state_(const char *file, int line,
161 HWND active, HWND foreground, HWND focus)
162{
163 ok_(file, line)(active == GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
164 /* only check foreground if it belongs to the current thread */
165 /* foreground can be moved to a different app pretty much at any time */
166 if (foreground && GetForegroundWindow() &&
169 ok_(file, line)(foreground == GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
170 ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus());
171}
172
174{
175 /* these are always ignored */
176 return (message >= 0xc000 ||
177 message == WM_GETICON ||
178 message == WM_GETOBJECT ||
179 message == WM_TIMER ||
180 message == WM_SYSTIMER ||
183}
184
186{
187 (*(LPINT)lParam)++;
188 trace("EnumChildProc on %p\n", hwndChild);
189 if (*(LPINT)lParam > 1) return FALSE;
190 return TRUE;
191}
192
193/* will search for the given window */
195{
196 trace("EnumChildProc1 on %p\n", hwndChild);
197 if ((HWND)lParam == hwndChild) return FALSE;
198 return TRUE;
199}
200
202{
203 HWND ret = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style,
204 0, 0, 100, 100, parent, 0, 0, NULL );
205 ok( ret != 0, "Creation failed\n" );
206 return ret;
207}
208
209/* test parent and owner values for various combinations */
210static void test_parent_owner(void)
211{
212 LONG style;
213 HWND test, owner, ret;
214 HWND desktop = GetDesktopWindow();
216 INT numChildren;
217
218 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain, hwndMain2, desktop, child );
219
220 /* child without parent, should fail */
221 SetLastError(0xdeadbeef);
222 test = CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
223 WS_CHILD, 0, 0, 100, 100, 0, 0, 0, NULL );
224 ok( !test, "WS_CHILD without parent created\n" );
226 broken(GetLastError() == 0xdeadbeef), /* win9x */
227 "CreateWindowExA error %u\n", GetLastError() );
228
229 /* desktop window */
230 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
231 style = GetWindowLongA( desktop, GWL_STYLE );
232 ok( !SetWindowLongA( desktop, GWL_STYLE, WS_POPUP ), "Set GWL_STYLE on desktop succeeded\n" );
233 ok( !SetWindowLongA( desktop, GWL_STYLE, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
234 ok( GetWindowLongA( desktop, GWL_STYLE ) == style, "Desktop style changed\n" );
235
236 /* normal child window */
238 trace( "created child %p\n", test );
248
249 /* normal child window with WS_MAXIMIZE */
252
253 /* normal child window with WS_THICKFRAME */
256
257 /* popup window with WS_THICKFRAME */
260
261 /* child of desktop */
262 test = create_tool_window( WS_CHILD, desktop );
263 trace( "created child of desktop %p\n", test );
264 check_parents( test, desktop, 0, desktop, 0, test, desktop );
266 check_parents( test, desktop, 0, 0, 0, test, test );
268 check_parents( test, desktop, 0, 0, 0, test, test );
270
271 /* child of desktop with WS_MAXIMIZE */
274
275 /* child of desktop with WS_MINIMIZE */
278
279 /* child of child */
281 trace( "created child of child %p\n", test );
288
289 /* child of child with WS_MAXIMIZE */
292
293 /* child of child with WS_MINIMIZE */
296
297 /* not owned top-level window */
298 test = create_tool_window( 0, 0 );
299 trace( "created top-level %p\n", test );
300 check_parents( test, desktop, 0, 0, 0, test, test );
302 check_parents( test, desktop, 0, 0, 0, test, test );
304 check_parents( test, desktop, 0, desktop, 0, test, desktop );
306
307 /* not owned top-level window with WS_MAXIMIZE */
310
311 /* owned top-level window */
313 trace( "created owned top-level %p\n", test );
314 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
318 check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
320
321 /* owned top-level window with WS_MAXIMIZE */
324
325 /* not owned popup */
327 trace( "created popup %p\n", test );
328 check_parents( test, desktop, 0, 0, 0, test, test );
330 check_parents( test, desktop, 0, desktop, 0, test, desktop );
332 check_parents( test, desktop, 0, 0, 0, test, test );
334
335 /* not owned popup with WS_MAXIMIZE */
338
339 /* owned popup */
341 trace( "created owned popup %p\n", test );
344 check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
346 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
348
349 /* owned popup with WS_MAXIMIZE */
352
353 /* top-level window owned by child (same as owned by top-level) */
355 trace( "created top-level owned by child %p\n", test );
356 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
358
359 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
362
363 /* popup owned by desktop (same as not owned) */
364 test = create_tool_window( WS_POPUP, desktop );
365 trace( "created popup owned by desktop %p\n", test );
366 check_parents( test, desktop, 0, 0, 0, test, test );
368
369 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
372
373 /* popup owned by child (same as owned by top-level) */
375 trace( "created popup owned by child %p\n", test );
378
379 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
382
383 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
385 trace( "created WS_CHILD popup %p\n", test );
386 check_parents( test, desktop, 0, 0, 0, test, test );
388
389 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
392
393 /* owned popup with WS_CHILD (same as WS_POPUP only) */
395 trace( "created owned WS_CHILD popup %p\n", test );
398
399 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
402
403 /******************** parent changes *************************/
404 trace( "testing parent changes\n" );
405
406 /* desktop window */
407 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
408 if (0)
409 {
410 /* this test succeeds on NT but crashes on win9x systems */
412 ok( !ret, "Set GWL_HWNDPARENT succeeded on desktop\n" );
413 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
414 ok( !SetParent( desktop, hwndMain ), "SetParent succeeded on desktop\n" );
415 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
416 }
417 /* normal child window */
419 trace( "created child %p\n", test );
420
422 ok( ret == hwndMain, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain );
424
426 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
428
430 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
431 check_parents( test, desktop, 0, desktop, 0, test, desktop );
432
433 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
434 if (!is_win9x)
435 {
437 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
438 check_parents( test, desktop, 0, desktop, 0, test, desktop );
439 }
440 else
441 win_skip("Test creates circular window tree under Win9x/WinMe\n" );
442
444 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
445 check_parents( test, desktop, child, desktop, child, test, desktop );
446
448 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
449 check_parents( test, desktop, 0, desktop, 0, test, desktop );
451
452 /* not owned top-level window */
453 test = create_tool_window( 0, 0 );
454 trace( "created top-level %p\n", test );
455
457 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
458 check_parents( test, desktop, hwndMain2, 0, hwndMain2, test, test );
459
461 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
462 check_parents( test, desktop, child, 0, child, test, test );
463
465 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
466 check_parents( test, desktop, 0, 0, 0, test, test );
468
469 /* not owned popup */
471 trace( "created popup %p\n", test );
472
474 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
476
478 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
480
482 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
483 check_parents( test, desktop, 0, 0, 0, test, test );
485
486 /* normal child window */
488 trace( "created child %p\n", test );
489
490 ret = SetParent( test, desktop );
491 ok( ret == hwndMain, "SetParent return value %p expected %p\n", ret, hwndMain );
492 check_parents( test, desktop, 0, desktop, 0, test, desktop );
493
494 ret = SetParent( test, child );
495 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
497
499 ok( ret == child, "SetParent return value %p expected %p\n", ret, child );
502
503 /* not owned top-level window */
504 test = create_tool_window( 0, 0 );
505 trace( "created top-level %p\n", test );
506
507 ret = SetParent( test, child );
508 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
510
511 if (!is_win9x)
512 {
514 ret = SetParent( test, test );
515 ok( ret == NULL, "SetParent return value %p expected %p\n", ret, NULL );
516 ok( GetWindowLongA( test, GWL_STYLE ) & WS_VISIBLE, "window is not visible after SetParent\n" );
518 }
519 else
520 win_skip( "Test crashes on Win9x/WinMe\n" );
522
523 /* owned popup */
525 trace( "created owned popup %p\n", test );
526
527 ret = SetParent( test, child );
528 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
530
532 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
535
536 /**************** test owner destruction *******************/
537
538 /* owned child popup */
539 owner = create_tool_window( 0, 0 );
540 test = create_tool_window( WS_POPUP, owner );
541 trace( "created owner %p and popup %p\n", owner, test );
542 ret = SetParent( test, child );
543 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
544 check_parents( test, child, child, owner, owner, hwndMain, owner );
545 /* window is now child of 'child' but owned by 'owner' */
546 DestroyWindow( owner );
547 ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
548 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
549 * while Win95, Win2k, WinXP do.
550 */
551 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
552 ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
554
555 /* owned top-level popup */
556 owner = create_tool_window( 0, 0 );
557 test = create_tool_window( WS_POPUP, owner );
558 trace( "created owner %p and popup %p\n", owner, test );
559 check_parents( test, desktop, owner, owner, owner, test, owner );
560 DestroyWindow( owner );
561 ok( !IsWindow(test), "Window %p not destroyed by owner destruction\n", test );
562
563 /* top-level popup owned by child */
566 trace( "created owner %p and popup %p\n", owner, test );
568 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
569 check_parents( test, desktop, owner, owner, owner, test, hwndMain2 );
570 DestroyWindow( owner );
571 ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
572 ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
573 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
574 * while Win95, Win2k, WinXP do.
575 */
576 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
578
579 /* final cleanup */
581
582
583 owner = create_tool_window( WS_OVERLAPPED, 0 );
584 test = create_tool_window( WS_POPUP, desktop );
585
586 ok( !GetWindow( test, GW_OWNER ), "Wrong owner window\n" );
587 numChildren = 0;
588 ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
589 "EnumChildWindows should have returned FALSE\n" );
590 ok( numChildren == 0, "numChildren should be 0 got %d\n", numChildren );
591
593 ret = SetParent( test, owner );
594 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
595
596 numChildren = 0;
597 ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
598 "EnumChildWindows should have returned TRUE\n" );
599 ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
600
602 numChildren = 0;
603 ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
604 "EnumChildWindows should have returned FALSE\n" );
605 ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
607
609 ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
610 numChildren = 0;
611 ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
612 "EnumChildWindows should have returned TRUE\n" );
613 ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
614
615 ret = SetParent( child, owner );
616 ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
617 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
618 numChildren = 0;
619 ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
620 "EnumChildWindows should have returned FALSE\n" );
621 ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
622
623 ret = SetParent( child, NULL );
624 ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
625 ok( ret == owner, "SetParent return value %p expected %p\n", ret, owner );
626 numChildren = 0;
627 ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
628 "EnumChildWindows should have returned TRUE\n" );
629 ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
630
631 /* even GW_OWNER == owner it's still a desktop's child */
633 "EnumChildWindows should have found %p and returned FALSE\n", child );
634
637
639 "EnumChildWindows should have found %p and returned FALSE\n", child );
640
643 DestroyWindow( owner );
644
645 /* Test that owner window takes into account WS_CHILD flag even if parent is set by SetParent. */
647 SetParent(owner, hwndMain);
648 check_parents( owner, hwndMain, hwndMain, NULL, NULL, hwndMain, owner );
650 check_parents( test, desktop, owner, NULL, owner, test, test );
651 DestroyWindow( owner );
653
654 owner = create_tool_window( WS_VISIBLE | WS_CHILD, desktop );
655 SetParent(owner, hwndMain);
659 DestroyWindow( owner );
661
662 owner = create_tool_window( WS_VISIBLE | WS_POPUP | WS_CHILD, desktop );
663 SetParent(owner, hwndMain);
664 check_parents( owner, hwndMain, hwndMain, NULL, NULL, hwndMain, owner );
666 check_parents( test, desktop, owner, NULL, owner, test, test );
667 DestroyWindow( owner );
669}
670
672{
673 (*(LPINT)lParam)++;
674 if (*(LPINT)lParam > 2) return FALSE;
675 return TRUE;
676}
678{
679 INT count;
680 HWND hwnd[3];
681 BOOL ret;
682 MSG msg;
683
684 if (pGetGUIThreadInfo)
685 {
687 info.cbSize = sizeof(info);
688 ret = pGetGUIThreadInfo( GetCurrentThreadId(), &info );
689 ok( ret || broken(!ret), /* win9x */
690 "GetGUIThreadInfo failed without message queue\n" );
691 SetLastError( 0xdeadbeef );
692 info.cbSize = sizeof(info) + 1;
693 ret = pGetGUIThreadInfo( GetCurrentThreadId(), &info );
694 ok( !ret, "GetGUIThreadInfo succeeded with wrong size\n" );
696 broken(GetLastError() == 0xdeadbeef), /* win9x */
697 "wrong error %u\n", GetLastError() );
698 }
699
700 PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */
701
702 count = 0;
704 ok( ret, "EnumThreadWindows should have returned TRUE\n" );
705 ok( count == 0, "count should be 0 got %d\n", count );
706
707 hwnd[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP,
708 0, 0, 100, 100, 0, 0, 0, NULL );
709 count = 0;
711 ok( ret, "EnumThreadWindows should have returned TRUE\n" );
712 if (count != 2) /* Vista gives us two windows for the price of one */
713 {
714 ok( count == 1, "count should be 1 got %d\n", count );
715 hwnd[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP,
716 0, 0, 100, 100, 0, 0, 0, NULL );
717 }
718 else hwnd[2] = 0;
719
720 hwnd[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP,
721 0, 0, 100, 100, 0, 0, 0, NULL );
722 count = 0;
724 ok( !ret, "EnumThreadWindows should have returned FALSE\n" );
725 ok( count == 3, "count should be 3 got %d\n", count );
726
727 if (hwnd[2]) DestroyWindow(hwnd[2]);
730 return 0;
731}
732
733/* test EnumThreadWindows in a separate thread */
735{
736 DWORD id;
737 HANDLE handle = CreateThread( NULL, 0, enum_thread, 0, 0, &id );
738 ok( !WaitForSingleObject( handle, 10000 ), "wait failed\n" );
740}
741
743{
744 BOOL enabled; /* when 1 bypasses default procedure */
745 char *buff; /* expected text buffer pointer */
746 WCHAR *buffW; /* same, for W test */
748
750{
751 switch (msg)
752 {
753 case WM_GETMINMAXINFO:
754 {
756 break;
757 }
759 {
760 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
761 if (!(winpos->flags & SWP_NOMOVE))
762 {
763 ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
764 ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
765 }
766 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
767 if (!(winpos->flags & SWP_NOSIZE) && !is_win9x)
768 {
769 ok((winpos->cx >= 0 && winpos->cx <= 32767) ||
770 winpos->cx == 32768, /* win7 doesn't truncate */
771 "bad winpos->cx %d\n", winpos->cx);
772 ok((winpos->cy >= 0 && winpos->cy <= 32767) ||
773 winpos->cy == 40000, /* win7 doesn't truncate */
774 "bad winpos->cy %d\n", winpos->cy);
775 }
776 break;
777 }
780 {
781 RECT rc1, rc2;
782 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
783 ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
784 ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
785
786 ok((winpos->cx >= 0 && winpos->cx <= 32767) ||
787 winpos->cx == 32768, /* win7 doesn't truncate */
788 "bad winpos->cx %d\n", winpos->cx);
789 ok((winpos->cy >= 0 && winpos->cy <= 32767) ||
790 winpos->cy == 40000, /* win7 doesn't truncate */
791 "bad winpos->cy %d\n", winpos->cy);
792
793 GetWindowRect(hwnd, &rc1);
794 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
795 /* note: winpos coordinates are relative to parent */
797 if (0)
798 {
799 /* Uncomment this once the test succeeds in all cases */
800 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
802
805 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
806 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
808 }
809 break;
810 }
811 case WM_NCCREATE:
812 {
813 BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021;
815
816 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
817 ok(got_getminmaxinfo, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
818 else
819 ok(!got_getminmaxinfo, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
820 break;
821 }
822 case WM_COMMAND:
824 {
827 }
828 break;
829 case WM_GETTEXT:
831 if (g_wm_gettext_override.enabled)
832 {
833 char *text = (char*)lparam;
834 ok(g_wm_gettext_override.buff == text, "expected buffer %p, got %p\n", g_wm_gettext_override.buff, text);
835 ok(*text == 0, "expected empty string buffer %x\n", *text);
836 return 0;
837 }
838 break;
839 case WM_SETTEXT:
841 break;
842 case WM_ACTIVATEAPP:
844 else app_deactivated = TRUE;
845 break;
846 }
847
849}
850
852{
853 switch (msg)
854 {
855 case WM_GETTEXT:
857 if (g_wm_gettext_override.enabled)
858 {
859 WCHAR *text = (WCHAR*)lparam;
860 ok(g_wm_gettext_override.buffW == text, "expected buffer %p, got %p\n", g_wm_gettext_override.buffW, text);
861 ok(*text == 0, "expected empty string buffer %x\n", *text);
862 return 0;
863 }
864 break;
865 }
866
868}
869
871{
872 switch (msg)
873 {
874 case WM_GETMINMAXINFO:
875 {
877 break;
878 }
879 case WM_NCCREATE:
880 {
881 BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021;
883
884 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
885 ok(got_getminmaxinfo, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
886 else
887 ok(!got_getminmaxinfo, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
888 break;
889 }
890 }
891
893}
894
895static const WCHAR mainclassW[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s','W',0};
896
898{
899 WNDCLASSW clsW;
900 WNDCLASSA cls;
901
902 cls.style = CS_DBLCLKS;
904 cls.cbClsExtra = 0;
905 cls.cbWndExtra = 0;
907 cls.hIcon = 0;
910 cls.lpszMenuName = NULL;
911 cls.lpszClassName = "MainWindowClass";
912
913 if(!RegisterClassA(&cls)) return FALSE;
914
915 clsW.style = CS_DBLCLKS;
917 clsW.cbClsExtra = 0;
918 clsW.cbWndExtra = 0;
919 clsW.hInstance = GetModuleHandleA(0);
920 clsW.hIcon = 0;
923 clsW.lpszMenuName = NULL;
925
926 if(!RegisterClassW(&clsW)) return FALSE;
927
928 cls.style = 0;
930 cls.cbClsExtra = 0;
931 cls.cbWndExtra = 0;
933 cls.hIcon = 0;
936 cls.lpszMenuName = NULL;
937 cls.lpszClassName = "ToolWindowClass";
938
939 if(!RegisterClassA(&cls)) return FALSE;
940
941 return TRUE;
942}
943
944static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *info)
945{
946 RECT rcWindow, rcClient;
948
949 ok(IsWindow(hwnd), "bad window handle %p in hook %s\n", hwnd, hook);
950
951 GetWindowRect(hwnd, &rcWindow);
952 ok(EqualRect(&rcWindow, &info->rcWindow), "wrong rcWindow for %p in hook %s\n", hwnd, hook);
953
954 GetClientRect(hwnd, &rcClient);
955 /* translate to screen coordinates */
956 MapWindowPoints(hwnd, 0, (LPPOINT)&rcClient, 2);
957 ok(EqualRect(&rcClient, &info->rcClient), "wrong rcClient for %p in hook %s\n", hwnd, hook);
958
959 ok(info->dwStyle == (DWORD)GetWindowLongA(hwnd, GWL_STYLE),
960 "wrong dwStyle: %08x != %08x for %p in hook %s\n",
961 info->dwStyle, GetWindowLongA(hwnd, GWL_STYLE), hwnd, hook);
962 /* Windows reports some undocumented exstyles in WINDOWINFO, but
963 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
964 */
965 ok((info->dwExStyle & ~0xe0000800) == (DWORD)GetWindowLongA(hwnd, GWL_EXSTYLE),
966 "wrong dwExStyle: %08x != %08x for %p in hook %s\n",
967 info->dwExStyle, GetWindowLongA(hwnd, GWL_EXSTYLE), hwnd, hook);
970 ok(info->dwWindowStatus == status, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n",
971 info->dwWindowStatus, status, GetActiveWindow(), GetForegroundWindow(), hook);
972 else
973 ok(1, "Just counting");
974
975 /* win2k and XP return broken border info in GetWindowInfo most of
976 * the time, so there is no point in testing it.
977 */
978if (0)
979{
980 UINT border;
981 ok(info->cxWindowBorders == (unsigned)(rcClient.left - rcWindow.left),
982 "wrong cxWindowBorders %d != %d\n", info->cxWindowBorders, rcClient.left - rcWindow.left);
983 border = min(rcWindow.bottom - rcClient.bottom, rcClient.top - rcWindow.top);
984 ok(info->cyWindowBorders == border,
985 "wrong cyWindowBorders %d != %d\n", info->cyWindowBorders, border);
986}
987 ok(info->atomWindowType == GetClassLongA(hwnd, GCW_ATOM), "wrong atomWindowType for %p in hook %s\n",
988 hwnd, hook);
989 ok(info->wCreatorVersion == 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
990 info->wCreatorVersion == 0x0500 /* Vista */,
991 "wrong wCreatorVersion %04x for %p in hook %s\n", info->wCreatorVersion, hwnd, hook);
992}
993
994static void FixedAdjustWindowRectEx(RECT* rc, LONG style, BOOL menu, LONG exstyle)
995{
996 AdjustWindowRectEx(rc, style, menu, exstyle);
997 /* AdjustWindowRectEx does not include scroll bars */
998 if (style & WS_VSCROLL)
999 {
1000 if(exstyle & WS_EX_LEFTSCROLLBAR)
1002 else
1004 }
1005 if (style & WS_HSCROLL)
1007}
1008
1009/* reimplement it to check that the Wine algorithm gives the correct result */
1010static void wine_AdjustWindowRectEx( RECT *rect, LONG style, BOOL menu, LONG exStyle )
1011{
1012 int adjust;
1013
1014 if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) ==
1016 {
1017 adjust = 1; /* for the outer frame always present */
1018 }
1019 else
1020 {
1021 adjust = 0;
1022 if ((exStyle & WS_EX_DLGMODALFRAME) ||
1023 (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */
1024 }
1025 if (style & WS_THICKFRAME)
1026 adjust += GetSystemMetrics(SM_CXFRAME) - GetSystemMetrics(SM_CXDLGFRAME); /* The resize border */
1027 if ((style & (WS_BORDER|WS_DLGFRAME)) ||
1028 (exStyle & WS_EX_DLGMODALFRAME))
1029 adjust++; /* The other border */
1030
1031 InflateRect (rect, adjust, adjust);
1032
1033 if ((style & WS_CAPTION) == WS_CAPTION)
1034 {
1035 if (exStyle & WS_EX_TOOLWINDOW)
1037 else
1039 }
1040 if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
1041
1042 if (exStyle & WS_EX_CLIENTEDGE)
1044
1045 if (style & WS_VSCROLL)
1046 {
1047 if((exStyle & WS_EX_LEFTSCROLLBAR) != 0)
1049 else
1051 }
1053}
1054
1056{
1057 DWORD style, exstyle;
1058 RECT rc_window, rc_client, rc;
1059 BOOL menu;
1060 LRESULT ret;
1061
1063 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1064 menu = !(style & WS_CHILD) && GetMenu(hwnd) != 0;
1065
1066 GetWindowRect(hwnd, &rc_window);
1067 GetClientRect(hwnd, &rc_client);
1068
1069 /* avoid some cases when things go wrong */
1070 if (IsRectEmpty(&rc_window) || IsRectEmpty(&rc_client) ||
1071 rc_window.right > 32768 || rc_window.bottom > 32768) return;
1072
1073 rc = rc_client;
1074 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
1075 FixedAdjustWindowRectEx(&rc, style, menu, exstyle);
1076
1077 ok(EqualRect(&rc, &rc_window),
1078 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=%s, calc=%s\n",
1079 style, exstyle, menu, wine_dbgstr_rect(&rc_window), wine_dbgstr_rect(&rc));
1080
1081 rc = rc_client;
1082 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
1083 wine_AdjustWindowRectEx(&rc, style, menu, exstyle);
1084 ok(EqualRect(&rc, &rc_window),
1085 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=%s, calc=%s\n",
1086 style, exstyle, menu, wine_dbgstr_rect(&rc_window), wine_dbgstr_rect(&rc));
1087
1088
1089 rc = rc_window;
1091 MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
1092 ok(EqualRect(&rc, &rc_client),
1093 "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d client=%s, calc=%s\n",
1094 style, exstyle, menu, wine_dbgstr_rect(&rc_client), wine_dbgstr_rect(&rc));
1095
1096 /* NULL rectangle shouldn't crash */
1098 ok(ret == 0, "NULL rectangle returned %ld instead of 0\n", ret);
1099
1100 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
1101 if (is_win9x)
1102 return;
1103
1104 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
1105 SetRect(&rc_client, 0, 0, 250, 150);
1106 rc_window = rc_client;
1107 MapWindowPoints(hwnd, 0, (LPPOINT)&rc_window, 2);
1108 FixedAdjustWindowRectEx(&rc_window, style, menu, exstyle);
1109
1110 rc = rc_window;
1112 MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
1113 ok(EqualRect(&rc, &rc_client),
1114 "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, client=%s, calc=%s\n",
1115 style, exstyle, menu, wine_dbgstr_rect(&rc_client), wine_dbgstr_rect(&rc));
1116}
1117
1119{
1120 static const char *CBT_code_name[10] = {
1121 "HCBT_MOVESIZE",
1122 "HCBT_MINMAX",
1123 "HCBT_QS",
1124 "HCBT_CREATEWND",
1125 "HCBT_DESTROYWND",
1126 "HCBT_ACTIVATE",
1127 "HCBT_CLICKSKIPPED",
1128 "HCBT_KEYSKIPPED",
1129 "HCBT_SYSCOMMAND",
1130 "HCBT_SETFOCUS" };
1131 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
1132 HWND hwnd = (HWND)wParam;
1133
1134 switch (nCode)
1135 {
1136 case HCBT_CREATEWND:
1137 {
1138 static const RECT rc_null;
1139 RECT rc;
1140 LONG style;
1141 CBT_CREATEWNDA *createwnd = (CBT_CREATEWNDA *)lParam;
1142 ok(createwnd->hwndInsertAfter == HWND_TOP, "hwndInsertAfter should be always HWND_TOP\n");
1143
1144 if (pGetWindowInfo)
1145 {
1147 info.cbSize = sizeof(WINDOWINFO);
1148 ok(pGetWindowInfo(hwnd, &info), "GetWindowInfo should not fail\n");
1149 verify_window_info(code_name, hwnd, &info);
1150 }
1151
1152 /* WS_VISIBLE should be turned off yet */
1153 style = createwnd->lpcs->style & ~WS_VISIBLE;
1155 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
1157
1158 if (0)
1159 {
1160 /* Uncomment this once the test succeeds in all cases */
1161 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1162 {
1164 "wrong result from GetParent %p: message window %p\n",
1166 }
1167 else
1168 ok(!GetParent(hwnd), "GetParent should return 0 at this point\n");
1169
1170 ok(!GetWindow(hwnd, GW_OWNER), "GW_OWNER should be set to 0 at this point\n");
1171 }
1172 if (0)
1173 {
1174 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
1175 * Win9x still has them set to 0.
1176 */
1177 ok(GetWindow(hwnd, GW_HWNDFIRST) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
1178 ok(GetWindow(hwnd, GW_HWNDLAST) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
1179 }
1180 ok(!GetWindow(hwnd, GW_HWNDPREV), "GW_HWNDPREV should be set to 0 at this point\n");
1181 ok(!GetWindow(hwnd, GW_HWNDNEXT), "GW_HWNDNEXT should be set to 0 at this point\n");
1182
1183 if (0)
1184 {
1185 /* Uncomment this once the test succeeds in all cases */
1186 if (pGetAncestor)
1187 {
1188 ok(pGetAncestor(hwnd, GA_PARENT) == hwndMessage, "GA_PARENT should be set to hwndMessage at this point\n");
1189 ok(pGetAncestor(hwnd, GA_ROOT) == hwnd,
1190 "GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd, GA_ROOT), hwnd);
1191
1192 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1193 ok(pGetAncestor(hwnd, GA_ROOTOWNER) == hwndMessage,
1194 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
1195 else
1196 ok(pGetAncestor(hwnd, GA_ROOTOWNER) == hwnd,
1197 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd, GA_ROOTOWNER), hwnd);
1198 }
1199
1200 ok(GetWindowRect(hwnd, &rc), "GetWindowRect failed\n");
1201 ok(EqualRect(&rc, &rc_null), "window rect should be set to 0 HCBT_CREATEWND\n");
1202 ok(GetClientRect(hwnd, &rc), "GetClientRect failed\n");
1203 ok(EqualRect(&rc, &rc_null), "client rect should be set to 0 on HCBT_CREATEWND\n");
1204 }
1205 break;
1206 }
1207 case HCBT_MOVESIZE:
1208 case HCBT_MINMAX:
1209 case HCBT_ACTIVATE:
1210 if (pGetWindowInfo && IsWindow(hwnd))
1211 {
1213
1214 /* Win98 actually does check the info.cbSize and doesn't allow
1215 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
1216 * WinXP do not check it at all.
1217 */
1218 info.cbSize = sizeof(WINDOWINFO);
1219 ok(pGetWindowInfo(hwnd, &info), "GetWindowInfo should not fail\n");
1220 verify_window_info(code_name, hwnd, &info);
1221 }
1222 break;
1223 /* window state is undefined */
1224 case HCBT_SETFOCUS:
1225 case HCBT_DESTROYWND:
1226 break;
1227 default:
1228 break;
1229 }
1230
1231 return CallNextHookEx(hhook, nCode, wParam, lParam);
1232}
1233
1234static void test_shell_window(void)
1235{
1236 BOOL ret;
1237 DWORD error;
1238 HMODULE hinst, hUser32;
1240 HWND hwnd1, hwnd2, hwnd3, hwnd4, hwnd5;
1241 HWND shellWindow, nextWnd;
1242
1243 if (is_win9x)
1244 {
1245 win_skip("Skipping shell window test on Win9x\n");
1246 return;
1247 }
1248
1249 shellWindow = GetShellWindow();
1251 hUser32 = GetModuleHandleA("user32");
1252
1253 SetShellWindow = (void *)GetProcAddress(hUser32, "SetShellWindow");
1254
1255 trace("previous shell window: %p\n", shellWindow);
1256
1257 if (shellWindow) {
1258 DWORD pid;
1260
1261 GetWindowThreadProcessId(shellWindow, &pid);
1263 if (!hProcess)
1264 {
1265 skip( "cannot get access to shell process\n" );
1266 return;
1267 }
1268
1269 SetLastError(0xdeadbeef);
1270 ret = DestroyWindow(shellWindow);
1271 error = GetLastError();
1272
1273 ok(!ret, "DestroyWindow(shellWindow)\n");
1274 /* passes on Win XP, but not on Win98 */
1275 ok(error==ERROR_ACCESS_DENIED || error == 0xdeadbeef,
1276 "got %u after DestroyWindow(shellWindow)\n", error);
1277
1278 /* close old shell instance */
1280 ok(ret, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
1281 WaitForSingleObject(hProcess, INFINITE); /* wait for termination */
1283 }
1284
1285 hwnd1 = CreateWindowExA(0, "#32770", "TEST1", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst, 0);
1286 trace("created window 1: %p\n", hwnd1);
1287
1288 ret = SetShellWindow(hwnd1);
1289 ok(ret, "first call to SetShellWindow(hwnd1)\n");
1290 shellWindow = GetShellWindow();
1291 ok(shellWindow==hwnd1, "wrong shell window: %p\n", shellWindow);
1292
1293 ret = SetShellWindow(hwnd1);
1294 ok(!ret, "second call to SetShellWindow(hwnd1)\n");
1295
1296 ret = SetShellWindow(0);
1297 error = GetLastError();
1298 /* passes on Win XP, but not on Win98
1299 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1300 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1301
1302 ret = SetShellWindow(hwnd1);
1303 /* passes on Win XP, but not on Win98
1304 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1305
1307 ret = (GetWindowLongA(hwnd1,GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
1308 ok(!ret, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1309
1310 ret = DestroyWindow(hwnd1);
1311 ok(ret, "DestroyWindow(hwnd1)\n");
1312
1313 hwnd2 = CreateWindowExA(WS_EX_TOPMOST, "#32770", "TEST2", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst, 0);
1314 trace("created window 2: %p\n", hwnd2);
1315 ret = SetShellWindow(hwnd2);
1316 ok(!ret, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1317
1318 hwnd3 = CreateWindowExA(0, "#32770", "TEST3", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst, 0);
1319 trace("created window 3: %p\n", hwnd3);
1320
1321 hwnd4 = CreateWindowExA(0, "#32770", "TEST4", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst, 0);
1322 trace("created window 4: %p\n", hwnd4);
1323
1324 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
1325 ok(nextWnd==hwnd3, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd);
1326
1327 ret = SetShellWindow(hwnd4);
1328 ok(ret, "SetShellWindow(hwnd4)\n");
1329 shellWindow = GetShellWindow();
1330 ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow);
1331
1332 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
1333 ok(nextWnd==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd);
1334
1335 ret = SetWindowPos(hwnd4, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
1336 ok(ret, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1337
1338 ret = SetWindowPos(hwnd4, hwnd3, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
1339 ok(ret, "SetWindowPos(hwnd4, hwnd3\n");
1340
1341 ret = SetShellWindow(hwnd3);
1342 ok(!ret, "SetShellWindow(hwnd3)\n");
1343 shellWindow = GetShellWindow();
1344 ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow);
1345
1346 hwnd5 = CreateWindowExA(0, "#32770", "TEST5", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst, 0);
1347 trace("created window 5: %p\n", hwnd5);
1348 ret = SetWindowPos(hwnd4, hwnd5, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
1349 ok(ret, "SetWindowPos(hwnd4, hwnd5)\n");
1350
1351 todo_wine
1352 {
1353 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
1354 ok(nextWnd==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd);
1355 }
1356
1357 /* destroy test windows */
1358 DestroyWindow(hwnd2);
1359 DestroyWindow(hwnd3);
1360 DestroyWindow(hwnd4);
1361 DestroyWindow(hwnd5);
1362}
1363
1364/************** MDI test ****************/
1365
1366static char mdi_lParam_test_message[] = "just a test string";
1367
1369{
1370 MDICREATESTRUCTA mdi_cs;
1371 HWND mdi_child, hwnd, exp_hwnd;
1372 INT_PTR id;
1373 static const WCHAR classW[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1374 static const WCHAR titleW[] = {'M','D','I',' ','c','h','i','l','d',0};
1375 BOOL isWin9x = FALSE;
1376 HMENU frame_menu = GetMenu(parent);
1377
1378 ok(frame_menu != NULL, "Frame window didn't have a menu\n");
1379
1380 mdi_cs.szClass = "MDI_child_Class_1";
1381 mdi_cs.szTitle = "MDI child";
1382 mdi_cs.hOwner = GetModuleHandleA(NULL);
1383 mdi_cs.x = CW_USEDEFAULT;
1384 mdi_cs.y = CW_USEDEFAULT;
1385 mdi_cs.cx = CW_USEDEFAULT;
1386 mdi_cs.cy = CW_USEDEFAULT;
1387 mdi_cs.style = 0;
1389 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1390 ok(mdi_child != 0, "MDI child creation failed\n");
1391 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1392 ok(id == first_id, "wrong child id %ld\n", id);
1394 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1395 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1397 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1398
1399 mdi_cs.style = 0x7fffffff; /* without WS_POPUP */
1400 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1401 ok(mdi_child != 0, "MDI child creation failed\n");
1402 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1403 ok(id == first_id, "wrong child id %ld\n", id);
1405 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1407 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1408
1409 mdi_cs.style = 0xffffffff; /* with WS_POPUP */
1410 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1412 {
1413 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1414 }
1415 else
1416 {
1417 ok(mdi_child != 0, "MDI child creation failed\n");
1418 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1419 ok(id == first_id, "wrong child id %ld\n", id);
1421 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1422 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1424 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1425 }
1426
1427 /* test MDICREATESTRUCT A<->W mapping */
1428 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1429 mdi_cs.style = 0;
1430 mdi_cs.szClass = (LPCSTR)classW;
1431 mdi_cs.szTitle = (LPCSTR)titleW;
1432 SetLastError(0xdeadbeef);
1433 mdi_child = (HWND)SendMessageW(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1434 if (!mdi_child)
1435 {
1437 isWin9x = TRUE;
1438 else
1439 ok(mdi_child != 0, "MDI child creation failed\n");
1440 }
1441 else
1442 {
1443 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1444 ok(id == first_id, "wrong child id %ld\n", id);
1446 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1447 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1448 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1450 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1451 }
1452
1453 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1454 0,
1459 ok(mdi_child != 0, "MDI child creation failed\n");
1460 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1461 ok(id == first_id, "wrong child id %ld\n", id);
1463 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1464 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1465 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1467 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1468
1469 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1470 0x7fffffff, /* without WS_POPUP */
1475 ok(mdi_child != 0, "MDI child creation failed\n");
1476 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1477 ok(id == first_id, "wrong child id %ld\n", id);
1479 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1480 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1482 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1483
1484 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1485 0xffffffff, /* with WS_POPUP */
1491 {
1492 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1493 }
1494 else
1495 {
1496 ok(mdi_child != 0, "MDI child creation failed\n");
1497 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1498 ok(id == first_id, "wrong child id %ld\n", id);
1500 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1501 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1503 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1504 }
1505
1506 /* test MDICREATESTRUCT A<->W mapping */
1507 SetLastError(0xdeadbeef);
1508 mdi_child = CreateMDIWindowW(classW, titleW,
1509 0,
1514 if (!mdi_child)
1515 {
1517 isWin9x = TRUE;
1518 else
1519 ok(mdi_child != 0, "MDI child creation failed\n");
1520 }
1521 else
1522 {
1523 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1524 ok(id == first_id, "wrong child id %ld\n", id);
1526 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1527 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1528 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1530 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1531 }
1532
1533 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1534 0,
1539 ok(mdi_child != 0, "MDI child creation failed\n");
1540 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1541 ok(id == first_id, "wrong child id %ld\n", id);
1543 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1544 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1545 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1547 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1548
1549 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1555 ok(mdi_child != 0, "MDI child creation failed\n");
1556 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1557 ok(id == first_id, "wrong child id %ld\n", id);
1559 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1560 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1562 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1563 else
1564 ok(GetMenuItemCount(frame_menu) == 4, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1566 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1567
1568 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1569 0x7fffffff, /* without WS_POPUP */
1574 ok(mdi_child != 0, "MDI child creation failed\n");
1575 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1576 ok(id == first_id, "wrong child id %ld\n", id);
1578 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1579 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1581 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1582
1583 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1584 0xffffffff, /* with WS_POPUP */
1590 {
1591 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1592 }
1593 else
1594 {
1595 ok(mdi_child != 0, "MDI child creation failed\n");
1596 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1597 ok(id == first_id, "wrong child id %ld\n", id);
1599 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1600 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1602 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1603 }
1604
1605 /* test MDICREATESTRUCT A<->W mapping */
1606 SetLastError(0xdeadbeef);
1608 0,
1613 if (!mdi_child)
1614 {
1616 isWin9x = TRUE;
1617 else
1618 ok(mdi_child != 0, "MDI child creation failed\n");
1619 }
1620 else
1621 {
1622 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1623 ok(id == first_id, "wrong child id %ld\n", id);
1625 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1626 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1627 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1629 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1630 }
1631
1632 /* This test fails on Win9x */
1633 if (!isWin9x)
1634 {
1635 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_2", "MDI child",
1636 WS_CHILD,
1641 ok(!mdi_child, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1642 }
1643
1644 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1645 WS_CHILD, /* without WS_POPUP */
1650 ok(mdi_child != 0, "MDI child creation failed\n");
1651 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1652 ok(id == 0, "wrong child id %ld\n", id);
1653 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1655 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1656 DestroyWindow(mdi_child);
1657
1658 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1659 WS_CHILD | WS_POPUP, /* with WS_POPUP */
1664 ok(mdi_child != 0, "MDI child creation failed\n");
1665 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1666 ok(id == 0, "wrong child id %ld\n", id);
1668 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1669 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1670 DestroyWindow(mdi_child);
1671
1672 /* maximized child */
1673 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1679 ok(mdi_child != 0, "MDI child creation failed\n");
1680 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1681 ok(id == 0, "wrong child id %ld\n", id);
1683 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1684 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1685 DestroyWindow(mdi_child);
1686
1687 trace("Creating maximized child with a caption\n");
1688 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1694 ok(mdi_child != 0, "MDI child creation failed\n");
1695 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1696 ok(id == 0, "wrong child id %ld\n", id);
1698 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1699 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1700 DestroyWindow(mdi_child);
1701
1702 trace("Creating maximized child with a caption and a thick frame\n");
1703 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1709 ok(mdi_child != 0, "MDI child creation failed\n");
1710 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1711 ok(id == 0, "wrong child id %ld\n", id);
1713 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1714 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1715 DestroyWindow(mdi_child);
1716}
1717
1719{
1720 HWND child_1, child_2, child_3, child_4;
1721 HWND stack[4];
1723
1724 cs.szClass = "MDI_child_Class_1";
1725 cs.szTitle = "MDI child";
1726 cs.hOwner = GetModuleHandleA(0);
1727 cs.x = CW_USEDEFAULT;
1728 cs.y = CW_USEDEFAULT;
1729 cs.cx = CW_USEDEFAULT;
1730 cs.cy = CW_USEDEFAULT;
1731 cs.style = 0;
1733
1734 child_1 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
1735 ok(child_1 != 0, "expected child_1 to be non NULL\n");
1736 child_2 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
1737 ok(child_2 != 0, "expected child_2 to be non NULL\n");
1738 child_3 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
1739 ok(child_3 != 0, "expected child_3 to be non NULL\n");
1740 child_4 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
1741 ok(child_4 != 0, "expected child_4 to be non NULL\n");
1742
1744 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
1745 stack[2] = GetWindow(stack[1], GW_HWNDNEXT);
1746 stack[3] = GetWindow(stack[2], GW_HWNDNEXT);
1747 trace("Initial MDI child stack: %p->%p->%p->%p\n", stack[0], stack[1], stack[2], stack[3]);
1748 ok(stack[0] == child_4 && stack[1] == child_3 &&
1749 stack[2] == child_2 && stack[3] == child_1,
1750 "Unexpected initial order, should be: %p->%p->%p->%p\n",
1751 child_4, child_3, child_2, child_1);
1752
1753 trace("Activate child next to %p\n", child_3);
1755
1757 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
1758 stack[2] = GetWindow(stack[1], GW_HWNDNEXT);
1759 stack[3] = GetWindow(stack[2], GW_HWNDNEXT);
1760 ok(stack[0] == child_2 && stack[1] == child_4 &&
1761 stack[2] == child_1 && stack[3] == child_3,
1762 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1763 child_2, child_4, child_1, child_3, stack[0], stack[1], stack[2], stack[3]);
1764
1765 trace("Activate child previous to %p\n", child_1);
1767
1769 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
1770 stack[2] = GetWindow(stack[1], GW_HWNDNEXT);
1771 stack[3] = GetWindow(stack[2], GW_HWNDNEXT);
1772 ok(stack[0] == child_4 && stack[1] == child_2 &&
1773 stack[2] == child_1 && stack[3] == child_3,
1774 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1775 child_4, child_2, child_1, child_3, stack[0], stack[1], stack[2], stack[3]);
1776
1777 DestroyWindow(child_1);
1778 DestroyWindow(child_2);
1779 DestroyWindow(child_3);
1780 DestroyWindow(child_4);
1781}
1782
1783/**********************************************************************
1784 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1785 *
1786 * Note: The rule here is that client rect of the maximized MDI child
1787 * is equal to the client rect of the MDI client window.
1788 */
1790{
1791 RECT rect;
1792
1796
1797 rect.right -= rect.left;
1798 rect.bottom -= rect.top;
1799 lpMinMax->ptMaxSize.x = rect.right;
1800 lpMinMax->ptMaxSize.y = rect.bottom;
1801
1802 lpMinMax->ptMaxPosition.x = rect.left;
1803 lpMinMax->ptMaxPosition.y = rect.top;
1804
1805 trace("max rect %s\n", wine_dbgstr_rect(&rect));
1806}
1807
1809{
1810 switch (msg)
1811 {
1812 case WM_NCCREATE:
1813 case WM_CREATE:
1814 {
1816 MDICREATESTRUCTA *mdi_cs = cs->lpCreateParams;
1817
1818 ok(cs->dwExStyle & WS_EX_MDICHILD, "WS_EX_MDICHILD should be set\n");
1819 ok(mdi_cs->lParam == (LPARAM)mdi_lParam_test_message, "wrong mdi_cs->lParam\n");
1820
1821 ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_1"), "wrong class name\n");
1822 ok(!lstrcmpA(cs->lpszClass, mdi_cs->szClass), "class name does not match\n");
1823 ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
1824 ok(!lstrcmpA(cs->lpszName, mdi_cs->szTitle), "title does not match\n");
1825 ok(cs->hInstance == mdi_cs->hOwner, "%p != %p\n", cs->hInstance, mdi_cs->hOwner);
1826
1827 /* MDICREATESTRUCT should have original values */
1828 ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff || mdi_cs->style == WS_MAXIMIZE,
1829 "mdi_cs->style does not match (%08x)\n", mdi_cs->style);
1830 ok(mdi_cs->x == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->x);
1831 ok(mdi_cs->y == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->y);
1832 ok(mdi_cs->cx == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cx);
1833 ok(mdi_cs->cy == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cy);
1834
1835 /* CREATESTRUCT should have fixed values */
1836 ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);
1837 ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
1838
1839 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1840 ok(cs->cx != CW_USEDEFAULT && cs->cx != 0, "%d == CW_USEDEFAULT\n", cs->cx);
1841 ok(cs->cy != CW_USEDEFAULT && cs->cy != 0, "%d == CW_USEDEFAULT\n", cs->cy);
1842
1843 ok(!(cs->style & WS_POPUP), "WS_POPUP is not allowed\n");
1844
1845 if (GetWindowLongA(cs->hwndParent, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
1846 {
1847 LONG style = mdi_cs->style | WS_CHILD | WS_CLIPSIBLINGS;
1848 ok(cs->style == style,
1849 "cs->style does not match (%08x)\n", cs->style);
1850 }
1851 else
1852 {
1853 LONG style = mdi_cs->style;
1854 style &= ~WS_POPUP;
1857 ok(cs->style == style,
1858 "cs->style does not match (%08x)\n", cs->style);
1859 }
1860 break;
1861 }
1862
1863 case WM_GETMINMAXINFO:
1864 {
1866 RECT rc;
1867 MINMAXINFO *minmax = (MINMAXINFO *)lparam;
1868 MINMAXINFO my_minmax;
1869 LONG style, exstyle;
1870
1872 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1873
1874 GetClientRect(client, &rc);
1875
1876 GetClientRect(client, &rc);
1877 if ((style & WS_CAPTION) == WS_CAPTION)
1878 style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1879 AdjustWindowRectEx(&rc, style, 0, exstyle);
1880 trace("MDI child: calculated max window size = (%d x %d)\n", rc.right-rc.left, rc.bottom-rc.top);
1881 dump_minmax_info( minmax );
1882
1883 ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %d != %d\n",
1884 minmax->ptMaxSize.x, rc.right - rc.left);
1885 ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %d != %d\n",
1886 minmax->ptMaxSize.y, rc.bottom - rc.top);
1887
1889
1890 trace("DefMDIChildProc returned:\n");
1891 dump_minmax_info( minmax );
1892
1893 MDI_ChildGetMinMaxInfo(client, hwnd, &my_minmax);
1894 ok(minmax->ptMaxSize.x == my_minmax.ptMaxSize.x, "default width of maximized child %d != %d\n",
1895 minmax->ptMaxSize.x, my_minmax.ptMaxSize.x);
1896 ok(minmax->ptMaxSize.y == my_minmax.ptMaxSize.y, "default height of maximized child %d != %d\n",
1897 minmax->ptMaxSize.y, my_minmax.ptMaxSize.y);
1898
1899 return 1;
1900 }
1901
1902 case WM_MDIACTIVATE:
1903 {
1904 HWND active, client = GetParent(hwnd);
1905 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1906 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
1907 if (hwnd == (HWND)lparam) /* if we are being activated */
1908 ok (active == (HWND)lparam, "new active %p != active %p\n", (HWND)lparam, active);
1909 else
1910 ok (active == (HWND)wparam, "old active %p != active %p\n", (HWND)wparam, active);
1911 break;
1912 }
1913 }
1915}
1916
1918{
1919 switch (msg)
1920 {
1921 case WM_NCCREATE:
1922 case WM_CREATE:
1923 {
1925
1926 trace("%s: x %d, y %d, cx %d, cy %d\n", (msg == WM_NCCREATE) ? "WM_NCCREATE" : "WM_CREATE",
1927 cs->x, cs->y, cs->cx, cs->cy);
1928
1929 ok(!(cs->dwExStyle & WS_EX_MDICHILD), "WS_EX_MDICHILD should not be set\n");
1930 ok(cs->lpCreateParams == mdi_lParam_test_message, "wrong cs->lpCreateParams\n");
1931
1932 ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_2"), "wrong class name\n");
1933 ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
1934
1935 /* CREATESTRUCT should have fixed values */
1936 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1937 while NT does. */
1938 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1939 ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
1940
1941 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1942 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1943 while Win95, Win2k, WinXP do. */
1944 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1945 ok(cs->cy == 0, "%d != 0\n", cs->cy);
1946 break;
1947 }
1948
1949 case WM_GETMINMAXINFO:
1950 {
1952 RECT rc;
1953 MINMAXINFO *minmax = (MINMAXINFO *)lparam;
1954 LONG style, exstyle;
1955
1957 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1958
1959 GetClientRect(parent, &rc);
1960 trace("WM_GETMINMAXINFO: parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
1961
1962 GetClientRect(parent, &rc);
1963 if ((style & WS_CAPTION) == WS_CAPTION)
1964 style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1965 AdjustWindowRectEx(&rc, style, 0, exstyle);
1966 dump_minmax_info( minmax );
1967
1968 ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %d != %d\n",
1969 minmax->ptMaxSize.x, rc.right - rc.left);
1970 ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %d != %d\n",
1971 minmax->ptMaxSize.y, rc.bottom - rc.top);
1972 break;
1973 }
1974
1976 {
1977 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1978 RECT rc1, rc2;
1979
1980 GetWindowRect(hwnd, &rc1);
1981 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
1982 /* note: winpos coordinates are relative to parent */
1984 ok(EqualRect(&rc1, &rc2), "rects do not match, window=%s pos=%s\n",
1986 GetWindowRect(hwnd, &rc1);
1989 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
1990 ok(EqualRect(&rc1, &rc2), "rects do not match, window=%s client=%s\n",
1992 }
1993 /* fall through */
1995 {
1996 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1997 WINDOWPOS my_winpos = *winpos;
1998
1999 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2000 (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
2001 winpos->hwnd, winpos->hwndInsertAfter,
2002 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2003
2005
2006 ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
2007 "DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2008 winpos->hwnd, winpos->hwndInsertAfter,
2009 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2010
2011 return 1;
2012 }
2013 }
2014 return DefWindowProcA(hwnd, msg, wparam, lparam);
2015}
2016
2018{
2019 static HWND mdi_client;
2020
2021 switch (msg)
2022 {
2023 case WM_CREATE:
2024 return 1;
2025
2027 {
2028 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
2029 RECT rc1, rc2;
2030
2031 GetWindowRect(hwnd, &rc1);
2032 trace("window: %s\n", wine_dbgstr_rect(&rc1));
2033 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
2034 /* note: winpos coordinates are relative to parent */
2036 trace("pos: %s\n", wine_dbgstr_rect(&rc2));
2037 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
2038
2039 GetWindowRect(hwnd, &rc1);
2042 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
2043 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
2044 }
2045 /* fall through */
2047 {
2048 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
2049 WINDOWPOS my_winpos = *winpos;
2050
2051 trace("%s\n", (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2052 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2053 winpos->hwnd, winpos->hwndInsertAfter,
2054 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2055
2057
2058 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2059 winpos->hwnd, winpos->hwndInsertAfter,
2060 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2061
2062 ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
2063 "DefWindowProc should not change WINDOWPOS values\n");
2064
2065 return 1;
2066 }
2067
2068 case WM_CLOSE:
2069 PostQuitMessage(0);
2070 break;
2071 }
2073}
2074
2076{
2077 WNDCLASSA cls;
2078
2079 cls.style = 0;
2081 cls.cbClsExtra = 0;
2082 cls.cbWndExtra = 0;
2083 cls.hInstance = GetModuleHandleA(0);
2084 cls.hIcon = 0;
2087 cls.lpszMenuName = NULL;
2088 cls.lpszClassName = "MDI_parent_Class";
2089 if(!RegisterClassA(&cls)) return FALSE;
2090
2092 cls.lpszClassName = "MDI_child_Class_1";
2093 if(!RegisterClassA(&cls)) return FALSE;
2094
2096 cls.lpszClassName = "MDI_child_Class_2";
2097 if(!RegisterClassA(&cls)) return FALSE;
2098
2099 return TRUE;
2100}
2101
2102static void test_mdi(void)
2103{
2104 static const DWORD style[] = { 0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL | WS_VSCROLL };
2105 HWND mdi_hwndMain, mdi_client, mdi_child;
2106 CLIENTCREATESTRUCT client_cs;
2107 RECT rc;
2108 DWORD i;
2109 MSG msg;
2110 HMENU frame_menu, child_menu;
2111
2113
2114 mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
2116 WS_MAXIMIZEBOX /*| WS_VISIBLE*/,
2117 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2118 GetDesktopWindow(), 0,
2120 assert(mdi_hwndMain);
2121
2122 frame_menu = CreateMenu();
2123
2124 GetClientRect(mdi_hwndMain, &rc);
2125
2126 client_cs.hWindowMenu = 0;
2127 client_cs.idFirstChild = 1;
2128
2129 for (i = 0; i < sizeof(style)/sizeof(style[0]); i++)
2130 {
2131 SCROLLINFO si;
2132 BOOL ret, gotit;
2133
2134 mdi_client = CreateWindowExA(0, "mdiclient", NULL,
2135 WS_CHILD | style[i],
2136 0, 0, rc.right, rc.bottom,
2137 mdi_hwndMain, 0, 0, &client_cs);
2138 ok(mdi_client != 0, "MDI client creation failed\n");
2139
2140 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2141 0,
2144 mdi_client, 0, 0,
2146 ok(mdi_child != 0, "MDI child creation failed\n");
2147
2148 SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
2149 SetMenu(mdi_hwndMain, frame_menu);
2150
2151 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child maximize, but has %u\n",
2152 GetMenuItemCount(frame_menu));
2153
2154 child_menu = CreateMenu();
2155 SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
2156
2157 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after WM_MDISETMENU, but has %u\n",
2158 GetMenuItemCount(frame_menu));
2159
2160 SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
2161
2162 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
2163 GetMenuItemCount(frame_menu));
2164
2165 SetMenu(mdi_hwndMain, NULL);
2166
2167 si.cbSize = sizeof(si);
2168 si.fMask = SIF_ALL;
2170 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2171 {
2172 ok(ret, "style %#x: GetScrollInfo(SB_HORZ) failed\n", style[i]);
2173 ok(si.nPage == 0, "expected 0\n");
2174 ok(si.nPos == 0, "expected 0\n");
2175 ok(si.nTrackPos == 0, "expected 0\n");
2176 ok(si.nMin == 0, "expected 0\n");
2177 ok(si.nMax == 100, "expected 100\n");
2178 }
2179 else
2180 ok(!ret, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style[i]);
2181
2183 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2184 {
2185 ok(ret, "style %#x: GetScrollInfo(SB_VERT) failed\n", style[i]);
2186 ok(si.nPage == 0, "expected 0\n");
2187 ok(si.nPos == 0, "expected 0\n");
2188 ok(si.nTrackPos == 0, "expected 0\n");
2189 ok(si.nMin == 0, "expected 0\n");
2190 ok(si.nMax == 100, "expected 100\n");
2191 }
2192 else
2193 ok(!ret, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style[i]);
2194
2195 SetWindowPos(mdi_child, 0, -100, -100, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
2196
2197 si.cbSize = sizeof(si);
2198 si.fMask = SIF_ALL;
2200 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2201 {
2202 ok(ret, "style %#x: GetScrollInfo(SB_HORZ) failed\n", style[i]);
2203 ok(si.nPage == 0, "expected 0\n");
2204 ok(si.nPos == 0, "expected 0\n");
2205 ok(si.nTrackPos == 0, "expected 0\n");
2206 ok(si.nMin == 0, "expected 0\n");
2207 ok(si.nMax == 100, "expected 100\n");
2208 }
2209 else
2210 ok(!ret, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style[i]);
2211
2213 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2214 {
2215 ok(ret, "style %#x: GetScrollInfo(SB_VERT) failed\n", style[i]);
2216 ok(si.nPage == 0, "expected 0\n");
2217 ok(si.nPos == 0, "expected 0\n");
2218 ok(si.nTrackPos == 0, "expected 0\n");
2219 ok(si.nMin == 0, "expected 0\n");
2220 ok(si.nMax == 100, "expected 100\n");
2221 }
2222 else
2223 ok(!ret, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style[i]);
2224
2225 gotit = FALSE;
2226 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
2227 {
2228 if (msg.message == WM_MOUSEMOVE || msg.message == WM_PAINT)
2229 {
2231 continue;
2232 }
2233
2234 if (msg.message == 0x003f) /* WM_MDICALCCHILDSCROLL ??? */
2235 {
2236 ok(msg.hwnd == mdi_client, "message 0x003f should be posted to mdiclient\n");
2237 gotit = TRUE;
2238 }
2239 else
2240 ok(msg.hwnd != mdi_client, "message %04x should not be posted to mdiclient\n", msg.message);
2242 }
2243 ok(gotit, "message 0x003f should appear after SetWindowPos\n");
2244
2245 si.cbSize = sizeof(si);
2246 si.fMask = SIF_ALL;
2248 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2249 {
2250 ok(ret, "style %#x: GetScrollInfo(SB_HORZ) failed\n", style[i]);
2252 ok(si.nPage != 0, "expected !0\n");
2253 ok(si.nPos == 0, "expected 0\n");
2254 ok(si.nTrackPos == 0, "expected 0\n");
2255 ok(si.nMin != 0, "expected !0\n");
2256 ok(si.nMax != 100, "expected !100\n");
2257 }
2258 else
2259 ok(!ret, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style[i]);
2260
2262 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2263 {
2264 ok(ret, "style %#x: GetScrollInfo(SB_VERT) failed\n", style[i]);
2266 ok(si.nPage != 0, "expected !0\n");
2267 ok(si.nPos == 0, "expected 0\n");
2268 ok(si.nTrackPos == 0, "expected 0\n");
2269 ok(si.nMin != 0, "expected !0\n");
2270 ok(si.nMax != 100, "expected !100\n");
2271 }
2272 else
2273 ok(!ret, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style[i]);
2274
2275 DestroyMenu(child_menu);
2276 DestroyWindow(mdi_child);
2278 }
2279
2280 SetMenu(mdi_hwndMain, frame_menu);
2281
2282 mdi_client = CreateWindowExA(0, "mdiclient", NULL,
2283 WS_CHILD,
2284 0, 0, rc.right, rc.bottom,
2285 mdi_hwndMain, 0, 0, &client_cs);
2286 ok(mdi_client != 0, "MDI client creation failed\n");
2287
2288 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2289 0,
2292 mdi_client, 0, 0,
2294 ok(mdi_child != 0, "MDI child creation failed\n");
2295
2296 SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
2297 ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after child maximize, but has %u\n",
2298 GetMenuItemCount(frame_menu));
2299
2300 child_menu = CreateMenu();
2301 SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
2302
2303 ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after WM_MDISETMENU, but has %u\n",
2304 GetMenuItemCount(frame_menu));
2305
2306 SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
2307
2308 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
2309 GetMenuItemCount(frame_menu));
2310
2311 DestroyMenu(child_menu);
2312 DestroyWindow(mdi_child);
2314
2315 /* MDIClient without MDIS_ALLCHILDSTYLES */
2316 mdi_client = CreateWindowExA(0, "mdiclient",
2317 NULL,
2318 WS_CHILD /*| WS_VISIBLE*/,
2319 /* tests depend on a not zero MDIClient size */
2320 0, 0, rc.right, rc.bottom,
2321 mdi_hwndMain, 0, GetModuleHandleA(NULL),
2322 &client_cs);
2324 test_MDI_create(mdi_hwndMain, mdi_client, client_cs.idFirstChild);
2326
2327 /* MDIClient with MDIS_ALLCHILDSTYLES */
2328 mdi_client = CreateWindowExA(0, "mdiclient",
2329 NULL,
2330 WS_CHILD | MDIS_ALLCHILDSTYLES /*| WS_VISIBLE*/,
2331 /* tests depend on a not zero MDIClient size */
2332 0, 0, rc.right, rc.bottom,
2333 mdi_hwndMain, 0, GetModuleHandleA(NULL),
2334 &client_cs);
2336 test_MDI_create(mdi_hwndMain, mdi_client, client_cs.idFirstChild);
2338
2339 /* Test child window stack management */
2340 mdi_client = CreateWindowExA(0, "mdiclient",
2341 NULL,
2342 WS_CHILD,
2343 0, 0, rc.right, rc.bottom,
2344 mdi_hwndMain, 0, GetModuleHandleA(NULL),
2345 &client_cs);
2349/*
2350 while(GetMessage(&msg, 0, 0, 0))
2351 {
2352 TranslateMessage(&msg);
2353 DispatchMessage(&msg);
2354 }
2355*/
2356 DestroyWindow(mdi_hwndMain);
2357}
2358
2359static void test_icons(void)
2360{
2361 WNDCLASSEXA cls;
2362 HWND hwnd;
2364 HICON icon2 = LoadIconA(0, (LPCSTR)IDI_QUESTION);
2367 HICON res;
2368
2369 cls.cbSize = sizeof(cls);
2370 cls.style = 0;
2372 cls.cbClsExtra = 0;
2373 cls.cbWndExtra = 0;
2374 cls.hInstance = 0;
2375 cls.hIcon = LoadIconA(0, (LPCSTR)IDI_HAND);
2376 cls.hIconSm = small_icon;
2379 cls.lpszMenuName = NULL;
2380 cls.lpszClassName = "IconWindowClass";
2381
2382 RegisterClassExA(&cls);
2383
2384 hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
2385 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
2386 assert( hwnd );
2387
2388 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2389 ok( res == 0, "wrong big icon %p/0\n", res );
2390 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon );
2391 ok( res == 0, "wrong previous big icon %p/0\n", res );
2392 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2393 ok( res == icon, "wrong big icon after set %p/%p\n", res, icon );
2394 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon2 );
2395 ok( res == icon, "wrong previous big icon %p/%p\n", res, icon );
2396 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2397 ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
2398
2399 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
2400 ok( res == 0, "wrong small icon %p/0\n", res );
2401 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2402 ok( (res && res != small_icon && res != icon2) || broken(!res), "wrong small2 icon %p\n", res );
2403 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon );
2404 ok( res == 0, "wrong previous small icon %p/0\n", res );
2405 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
2406 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );
2407 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2408 ok( res == icon || broken(!res), "wrong small2 icon after set %p/%p\n", res, icon );
2409 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)small_icon );
2410 ok( res == icon, "wrong previous small icon %p/%p\n", res, icon );
2411 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
2412 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );
2413 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2414 ok( res == small_icon || broken(!res), "wrong small2 icon after set %p/%p\n", res, small_icon );
2415
2416 /* make sure the big icon hasn't changed */
2417 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2418 ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
2419
2421}
2422
2424{
2425 if (msg == WM_NCCALCSIZE)
2426 {
2427 RECT *rect = (RECT *)lparam;
2428 /* first time around increase the rectangle, next time decrease it */
2429 if (rect->left == 100) InflateRect( rect, 10, 10 );
2430 else InflateRect( rect, -10, -10 );
2431 return 0;
2432 }
2433 return DefWindowProcA( hwnd, msg, wparam, lparam );
2434}
2435
2436static void test_SetWindowPos(HWND hwnd, HWND hwnd2)
2437{
2438 RECT orig_win_rc, rect;
2440 HWND hwnd_grandchild, hwnd_child, hwnd_child2;
2441 HWND hwnd_desktop;
2442 RECT rc1, rc2;
2443 BOOL ret;
2444
2445 SetRect(&rect, 111, 222, 333, 444);
2446 ok(!GetWindowRect(0, &rect), "GetWindowRect succeeded\n");
2447 ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444,
2448 "wrong window rect %s\n", wine_dbgstr_rect(&rect));
2449
2450 SetRect(&rect, 111, 222, 333, 444);
2451 ok(!GetClientRect(0, &rect), "GetClientRect succeeded\n");
2452 ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444,
2453 "wrong window rect %s\n", wine_dbgstr_rect(&rect));
2454
2455 GetWindowRect(hwnd, &orig_win_rc);
2456
2458 ret = SetWindowPos(hwnd, 0, 100, 100, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED);
2459 ok(ret, "Got %d\n", ret);
2460 GetWindowRect( hwnd, &rect );
2461 ok( rect.left == 100 && rect.top == 100 && rect.right == 100 && rect.bottom == 100,
2462 "invalid window rect %s\n", wine_dbgstr_rect(&rect));
2463 GetClientRect( hwnd, &rect );
2464 MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 );
2465 ok( rect.left == 90 && rect.top == 90 && rect.right == 110 && rect.bottom == 110,
2466 "invalid client rect %s\n", wine_dbgstr_rect(&rect));
2467
2468 ret = SetWindowPos(hwnd, 0, 200, 200, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED);
2469 ok(ret, "Got %d\n", ret);
2470 GetWindowRect( hwnd, &rect );
2471 ok( rect.left == 200 && rect.top == 200 && rect.right == 200 && rect.bottom == 200,
2472 "invalid window rect %s\n", wine_dbgstr_rect(&rect));
2473 GetClientRect( hwnd, &rect );
2474 MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 );
2475 ok( rect.left == 210 && rect.top == 210 && rect.right == 190 && rect.bottom == 190,
2476 "invalid client rect %s\n", wine_dbgstr_rect(&rect));
2477
2478 ret = SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top,
2479 orig_win_rc.right, orig_win_rc.bottom, 0);
2480 ok(ret, "Got %d\n", ret);
2482
2483 /* Win9x truncates coordinates to 16-bit irrespectively */
2484 if (!is_win9x)
2485 {
2486 ret = SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE);
2487 ok(ret, "Got %d\n", ret);
2488 ret = SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE);
2489 ok(ret, "Got %d\n", ret);
2490
2491 ret = SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE);
2492 ok(ret, "Got %d\n", ret);
2493 ret = SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE);
2494 ok(ret, "Got %d\n", ret);
2495 }
2496
2497 ret = SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top,
2498 orig_win_rc.right, orig_win_rc.bottom, 0);
2499 ok(ret, "Got %d\n", ret);
2500
2501 ok(!(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n");
2503 ok(ret, "Got %d\n", ret);
2504 ok(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n");
2506 ok(ret, "Got %d\n", ret);
2507 ok(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n");
2509 ok(ret, "Got %d\n", ret);
2510 ok(!(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n");
2511
2512 hwnd_desktop = GetDesktopWindow();
2513 ok(!!hwnd_desktop, "Failed to get hwnd_desktop window (%d).\n", GetLastError());
2515 ok(!!hwnd_child, "Failed to create child window (%d)\n", GetLastError());
2516 hwnd_grandchild = create_tool_window(WS_VISIBLE|WS_CHILD, hwnd_child);
2517 ok(!!hwnd_child, "Failed to create child window (%d)\n", GetLastError());
2519 ok(!!hwnd_child2, "Failed to create second child window (%d)\n", GetLastError());
2520
2521 ret = SetWindowPos(hwnd, hwnd2, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2522 ok(ret, "Got %d\n", ret);
2524
2525 ret = SetWindowPos(hwnd2, hwnd, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2526 ok(ret, "Got %d\n", ret);
2527 check_active_state(hwnd2, hwnd2, hwnd2);
2528
2529 /* Returns TRUE also for windows that are not siblings */
2530 ret = SetWindowPos(hwnd_child, hwnd2, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2531 ok(ret, "Got %d\n", ret);
2532 check_active_state(hwnd2, hwnd2, hwnd2);
2533
2534 ret = SetWindowPos(hwnd2, hwnd_child, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2535 ok(ret, "Got %d\n", ret);
2536 check_active_state(hwnd2, hwnd2, hwnd2);
2537
2538 /* Does not seem to do anything even without passing flags, still returns TRUE */
2539 GetWindowRect(hwnd_child, &rc1);
2540 ret = SetWindowPos(hwnd_child, hwnd2 , 1, 2, 3, 4, 0);
2541 ok(ret, "Got %d\n", ret);
2542 GetWindowRect(hwnd_child, &rc2);
2543 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
2544 check_active_state(hwnd2, hwnd2, hwnd2);
2545
2546 /* Same thing the other way around. */
2547 GetWindowRect(hwnd2, &rc1);
2548 ret = SetWindowPos(hwnd2, hwnd_child, 1, 2, 3, 4, 0);
2549 ok(ret, "Got %d\n", ret);
2550 GetWindowRect(hwnd2, &rc2);
2551 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
2552 check_active_state(hwnd2, hwnd2, hwnd2);
2553
2554 /* .. and with these windows. */
2555 GetWindowRect(hwnd_grandchild, &rc1);
2556 ret = SetWindowPos(hwnd_grandchild, hwnd_child2, 1, 2, 3, 4, 0);
2557 ok(ret, "Got %d\n", ret);
2558 GetWindowRect(hwnd_grandchild, &rc2);
2559 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
2560 check_active_state(hwnd2, hwnd2, hwnd2);
2561
2562 /* Add SWP_NOZORDER and it will be properly resized. */
2563 GetWindowRect(hwnd_grandchild, &rc1);
2564 ret = SetWindowPos(hwnd_grandchild, hwnd_child2, 1, 2, 3, 4, SWP_NOZORDER);
2565 ok(ret, "Got %d\n", ret);
2566 GetWindowRect(hwnd_grandchild, &rc2);
2567 ok((rc1.left+1) == rc2.left && (rc1.top+2) == rc2.top &&
2568 (rc1.left+4) == rc2.right && (rc1.top+6) == rc2.bottom,
2569 "(%d,%d)-(%d,%d) != %s\n", rc1.left+1, rc1.top+2, rc1.left+4, rc1.top+6,
2571 check_active_state(hwnd2, hwnd2, hwnd2);
2572
2573 /* Given a sibling window, the window is properly resized. */
2574 GetWindowRect(hwnd_child, &rc1);
2575 ret = SetWindowPos(hwnd_child, hwnd_child2, 1, 2, 3, 4, 0);
2576 ok(ret, "Got %d\n", ret);
2577 GetWindowRect(hwnd_child, &rc2);
2578 ok((rc1.left+1) == rc2.left && (rc1.top+2) == rc2.top &&
2579 (rc1.left+4) == rc2.right && (rc1.top+6) == rc2.bottom,
2580 "(%d,%d)-(%d,%d) != %s\n", rc1.left+1, rc1.top+2, rc1.left+4, rc1.top+6,
2582 check_active_state(hwnd2, hwnd2, hwnd2);
2583
2584 /* Involving the desktop window changes things. */
2585 ret = SetWindowPos(hwnd_child, hwnd_desktop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2586 ok(!ret, "Got %d\n", ret);
2587 check_active_state(hwnd2, hwnd2, hwnd2);
2588
2589 GetWindowRect(hwnd_child, &rc1);
2590 ret = SetWindowPos(hwnd_child, hwnd_desktop, 0, 0, 0, 0, 0);
2591 ok(!ret, "Got %d\n", ret);
2592 GetWindowRect(hwnd_child, &rc2);
2593 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
2594 check_active_state(hwnd2, hwnd2, hwnd2);
2595
2596 ret = SetWindowPos(hwnd_desktop, hwnd_child, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2597 ok(!ret, "Got %d\n", ret);
2598 check_active_state(hwnd2, hwnd2, hwnd2);
2599
2600 ret = SetWindowPos(hwnd_desktop, hwnd, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2601 ok(!ret, "Got %d\n", ret);
2602 check_active_state(hwnd2, hwnd2, hwnd2);
2603
2604 ret = SetWindowPos(hwnd, hwnd_desktop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
2605 ok(!ret, "Got %d\n", ret);
2606 check_active_state(hwnd2, hwnd2, hwnd2);
2607
2608 DestroyWindow(hwnd_grandchild);
2609 DestroyWindow(hwnd_child);
2610 DestroyWindow(hwnd_child2);
2611
2612 hwnd_child = create_tool_window(WS_CHILD|WS_POPUP|WS_SYSMENU, hwnd2);
2613 ok(!!hwnd_child, "Failed to create child window (%d)\n", GetLastError());
2615 ok(ret, "Got %d\n", ret);
2616 flush_events( TRUE );
2617 todo_wine check_active_state(hwnd2, hwnd2, hwnd2);
2618 DestroyWindow(hwnd_child);
2619}
2620
2622{
2623 HWND child;
2624 HMENU hMenu, ret;
2625 BOOL retok;
2626 DWORD style;
2627
2628 hMenu = CreateMenu();
2629 assert(hMenu);
2630
2631 ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
2632 if (0)
2633 {
2634 /* fails on (at least) Wine, NT4, XP SP2 */
2636 }
2637 ret = GetMenu(parent);
2638 ok(ret == hMenu, "unexpected menu id %p\n", ret);
2639 /* test whether we can destroy a menu assigned to a window */
2640 retok = DestroyMenu(hMenu);
2641 ok( retok, "DestroyMenu error %d\n", GetLastError());
2642 retok = IsMenu(hMenu);
2643 ok(!retok || broken(retok) /* nt4 */, "menu handle should be not valid after DestroyMenu\n");
2644 ret = GetMenu(parent);
2645 /* This test fails on Win9x */
2646 if (!is_win9x)
2647 ok(ret == hMenu, "unexpected menu id %p\n", ret);
2648 ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
2650
2651 hMenu = CreateMenu();
2652 assert(hMenu);
2653
2654 /* parent */
2655 ret = GetMenu(parent);
2656 ok(ret == 0, "unexpected menu id %p\n", ret);
2657
2658 ok(!SetMenu(parent, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
2660 ret = GetMenu(parent);
2661 ok(ret == 0, "unexpected menu id %p\n", ret);
2662
2663 ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
2664 if (0)
2665 {
2666 /* fails on (at least) Wine, NT4, XP SP2 */
2668 }
2669 ret = GetMenu(parent);
2670 ok(ret == hMenu, "unexpected menu id %p\n", ret);
2671
2672 ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
2674 ret = GetMenu(parent);
2675 ok(ret == 0, "unexpected menu id %p\n", ret);
2676
2677 /* child */
2678 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, parent, (HMENU)10, 0, NULL);
2679 assert(child);
2680
2681 ret = GetMenu(child);
2682 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
2683
2684 ok(!SetMenu(child, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
2686 ret = GetMenu(child);
2687 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
2688
2689 ok(!SetMenu(child, hMenu), "SetMenu on a child window should fail\n");
2691 ret = GetMenu(child);
2692 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
2693
2694 ok(!SetMenu(child, 0), "SetMenu(0) on a child window should fail\n");
2696 ret = GetMenu(child);
2697 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
2698
2701 ok(SetMenu(child, hMenu), "SetMenu on a popup child window should not fail\n");
2702 ok(SetMenu(child, 0), "SetMenu on a popup child window should not fail\n");
2704
2706 ok(!SetMenu(child, hMenu), "SetMenu on an overlapped child window should fail\n");
2708
2710 DestroyMenu(hMenu);
2711}
2712
2713static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total)
2714{
2715 HWND child[5], hwnd;
2716 INT_PTR i;
2717
2718 assert(total <= 5);
2719
2721 ok(!hwnd, "have to start without children to perform the test\n");
2722
2723 for (i = 0; i < total; i++)
2724 {
2725 if (style[i] & DS_CONTROL)
2726 {
2727 child[i] = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(32770), "", style[i] & ~WS_VISIBLE,
2728 0,0,0,0, parent, (HMENU)i, 0, NULL);
2729 if (style[i] & WS_VISIBLE)
2731
2733 }
2734 else
2735 child[i] = CreateWindowExA(0, "static", "", style[i], 0,0,10,10,
2736 parent, (HMENU)i, 0, NULL);
2737 trace("child[%ld] = %p\n", i, child[i]);
2738 ok(child[i] != 0, "CreateWindowEx failed to create child window\n");
2739 }
2740
2742 ok(hwnd != 0, "GetWindow(GW_CHILD) failed\n");
2743 ok(hwnd == GetWindow(child[total - 1], GW_HWNDFIRST), "GW_HWNDFIRST is wrong\n");
2744 ok(child[order[total - 1]] == GetWindow(child[0], GW_HWNDLAST), "GW_HWNDLAST is wrong\n");
2745
2746 for (i = 0; i < total; i++)
2747 {
2748 trace("hwnd[%ld] = %p\n", i, hwnd);
2749 ok(child[order[i]] == hwnd, "Z order of child #%ld is wrong\n", i);
2750
2752 }
2753
2754 for (i = 0; i < total; i++)
2755 ok(DestroyWindow(child[i]), "DestroyWindow failed\n");
2756}
2757
2759{
2760 const DWORD simple_style[5] = { WS_CHILD, WS_CHILD, WS_CHILD, WS_CHILD,
2761 WS_CHILD };
2762 const int simple_order[5] = { 0, 1, 2, 3, 4 };
2763
2764 const DWORD complex_style[5] = { WS_CHILD, WS_CHILD | WS_MAXIMIZE,
2767 const int complex_order_1[1] = { 0 };
2768 const int complex_order_2[2] = { 1, 0 };
2769 const int complex_order_3[3] = { 1, 0, 2 };
2770 const int complex_order_4[4] = { 1, 0, 2, 3 };
2771 const int complex_order_5[5] = { 4, 1, 0, 2, 3 };
2772 const DWORD complex_style_6[3] = { WS_CHILD | WS_VISIBLE,
2774 WS_CHILD | WS_VISIBLE };
2775 const int complex_order_6[3] = { 0, 1, 2 };
2776
2777 /* simple WS_CHILD */
2778 test_window_tree(parent, simple_style, simple_order, 5);
2779
2780 /* complex children styles */
2781 test_window_tree(parent, complex_style, complex_order_1, 1);
2782 test_window_tree(parent, complex_style, complex_order_2, 2);
2783 test_window_tree(parent, complex_style, complex_order_3, 3);
2784 test_window_tree(parent, complex_style, complex_order_4, 4);
2785 test_window_tree(parent, complex_style, complex_order_5, 5);
2786
2787 /* another set of complex children styles */
2788 test_window_tree(parent, complex_style_6, complex_order_6, 3);
2789}
2790
2791#define check_z_order(hwnd, next, prev, owner, topmost) \
2792 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
2793 __FILE__, __LINE__)
2794
2795static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner,
2796 BOOL topmost, const char *file, int line)
2797{
2798 HWND test;
2799 DWORD ex_style;
2800
2802 /* skip foreign windows */
2803 while (test && test != next &&
2807 {
2808 /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2810 }
2811 ok_(file, line)(next == test, "%p: expected next %p, got %p\n", hwnd, next, test);
2812
2814 /* skip foreign windows */
2815 while (test && test != prev &&
2819 {
2820 /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2822 }
2823 ok_(file, line)(prev == test, "%p: expected prev %p, got %p\n", hwnd, prev, test);
2824
2826 ok_(file, line)(owner == test, "%p: expected owner %p, got %p\n", hwnd, owner, test);
2827
2828 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
2829 ok_(file, line)(!(ex_style & WS_EX_TOPMOST) == !topmost, "%p: expected %stopmost\n",
2830 hwnd, topmost ? "" : "NOT ");
2831}
2832
2833static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style)
2834{
2835 HWND hwnd_A, hwnd_B, hwnd_C, hwnd_F;
2836
2837 trace("hwnd_D %p, hwnd_E %p\n", hwnd_D, hwnd_E);
2838
2839 SetWindowPos(hwnd_E, hwnd_D, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
2840
2841 check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
2842 check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
2843
2844 hwnd_F = CreateWindowExA(0, "MainWindowClass", "Owner window",
2846 100, 100, 100, 100,
2847 0, 0, GetModuleHandleA(NULL), NULL);
2848 trace("hwnd_F %p\n", hwnd_F);
2849 check_z_order(hwnd_F, hwnd_D, 0, 0, FALSE);
2850
2851 SetWindowPos(hwnd_F, hwnd_E, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
2852 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
2853 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
2854 check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
2855
2856 hwnd_C = CreateWindowExA(0, "MainWindowClass", NULL,
2857 style,
2858 100, 100, 100, 100,
2859 hwnd_F, 0, GetModuleHandleA(NULL), NULL);
2860 trace("hwnd_C %p\n", hwnd_C);
2861 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
2862 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
2863 check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
2864 check_z_order(hwnd_C, hwnd_D, 0, hwnd_F, FALSE);
2865
2866 hwnd_B = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", NULL,
2867 style,
2868 100, 100, 100, 100,
2869 hwnd_F, 0, GetModuleHandleA(NULL), NULL);
2870 trace("hwnd_B %p\n", hwnd_B);
2871 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
2872 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
2873 check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
2874 check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE);
2875 check_z_order(hwnd_B, hwnd_C, 0, hwnd_F, TRUE);
2876
2877 hwnd_A = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", NULL,
2878 style,
2879 100, 100, 100, 100,
2880 0, 0, GetModuleHandleA(NULL), NULL);
2881 trace("hwnd_A %p\n", hwnd_A);
2882 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
2883 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
2884 check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
2885 check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE);
2886 check_z_order(hwnd_B, hwnd_C, hwnd_A, hwnd_F, TRUE);
2887 check_z_order(hwnd_A, hwnd_B, 0, 0, TRUE);
2888
2889 trace("A %p B %p C %p D %p E %p F %p\n", hwnd_A, hwnd_B, hwnd_C, hwnd_D, hwnd_E, hwnd_F);
2890
2891 /* move hwnd_F and its popups up */
2893 check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
2894 check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE);
2895 check_z_order(hwnd_F, hwnd_D, hwnd_C, 0, FALSE);
2896 check_z_order(hwnd_C, hwnd_F, hwnd_B, hwnd_F, FALSE);
2897 check_z_order(hwnd_B, hwnd_C, hwnd_A, hwnd_F, TRUE);
2898 check_z_order(hwnd_A, hwnd_B, 0, 0, TRUE);
2899
2900 /* move hwnd_F and its popups down */
2901#if 0 /* enable once Wine is fixed to pass this test */
2903 check_z_order(hwnd_F, 0, hwnd_C, 0, FALSE);
2904 check_z_order(hwnd_C, hwnd_F, hwnd_B, hwnd_F, FALSE);
2905 check_z_order(hwnd_B, hwnd_C, hwnd_E, hwnd_F, FALSE);
2906 check_z_order(hwnd_E, hwnd_B, hwnd_D, 0, FALSE);
2907 check_z_order(hwnd_D, hwnd_E, hwnd_A, 0, FALSE);
2908 check_z_order(hwnd_A, hwnd_D, 0, 0, TRUE);
2909#endif
2910
2911 /* make hwnd_C owned by a topmost window */
2912 DestroyWindow( hwnd_C );
2913 hwnd_C = CreateWindowExA(0, "MainWindowClass", NULL,
2914 style,
2915 100, 100, 100, 100,
2916 hwnd_A, 0, GetModuleHandleA(NULL), NULL);
2917 trace("hwnd_C %p\n", hwnd_C);
2918 check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
2919 check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE);
2920 check_z_order(hwnd_F, hwnd_D, hwnd_B, 0, FALSE);
2921 check_z_order(hwnd_B, hwnd_F, hwnd_A, hwnd_F, TRUE);
2922 check_z_order(hwnd_A, hwnd_B, hwnd_C, 0, TRUE);
2923 check_z_order(hwnd_C, hwnd_A, 0, hwnd_A, TRUE);
2924
2925 DestroyWindow(hwnd_A);
2926 DestroyWindow(hwnd_B);
2927 DestroyWindow(hwnd_C);
2928 DestroyWindow(hwnd_F);
2929}
2930
2931static void test_vis_rgn( HWND hwnd )
2932{
2933 RECT win_rect, rgn_rect;
2934 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
2935 HDC hdc;
2936
2938 hdc = GetDC( hwnd );
2939 ok( GetRandomRgn( hdc, hrgn, SYSRGN ) != 0, "GetRandomRgn failed\n" );
2940 GetWindowRect( hwnd, &win_rect );
2941 GetRgnBox( hrgn, &rgn_rect );
2942 if (is_win9x)
2943 {
2944 trace("win9x, mapping to screen coords\n");
2945 MapWindowPoints( hwnd, 0, (POINT *)&rgn_rect, 2 );
2946 }
2947 trace("win: %s\n", wine_dbgstr_rect(&win_rect));
2948 trace("rgn: %s\n", wine_dbgstr_rect(&rgn_rect));
2949 ok( win_rect.left <= rgn_rect.left, "rgn left %d not inside win rect %d\n",
2950 rgn_rect.left, win_rect.left );
2951 ok( win_rect.top <= rgn_rect.top, "rgn top %d not inside win rect %d\n",
2952 rgn_rect.top, win_rect.top );
2953 ok( win_rect.right >= rgn_rect.right, "rgn right %d not inside win rect %d\n",
2954 rgn_rect.right, win_rect.right );
2955 ok( win_rect.bottom >= rgn_rect.bottom, "rgn bottom %d not inside win rect %d\n",
2956 rgn_rect.bottom, win_rect.bottom );
2957 ReleaseDC( hwnd, hdc );
2958}
2959
2961{
2962 if (msg == WM_ACTIVATE && LOWORD(wp) == WA_ACTIVE)
2963 {
2965 ok(child != 0, "couldn't find child window\n");
2966 SetFocus(child);
2967 ok(GetFocus() == child, "Focus should be on child %p\n", child);
2968 return 0;
2969 }
2970 return DefWindowProcA(hwnd, msg, wp, lp);
2971}
2972
2974{
2975 HWND child, child2, ret;
2977
2978 /* check if we can set focus to non-visible windows */
2979
2981 SetFocus(0);
2982 SetFocus(hwnd);
2983 ok( GetFocus() == hwnd, "Failed to set focus to visible window %p\n", hwnd );
2984 ok( GetWindowLongA(hwnd,GWL_STYLE) & WS_VISIBLE, "Window %p not visible\n", hwnd );
2986 SetFocus(0);
2987 SetFocus(hwnd);
2988 ok( GetFocus() == hwnd, "Failed to set focus to invisible window %p\n", hwnd );
2989 ok( !(GetWindowLongA(hwnd,GWL_STYLE) & WS_VISIBLE), "Window %p still visible\n", hwnd );
2990 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, NULL);
2991 assert(child);
2992 SetFocus(child);
2993 ok( GetFocus() == child, "Failed to set focus to invisible child %p\n", child );
2994 ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
2996 ok( GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE, "Child %p is not visible\n", child );
2997 ok( GetFocus() == child, "Focus no longer on child %p\n", child );
2999 ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
3000 ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
3002 child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, 0, 0, NULL);
3003 assert(child2);
3004 ShowWindow(child2, SW_SHOW);
3005 SetFocus(child2);
3007 ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
3008 ok( GetFocus() == child2, "Focus should be on %p, not %p\n", child2, GetFocus() );
3010 SetFocus(child);
3011 ok( GetFocus() == child, "Focus should be on child %p\n", child );
3013 ok( GetFocus() == child, "Focus should still be on child %p\n", child );
3014
3016 SetFocus(hwnd);
3017 ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
3019 ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
3021 ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
3022
3025 SetFocus(child);
3026 ok( GetFocus() == child, "Focus should be on child %p\n", child );
3028 ok( GetFocus() == child, "Focus should still be on child %p\n", child );
3030
3031 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3033 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3035 ok( GetFocus() != child, "Focus should not be on child %p\n", child );
3036 ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd );
3038 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3039 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3041 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3042 ok( GetFocus() != child, "Focus should not be on child %p\n", child );
3044 ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd );
3047 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3049 ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() );
3051
3052 SetFocus( hwnd );
3054 SetParent( child2, child );
3055 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3056 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3057 ret = SetFocus( child2 );
3058 ok( ret == 0, "SetFocus %p should fail\n", child2);
3059 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3060 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3061 ret = SetFocus( child );
3062 ok( ret == 0, "SetFocus %p should fail\n", child);
3063 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3064 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3066 SetFocus( child2 );
3067 ok( GetActiveWindow() == child, "child window %p should be active\n", child);
3068 ok( GetFocus() == child2, "Focus should be on child2 %p\n", child2 );
3069 SetFocus( hwnd );
3070 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3071 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3072 SetFocus( child );
3073 ok( GetActiveWindow() == child, "child window %p should be active\n", child);
3074 ok( GetFocus() == child, "Focus should be on child %p\n", child );
3075
3076 DestroyWindow( child2 );
3078}
3079
3081{
3082 HWND hwnd2;
3083
3084 flush_events( TRUE );
3086 SetFocus(0);
3087 SetActiveWindow(0);
3088 check_wnd_state(0, 0, 0, 0);
3089
3090 /*trace("testing SetActiveWindow %p\n", hwnd);*/
3091
3094
3095 hwnd2 = SetActiveWindow(0);
3096 ok(hwnd2 == hwnd, "SetActiveWindow returned %p instead of %p\n", hwnd2, hwnd);
3097 if (!GetActiveWindow()) /* doesn't always work on vista */
3098 {
3100 check_wnd_state(0, 0, 0, 0);
3101 hwnd2 = SetActiveWindow(hwnd);
3103 ok(hwnd2 == 0, "SetActiveWindow returned %p instead of 0\n", hwnd2);
3104 }
3106
3109
3112
3114 check_wnd_state(0, 0, 0, 0);
3115
3116 /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
3119
3122
3123 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3124 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3125
3126 DestroyWindow(hwnd2);
3128
3129 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3130 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3131
3133 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3134
3135 DestroyWindow(hwnd2);
3137}
3138
3140{
3144};
3145
3147{
3149 DWORD res;
3150 BOOL ret;
3151
3152 p->window = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
3153
3154 ret = SetEvent(p->window_created);
3155 ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
3156
3157 res = WaitForSingleObject(p->test_finished, INFINITE);
3158 ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
3159
3160 DestroyWindow(p->window);
3161 return 0;
3162}
3163
3165{
3166 struct create_window_thread_params thread_params;
3167 HANDLE thread;
3168 DWORD res, tid;
3169 BOOL ret;
3170 HWND hwnd2;
3171 MSG msg;
3172 LONG style;
3173
3174 flush_events( TRUE );
3176 SetFocus(0);
3177 SetActiveWindow(0);
3178 check_wnd_state(0, 0, 0, 0);
3179
3180 /*trace("testing SetForegroundWindow %p\n", hwnd);*/
3181
3184
3185 hwnd2 = SetActiveWindow(0);
3186 ok(hwnd2 == hwnd, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2, hwnd);
3187 if (GetActiveWindow() == hwnd) /* doesn't always work on vista */
3189 else
3190 check_wnd_state(0, 0, 0, 0);
3191
3193 if (!ret)
3194 {
3195 skip( "SetForegroundWindow not working\n" );
3196 return;
3197 }
3199
3200 SetLastError(0xdeadbeef);
3202 ok(!ret, "SetForegroundWindow returned TRUE instead of FALSE\n");
3204 broken(GetLastError() == 0xdeadbeef), /* win9x */
3205 "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
3207
3210
3213
3214 hwnd2 = GetForegroundWindow();
3215 ok(hwnd2 == hwnd, "Wrong foreground window %p\n", hwnd2);
3217 ok(ret, "SetForegroundWindow(desktop) error: %d\n", GetLastError());
3218 hwnd2 = GetForegroundWindow();
3219 ok(hwnd2 != hwnd, "Wrong foreground window %p\n", hwnd2);
3220
3222 check_wnd_state(0, 0, 0, 0);
3223
3224 /*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
3226 ok(ret || broken(!ret), /* win98 */ "SetForegroundWindow returned FALSE instead of TRUE\n");
3228
3231
3232 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3233 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3234
3235 DestroyWindow(hwnd2);
3237
3238 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3239 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3240
3242 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3243
3244 DestroyWindow(hwnd2);
3246
3247 hwnd2 = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
3248 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3249
3250 thread_params.window_created = CreateEventW(NULL, FALSE, FALSE, NULL);
3251 ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
3252 thread_params.test_finished = CreateEventW(NULL, FALSE, FALSE, NULL);
3253 ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
3254 thread = CreateThread(NULL, 0, create_window_thread, &thread_params, 0, &tid);
3255 ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
3257 ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
3258 check_wnd_state(hwnd2, thread_params.window, hwnd2, 0);
3259
3260 SetForegroundWindow(hwnd2);
3261 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3262
3263 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
3264 if (0) check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3265 todo_wine ok(GetActiveWindow() == hwnd2, "Expected active window %p, got %p.\n", hwnd2, GetActiveWindow());
3266 todo_wine ok(GetFocus() == hwnd2, "Expected focus window %p, got %p.\n", hwnd2, GetFocus());
3267
3271 ok(SetWindowLongA(hwnd2, GWL_STYLE, style), "SetWindowLong failed\n");
3272 ok(SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n");
3273 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3274
3277 ok(SetWindowLongA(hwnd2, GWL_STYLE, style & (~WS_POPUP)), "SetWindowLong failed\n");
3278 ok(!SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n");
3280
3281 SetEvent(thread_params.test_finished);
3283 CloseHandle(thread_params.test_finished);
3284 CloseHandle(thread_params.window_created);
3286 DestroyWindow(hwnd2);
3287}
3288
3290
3292{
3293 LRESULT ret;
3294 USHORT key_state;
3295
3296 key_state = GetKeyState(VK_LBUTTON);
3297 ok(!(key_state & 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state);
3298
3300
3301 if (msg == WM_LBUTTONDOWN)
3302 {
3303 HWND hwnd, capture;
3304
3306
3307 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
3308 assert(hwnd);
3309 trace("hwnd %p\n", hwnd);
3310
3312
3314
3316
3318
3319 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
3320 assert(hwnd);
3321 trace("hwnd %p\n", hwnd);
3322
3324
3325 /* button wnd proc should release capture on WM_KILLFOCUS if it does
3326 * match internal button state.
3327 */
3330
3333
3334 capture = SetCapture(hwnd);
3335 ok(capture == 0, "SetCapture() = %p\n", capture);
3336
3338
3340
3342 }
3343
3344 return ret;
3345}
3346
3347static void test_capture_1(void)
3348{
3349 HWND button, capture;
3350
3351 capture = GetCapture();
3352 ok(capture == 0, "GetCapture() = %p\n", capture);
3353
3354 button = CreateWindowExA(0, "button", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
3355 assert(button);
3356 trace("button %p\n", button);
3357
3359
3361
3362 capture = SetCapture(button);
3363 ok(capture == 0, "SetCapture() = %p\n", capture);
3365
3367 /* old active window test depends on previously executed window
3368 * activation tests, and fails under NT4.
3369 check_wnd_state(oldActive, 0, oldFocus, 0);*/
3370}
3371
3372static void test_capture_2(void)
3373{
3374 HWND button, hwnd, capture, oldFocus, oldActive;
3375
3376 oldFocus = GetFocus();
3377 oldActive = GetActiveWindow();
3378 check_wnd_state(oldActive, 0, oldFocus, 0);
3379
3380 button = CreateWindowExA(0, "button", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
3381 assert(button);
3382 trace("button %p\n", button);
3383
3385
3386 capture = SetCapture(button);
3387 ok(capture == 0, "SetCapture() = %p\n", capture);
3388
3390
3391 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
3392 * internal button state.
3393 */
3396
3397 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
3398 assert(hwnd);
3399 trace("hwnd %p\n", hwnd);
3400
3402
3404
3406
3408
3409 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
3410 assert(hwnd);
3411 trace("hwnd %p\n", hwnd);
3412
3414
3416
3418
3419 capture = SetCapture(hwnd);
3420 ok(capture == button, "SetCapture() = %p\n", capture);
3421
3423
3426
3428 check_wnd_state(oldActive, 0, oldFocus, 0);
3429}
3430
3431static void test_capture_3(HWND hwnd1, HWND hwnd2)
3432{
3433 BOOL ret;
3434
3435 ShowWindow(hwnd1, SW_HIDE);
3436 ShowWindow(hwnd2, SW_HIDE);
3437
3438 ok(!IsWindowVisible(hwnd1), "%p should be invisible\n", hwnd1);
3439 ok(!IsWindowVisible(hwnd2), "%p should be invisible\n", hwnd2);
3440
3441 SetCapture(hwnd1);
3442 check_wnd_state(0, 0, 0, hwnd1);
3443
3444 SetCapture(hwnd2);
3445 check_wnd_state(0, 0, 0, hwnd2);
3446
3447 ShowWindow(hwnd1, SW_SHOW);
3448 check_wnd_state(hwnd1, hwnd1, hwnd1, hwnd2);
3449
3450 ret = ReleaseCapture();
3451 ok (ret, "releasecapture did not return TRUE.\n");
3452 ret = ReleaseCapture();
3453 ok (ret, "releasecapture did not return TRUE after second try.\n");
3454}
3455
3457{
3459 HWND cap_wnd, cap_wnd2, set_cap_wnd;
3460 BOOL status;
3461 switch (msg)
3462 {
3463 case WM_CAPTURECHANGED:
3464
3465 /* now try to release capture from menu. this should fail */
3466 if (pGetGUIThreadInfo)
3467 {
3468 memset(&gti, 0, sizeof(GUITHREADINFO));
3469 gti.cbSize = sizeof(GUITHREADINFO);
3470 status = pGetGUIThreadInfo(GetCurrentThreadId(), &gti);
3471 ok(status, "GetGUIThreadInfo() failed!\n");
3472 ok(gti.flags & GUI_INMENUMODE, "Thread info incorrect (flags=%08X)!\n", gti.flags);
3473 }
3474 cap_wnd = GetCapture();
3475
3476 ok(cap_wnd == (HWND)lParam, "capture window %p does not match lparam %lx\n", cap_wnd, lParam);
3477 todo_wine ok(cap_wnd == hWnd, "capture window %p does not match hwnd %p\n", cap_wnd, hWnd);
3478
3479 /* check that re-setting the capture for the menu fails */
3480 set_cap_wnd = SetCapture(cap_wnd);
3481 ok(!set_cap_wnd || broken(set_cap_wnd == cap_wnd), /* nt4 */
3482 "SetCapture should have failed!\n");
3483 if (set_cap_wnd)
3484 {
3486 break;
3487 }
3488
3489 /* check that SetCapture fails for another window and that it does not touch the error code */
3490 set_cap_wnd = SetCapture(hWnd);
3491 ok(!set_cap_wnd, "SetCapture should have failed!\n");
3492
3493 /* check that ReleaseCapture fails and does not touch the error code */
3495 ok(!status, "ReleaseCapture should have failed!\n");
3496
3497 /* check that thread info did not change */
3498 if (pGetGUIThreadInfo)
3499 {
3500 memset(&gti, 0, sizeof(GUITHREADINFO));
3501 gti.cbSize = sizeof(GUITHREADINFO);
3502 status = pGetGUIThreadInfo(GetCurrentThreadId(), &gti);
3503 ok(status, "GetGUIThreadInfo() failed!\n");
3504 ok(gti.flags & GUI_INMENUMODE, "Thread info incorrect (flags=%08X)!\n", gti.flags);
3505 }
3506
3507 /* verify that no capture change took place */
3508 cap_wnd2 = GetCapture();
3509 ok(cap_wnd2 == cap_wnd, "Capture changed!\n");
3510
3511 /* we are done. kill the window */
3513 break;
3514
3515 default:
3516 return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
3517 }
3518 return 0;
3519}
3520
3521/* Test that no-one can mess around with the current capture while a menu is open */
3522static void test_capture_4(void)
3523{
3524 BOOL ret;
3525 HMENU hmenu;
3526 HWND hwnd;
3527 WNDCLASSA wclass;
3529 ATOM aclass;
3530
3531 if (!pGetGUIThreadInfo)
3532 {
3533 win_skip("GetGUIThreadInfo is not available\n");
3534 return;
3535 }
3536 wclass.lpszClassName = "TestCapture4Class";
3537 wclass.style = CS_HREDRAW | CS_VREDRAW;
3539 wclass.hInstance = hInstance;
3540 wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
3541 wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW );
3542 wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
3543 wclass.lpszMenuName = 0;
3544 wclass.cbClsExtra = 0;
3545 wclass.cbWndExtra = 0;
3546 aclass = RegisterClassA( &wclass );
3547 ok( aclass, "RegisterClassA failed with error %d\n", GetLastError());
3548 hwnd = CreateWindowA( wclass.lpszClassName, "MenuTest",
3550 400, 200, NULL, NULL, hInstance, NULL);
3551 ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
3552 if (!hwnd) return;
3554
3555 ret = AppendMenuA( hmenu, MF_STRING, 1, "winetest2");
3556 ok( ret, "AppendMenuA has failed!\n");
3557
3558 /* set main window to have initial capture */
3560
3561 if (is_win9x)
3562 {
3563 win_skip("TrackPopupMenu test crashes on Win9x/WinMe\n");
3564 }
3565 else
3566 {
3567 /* create popup (it will self-destruct) */
3568 ret = TrackPopupMenu(hmenu, TPM_RETURNCMD, 100, 100, 0, hwnd, NULL);
3569 ok( ret == 0, "TrackPopupMenu returned %d expected zero\n", ret);
3570 }
3571
3572 /* clean up */
3575}
3576
3577/* PeekMessage wrapper that ignores the messages we don't care about */
3579{
3580 BOOL ret;
3581 do
3582 {
3583 ret = PeekMessageA(msg, 0, 0, 0, PM_REMOVE);
3584 } while (ret && ignore_message(msg->message));
3585 return ret;
3586}
3587
3589{
3590 MSG msg;
3591 BOOL ret;
3592
3593 flush_events( TRUE );
3596 flush_events( TRUE );
3597
3598 ok(GetActiveWindow() == hwnd, "wrong active window %p\n", GetActiveWindow());
3599
3600 SetFocus(hwnd);
3601 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
3602
3603 flush_events( TRUE );
3604
3606 ret = peek_message(&msg);
3607 ok( ret, "no message available\n");
3608 ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3609 ret = peek_message(&msg);
3610 ok( !ret, "message %04x available\n", msg.message);
3611
3612 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
3613
3615 ret = peek_message(&msg);
3616 ok(ret, "no message available\n");
3617 ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3618 ret = peek_message(&msg);
3619 ok( !ret, "message %04x available\n", msg.message);
3620
3621 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
3622
3623 keybd_event(VK_SPACE, 0, 0, 0);
3624 if (!peek_message(&msg))
3625 {
3626 skip( "keybd_event didn't work, skipping keyboard test\n" );
3627 return;
3628 }
3629 ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3630 ret = peek_message(&msg);
3631 ok( !ret, "message %04x available\n", msg.message);
3632
3633 SetFocus(0);
3634 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3635
3636 flush_events( TRUE );
3637
3639 ret = peek_message(&msg);
3640 ok(ret, "no message available\n");
3641 ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3642 ret = peek_message(&msg);
3643 ok( !ret, "message %04x available\n", msg.message);
3644
3645 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3646
3648 ret = peek_message(&msg);
3649 ok(ret, "no message available\n");
3650 ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3651 ret = peek_message(&msg);
3652 ok( !ret, "message %04x available\n", msg.message);
3653
3654 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3655
3656 keybd_event(VK_SPACE, 0, 0, 0);
3657 ret = peek_message(&msg);
3658 ok(ret, "no message available\n");
3659 ok(msg.hwnd == hwnd && msg.message == WM_SYSKEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3660 ret = peek_message(&msg);
3661 ok( !ret, "message %04x available\n", msg.message);
3662}
3663
3665{
3666 BOOL ret;
3667
3668 for (;;)
3669 {
3670 ret = peek_message(msg);
3671 if (ret)
3672 {
3673 if (msg->message == WM_PAINT) DispatchMessageA(msg);
3674 else break;
3675 }
3676 else if (MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
3677 }
3678 if (!ret) msg->message = 0;
3679 return ret;
3680}
3681
3683{
3684 RECT rc;
3685 POINT pt;
3686 int x, y;
3687 HWND popup;
3688 MSG msg;
3689 BOOL ret;
3690 LRESULT res;
3691
3695
3696 GetWindowRect(hwnd, &rc);
3697 trace("main window %p: %s\n", hwnd, wine_dbgstr_rect(&rc));
3698
3699 popup = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP,
3700 rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
3701 hwnd, 0, 0, NULL);
3702 assert(popup != 0);
3703 ShowWindow(popup, SW_SHOW);
3704 UpdateWindow(popup);
3705 SetWindowPos( popup, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
3706
3707 GetWindowRect(popup, &rc);
3708 trace("popup window %p: %s\n", popup, wine_dbgstr_rect(&rc));
3709
3710 x = rc.left + (rc.right - rc.left) / 2;
3711 y = rc.top + (rc.bottom - rc.top) / 2;
3712 trace("setting cursor to (%d,%d)\n", x, y);
3713
3714 SetCursorPos(x, y);
3715 GetCursorPos(&pt);
3716 if (x != pt.x || y != pt.y)
3717 {
3718 skip( "failed to set mouse position, skipping mouse input tests\n" );
3719 goto done;
3720 }
3721
3722 flush_events( TRUE );
3723
3724 /* Check that setting the same position may generate WM_MOUSEMOVE */
3725 SetCursorPos(x, y);
3726 msg.message = 0;
3727 ret = peek_message(&msg);
3728 if (ret)
3729 {
3730 ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n",
3731 msg.hwnd, msg.message);
3732 ok(msg.pt.x == x && msg.pt.y == y, "wrong message coords (%d,%d)/(%d,%d)\n",
3733 x, y, msg.pt.x, msg.pt.y);
3734 }
3735
3736 /* force the system to update its internal queue mouse position,
3737 * otherwise it won't generate relative mouse movements below.
3738 */
3739 mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
3740 flush_events( TRUE );
3741
3742 msg.message = 0;
3743 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
3745 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
3746 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
3747 {
3748 if (ignore_message(msg.message)) continue;
3749 ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE,
3750 "hwnd %p message %04x\n", msg.hwnd, msg.message);
3752 }
3753 ret = peek_message(&msg);
3754 ok( !ret, "message %04x available\n", msg.message);
3755
3756 mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
3757 ShowWindow(popup, SW_HIDE);
3758 ret = wait_for_message( &msg );
3759 if (ret)
3760 ok(msg.hwnd == hwnd && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message);
3761 flush_events( TRUE );
3762
3763 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
3765 ret = wait_for_message( &msg );
3766 ok( !ret, "message %04x available\n", msg.message);
3767 flush_events( TRUE );
3768
3769 /* test mouse clicks */
3770
3773 flush_events( TRUE );
3774 ShowWindow(popup, SW_SHOW);
3775 SetWindowPos( popup, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
3776 flush_events( TRUE );
3777
3778 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
3779 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
3780 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
3781 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
3782
3783 ret = wait_for_message( &msg );
3784 if (!ret)
3785 {
3786 skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
3787 goto done;
3788 }
3789 if (msg.message == WM_MOUSEMOVE) /* win2k has an extra WM_MOUSEMOVE here */
3790 {
3791 ret = wait_for_message( &msg );
3792 ok(ret, "no message available\n");
3793 }
3794
3795 ok(msg.hwnd == popup && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
3796 msg.hwnd, popup, msg.message);
3797
3798 ret = wait_for_message( &msg );
3799 ok(ret, "no message available\n");
3800 ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
3801 msg.hwnd, popup, msg.message);
3802
3803 ret = wait_for_message( &msg );
3804 ok(ret, "no message available\n");
3805 ok(msg.hwnd == popup && msg.message == WM_LBUTTONDBLCLK, "hwnd %p/%p message %04x\n",
3806 msg.hwnd, popup, msg.message);
3807
3808 ret = wait_for_message( &msg );
3809 ok(ret, "no message available\n");
3810 ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
3811 msg.hwnd, popup, msg.message);
3812
3813 ret = peek_message(&msg);
3814 ok(!ret, "message %04x available\n", msg.message);
3815
3816 ShowWindow(popup, SW_HIDE);
3817 flush_events( TRUE );
3818
3819 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
3820 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
3821 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
3822 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
3823
3824 ret = wait_for_message( &msg );
3825 ok(ret, "no message available\n");
3826 ok(msg.hwnd == hwnd && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
3827 msg.hwnd, hwnd, msg.message);
3828 ret = wait_for_message( &msg );
3829 ok(ret, "no message available\n");
3830 ok(msg.hwnd == hwnd && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
3831 msg.hwnd, hwnd, msg.message);
3832
3834 SendMessageA(hwnd, WM_COMMAND, (WPARAM)popup, 0);
3836
3837 ret = wait_for_message( &msg );
3838 ok(ret, "no message available\n");
3839 ok(msg.hwnd == popup && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
3840 msg.hwnd, popup, msg.message);
3841 ok(peek_message(&msg), "no message available\n");
3842 ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
3843 msg.hwnd, popup, msg.message);
3844 ok(peek_message(&msg), "no message available\n");
3845
3846 /* Test WM_MOUSEACTIVATE */
3847#define TEST_MOUSEACTIVATE(A,B) \
3848 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
3849 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
3850
3875
3876done:
3877 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
3878 flush_events( TRUE );
3879
3880 DestroyWindow(popup);
3881}
3882
3884{
3885 HWND child;
3886 RECT rc, rc2;
3887 HRGN rgn;
3888 int ret;
3889 child = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE, 10, 10, 10, 10, hwnd, 0, 0, NULL);
3892 /* test that ValidateRect validates children*/
3894 GetWindowRect( child, &rc);
3895 MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
3896 ret = GetUpdateRect( child, &rc2, 0);
3897 ok( ret == 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret);
3898 ok( rc2.right > rc2.left && rc2.bottom > rc2.top,
3899 "Update rectangle is empty!\n");
3900 ValidateRect( hwnd, &rc);
3901 ret = GetUpdateRect( child, &rc2, 0);
3902 ok( !ret, "Expected GetUpdateRect to return zero, got %d\n", ret);
3903 ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
3904 "Update rectangle %s is not empty!\n", wine_dbgstr_rect(&rc2));
3905
3906 /* now test ValidateRgn */
3908 GetWindowRect( child, &rc);
3909 MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
3910 rgn = CreateRectRgnIndirect( &rc);
3911 ValidateRgn( hwnd, rgn);
3912 ret = GetUpdateRect( child, &rc2, 0);
3913 ok( !ret, "Expected GetUpdateRect to return zero, got %d\n", ret);
3914 ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
3915 "Update rectangle %s is not empty!\n", wine_dbgstr_rect(&rc2));
3916
3917 DeleteObject( rgn);
3919}
3920
3922{
3923 RECT rc;
3924 MoveWindow( hwnd, 0, 0, x, y, 0);
3926 rc = *prc;
3928 trace("window rect is %s, nccalc rect is %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(prc));
3929}
3930
3932{
3933 RECT rc1;
3934 INT sbheight = GetSystemMetrics( SM_CYHSCROLL);
3935 INT sbwidth = GetSystemMetrics( SM_CXVSCROLL);
3936 HWND hwnd = CreateWindowExA(0, "static", NULL,
3938 10, 10, 200, 200, parent, 0, 0, NULL);
3941
3942 /* test window too low for a horizontal scroll bar */
3943 nccalchelper( hwnd, 100, sbheight, &rc1);
3944 ok( rc1.bottom - rc1.top == sbheight, "Height should be %d size is %s\n", sbheight,
3945 wine_dbgstr_rect(&rc1));
3946
3947 /* test window just high enough for a horizontal scroll bar */
3948 nccalchelper( hwnd, 100, sbheight + 1, &rc1);
3949 ok( rc1.bottom - rc1.top == 1, "Height should be 1 size is %s\n", wine_dbgstr_rect(&rc1));
3950
3951 /* test window too narrow for a vertical scroll bar */
3952 nccalchelper( hwnd, sbwidth - 1, 100, &rc1);
3953 ok( rc1.right - rc1.left == sbwidth - 1 , "Width should be %d size is %s\n", sbwidth - 1,
3954 wine_dbgstr_rect(&rc1));
3955
3956 /* test window just wide enough for a vertical scroll bar */
3957 nccalchelper( hwnd, sbwidth, 100, &rc1);
3958 ok( rc1.right - rc1.left == 0, "Width should be 0 size is %s\n", wine_dbgstr_rect(&rc1));
3959
3960 /* same test, but with client edge: not enough width */
3962 nccalchelper( hwnd, sbwidth, 100, &rc1);
3963 ok( rc1.right - rc1.left == sbwidth - 2 * GetSystemMetrics(SM_CXEDGE),
3964 "Width should be %d size is %s\n", sbwidth - 2 * GetSystemMetrics(SM_CXEDGE),
3965 wine_dbgstr_rect(&rc1));
3966
3968}
3969
3970static void test_SetParent(void)
3971{
3972 HWND desktop = GetDesktopWindow();
3973 HMENU hMenu;
3974 HWND ret, parent, child1, child2, child3, child4, sibling, popup;
3975 BOOL bret;
3976
3978 100, 100, 200, 200, 0, 0, 0, NULL);
3979 assert(parent != 0);
3980 child1 = CreateWindowExA(0, "static", NULL, WS_CHILD,
3981 0, 0, 50, 50, parent, 0, 0, NULL);
3982 assert(child1 != 0);
3983 child2 = CreateWindowExA(0, "static", NULL, WS_POPUP,
3984 0, 0, 50, 50, child1, 0, 0, NULL);
3985 assert(child2 != 0);
3986 child3 = CreateWindowExA(0, "static", NULL, WS_CHILD,
3987 0, 0, 50, 50, child2, 0, 0, NULL);
3988 assert(child3 != 0);
3989 child4 = CreateWindowExA(0, "static", NULL, WS_POPUP,
3990 0, 0, 50, 50, child3, 0, 0, NULL);
3991 assert(child4 != 0);
3992
3993 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
3994 parent, child1, child2, child3, child4);
3995
3996 check_parents(parent, desktop, 0, 0, 0, parent, parent);
3998 check_parents(child2, desktop, parent, parent, parent, child2, parent);
3999 check_parents(child3, child2, child2, child2, 0, child2, parent);
4000 check_parents(child4, desktop, child2, child2, child2, child4, parent);
4001
4002 ok(!IsChild(desktop, parent), "wrong parent/child %p/%p\n", desktop, parent);
4003 ok(!IsChild(desktop, child1), "wrong parent/child %p/%p\n", desktop, child1);
4004 ok(!IsChild(desktop, child2), "wrong parent/child %p/%p\n", desktop, child2);
4005 ok(!IsChild(desktop, child3), "wrong parent/child %p/%p\n", desktop, child3);
4006 ok(!IsChild(desktop, child4), "wrong parent/child %p/%p\n", desktop, child4);
4007
4008 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
4009 ok(!IsChild(desktop, child2), "wrong parent/child %p/%p\n", desktop, child2);
4010 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
4011 ok(!IsChild(child1, child2), "wrong parent/child %p/%p\n", child1, child2);
4012 ok(!IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
4013 ok(IsChild(child2, child3), "wrong parent/child %p/%p\n", child2, child3);
4014 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
4015 ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
4016 ok(!IsChild(desktop, child4), "wrong parent/child %p/%p\n", desktop, child4);
4017
4018 if (!is_win9x) /* Win9x doesn't survive this test */
4019 {
4020 ok(!SetParent(parent, child1), "SetParent should fail\n");
4021 ok(!SetParent(child2, child3), "SetParent should fail\n");
4022 ok(SetParent(child1, parent) != 0, "SetParent should not fail\n");
4023 ret = SetParent(parent, child2);
4024 todo_wine ok( !ret || broken( ret != 0 ), "SetParent should fail\n");
4025 if (ret) /* nt4, win2k */
4026 {
4027 ret = SetParent(parent, child3);
4028 ok(ret != 0, "SetParent should not fail\n");
4029 ret = SetParent(child2, parent);
4030 ok(!ret, "SetParent should fail\n");
4031 ret = SetParent(parent, child4);
4032 ok(ret != 0, "SetParent should not fail\n");
4033 check_parents(parent, child4, child4, 0, 0, child4, parent);
4034 check_parents(child1, parent, parent, parent, 0, child4, parent);
4035 check_parents(child2, desktop, parent, parent, parent, child2, parent);
4036 check_parents(child3, child2, child2, child2, 0, child2, parent);
4037 check_parents(child4, desktop, child2, child2, child2, child4, parent);
4038 }
4039 else
4040 {
4041 ret = SetParent(parent, child3);
4042 ok(ret != 0, "SetParent should not fail\n");
4043 ret = SetParent(child2, parent);
4044 ok(!ret, "SetParent should fail\n");
4045 ret = SetParent(parent, child4);
4046 ok(!ret, "SetParent should fail\n");
4047 check_parents(parent, child3, child3, 0, 0, child2, parent);
4048 check_parents(child1, parent, parent, parent, 0, child2, parent);
4049 check_parents(child2, desktop, parent, parent, parent, child2, parent);
4050 check_parents(child3, child2, child2, child2, 0, child2, parent);
4051 check_parents(child4, desktop, child2, child2, child2, child4, parent);
4052 }
4053 }
4054 else
4055 skip("Win9x/WinMe crash\n");
4056
4057 hMenu = CreateMenu();
4058 sibling = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
4059 100, 100, 200, 200, 0, hMenu, 0, NULL);
4060 assert(sibling != 0);
4061
4062 ok(SetParent(sibling, parent) != 0, "SetParent should not fail\n");
4063 ok(GetMenu(sibling) == hMenu, "SetParent should not remove menu\n");
4064
4065 ok(SetParent(parent, desktop) != 0, "SetParent should not fail\n");
4066 ok(SetParent(child4, child3) != 0, "SetParent should not fail\n");
4067 ok(SetParent(child3, child2) != 0, "SetParent should not fail\n");
4068 ok(SetParent(child2, child1) != 0, "SetParent should not fail\n");
4069 ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
4071 ok(IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
4072 ok(IsChild(child2, child4), "wrong parent/child %p/%p\n", child2, child4);
4073 ok(!IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4);
4075 ok(IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4);
4076 ok(IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
4077
4078 ok(DestroyWindow(parent), "DestroyWindow() failed\n");
4079
4080 ok(!IsWindow(parent), "parent still exists\n");
4081 ok(!IsWindow(sibling), "sibling still exists\n");
4082 ok(!IsWindow(child1), "child1 still exists\n");
4083 ok(!IsWindow(child2), "child2 still exists\n");
4084 ok(!IsWindow(child3), "child3 still exists\n");
4085 ok(!IsWindow(child4), "child4 still exists\n");
4086
4088 100, 100, 200, 200, 0, 0, 0, NULL);
4089 assert(parent != 0);
4090 child1 = CreateWindowExA(0, "static", NULL, WS_CHILD,
4091 0, 0, 50, 50, parent, 0, 0, NULL);
4092 assert(child1 != 0);
4093 popup = CreateWindowExA(0, "static", NULL, WS_POPUP,
4094 0, 0, 50, 50, 0, 0, 0, NULL);
4095 assert(popup != 0);
4096
4097 trace("parent %p, child %p, popup %p\n", parent, child1, popup);
4098
4099 check_parents(parent, desktop, 0, 0, 0, parent, parent);
4101 check_parents(popup, desktop, 0, 0, 0, popup, popup);
4102
4106
4107 ret = SetParent(popup, child1);
4108 ok(ret == desktop, "expected %p, got %p\n", desktop, ret);
4109 check_parents(popup, child1, child1, 0, 0, parent, popup);
4110 check_active_state(popup, 0, popup);
4111
4113 SetFocus(popup);
4114 check_active_state(popup, 0, popup);
4115
4116 EnableWindow(child1, FALSE);
4117 check_active_state(popup, 0, popup);
4120 SetFocus(popup);
4121 check_active_state(popup, 0, popup);
4122 EnableWindow(child1, TRUE);
4123
4124 ShowWindow(child1, SW_MINIMIZE);
4127 SetFocus(popup);
4128 check_active_state(popup, 0, popup);
4129 ShowWindow(child1, SW_HIDE);
4130
4134
4135 bret = SetForegroundWindow(popup);
4136 ok(bret, "SetForegroundWindow() failed\n");
4137 check_active_state(popup, popup, popup);
4138
4140 SetActiveWindow(popup);
4141 ok(DestroyWindow(popup), "DestroyWindow() failed\n");
4143
4144 ok(DestroyWindow(parent), "DestroyWindow() failed\n");
4145
4146 ok(!IsWindow(parent), "parent still exists\n");
4147 ok(!IsWindow(child1), "child1 still exists\n");
4148 ok(!IsWindow(popup), "popup still exists\n");
4149}
4150
4152{
4153 LPCREATESTRUCTA lpcs;
4154 LPSTYLESTRUCT lpss;
4155
4156 switch (msg)
4157 {
4158 case WM_NCCREATE:
4159 case WM_CREATE:
4160 lpcs = (LPCREATESTRUCTA)lparam;
4161 lpss = lpcs->lpCreateParams;
4162 if (lpss)
4163 {
4164 if ((lpcs->dwExStyle & WS_EX_DLGMODALFRAME) ||
4165 ((!(lpcs->dwExStyle & WS_EX_STATICEDGE)) &&
4166 (lpcs->style & (WS_DLGFRAME | WS_THICKFRAME))))
4167 ok(lpcs->dwExStyle & WS_EX_WINDOWEDGE, "Window should have WS_EX_WINDOWEDGE style\n");
4168 else
4169 ok(!(lpcs->dwExStyle & WS_EX_WINDOWEDGE), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
4170
4171 ok((lpss->styleOld & ~WS_EX_WINDOWEDGE) == (lpcs->dwExStyle & ~WS_EX_WINDOWEDGE),
4172 "Ex style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
4173 lpss->styleOld, lpcs->dwExStyle);
4174
4175 ok(lpss->styleNew == lpcs->style,
4176 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
4177 lpss->styleNew, lpcs->style);
4178 }
4179 break;
4180 }
4181 return DefWindowProcA(hwnd, msg, wparam, lparam);
4182}
4183
4185
4187{
4188 WNDCLASSA wc =
4189 {
4190 0,
4192 0,
4193 0,
4195 NULL,
4197 (HBRUSH)(COLOR_BTNFACE+1),
4198 NULL,
4199 "WineStyleCheck",
4200 };
4201
4204}
4205
4206static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut)
4207{
4208 DWORD dwActualStyle;
4209 DWORD dwActualExStyle;
4211 HWND hwnd;
4213
4214 ss.styleNew = dwStyleIn;
4215 ss.styleOld = dwExStyleIn;
4216
4217 if (dwStyleIn & WS_CHILD)
4218 {
4220 WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
4221 }
4222
4224 dwStyleIn, 0, 0, 0, 0, hwndParent, NULL, NULL, &ss);
4225 assert(hwnd);
4226
4227 flush_events( TRUE );
4228
4229 dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE);
4230 dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
4231 ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle);
4232 ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
4233
4234 /* try setting the styles explicitly */
4235 SetWindowLongA( hwnd, GWL_EXSTYLE, dwExStyleIn );
4236 dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE);
4237 dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
4238 /* WS_EX_WINDOWEDGE can't always be changed */
4239 if (dwExStyleIn & WS_EX_DLGMODALFRAME)
4240 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
4241 else if ((dwActualStyle & (WS_DLGFRAME | WS_THICKFRAME)) && !(dwExStyleIn & WS_EX_STATICEDGE))
4242 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
4243 else
4244 dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE;
4245 ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle);
4246 ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
4247
4248 SetWindowLongA( hwnd, GWL_STYLE, dwStyleIn );
4249 dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE);
4250 dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
4251 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
4252 if ((dwStyleIn & (WS_CHILD|WS_POPUP)) == WS_CHILD) dwStyleOut = dwStyleIn;
4253 else dwStyleOut = dwStyleIn | WS_CLIPSIBLINGS;
4254 /* WS_EX_WINDOWEDGE can't always be changed */
4255 if (dwExStyleIn & WS_EX_DLGMODALFRAME)
4256 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
4257 else if ((dwActualStyle & (WS_DLGFRAME | WS_THICKFRAME)) && !(dwExStyleIn & WS_EX_STATICEDGE))
4258 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
4259 else
4260 dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE;
4261 ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle);
4262 /* FIXME: Remove the condition below once Wine is fixed */
4263 todo_wine_if (dwActualExStyle != dwExStyleOut)
4264 ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle);
4265
4268}
4269
4270/* tests what window styles the window manager automatically adds */
4271static void test_window_styles(void)
4272{
4274
4308
4309 if (pGetLayeredWindowAttributes)
4310 {
4315 }
4316}
4317
4319{
4322 {
4324
4325 /* simple detector for a window being a dialog */
4326 if (!DefDlgProcA(parent, DM_GETDEFID, 0, 0))
4327 break;
4328
4329 hwnd = parent;
4330
4332 break;
4333 }
4334
4335 return hwnd;
4336}
4337
4339{
4340 return 0;
4341}
4342
4344
4346{
4347 if (msg == WM_INITDIALOG)
4348 {
4350 LRESULT id, ret;
4351
4352 id = DefDlgProcA(parent, DM_GETDEFID, 0, 0);
4353 if (!id || root_dialog(hwnd) == hwnd)
4354 parent = 0;
4355
4356 id = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4357 if (!parent)
4358 ok(id == MAKELONG(IDOK,DC_HASDEFID), "expected (IDOK,DC_HASDEFID), got %08lx\n", id);
4359 else
4360 ok(id == expected_id, "expected %08lx, got %08lx\n", expected_id, id);
4361
4362 ret = DefDlgProcA(hwnd, DM_SETDEFID, 0x3333, 0);
4363 ok(ret, "DefDlgProc(DM_SETDEFID) failed\n");
4364 id = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4365 ok(id == MAKELONG(0x3333,DC_HASDEFID), "expected (0x3333,DC_HASDEFID), got %08lx\n", id);
4366
4367 if (parent)
4368 {
4369 id = DefDlgProcA(parent, DM_GETDEFID, 0, 0);
4370 ok(id == MAKELONG(0x3333,DC_HASDEFID), "expected (0x3333,DC_HASDEFID), got %08lx\n", id);
4371
4373 }
4374
4375 EndDialog(hwnd, 0);
4376 }
4377
4378 return 0;
4379}
4380
4382{
4385};
4386
4388{
4389 if (msg == WM_INITDIALOG)
4390 {
4392 struct dialog_param *param = (struct dialog_param *)lparam;
4393 BOOL parent_is_child;
4394 HWND disabled_hwnd;
4395 LRESULT id, ret;
4396
4397 id = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4398 ok(id == MAKELONG(IDOK,DC_HASDEFID), "expected (IDOK,DC_HASDEFID), got %08lx\n", id);
4399 ret = DefDlgProcA(hwnd, DM_SETDEFID, 0x2222, 0);
4400 ok(ret, "DefDlgProc(DM_SETDEFID) failed\n");
4401 id = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4402 ok(id == MAKELONG(0x2222,DC_HASDEFID), "expected (0x2222,DC_HASDEFID), got %08lx\n", id);
4403
4405
4406 parent_is_child = (GetWindowLongA(param->parent, GWL_STYLE) & (WS_POPUP | WS_CHILD)) == WS_CHILD;
4407
4408 ok(IsWindowEnabled(hwnd), "wrong state for %p\n", hwnd);
4409 if (parent_is_child)
4410 {
4411 ok(IsWindowEnabled(param->parent), "wrong state for %08x\n", style);
4412 disabled_hwnd = param->grand_parent;
4413 }
4414 else
4415 {
4416 ok(!IsWindowEnabled(param->parent), "wrong state for %08x\n", style);
4417 disabled_hwnd = param->parent;
4418 }
4419
4420 if (param->grand_parent)
4421 {
4422 if (parent_is_child)
4423 ok(!IsWindowEnabled(param->grand_parent), "wrong state for %08x\n", style);
4424 else
4425 ok(IsWindowEnabled(param->grand_parent), "wrong state for %08x\n", style);
4426 }
4427
4428 DialogBoxIndirectParamA(GetModuleHandleA(NULL), param->dlg_data, disabled_hwnd, empty_dlg_proc3, 0);
4429 ok(IsWindowEnabled(disabled_hwnd), "wrong state for %08x\n", style);
4430
4431 ok(IsWindowEnabled(hwnd), "wrong state for %p\n", hwnd);
4432 ok(IsWindowEnabled(param->parent), "wrong state for %p\n", param->parent);
4433 if (param->grand_parent)
4434 ok(IsWindowEnabled(param->grand_parent), "wrong state for %p (%08x)\n", param->grand_parent, style);
4435
4437 ok(IsWindowEnabled(hwnd), "wrong state for %p\n", hwnd);
4438 ok(IsWindowEnabled(param->parent), "wrong state for %p\n", param->parent);
4439 if (param->grand_parent)
4440 ok(IsWindowEnabled(param->grand_parent), "wrong state for %p (%08x)\n", param->grand_parent, style);
4441
4442 param->dlg_data->style |= WS_CHILD;
4444 ok(IsWindowEnabled(hwnd), "wrong state for %p (%08x)\n", hwnd, style);
4445
4446 param->dlg_data->style |= DS_CONTROL;
4448 ok(IsWindowEnabled(hwnd), "wrong state for %p (%08x)\n", hwnd, style);
4449
4450 param->dlg_data->dwExtendedStyle |= WS_EX_CONTROLPARENT;
4453 param->dlg_data->style &= ~DS_CONTROL;
4455 ok(IsWindowEnabled(hwnd), "wrong state for %p (%08x)\n", hwnd, style);
4456
4459 ok(IsWindowEnabled(hwnd), "wrong state for %p (%08x)\n", hwnd, style);
4460
4461 param->dlg_data->style |= DS_CONTROL;
4463 ok(IsWindowEnabled(hwnd), "wrong state for %p (%08x)\n", hwnd, style);
4464
4465 EndDialog(hwnd, 0);
4466 }
4467 return 0;
4468}
4469
4470static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_out, DWORD ex_style_out)
4471{
4472 struct
4473 {
4474 DLGTEMPLATE dt;
4475 WORD menu_name;
4476 WORD class_id;
4477 WORD class_atom;
4478 WCHAR caption[1];
4479 } dlg_data;
4480 DWORD style, ex_style;
4481 HWND hwnd, grand_parent = 0, parent = 0;
4482 struct dialog_param param;
4483 LRESULT id, ret;
4484
4485 if (style_in & WS_CHILD)
4486 {
4488 0, 0, 0, 0, NULL, NULL, NULL, NULL);
4489 ok(grand_parent != 0, "grand_parent creation failed\n");
4490 }
4491
4492 parent = CreateWindowExA(0, "static", NULL, style_in,
4493 0, 0, 0, 0, grand_parent, NULL, NULL, NULL);
4494 ok(parent != 0, "parent creation failed, style %#x\n", style_in);
4495
4496 dlg_data.dt.style = style_in;
4497 dlg_data.dt.dwExtendedStyle = ex_style_in;
4498 dlg_data.dt.cdit = 0;
4499 dlg_data.dt.x = 0;
4500 dlg_data.dt.y = 0;
4501 dlg_data.dt.cx = 100;
4502 dlg_data.dt.cy = 100;
4503 dlg_data.menu_name = 0;
4504 dlg_data.class_id = 0;
4505 dlg_data.class_atom = 0;
4506 dlg_data.caption[0] = 0;
4507
4509 ok(hwnd != 0, "dialog creation failed, style %#x, exstyle %#x\n", style_in, ex_style_in);
4510
4511 id = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4512 ok(id == MAKELONG(IDOK,DC_HASDEFID), "expected (IDOK,DC_HASDEFID), got %08lx\n", id);
4513 ret = DefDlgProcA(hwnd, DM_SETDEFID, 0x1111, 0);
4514 ok(ret, "DefDlgProc(DM_SETDEFID) failed\n");
4515 id = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4516 ok(id == MAKELONG(0x1111,DC_HASDEFID), "expected (0x1111,DC_HASDEFID), got %08lx\n", id);
4517
4518 flush_events( TRUE );
4519
4521 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
4522 ok(style == (style_out | DS_3DLOOK), "got %#x\n", style);
4523 ok(ex_style == ex_style_out, "expected ex_style %#x, got %#x\n", ex_style_out, ex_style);
4524
4525 ok(IsWindowEnabled(parent), "wrong parent state (dialog style %#x)\n", style_in);
4526
4527 /* try setting the styles explicitly */
4528 SetWindowLongA(hwnd, GWL_EXSTYLE, ex_style_in);
4530 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
4531 ok(style == (style_out | DS_3DLOOK), "got %#x\n", style);
4532 /* WS_EX_WINDOWEDGE can't always be changed */
4533 if (ex_style_in & WS_EX_DLGMODALFRAME)
4534 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
4535 else if ((style & (WS_DLGFRAME | WS_THICKFRAME)) && !(ex_style_in & WS_EX_STATICEDGE))
4536 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
4537 else
4538 ex_style_out = ex_style_in & ~WS_EX_WINDOWEDGE;
4539 ok(ex_style == ex_style_out, "expected ex_style %#x, got %#x\n", ex_style_out, ex_style);
4540
4541 SetWindowLongA(hwnd, GWL_STYLE, style_in);
4543 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
4544 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
4545 if ((style_in & (WS_CHILD | WS_POPUP)) == WS_CHILD) style_out = style_in;
4546 else style_out = style_in | WS_CLIPSIBLINGS;
4547 ok(style == style_out, "expected style %#x, got %#x\n", style_out, style);
4548 /* WS_EX_WINDOWEDGE can't always be changed */
4549 if (ex_style_in & WS_EX_DLGMODALFRAME)
4550 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
4551 else if ((style & (WS_DLGFRAME | WS_THICKFRAME)) && !(ex_style_in & WS_EX_STATICEDGE))
4552 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
4553 else
4554 ex_style_out = ex_style_in & ~WS_EX_WINDOWEDGE;
4555 /* FIXME: Remove the condition below once Wine is fixed */
4556 todo_wine_if (ex_style != ex_style_out)
4557 ok(ex_style == ex_style_out, "expected ex_style %#x, got %#x\n", ex_style_out, ex_style);
4558
4560
4561 param.parent = parent;
4562 param.grand_parent = grand_parent;
4563 param.dlg_data = &dlg_data.dt;
4565
4566 ok(IsWindowEnabled(parent), "wrong parent state (dialog style %#x)\n", style_in);
4567 if (grand_parent)
4568 ok(IsWindowEnabled(grand_parent), "wrong grand parent state (dialog style %#x)\n", style_in);
4569
4572}
4573
4574static void test_dialog_styles(void)
4575{
4651
4652 if (pGetLayeredWindowAttributes)
4653 {
4658 }
4659}
4660
4662{
4669};
4670
4672{
4673 if (msg == WM_INITDIALOG) {
4674 struct dlg_parent_param *param = (void*)lparam;
4675 check_parents(hwnd, param->ga_parent, param->gwl_parent, param->get_parent, param->owner,
4676 param->root ? param->root : hwnd, param->ga_root_owner ? param->ga_root_owner : hwnd);
4677
4678 ok(!IsWindowEnabled(param->gwl_parent), "parent is not disabled\n");
4679 EndDialog(hwnd, 2);
4680 ok(IsWindowEnabled(param->gwl_parent), "parent is not enabled\n");
4681 }
4682
4683 return 0;
4684}
4685
4687{
4688 if (msg == WM_INITDIALOG) {
4689 ok(!IsWindowEnabled(GetParent(hwnd)), "parent is not disabled\n");
4691 }
4692
4693 return 0;
4694}
4695
4697{
4698 if (msg == WM_INITDIALOG) {
4699 HWND new_parent = (HWND)lparam;
4701 ok(!IsWindowEnabled(owner), "owner is not disabled\n");
4703 SetParent(hwnd, new_parent);
4704 ok(GetParent(hwnd) == new_parent, "GetParent(hwnd) = %p, expected %p\n", GetParent(hwnd), new_parent);
4705 PostMessageA(hwnd, WM_QUIT, 0, 0);
4706 }
4707
4708 return 0;
4709}
4710
4712{
4713 if (msg == WM_ENTERIDLE) {
4716 /* EndDialog will enable owner */
4718 EndDialog(dialog, 2);
4719 ok(IsWindowEnabled(owner), "owner is not enabled\n");
4720 /* ...but it won't be enabled on dialog exit */
4722 }
4723 return DefWindowProcA( hwnd, msg, wparam, lparam );
4724}
4725
4727{
4728 if (msg == WM_ENTERIDLE) {
4730 PostMessageA(dialog, WM_QUIT, 0, 0);
4731 }
4732 return DefWindowProcA( hwnd, msg, wparam, lparam );
4733}
4734
4736{
4737 if (msg == WM_ENTERIDLE) {
4740 }
4741 return DefWindowProcA( hwnd, msg, wparam, lparam );
4742}
4743
4744static void test_dialog_parent(void)
4745{
4746 HWND dialog, parent, child, child2, other, desktop = GetDesktopWindow();
4747 struct dlg_parent_param param;
4748 INT_PTR ret;
4749 struct
4750 {
4751 DLGTEMPLATE dt;
4752 WORD menu_name;
4753 WORD class_id;
4754 WORD class_atom;
4755 WCHAR caption[1];
4756 } dlg_data;
4757
4758 dlg_data.dt.dwExtendedStyle = 0;
4759 dlg_data.dt.cdit = 0;
4760 dlg_data.dt.x = 0;
4761 dlg_data.dt.y = 0;
4762 dlg_data.dt.cx = 100;
4763 dlg_data.dt.cy = 100;
4764 dlg_data.menu_name = 0;
4765 dlg_data.class_id = 0;
4766 dlg_data.class_atom = 0;
4767 dlg_data.caption[0] = 0;
4768
4769 parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
4770 /* Create a child without WS_CHILD flag. It's a valid owner window. */
4771 child = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
4773 /* Regular child. If passed as an owner, its parent will be true owner window. */
4774 child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, NULL, NULL, NULL);
4775
4776 trace("parent %p child %p child2 %p desktop %p\n", parent, child, child2, desktop);
4777
4778 /* When dialog is created with WS_CHILD style, its parent depends on function used to create it. */
4779 dlg_data.dt.style = WS_CHILD;
4780
4781 /* CreateDialogIndirectParam uses passed parent as dialog parent. */
4783 ok(dialog != 0, "dialog creation failed\n");
4784 check_parents(dialog, child2, child2, child2, NULL, parent, child);
4785
4786 ok(IsWindowEnabled(child2), "child2 is disabled\n");
4787 EnableWindow(child2, FALSE);
4788 EndDialog(dialog, 0);
4789 ok(IsWindowEnabled(child2), "child2 is not enabled\n");
4791
4792 /* DialogBoxIndirectParam uses the first parent of passed owner that's not a child window as dialog
4793 * parent (like in case of dialog with owner). */
4794 param.ga_parent = param.gwl_parent = param.get_parent = child;
4795 param.owner = NULL;
4796 param.root = parent;
4797 param.ga_root_owner = child;
4799 ok(ret == 2, "DialogBoxIndirectParam returned %ld\n", ret);
4800
4801 /* Dialogs without WS_CHILD behave as expected, they use passed owner just like CreateWindow does. */
4802 dlg_data.dt.style = WS_OVERLAPPEDWINDOW;
4803
4805 ok(dialog != 0, "dialog creation failed\n");
4807
4808 ok(IsWindowEnabled(child), "child is disabled\n");
4810 EndDialog(dialog, 0);
4811 ok(IsWindowEnabled(child), "child is not enabled\n");
4813
4814 param.ga_parent = desktop;
4815 param.gwl_parent = child;
4816 param.get_parent = NULL;
4817 param.owner = child;
4818 param.root = param.ga_root_owner = NULL;
4820 ok(ret == 2, "DialogBoxIndirectParam returned %ld\n", ret);
4821
4822 other = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
4824
4825 /* When dialog is created with WS_CHILD|WS_POPUP style, we have an owner. */
4826 dlg_data.dt.style = WS_CHILD|WS_POPUP;
4827
4829 ok(dialog != 0, "dialog creation failed\n");
4831
4832 ok(IsWindowEnabled(child), "child is disabled\n");
4834 EndDialog(dialog, 0);
4835 ok(IsWindowEnabled(child), "child is not enabled\n");
4837
4838 param.ga_parent = desktop;
4839 param.gwl_parent = param.get_parent = child;
4840 param.owner = child;
4841 param.root = NULL;
4842 param.ga_root_owner = child;
4844 ok(ret == 2, "DialogBoxIndirectParam returned %ld\n", ret);
4845
4846 /* If we change parent in WM_INITDIALOG for WS_CHILD dialog WM_ENTERIDLE is still sent to the original
4847 * parent. EndDialog will enable the new parent. */
4850 dlg_data.dt.style = WS_CHILD;
4852 ok(ret == 2, "DialogBoxIndirectParam returned %ld\n", ret);
4853 ok(!IsWindowEnabled(other), "other is not disabled\n");
4854 ok(!IsWindowEnabled(child), "child is not disabled\n");
4855 ok(IsWindowEnabled(child2), "child2 is not enabled\n");
4857
4858 /* If we change parent and style in WM_INITDIALOG for dialog with an owner to make it true child
4859 * (thus GetParent() will return the new parent instead of an owner), WM_ENTERIDLE is still sent
4860 * to the original parent. EndDialog will enable the new parent. */
4862 dlg_data.dt.style = WS_OVERLAPPED;
4864 ok(ret == 1, "DialogBoxIndirectParam returned %ld\n", ret);
4865 ok(!IsWindowEnabled(other), "other is not disabled\n");
4866 ok(!IsWindowEnabled(child), "child is not disabled\n");
4867 ok(IsWindowEnabled(child2), "child2 is not enabled\n");
4870
4871 /* Quit dialog message loop by sending WM_QUIT message. Dialog owner is not enabled. */
4874 ok(ret == 1, "DialogBoxIndirectParam returned %ld\n", ret);
4875 ok(!IsWindowEnabled(other), "other is enabled\n");
4877
4878 /* Quit dialog message loop by destroying the window. Dialog owner is not enabled. */
4881 ok(ret == 1, "DialogBoxIndirectParam returned %ld\n", ret);
4882 ok(!IsWindowEnabled(other), "other is enabled\n");
4884
4886}
4887
4889{
4890 HDC hdc;
4891 RECT rc, rc2, rc3;
4892 COLORREF colr;
4893
4896 flush_events( TRUE );
4897 GetClientRect( hwnd, &rc);
4898 hdc = GetDC( hwnd);
4899 /* test ScrollWindow(Ex) with no clip rectangle */
4900 /* paint the lower half of the window black */
4901 rc2 = rc;
4902 rc2.top = ( rc2.top + rc2.bottom) / 2;
4904 /* paint the upper half of the window white */
4905 rc2.bottom = rc2.top;
4906 rc2.top =0;
4908 /* scroll lower half up */
4909 rc2 = rc;
4910 rc2.top = ( rc2.top + rc2.bottom) / 2;
4911 ScrollWindowEx( hwnd, 0, - rc2.top, &rc2, NULL, NULL, NULL, SW_ERASE);
4913 /* expected: black should have scrolled to the upper half */
4914 colr = GetPixel( hdc, (rc2.left+rc2.right)/ 2, rc2.bottom / 4 );
4915 ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
4916 /* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
4917 /* paint the lower half of the window black */
4918 rc2 = rc;
4919 rc2.top = ( rc2.top + rc2.bottom) / 2;
4921 /* paint the upper half of the window white */
4922 rc2.bottom = rc2.top;
4923 rc2.top =0;
4925 /* scroll lower half up */
4926 rc2 = rc;
4927 rc2.top = ( rc2.top + rc2.bottom) / 2;
4928 rc3 = rc;
4929 rc3.left = rc3.right / 4;
4930 rc3.right -= rc3.right / 4;
4931 ScrollWindowEx( hwnd, 0, - rc2.top, &rc2, &rc3, NULL, NULL, SW_ERASE);
4933 /* expected: black should have scrolled to the upper half */
4934 colr = GetPixel( hdc, (rc2.left+rc2.right)/ 2, rc2.bottom / 4 );
4935 ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
4936
4937 /* clean up */
4938 ReleaseDC( hwnd, hdc);
4939}
4940
4942{
4943 HDC hdc;
4944 HRGN hrgn=CreateRectRgn(0,0,0,0);
4945 HRGN exprgn, tmprgn, clipping;
4946 RECT rc, rcu, cliprc;
4947 /* create two overlapping child windows. The visual region
4948 * of hwnd1 is clipped by the overlapping part of
4949 * hwnd2 because of the WS_CLIPSIBLING style */
4950 HWND hwnd1, hwnd2;
4951
4952 clipping = CreateRectRgn(0,0,0,0);
4953 tmprgn = CreateRectRgn(0,0,0,0);
4954 exprgn = CreateRectRgn(0,0,0,0);
4955 hwnd2 = CreateWindowExA(0, "static", NULL,
4957 75, 30, 100, 100, parent, 0, 0, NULL);
4958 hwnd1 = CreateWindowExA(0, "static", NULL,
4960 25, 50, 100, 100, parent, 0, 0, NULL);
4963 GetClientRect( hwnd1, &rc);
4964 cliprc=rc;
4965 SetRectRgn( clipping, 10, 10, 90, 90);
4966 hdc = GetDC( hwnd1);
4967 /* for a visual touch */
4968 TextOutA( hdc, 0,10, "0123456789", 10);
4969 ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu);
4971 /* create a region with what is expected */
4972 SetRectRgn( exprgn, 39,0,49,74);
4973 SetRectRgn( tmprgn, 88,79,98,93);
4974 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
4975 SetRectRgn( tmprgn, 0,93,98,98);
4976 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
4977 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
4978 trace("update rect is %s\n", wine_dbgstr_rect(&rcu));
4979 /* now with clipping region */
4980 SelectClipRgn( hdc, clipping);
4981 ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu);
4983 /* create a region with what is expected */
4984 SetRectRgn( exprgn, 39,10,49,74);
4985 SetRectRgn( tmprgn, 80,79,90,85);
4986 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
4987 SetRectRgn( tmprgn, 10,85,90,90);
4988 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
4989 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
4990 trace("update rect is %s\n", wine_dbgstr_rect(&rcu));
4991 ReleaseDC( hwnd1, hdc);
4992
4993 /* test scrolling a rect by more than its size */
4994 DestroyWindow( hwnd2);
4995 ValidateRect( hwnd1, NULL);
4996 SetRect( &rc, 40,40, 50,50);
4997 InvalidateRect( hwnd1, &rc, 1);
4998 ScrollWindowEx( hwnd1, -20, 0, &rc, NULL, hrgn, &rcu,
5001 SetRectRgn( exprgn, 20, 40, 30, 50);
5002 SetRectRgn( tmprgn, 40, 40, 50, 50);
5003 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5004 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5005 ok( rcu.left == 20 && rcu.top == 40 && rcu.right == 50 && rcu.bottom == 50,
5006 "unexpected update rect: %s\n", wine_dbgstr_rect(&rcu));
5007
5008 /* test scrolling a window with an update region */
5009 ValidateRect( hwnd1, NULL);
5010 SetRect( &rc, 40,40, 50,50);
5011 InvalidateRect( hwnd1, &rc, 1);
5012 GetClientRect( hwnd1, &rc);
5013 cliprc=rc;
5014 ScrollWindowEx( hwnd1, -10, 0, &rc, &cliprc, hrgn, &rcu,
5017 SetRectRgn( exprgn, 88,0,98,98);
5018 SetRectRgn( tmprgn, 30, 40, 50, 50);
5019 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5020 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5021
5022 /* clear an update region */
5023 UpdateWindow( hwnd1 );
5024
5025 SetRect( &rc, 0,40, 100,60);
5026 SetRect( &cliprc, 0,0, 100,100);
5027 ScrollWindowEx( hwnd1, 0, -25, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
5028 if (winetest_debug > 0) dump_region( hrgn );
5029 SetRectRgn( exprgn, 0, 40, 98, 60 );
5030 ok( EqualRgn( exprgn, hrgn), "wrong update region in excessive scroll\n");
5031
5032 /* now test ScrollWindowEx with a combination of
5033 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
5034 /* make hwnd2 the child of hwnd1 */
5035 hwnd2 = CreateWindowExA(0, "static", NULL,
5037 50, 50, 100, 100, hwnd1, 0, 0, NULL);
5039 GetClientRect( hwnd1, &rc);
5040 cliprc=rc;
5041
5042 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
5044 ValidateRect( hwnd1, NULL);
5045 ValidateRect( hwnd2, NULL);
5046 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu,
5049 SetRectRgn( exprgn, 88,0,98,88);
5050 SetRectRgn( tmprgn, 0,88,98,98);
5051 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5052 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5053
5054 /* SW_SCROLLCHILDREN */
5056 ValidateRect( hwnd1, NULL);
5057 ValidateRect( hwnd2, NULL);
5058 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_SCROLLCHILDREN | SW_INVALIDATE);
5060 /* expected region is the same as in previous test */
5061 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5062
5063 /* no SW_SCROLLCHILDREN */
5065 ValidateRect( hwnd1, NULL);
5066 ValidateRect( hwnd2, NULL);
5067 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
5069 /* expected region is the same as in previous test */
5070 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5071
5072 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
5074 ValidateRect( hwnd1, NULL);
5075 ValidateRect( hwnd2, NULL);
5076 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
5078 SetRectRgn( exprgn, 88,0,98,20);
5079 SetRectRgn( tmprgn, 20,20,98,30);
5080 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5081 SetRectRgn( tmprgn, 20,30,30,88);
5082 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5083 SetRectRgn( tmprgn, 0,88,30,98);
5084 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5085 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5086
5087 /* clean up */
5089 DeleteObject( exprgn);
5090 DeleteObject( tmprgn);
5091 DestroyWindow( hwnd1);
5092 DestroyWindow( hwnd2);
5093}
5094
5095/* couple of tests of return values of scrollbar functions
5096 * called on a scrollbarless window */
5097static void test_scroll(void)
5098{
5099 BOOL ret;
5100 INT min, max;
5101 SCROLLINFO si;
5102 HWND hwnd = CreateWindowExA(0, "Static", "Wine test window",
5104 100, 100, 200, 200, 0, 0, 0, NULL);
5105 /* horizontal */
5107 if (!ret) /* win9x */
5108 {
5109 win_skip( "GetScrollRange doesn't work\n" );
5111 return;
5112 }
5113 ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
5114 ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
5115 si.cbSize = sizeof( si);
5116 si.fMask = SIF_PAGE;
5117 si.nPage = 0xdeadbeef;
5118 ret = GetScrollInfo( hwnd, SB_HORZ, &si);
5119 ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
5120 ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
5121 /* vertical */
5123 ok( ret, "GetScrollRange returns FALSE\n");
5124 ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
5125 ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
5126 si.cbSize = sizeof( si);
5127 si.fMask = SIF_PAGE;
5128 si.nPage = 0xdeadbeef;
5129 ret = GetScrollInfo( hwnd, SB_VERT, &si);
5130 ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
5131 ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
5132 /* clean up */
5134}
5135
5137{
5138 HDC hdc;
5139 HRGN exprgn, tmprgn, hrgn;
5140 RECT rc, rc2, rcu, cliprc;
5141 HWND hwnd1;
5142 COLORREF colr;
5143
5144 hrgn = CreateRectRgn(0,0,0,0);
5145 tmprgn = CreateRectRgn(0,0,0,0);
5146 exprgn = CreateRectRgn(0,0,0,0);
5147
5148 hwnd1 = CreateWindowExA(0, "static", NULL,
5150 25, 50, 100, 100, parent, 0, 0, NULL);
5153 flush_events( TRUE );
5154 GetClientRect( hwnd1, &rc);
5155 hdc = GetDC( hwnd1);
5156 /* paint the upper half of the window black */
5157 rc2 = rc;
5158 rc2.bottom = ( rc.top + rc.bottom) /2;
5160 /* clip region is the lower half */
5161 cliprc=rc;
5162 cliprc.top = (rc.top + rc.bottom) /2;
5163 /* test whether scrolled pixels are properly clipped */
5164 colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1);
5165 ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
5166 /* this scroll should not cause any visible changes */
5167 ScrollDC( hdc, 5, -20, &rc, &cliprc, hrgn, &rcu);
5168 colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1);
5169 ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
5170 /* test with NULL clip rect */
5171 ScrollDC( hdc, 20, -20, &rc, NULL, hrgn, &rcu);
5172 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
5173 trace("update rect: %s\n", wine_dbgstr_rect(&rcu));
5175 SetRect(&rc2, 0, 0, 100, 100);
5176 ok(EqualRect(&rcu, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rcu),
5178
5179 SetRectRgn( exprgn, 0, 0, 20, 80);
5180 SetRectRgn( tmprgn, 0, 80, 100, 100);
5181 CombineRgn(exprgn, exprgn, tmprgn, RGN_OR);
5182 if (winetest_debug > 0) dump_region(exprgn);
5183 ok(EqualRgn(exprgn, hrgn), "wrong update region\n");
5184 /* test clip rect > scroll rect */
5186 rc2=rc;
5187 InflateRect( &rc2, -(rc.right-rc.left)/4, -(rc.bottom-rc.top)/4);
5189 ScrollDC( hdc, 10, 10, &rc2, &rc, hrgn, &rcu);
5190 SetRectRgn( exprgn, 25, 25, 75, 35);
5191 SetRectRgn( tmprgn, 25, 35, 35, 75);
5192 CombineRgn(exprgn, exprgn, tmprgn, RGN_OR);
5193 ok(EqualRgn(exprgn, hrgn), "wrong update region\n");
5194 trace("update rect: %s\n", wine_dbgstr_rect(&rcu));
5196
5197 /* clean up */
5199 DeleteObject(exprgn);
5200 DeleteObject(tmprgn);
5201 DestroyWindow(hwnd1);
5202}
5203
5204static void test_params(void)
5205{
5206 HWND hwnd;
5207 INT rc;
5208
5209 ok(!IsWindow(0), "IsWindow(0)\n");
5210 ok(!IsWindow(HWND_BROADCAST), "IsWindow(HWND_BROADCAST)\n");
5211 ok(!IsWindow(HWND_TOPMOST), "IsWindow(HWND_TOPMOST)\n");
5212
5213 /* Just a param check */
5214 if (pGetMonitorInfoA)
5215 {
5216 SetLastError(0xdeadbeef);
5217 rc = GetWindowTextA(hwndMain2, NULL, 1024);
5218 ok( rc==0, "GetWindowText: rc=%d err=%d\n",rc,GetLastError());
5219 }
5220 else
5221 {
5222 /* Skips actually on Win95 and NT4 */
5223 win_skip("Test would crash on Win95\n");
5224 }
5225
5226 SetLastError(0xdeadbeef);
5227 hwnd=CreateWindowA("LISTBOX", "TestList",
5229 0, 0, 100, 100,
5230 NULL, (HMENU)1, NULL, 0);
5231
5232 ok(!hwnd || broken(hwnd != NULL), /* w2k3 sp2 */
5233 "CreateWindow with invalid menu handle should fail\n");
5234 if (!hwnd)
5236 GetLastError() == 0xdeadbeef, /* Win9x */
5237 "wrong last error value %d\n", GetLastError());
5238}
5239
5240static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)
5241{
5242 HWND hwnd = 0;
5243
5244 hwnd = CreateWindowExA(exStyle, class, class, style,
5245 110, 100,
5246 225, 200,
5247 0,
5248 menu ? hmenu : 0,
5249 0, 0);
5250 if (!hwnd) {
5251 trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style, exStyle);
5252 return;
5253 }
5255
5257
5258 SetMenu(hwnd, 0);
5260}
5261
5262static BOOL AWR_init(void)
5263{
5264 WNDCLASSA class;
5265
5266 class.style = CS_HREDRAW | CS_VREDRAW;
5267 class.lpfnWndProc = DefWindowProcA;
5268 class.cbClsExtra = 0;
5269 class.cbWndExtra = 0;
5270 class.hInstance = 0;
5271 class.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
5272 class.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
5273 class.hbrBackground = 0;
5274 class.lpszMenuName = 0;
5275 class.lpszClassName = szAWRClass;
5276
5277 if (!RegisterClassA(&class)) {
5278 ok(FALSE, "RegisterClass failed\n");
5279 return FALSE;
5280 }
5281
5282 hmenu = CreateMenu();
5283 if (!hmenu)
5284 return FALSE;
5285 ok(hmenu != 0, "Failed to create menu\n");
5286 ok(AppendMenuA(hmenu, MF_STRING, 1, "Test!"), "Failed to create menu item\n");
5287
5288 return TRUE;
5289}
5290
5291
5293{
5294 static const DWORD styles[] = {
5297 };
5298 static const DWORD exStyles[] = {
5301 };
5302
5303 unsigned int i;
5304
5305 /* A exhaustive check of all the styles takes too long
5306 * so just do a (hopefully representative) sample
5307 */
5308 for (i = 0; i < COUNTOF(styles); ++i)
5309 test_AWRwindow(szAWRClass, styles[i], 0, menu);
5310 for (i = 0; i < COUNTOF(exStyles); ++i) {
5311 test_AWRwindow(szAWRClass, WS_POPUP, exStyles[i], menu);
5312 test_AWRwindow(szAWRClass, WS_THICKFRAME, exStyles[i], menu);
5313 }
5314}
5315
5316static void test_AWR_flags(void)
5317{
5318 static const DWORD styles[] = { WS_POPUP, WS_BORDER, WS_DLGFRAME, WS_THICKFRAME };
5319 static const DWORD exStyles[] = { WS_EX_CLIENTEDGE, WS_EX_TOOLWINDOW, WS_EX_WINDOWEDGE,
5321
5322 DWORD i, j, k, style, exstyle;
5323 RECT rect, rect2;
5324
5325 for (i = 0; i < (1 << COUNTOF(styles)); i++)
5326 {
5327 for (k = style = 0; k < COUNTOF(styles); k++) if (i & (1 << k)) style |= styles[k];
5328
5329 for (j = 0; j < (1 << COUNTOF(exStyles)); j++)
5330 {
5331 for (k = exstyle = 0; k < COUNTOF(exStyles); k++) if (j & (1 << k)) exstyle |= exStyles[k];
5332 SetRect( &rect, 100, 100, 200, 200 );
5333 rect2 = rect;
5334 AdjustWindowRectEx( &rect, style, FALSE, exstyle );
5336 ok( EqualRect( &rect, &rect2 ), "rects do not match: win %s wine %s\n",
5338 }
5339 }
5340}
5341#undef COUNTOF
5342
5343#define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
5344
5345static void test_AdjustWindowRect(void)
5346{
5347 if (!AWR_init())
5348 return;
5349
5363
5367
5369}
5370#undef SHOWSYSMETRIC
5371
5372
5373/* Global variables to trigger exit from loop */
5375
5377{
5378 switch (msg)
5379 {
5380 case WM_PAINT:
5381 trace("doing WM_PAINT %d\n", WMPAINT_count);
5382 WMPAINT_count++;
5383 if (WMPAINT_count > 10 && redrawComplete == 0) {
5384 PAINTSTRUCT ps;
5385 BeginPaint(hwnd, &ps);
5386 EndPaint(hwnd, &ps);
5387 return 1;
5388 }
5389 return 0;
5390 }
5391 return DefWindowProcA(hwnd, msg, wparam, lparam);
5392}
5393
5394/* Ensure we exit from RedrawNow regardless of invalidated area */
5395static void test_redrawnow(void)
5396{
5397 WNDCLASSA cls;
5398 HWND hwndMain;
5399
5400 cls.style = CS_DBLCLKS;
5402 cls.cbClsExtra = 0;
5403 cls.cbWndExtra = 0;
5404 cls.hInstance = GetModuleHandleA(0);
5405 cls.hIcon = 0;
5408 cls.lpszMenuName = NULL;
5409 cls.lpszClassName = "RedrawWindowClass";
5410
5411 if(!RegisterClassA(&cls)) {
5412 trace("Register failed %d\n", GetLastError());
5413 return;
5414 }
5415
5416 hwndMain = CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW,
5417 CW_USEDEFAULT, 0, 100, 100, NULL, NULL, 0, NULL);
5418
5419 ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
5421 ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
5423 ok( WMPAINT_count == 1 || broken(WMPAINT_count == 0), /* sometimes on win9x */
5424 "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
5426 ok( WMPAINT_count < 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count);
5427
5428 /* clean up */
5430}
5431
5436};
5437
5442};
5443
5445{
5446 RECT rc;
5447 PAINTSTRUCT ps;
5448
5450
5451 switch (msg)
5452 {
5453 case WM_PAINT:
5454 GetClientRect(hwnd, &rc);
5455 t->client = rc;
5456 GetWindowRect(hwnd, &rc);
5457 trace("WM_PAINT: hwnd %p, client rect %s, window rect %s\n", hwnd,
5458 wine_dbgstr_rect(&t->client), wine_dbgstr_rect(&rc));
5459 BeginPaint(hwnd, &ps);
5460 t->paint = ps.rcPaint;
5461 GetClipBox(ps.hdc, &rc);
5462 t->clip = rc;
5463 trace("clip rect %s, paint rect %s\n", wine_dbgstr_rect(&rc),
5465 EndPaint(hwnd, &ps);
5466 return 0;
5467 }
5468 return DefWindowProcA(hwnd, msg, wparam, lparam);
5469}
5470
5472{
5473 SetRectEmpty(&t->client);
5474 SetRectEmpty(&t->clip);
5475 SetRectEmpty(&t->paint);
5476}
5477
5479{
5480 zero_parentdc_stat(&t->main);
5481 zero_parentdc_stat(&t->child1);
5482 zero_parentdc_stat(&t->child2);
5483}
5484
5485#define parentdc_field_ok(t, w, r, f, got) \
5486 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
5487 ": expected %d, got %d\n", \
5488 t.w.r.f, got.w.r.f)
5489
5490#define parentdc_todo_field_ok(t, w, r, f, got) \
5491 todo_wine_if (t.w##_todo.r.f) \
5492 parentdc_field_ok(t, w, r, f, got);
5493
5494#define parentdc_rect_ok(t, w, r, got) \
5495 parentdc_todo_field_ok(t, w, r, left, got); \
5496 parentdc_todo_field_ok(t, w, r, top, got); \
5497 parentdc_todo_field_ok(t, w, r, right, got); \
5498 parentdc_todo_field_ok(t, w, r, bottom, got);
5499
5500#define parentdc_win_ok(t, w, got) \
5501 parentdc_rect_ok(t, w, client, got); \
5502 parentdc_rect_ok(t, w, clip, got); \
5503 parentdc_rect_ok(t, w, paint, got);
5504
5505#define parentdc_ok(t, got) \
5506 parentdc_win_ok(t, main, got); \
5507 parentdc_win_ok(t, child1, got); \
5508 parentdc_win_ok(t, child2, got);
5509
5510static void test_csparentdc(void)
5511{
5512 WNDCLASSA clsMain, cls;
5513 HWND hwndMain, hwnd1, hwnd2;
5514 RECT rc;
5515
5516 struct parentdc_test test_answer;
5517
5518#define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
5519 const struct parentdc_test test1 =
5520 {
5521 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo,
5522 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5523 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5524 };
5525
5526 const struct parentdc_test test2 =
5527 {
5528 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo,
5529 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
5530 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
5531 };
5532
5533 const struct parentdc_test test3 =
5534 {
5535 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
5536 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
5537 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
5538 };
5539
5540 const struct parentdc_test test4 =
5541 {
5542 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo,
5543 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo,
5544 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
5545 };
5546
5547 const struct parentdc_test test5 =
5548 {
5549 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo,
5550 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5551 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
5552 };
5553
5554 const struct parentdc_test test6 =
5555 {
5556 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
5557 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
5558 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
5559 };
5560
5561 const struct parentdc_test test7 =
5562 {
5563 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
5564 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5565 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
5566 };
5567#undef nothing_todo
5568
5569 clsMain.style = CS_DBLCLKS;
5571 clsMain.cbClsExtra = 0;
5572 clsMain.cbWndExtra = 0;
5573 clsMain.hInstance = GetModuleHandleA(0);
5574 clsMain.hIcon = 0;
5575 clsMain.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
5577 clsMain.lpszMenuName = NULL;
5578 clsMain.lpszClassName = "ParentDcMainWindowClass";
5579
5580 if(!RegisterClassA(&clsMain)) {
5581 trace("Register failed %d\n", GetLastError());
5582 return;
5583 }
5584
5587 cls.cbClsExtra = 0;
5588 cls.cbWndExtra = 0;
5589 cls.hInstance = GetModuleHandleA(0);
5590 cls.hIcon = 0;
5593 cls.lpszMenuName = NULL;
5594 cls.lpszClassName = "ParentDcWindowClass";
5595
5596 if(!RegisterClassA(&cls)) {
5597 trace("Register failed %d\n", GetLastError());
5598 return;
5599 }
5600
5601 SetRect(&rc, 0, 0, 150, 150);
5603 hwndMain = CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW,
5604 CW_USEDEFAULT, 0, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, 0, NULL);
5605 SetWindowLongPtrA(hwndMain, GWLP_USERDATA, (DWORD_PTR)&test_answer.main);
5606 hwnd1 = CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD,
5607 20, 20, 40, 40, hwndMain, NULL, 0, NULL);
5608 SetWindowLongPtrA(hwnd1, GWLP_USERDATA, (DWORD_PTR)&test_answer.child1);
5609 hwnd2 = CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD,
5610 40, 40, 40, 40, hwndMain, NULL, 0, NULL);
5611 SetWindowLongPtrA(hwnd2, GWLP_USERDATA, (DWORD_PTR)&test_answer.child2);
5613 ShowWindow(hwnd1, SW_SHOW);
5614 ShowWindow(hwnd2, SW_SHOW);
5616 flush_events( TRUE );
5617
5618 zero_parentdc_test(&test_answer);
5620 flush_events( TRUE );
5621 parentdc_ok(test1, test_answer);
5622
5623 zero_parentdc_test(&test_answer);
5624 SetRect(&rc, 0, 0, 50, 50);
5626 flush_events( TRUE );
5627 parentdc_ok(test2, test_answer);
5628
5629 zero_parentdc_test(&test_answer);
5630 SetRect(&rc, 0, 0, 10, 10);
5632 flush_events( TRUE );
5633 parentdc_ok(test3, test_answer);
5634
5635 zero_parentdc_test(&test_answer);
5636 SetRect(&rc, 40, 40, 50, 50);
5638 flush_events( TRUE );
5639 parentdc_ok(test4, test_answer);
5640
5641 zero_parentdc_test(&test_answer);
5642 SetRect(&rc, 20, 20, 60, 60);
5644 flush_events( TRUE );
5645 parentdc_ok(test5, test_answer);
5646
5647 zero_parentdc_test(&test_answer);
5648 SetRect(&rc, 0, 0, 10, 10);
5649 InvalidateRect(hwnd1, &rc, TRUE);
5650 flush_events( TRUE );
5651 parentdc_ok(test6, test_answer);
5652
5653 zero_parentdc_test(&test_answer);
5654 SetRect(&rc, -5, -5, 65, 65);
5655 InvalidateRect(hwnd1, &rc, TRUE);
5656 flush_events( TRUE );
5657 parentdc_ok(test7, test_answer);
5658
5660 DestroyWindow(hwnd1);
5661 DestroyWindow(hwnd2);
5662}
5663
5665{
5666 return DefWindowProcA(hwnd, msg, wparam, lparam);
5667}
5668
5670{
5671 return DefWindowProcW(hwnd, msg, wparam, lparam);
5672}
5673
5674static void test_IsWindowUnicode(void)
5675{
5676 static const char ansi_class_nameA[] = "ansi class name";
5677 static const WCHAR ansi_class_nameW[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
5678 static const char unicode_class_nameA[] = "unicode class name";
5679 static const WCHAR unicode_class_nameW[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
5680 WNDCLASSA classA;
5682 HWND hwnd;
5683 ATOM atom;
5684
5685 memset(&classW, 0, sizeof(classW));
5686 classW.hInstance = GetModuleHandleA(0);
5687 classW.lpfnWndProc = def_window_procW;
5688 classW.lpszClassName = unicode_class_nameW;
5689 if (!RegisterClassW(&classW)) return; /* this catches Win9x as well */
5690
5691 memset(&classA, 0, sizeof(classA));
5692 classA.hInstance = GetModuleHandleA(0);
5694 classA.lpszClassName = ansi_class_nameA;
5695 atom = RegisterClassA(&classA);
5696 assert(atom);
5697
5698 /* unicode class: window proc */
5699 hwnd = CreateWindowExW(0, unicode_class_nameW, NULL, WS_POPUP,
5700 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5701 assert(hwnd);
5702
5703 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5705 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5707 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5708
5710
5711 hwnd = CreateWindowExA(0, unicode_class_nameA, NULL, WS_POPUP,
5712 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5713 assert(hwnd);
5714
5715 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5717 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5719 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5720
5722
5723 /* ansi class: window proc */
5724 hwnd = CreateWindowExW(0, ansi_class_nameW, NULL, WS_POPUP,
5725 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5726 assert(hwnd);
5727
5728 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5730 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5732 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5733
5735
5736 hwnd = CreateWindowExA(0, ansi_class_nameA, NULL, WS_POPUP,
5737 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5738 assert(hwnd);
5739
5740 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5742 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5744 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5745
5747
5748 /* unicode class: class proc */
5749 hwnd = CreateWindowExW(0, unicode_class_nameW, NULL, WS_POPUP,
5750 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5751 assert(hwnd);
5752
5753 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5755 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5756 /* do not restore class window proc back to unicode */
5757
5759
5760 hwnd = CreateWindowExA(0, unicode_class_nameA, NULL, WS_POPUP,
5761 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5762 assert(hwnd);
5763
5764 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5766 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5767
5769
5770 /* ansi class: class proc */
5771 hwnd = CreateWindowExW(0, ansi_class_nameW, NULL, WS_POPUP,
5772 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5773 assert(hwnd);
5774
5775 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5777 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
5778 /* do not restore class window proc back to ansi */
5779
5781
5782 hwnd = CreateWindowExA(0, ansi_class_nameA, NULL, WS_POPUP,
5783 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
5784 assert(hwnd);
5785
5786 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5788 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
5789
5791}
5792
5794{
5795 MINMAXINFO *minmax;
5796
5797 if (msg != WM_GETMINMAXINFO)
5798 return DefWindowProcA(hwnd, msg, wp, lp);
5799
5800 minmax = (MINMAXINFO *)lp;
5801
5803 {
5804 minmax->ptReserved.x = 0;
5805 minmax->ptReserved.y = 0;
5806 minmax->ptMaxSize.x = 400;
5807 minmax->ptMaxSize.y = 400;
5808 minmax->ptMaxPosition.x = 300;
5809 minmax->ptMaxPosition.y = 300;
5810 minmax->ptMaxTrackSize.x = 200;
5811 minmax->ptMaxTrackSize.y = 200;
5812 minmax->ptMinTrackSize.x = 100;
5813 minmax->ptMinTrackSize.y = 100;
5814 }
5815 else
5816 DefWindowProcA(hwnd, msg, wp, lp);
5817 return 1;
5818}
5819
5822
5824{
5825 switch(msg)
5826 {
5827 case WM_GETMINMAXINFO:
5828 {
5829 RECT rect;
5830 GetWindowRect( hwnd, &rect );
5831 ok( !rect.left && !rect.top && !rect.right && !rect.bottom, "wrong rect %s\n",
5833 return DefWindowProcA(hwnd, msg, wp, lp);
5834 }
5835 case WM_NCCREATE:
5836 case WM_CREATE:
5837 {
5839 RECT rect;
5840 GetWindowRect( hwnd, &rect );
5841 trace( "hwnd %p msg %x size %dx%d rect %s\n", hwnd, msg, cs->cx, cs->cy,
5843 ok( cs->cx == expected_cx || broken(cs->cx == (short)expected_cx),
5844 "wrong x size %d/%d\n", cs->cx, expected_cx );
5845 ok( cs->cy == expected_cy || broken(cs->cy == (short)expected_cy),
5846 "wrong y size %d/%d\n", cs->cy, expected_cy );
5847 ok( (rect.right - rect.left == expected_rect.right - expected_rect.left &&
5848 rect.bottom - rect.top == expected_rect.bottom - expected_rect.top) ||
5849 (rect.right - rect.left == min( 65535, expected_rect.right - expected_rect.left ) &&
5850 rect.bottom - rect.top == min( 65535, expected_rect.bottom - expected_rect.top )) ||
5851 broken( rect.right - rect.left == broken_rect.right - broken_rect.left &&
5852 rect.bottom - rect.top == broken_rect.bottom - broken_rect.top) ||
5853 broken( rect.right - rect.left == (short)broken_rect.right - (short)broken_rect.left &&
5854 rect.bottom - rect.top == (short)broken_rect.bottom - (short)broken_rect.top),
5855 "wrong rect %s / %s\n", wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &expected_rect ));
5856 return DefWindowProcA(hwnd, msg, wp, lp);
5857 }
5858 case WM_NCCALCSIZE:
5859 {
5860 RECT rect, *r = (RECT *)lp;
5861 GetWindowRect( hwnd, &rect );
5862 ok( EqualRect( &rect, r ), "passed rect %s doesn't match window rect %s\n",
5864 return DefWindowProcA(hwnd, msg, wp, lp);
5865 }
5866 default:
5867 return DefWindowProcA(hwnd, msg, wp, lp);
5868 }
5869}
5870
5871static void test_CreateWindow(void)
5872{
5873 WNDCLASSA cls;
5874 HWND hwnd, parent;
5875 HMENU hmenu;
5876 RECT rc, rc_minmax;
5877 MINMAXINFO minmax;
5878 BOOL res;
5879
5880#define expect_menu(window, menu) \
5881 SetLastError(0xdeadbeef); \
5882 res = (GetMenu(window) == (HMENU)menu); \
5883 ok(res, "GetMenu error %d\n", GetLastError())
5884
5885#define expect_style(window, style)\
5886 ok((ULONG)GetWindowLongA(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLongA(window, GWL_STYLE))
5887
5888#define expect_ex_style(window, ex_style)\
5889 ok((ULONG)GetWindowLongA(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLongA(window, GWL_EXSTYLE))
5890
5891#define expect_gle_broken_9x(gle)\
5892 ok(GetLastError() == gle ||\
5893 broken(GetLastError() == 0xdeadbeef),\
5894 "IsMenu set error %d\n", GetLastError())
5895
5896 hmenu = CreateMenu();
5897 assert(hmenu != 0);
5899 assert(parent != 0);
5900
5901 SetLastError(0xdeadbeef);
5902 res = IsMenu(hmenu);
5903 ok(res, "IsMenu error %d\n", GetLastError());
5904
5905 /* WS_CHILD */
5906 SetLastError(0xdeadbeef);
5908 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
5909 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5910 expect_menu(hwnd, 1);
5914
5915 SetLastError(0xdeadbeef);
5917 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
5918 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5919 expect_menu(hwnd, 1);
5923
5924 SetLastError(0xdeadbeef);
5925 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD,
5926 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
5927 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5928 expect_menu(hwnd, 1);
5932
5933 SetLastError(0xdeadbeef);
5934 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_CAPTION,
5935 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
5936 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5937 expect_menu(hwnd, 1);
5941
5942 /* WS_POPUP */
5943 SetLastError(0xdeadbeef);
5945 0, 0, 100, 100, parent, hmenu, 0, NULL);
5946 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5951 SetLastError(0xdeadbeef);
5952 ok(!IsMenu(hmenu), "IsMenu should fail\n");
5954
5955 hmenu = CreateMenu();
5956 assert(hmenu != 0);
5957 SetLastError(0xdeadbeef);
5959 0, 0, 100, 100, parent, hmenu, 0, NULL);
5960 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5965 SetLastError(0xdeadbeef);
5966 ok(!IsMenu(hmenu), "IsMenu should fail\n");
5968
5969 hmenu = CreateMenu();
5970 assert(hmenu != 0);
5971 SetLastError(0xdeadbeef);
5972 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
5973 0, 0, 100, 100, parent, hmenu, 0, NULL);
5974 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5979 SetLastError(0xdeadbeef);
5980 ok(!IsMenu(hmenu), "IsMenu should fail\n");
5982
5983 hmenu = CreateMenu();
5984 assert(hmenu != 0);
5985 SetLastError(0xdeadbeef);
5986 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_CAPTION,
5987 0, 0, 100, 100, parent, hmenu, 0, NULL);
5988 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
5993 SetLastError(0xdeadbeef);
5994 ok(!IsMenu(hmenu), "IsMenu should fail\n");
5996
5997 /* WS_CHILD | WS_POPUP */
5998 SetLastError(0xdeadbeef);
6000 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6001 ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
6003 if (hwnd)
6005
6006 hmenu = CreateMenu();
6007 assert(hmenu != 0);
6008 SetLastError(0xdeadbeef);
6010 0, 0, 100, 100, parent, hmenu, 0, NULL);
6011 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
6016 SetLastError(0xdeadbeef);
6017 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6019
6020 SetLastError(0xdeadbeef);
6022 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6023 ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
6025 if (hwnd)
6027
6028 hmenu = CreateMenu();
6029 assert(hmenu != 0);
6030 SetLastError(0xdeadbeef);
6032 0, 0, 100, 100, parent, hmenu, 0, NULL);
6033 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
6038 SetLastError(0xdeadbeef);
6039 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6041
6042 SetLastError(0xdeadbeef);
6043 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP,
6044 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6045 ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
6047 if (hwnd)
6049
6050 hmenu = CreateMenu();
6051 assert(hmenu != 0);
6052 SetLastError(0xdeadbeef);
6053 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP,
6054 0, 0, 100, 100, parent, hmenu, 0, NULL);
6055 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
6060 SetLastError(0xdeadbeef);
6061 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6063
6064 SetLastError(0xdeadbeef);
6066 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6067 ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
6069 if (hwnd)
6071
6072 hmenu = CreateMenu();
6073 assert(hmenu != 0);
6074 SetLastError(0xdeadbeef);
6076 0, 0, 100, 100, parent, hmenu, 0, NULL);
6077 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
6082 SetLastError(0xdeadbeef);
6083 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6085
6086 /* test child window sizing */
6087 cls.style = 0;
6089 cls.cbClsExtra = 0;
6090 cls.cbWndExtra = 0;
6092 cls.hIcon = 0;
6095 cls.lpszMenuName = NULL;
6096 cls.lpszClassName = "MinMax_WndClass";
6097 RegisterClassA(&cls);
6098
6099 SetLastError(0xdeadbeef);
6100 parent = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
6101 0, 0, 100, 100, 0, 0, 0, NULL);
6102 ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
6103 expect_menu(parent, 0);
6106
6107 memset(&minmax, 0, sizeof(minmax));
6109 SetRect(&rc_minmax, 0, 0, minmax.ptMaxSize.x, minmax.ptMaxSize.y);
6110 ok(IsRectEmpty(&rc_minmax), "ptMaxSize is not empty\n");
6111 SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
6112 ok(IsRectEmpty(&rc_minmax), "ptMaxTrackSize is not empty\n");
6113
6114 GetWindowRect(parent, &rc);
6115 ok(!IsRectEmpty(&rc), "parent window rect is empty\n");
6116 GetClientRect(parent, &rc);
6117 ok(!IsRectEmpty(&rc), "parent client rect is empty\n");
6118
6119 InflateRect(&rc, 200, 200);
6120 trace("creating child with rect %s\n", wine_dbgstr_rect(&rc));
6121
6122 SetLastError(0xdeadbeef);
6123 hwnd = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
6124 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
6125 parent, (HMENU)1, 0, NULL);
6126 ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
6127 expect_menu(hwnd, 1);
6130
6131 memset(&minmax, 0, sizeof(minmax));
6133 SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
6134
6135 GetWindowRect(hwnd, &rc);
6136 OffsetRect(&rc, -rc.left, -rc.top);
6137 ok(EqualRect(&rc, &rc_minmax), "rects don't match: %s and %s\n", wine_dbgstr_rect(&rc),
6138 wine_dbgstr_rect(&rc_minmax));
6140
6142 cls.lpszClassName = "Sizes_WndClass";
6143 RegisterClassA(&cls);
6144
6145 expected_cx = expected_cy = 200000;
6146 SetRect( &expected_rect, 0, 0, 200000, 200000 );
6148 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 300000, 300000, 200000, 200000, parent, 0, 0, NULL);
6149 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6150 GetClientRect( hwnd, &rc );
6151 ok( rc.right == 200000 || rc.right == 65535 || broken(rc.right == (short)200000),
6152 "invalid rect right %u\n", rc.right );
6153 ok( rc.bottom == 200000 || rc.bottom == 65535 || broken(rc.bottom == (short)200000),
6154 "invalid rect bottom %u\n", rc.bottom );
6156
6157 expected_cx = expected_cy = -10;
6159 SetRect( &broken_rect, 0, 0, -10, -10 );
6160 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, -20, -20, -10, -10, parent, 0, 0, NULL);
6161 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6162 GetClientRect( hwnd, &rc );
6163 ok( rc.right == 0, "invalid rect right %u\n", rc.right );
6164 ok( rc.bottom == 0, "invalid rect bottom %u\n", rc.bottom );
6166
6167 expected_cx = expected_cy = -200000;
6169 SetRect( &broken_rect, 0, 0, -200000, -200000 );
6170 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, -300000, -300000, -200000, -200000, parent, 0, 0, NULL);
6171 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6172 GetClientRect( hwnd, &rc );
6173 ok( rc.right == 0, "invalid rect right %u\n", rc.right );
6174 ok( rc.bottom == 0, "invalid rect bottom %u\n", rc.bottom );
6176
6177 /* we need a parent at 0,0 so that child coordinates match */
6179 parent = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL);
6180 ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
6181
6182 expected_cx = 100;
6183 expected_cy = 0x7fffffff;
6184 SetRect( &expected_rect, 10, 10, 110, 0x7fffffff );
6185 SetRect( &broken_rect, 10, 10, 110, 0x7fffffffU + 10 );
6186 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 10, 10, 100, 0x7fffffff, parent, 0, 0, NULL);
6187 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6188 GetClientRect( hwnd, &rc );
6189 ok( rc.right == 100, "invalid rect right %u\n", rc.right );
6190 ok( rc.bottom == 0x7fffffff - 10 || rc.bottom ==65535 || broken(rc.bottom == 0),
6191 "invalid rect bottom %u\n", rc.bottom );
6193
6194 expected_cx = 0x7fffffff;
6195 expected_cy = 0x7fffffff;
6196 SetRect( &expected_rect, 20, 10, 0x7fffffff, 0x7fffffff );
6197 SetRect( &broken_rect, 20, 10, 0x7fffffffU + 20, 0x7fffffffU + 10 );
6198 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 20, 10, 0x7fffffff, 0x7fffffff, parent, 0, 0, NULL);
6199 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6200 GetClientRect( hwnd, &rc );
6201 ok( rc.right == 0x7fffffff - 20 || rc.right == 65535 || broken(rc.right == 0),
6202 "invalid rect right %u\n", rc.right );
6203 ok( rc.bottom == 0x7fffffff - 10 || rc.right == 65535 || broken(rc.bottom == 0),
6204 "invalid rect bottom %u\n", rc.bottom );
6206
6207 /* top level window */
6208 expected_cx = expected_cy = 200000;
6210 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_OVERLAPPEDWINDOW, 300000, 300000, 200000, 200000, 0, 0, 0, NULL);
6211 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6212 GetClientRect( hwnd, &rc );
6213 ok( rc.right <= expected_cx, "invalid rect right %u\n", rc.right );
6214 ok( rc.bottom <= expected_cy, "invalid rect bottom %u\n", rc.bottom );
6216
6217 if (pGetLayout && pSetLayout)
6218 {
6219 HDC hdc = GetDC( parent );
6220 pSetLayout( hdc, LAYOUT_RTL );
6221 if (pGetLayout( hdc ))
6222 {
6223 ReleaseDC( parent, hdc );
6225 SetLastError( 0xdeadbeef );
6227 0, 0, 100, 100, 0, 0, 0, NULL);
6228 ok( parent != 0, "creation failed err %u\n", GetLastError());
6230 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL);
6231 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6234 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 20, 20, parent, 0, 0, NULL);
6235 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6236 expect_ex_style( hwnd, 0 );
6239 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL);
6240 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6241 expect_ex_style( hwnd, 0 );
6243
6244 if (pGetProcessDefaultLayout && pSetProcessDefaultLayout)
6245 {
6246 DWORD layout;
6247
6248 SetLastError( 0xdeadbeef );
6249 ok( !pGetProcessDefaultLayout( NULL ), "GetProcessDefaultLayout succeeded\n" );
6250 ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
6251 SetLastError( 0xdeadbeef );
6252 res = pGetProcessDefaultLayout( &layout );
6253 ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
6254 ok( layout == 0, "GetProcessDefaultLayout wrong layout %x\n", layout );
6255 SetLastError( 0xdeadbeef );
6256 res = pSetProcessDefaultLayout( 7 );
6257 ok( res, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
6258 res = pGetProcessDefaultLayout( &layout );
6259 ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
6260 ok( layout == 7, "GetProcessDefaultLayout wrong layout %x\n", layout );
6261 SetLastError( 0xdeadbeef );
6262 res = pSetProcessDefaultLayout( LAYOUT_RTL );
6263 ok( res, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
6264 res = pGetProcessDefaultLayout( &layout );
6265 ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
6266 ok( layout == LAYOUT_RTL, "GetProcessDefaultLayout wrong layout %x\n", layout );
6268 0, 0, 100, 100, 0, 0, 0, NULL);
6269 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6273 0, 0, 100, 100, parent, 0, 0, NULL);
6274 ok( hwnd != 0, "creation failed err %u\n", GetLastError());
6277 pSetProcessDefaultLayout( 0 );
6278 }
6279 else win_skip( "SetProcessDefaultLayout not supported\n" );
6280 }
6281 else win_skip( "SetLayout not supported\n" );
6282 }
6283 else win_skip( "SetLayout not available\n" );
6284
6286
6287 UnregisterClassA("MinMax_WndClass", GetModuleHandleA(NULL));
6288 UnregisterClassA("Sizes_WndClass", GetModuleHandleA(NULL));
6289
6290#undef expect_gle_broken_9x
6291#undef expect_menu
6292#undef expect_style
6293#undef expect_ex_style
6294}
6295
6296/* function that remembers whether the system the test is running on sets the
6297 * last error for user32 functions to make the tests stricter */
6298static int check_error(DWORD actual, DWORD expected)
6299{
6300 static int sets_last_error = -1;
6301 if (sets_last_error == -1)
6302 sets_last_error = (actual != 0xdeadbeef);
6303 return (!sets_last_error && (actual == 0xdeadbeef)) || (actual == expected);
6304}
6305
6306static void test_SetWindowLong(void)
6307{
6308 LONG_PTR retval;
6309 WNDPROC old_window_procW;
6310
6311 SetLastError(0xdeadbeef);
6312 retval = SetWindowLongPtrA(NULL, GWLP_WNDPROC, 0);
6313 ok(!retval, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval);
6315 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %d\n", GetLastError());
6316
6317 SetLastError(0xdeadbeef);
6318 retval = SetWindowLongPtrA(hwndMain, 0xdeadbeef, 0);
6319 ok(!retval, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval);
6321 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %d\n", GetLastError());
6322
6323 SetLastError(0xdeadbeef);
6325 ok((WNDPROC)retval == main_window_procA || broken(!retval), /* win9x */
6326 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval);
6327 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
6329 ok((WNDPROC)retval == main_window_procA,
6330 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval);
6331 ok(!IsWindowUnicode(hwndMain), "hwndMain shouldn't be Unicode\n");
6332
6333 old_window_procW = (WNDPROC)GetWindowLongPtrW(hwndMain, GWLP_WNDPROC);
6334 SetLastError(0xdeadbeef);
6337 {
6338 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
6339 ok(retval != 0, "SetWindowLongPtr error %d\n", GetLastError());
6340 ok((WNDPROC)retval == old_window_procW,
6341 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval);
6342 ok(IsWindowUnicode(hwndMain), "hwndMain should now be Unicode\n");
6343
6344 /* set it back to ANSI */
6346 }
6347}
6348
6350{
6352 const STYLESTRUCT *got = (STYLESTRUCT *)lParam;
6353
6354 if (message == WM_STYLECHANGING && wParam == GWL_STYLE)
6355 {
6356 ok(got->styleOld == expected[0].styleOld, "expected old style %#x, got %#x\n",
6357 expected[0].styleOld, got->styleOld);
6358 ok(got->styleNew == expected[0].styleNew, "expected new style %#x, got %#x\n",
6359 expected[0].styleNew, got->styleNew);
6360 }
6361 else if (message == WM_STYLECHANGED && wParam == GWL_STYLE)
6362 {
6363 ok(got->styleOld == expected[1].styleOld, "expected old style %#x, got %#x\n",
6364 expected[1].styleOld, got->styleOld);
6365 ok(got->styleNew == expected[1].styleNew, "expected new style %#x, got %#x\n",
6366 expected[1].styleNew, got->styleNew);
6367 }
6368
6370}
6371
6372static void test_set_window_style(void)
6373{
6374 LONG expected_style, new_style, old_style;
6375 STYLESTRUCT expected_stylestruct[2];
6376 unsigned int i;
6377 WNDCLASSA cls;
6378 HWND hwnd;
6379
6380 static const struct
6381 {
6382 LONG creation_style;
6383 LONG style;
6384 }
6385 tests[] =
6386 {
6403 };
6404
6405 memset(&cls, 0, sizeof(cls));
6407 cls.hInstance = GetModuleHandleA(0);
6408 cls.lpszClassName = "TestSetWindowStylesClass";
6409 ok(RegisterClassA(&cls), "RegisterClass failed\n");
6410
6411 for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
6412 {
6413 expected_style = tests[i].style;
6414 if (tests[i].creation_style & WS_MINIMIZE)
6415 expected_style |= WS_MINIMIZE;
6416
6417 expected_stylestruct[0].styleOld = tests[i].creation_style;
6418 expected_stylestruct[0].styleNew = tests[i].style;
6419 expected_stylestruct[1].styleOld = tests[i].creation_style;
6420 expected_stylestruct[1].styleNew = expected_style;
6421
6422 hwnd = CreateWindowA(cls.lpszClassName, "Test set styles",
6423 tests[i].creation_style, 100, 100, 200, 200, 0, 0, 0, NULL);
6424 ok(hwnd != 0, "CreateWindow failed\n");
6425 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)&expected_stylestruct);
6426
6427 old_style = SetWindowLongA(hwnd, GWL_STYLE, tests[i].style);
6428 ok(old_style == tests[i].creation_style, "expected old style %#x, got %#x\n",
6429 tests[i].creation_style, old_style);
6430 new_style = GetWindowLongA(hwnd, GWL_STYLE);
6431 ok(new_style == expected_style, "expected new style %#x, got %#x\n",
6432 expected_style, new_style);
6433
6436 }
6437
6439}
6440
6441static void test_ShowWindow(void)
6442{
6443 HWND hwnd;
6444 DWORD style;
6445 RECT rcMain, rc, rcMinimized;
6446 LPARAM ret;
6447
6448 SetRect(&rcMain, 120, 120, 210, 210);
6449
6450 hwnd = CreateWindowExA(0, "MainWindowClass", NULL,
6453 rcMain.left, rcMain.top,
6454 rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
6455 0, 0, 0, NULL);
6456 assert(hwnd);
6457
6459 ok(!(style & WS_DISABLED), "window should not be disabled\n");
6460 ok(!(style & WS_VISIBLE), "window should not be visible\n");
6461 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
6462 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6463 GetWindowRect(hwnd, &rc);
6464 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
6465 wine_dbgstr_rect(&rc));
6466
6468 ok(!ret, "not expected ret: %lu\n", ret);
6470 ok(!(style & WS_DISABLED), "window should not be disabled\n");
6471 ok(style & WS_VISIBLE, "window should be visible\n");
6472 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
6473 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6474 GetWindowRect(hwnd, &rc);
6475 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
6476 wine_dbgstr_rect(&rc));
6477
6479 ok(ret, "not expected ret: %lu\n", ret);
6481 ok(!(style & WS_DISABLED), "window should not be disabled\n");
6482 ok(style & WS_VISIBLE, "window should be visible\n");
6483 ok(style & WS_MINIMIZE, "window should be minimized\n");
6484 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6485 GetWindowRect(hwnd, &rcMinimized);
6486 ok(!EqualRect(&rcMain, &rcMinimized), "rects shouldn't match\n");
6487 /* shouldn't be able to resize minimized windows */
6488 ret = SetWindowPos(hwnd, 0, 0, 0,
6489 (rcMinimized.right - rcMinimized.left) * 2,
6490 (rcMinimized.bottom - rcMinimized.top) * 2,
6492 ok(ret, "not expected ret: %lu\n", ret);
6493 GetWindowRect(hwnd, &rc);
6494 ok(EqualRect(&rc, &rcMinimized), "rects should match\n");
6495
6497 ok(ret, "not expected ret: %lu\n", ret);
6499 ok(!(style & WS_DISABLED), "window should not be disabled\n");
6500 ok(style & WS_VISIBLE, "window should be visible\n");
6501 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
6502 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6503 GetWindowRect(hwnd, &rc);
6504 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
6505 wine_dbgstr_rect(&rc));
6506
6508 ok(!ret, "not expected ret: %lu\n", ret);
6510 ok(style & WS_DISABLED, "window should be disabled\n");
6511
6513 ok(!ret, "not expected ret: %lu\n", ret);
6515 ok(style & WS_DISABLED, "window should be disabled\n");
6516 ok(style & WS_VISIBLE, "window should be visible\n");
6517 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
6518 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6519 GetWindowRect(hwnd, &rc);
6520 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
6521 wine_dbgstr_rect(&rc));
6522
6524 ok(!ret, "not expected ret: %lu\n", ret);
6526 ok(style & WS_DISABLED, "window should be disabled\n");
6527 ok(style & WS_VISIBLE, "window should be visible\n");
6528 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
6529 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6530 GetWindowRect(hwnd, &rc);
6531 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
6532 wine_dbgstr_rect(&rc));
6533
6535 ok(ret, "not expected ret: %lu\n", ret);
6537 ok(style & WS_DISABLED, "window should be disabled\n");
6538 ok(style & WS_VISIBLE, "window should be visible\n");
6539 ok(style & WS_MINIMIZE, "window should be minimized\n");
6540 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6541 GetWindowRect(hwnd, &rc);
6542 ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
6543
6545 ok(!ret, "not expected ret: %lu\n", ret);
6547 ok(style & WS_DISABLED, "window should be disabled\n");
6548 ok(style & WS_VISIBLE, "window should be visible\n");
6549 ok(style & WS_MINIMIZE, "window should be minimized\n");
6550 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6551 GetWindowRect(hwnd, &rc);
6552 ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
6553
6555 ok(ret, "not expected ret: %lu\n", ret);
6557 ok(style & WS_DISABLED, "window should be disabled\n");
6558 ok(style & WS_VISIBLE, "window should be visible\n");
6559 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
6560 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
6561 GetWindowRect(hwnd, &rc);
6562 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
6563 wine_dbgstr_rect(&rc));
6564
6566 ok(!ret, "not expected ret: %lu\n", ret);
6567 ok(IsWindow(hwnd), "window should exist\n");
6568
6570 ok(ret, "not expected ret: %lu\n", ret);
6571
6573 ok(!ret, "not expected ret: %lu\n", ret);
6574 ok(!IsWindow(hwnd), "window should not exist\n");
6575}
6576
6578{
6579 HWND hwnd = arg;
6580 char buf[32];
6581 INT buf_len;
6582
6583 /* test GetWindowTextA */
6584 num_gettext_msgs = 0;
6585 memset( buf, 0, sizeof(buf) );
6586 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
6587 ok( buf_len != 0, "expected a nonempty window text\n" );
6588 ok( !strcmp(buf, "another_caption"), "got wrong window text '%s'\n", buf );
6589 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6590
6591 return 0;
6592}
6593
6595{
6596 HWND hwnd = arg;
6597 BOOL success;
6598
6599 /* test SetWindowTextA */
6600 num_settext_msgs = 0;
6601 success = SetWindowTextA( hwnd, "thread_caption" );
6602 ok( success, "SetWindowTextA failed\n" );
6603 ok( num_settext_msgs == 1, "got %u WM_SETTEXT messages\n", num_settext_msgs );
6604
6605 return 0;
6606}
6607
6608static void test_gettext(void)
6609{
6610 DWORD tid, num_msgs;
6611 WCHAR bufW[32];
6612 HANDLE thread;
6613 BOOL success;
6614 char buf[32];
6615 INT buf_len;
6616 HWND hwnd, hwnd2;
6617 LRESULT r;
6618 MSG msg;
6619
6620 hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL );
6621 ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
6622
6623 /* test GetWindowTextA */
6624 num_gettext_msgs = 0;
6625 memset( buf, 0, sizeof(buf) );
6626 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
6627 ok( buf_len != 0, "expected a nonempty window text\n" );
6628 ok( !strcmp(buf, "caption"), "got wrong window text '%s'\n", buf );
6629 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6630
6631 /* other process window */
6632 strcpy( buf, "a" );
6633 buf_len = GetWindowTextA( GetDesktopWindow(), buf, sizeof(buf) );
6634 ok( buf_len == 0, "expected a nonempty window text\n" );
6635 ok( *buf == 0, "got wrong window text '%s'\n", buf );
6636
6637 strcpy( buf, "blah" );
6638 buf_len = GetWindowTextA( GetDesktopWindow(), buf, 0 );
6639 ok( buf_len == 0, "expected a nonempty window text\n" );
6640 ok( !strcmp(buf, "blah"), "got wrong window text '%s'\n", buf );
6641
6642 bufW[0] = 0xcc;
6643 buf_len = GetWindowTextW( GetDesktopWindow(), bufW, 0 );
6644 ok( buf_len == 0, "expected a nonempty window text\n" );
6645 ok( bufW[0] == 0xcc, "got %x\n", bufW[0] );
6646
6647 g_wm_gettext_override.enabled = TRUE;
6648
6649 num_gettext_msgs = 0;
6650 memset( buf, 0xcc, sizeof(buf) );
6652 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
6653 ok( buf_len == 0, "got %d\n", buf_len );
6654 ok( *buf == 0, "got %x\n", *buf );
6655 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6656
6657 num_gettext_msgs = 0;
6658 strcpy( buf, "blah" );
6660 buf_len = GetWindowTextA( hwnd, buf, 0 );
6661 ok( buf_len == 0, "got %d\n", buf_len );
6662 ok( !strcmp(buf, "blah"), "got %s\n", buf );
6663 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6664
6665 g_wm_gettext_override.enabled = FALSE;
6666
6667 /* same for W window */
6668 hwnd2 = CreateWindowExW( 0, mainclassW, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL );
6669 ok( hwnd2 != 0, "CreateWindowExA error %d\n", GetLastError() );
6670
6671 g_wm_gettext_override.enabled = TRUE;
6672
6673 num_gettext_msgs = 0;
6674 memset( bufW, 0xcc, sizeof(bufW) );
6675 g_wm_gettext_override.buffW = bufW;
6676 buf_len = GetWindowTextW( hwnd2, bufW, sizeof(bufW)/sizeof(WCHAR) );
6677 ok( buf_len == 0, "got %d\n", buf_len );
6678 ok( *bufW == 0, "got %x\n", *bufW );
6679 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6680
6681 num_gettext_msgs = 0;
6682 memset( bufW, 0xcc, sizeof(bufW) );
6683 g_wm_gettext_override.buffW = bufW;
6684 buf_len = GetWindowTextW( hwnd2, bufW, 0 );
6685 ok( buf_len == 0, "got %d\n", buf_len );
6686 ok( *bufW == 0xcccc, "got %x\n", *bufW );
6687 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6688
6689 g_wm_gettext_override.enabled = FALSE;
6690
6691 DestroyWindow( hwnd2 );
6692
6693 /* test WM_GETTEXT */
6694 num_gettext_msgs = 0;
6695 memset( buf, 0, sizeof(buf) );
6696 r = SendMessageA( hwnd, WM_GETTEXT, sizeof(buf), (LONG_PTR)buf );
6697 ok( r != 0, "expected a nonempty window text\n" );
6698 ok( !strcmp(buf, "caption"), "got wrong window text '%s'\n", buf );
6699 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6700
6701 /* test SetWindowTextA */
6702 num_settext_msgs = 0;
6703 success = SetWindowTextA( hwnd, "new_caption" );
6704 ok( success, "SetWindowTextA failed\n" );
6705 ok( num_settext_msgs == 1, "got %u WM_SETTEXT messages\n", num_settext_msgs );
6706
6707 num_gettext_msgs = 0;
6708 memset( buf, 0, sizeof(buf) );
6709 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
6710 ok( buf_len != 0, "expected a nonempty window text\n" );
6711 ok( !strcmp(buf, "new_caption"), "got wrong window text '%s'\n", buf );
6712 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6713
6714 /* test WM_SETTEXT */
6715 num_settext_msgs = 0;
6716 r = SendMessageA( hwnd, WM_SETTEXT, 0, (ULONG_PTR)"another_caption" );
6717 ok( r != 0, "WM_SETTEXT failed\n" );
6718 ok( num_settext_msgs == 1, "got %u WM_SETTEXT messages\n", num_settext_msgs );
6719
6720 num_gettext_msgs = 0;
6721 memset( buf, 0, sizeof(buf) );
6722 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
6723 ok( buf_len != 0, "expected a nonempty window text\n" );
6724 ok( !strcmp(buf, "another_caption"), "got wrong window text '%s'\n", buf );
6725 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6726
6727 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ))
6729
6730 /* test interthread GetWindowTextA */
6731 num_msgs = 0;
6733 ok(thread != NULL, "CreateThread failed, error %d\n", GetLastError());
6735 {
6736 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ))
6738 num_msgs++;
6739 }
6741 ok( num_msgs >= 1, "got %u wakeups from MsgWaitForMultipleObjects\n", num_msgs );
6742
6743 /* test interthread SetWindowText */
6744 num_msgs = 0;
6746 ok(thread != NULL, "CreateThread failed, error %d\n", GetLastError());
6748 {
6749 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ))
6751 num_msgs++;
6752 }
6754 ok( num_msgs >= 1, "got %u wakeups from MsgWaitForMultipleObjects\n", num_msgs );
6755
6756 num_gettext_msgs = 0;
6757 memset( buf, 0, sizeof(buf) );
6758 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
6759 ok( buf_len != 0, "expected a nonempty window text\n" );
6760 ok( !strcmp(buf, "thread_caption"), "got wrong window text '%s'\n", buf );
6761 ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
6762
6763 /* seems to crash on every modern Windows version */
6764 if (0)
6765 {
6766 r = SendMessageA( hwnd, WM_GETTEXT, 0x10, 0x1000);
6767 ok( r == 0, "settext should return zero\n");
6768
6769 r = SendMessageA( hwnd, WM_GETTEXT, 0x10000, 0);
6770 ok( r == 0, "settext should return zero (%ld)\n", r);
6771
6772 r = SendMessageA( hwnd, WM_GETTEXT, 0xff000000, 0x1000);
6773 ok( r == 0, "settext should return zero (%ld)\n", r);
6774
6775 r = SendMessageA( hwnd, WM_GETTEXT, 0x1000, 0xff000000);
6776 ok( r == 0, "settext should return zero (%ld)\n", r);
6777 }
6778
6780}
6781
6782
6783static void test_GetUpdateRect(void)
6784{
6785 MSG msg;
6786 BOOL ret, parent_wm_paint, grandparent_wm_paint;
6787 RECT rc1, rc2;
6788 HWND hgrandparent, hparent, hchild;
6789 WNDCLASSA cls;
6790 static const char classNameA[] = "GetUpdateRectClass";
6791
6792 hgrandparent = CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW,
6793 0, 0, 100, 100, NULL, NULL, 0, NULL);
6794
6795 hparent = CreateWindowA("static", "parent", WS_CHILD|WS_VISIBLE,
6796 0, 0, 100, 100, hgrandparent, NULL, 0, NULL);
6797
6798 hchild = CreateWindowA("static", "child", WS_CHILD|WS_VISIBLE,
6799 10, 10, 30, 30, hparent, NULL, 0, NULL);
6800
6801 ShowWindow(hgrandparent, SW_SHOW);
6802 UpdateWindow(hgrandparent);
6803 flush_events( TRUE );
6804
6805 ShowWindow(hchild, SW_HIDE);
6806 SetRectEmpty(&rc2);
6807 ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
6808 ok(!ret, "GetUpdateRect returned not empty region\n");
6809 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
6811
6812 SetRect(&rc2, 10, 10, 40, 40);
6813 ret = GetUpdateRect(hparent, &rc1, FALSE);
6814 ok(ret, "GetUpdateRect returned empty region\n");
6815 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
6817
6818 parent_wm_paint = FALSE;
6819 grandparent_wm_paint = FALSE;
6820 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6821 {
6822 if (msg.message == WM_PAINT)
6823 {
6824 if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE;
6825 if (msg.hwnd == hparent) parent_wm_paint = TRUE;
6826 }
6828 }
6829 ok(parent_wm_paint, "WM_PAINT should have been received in parent\n");
6830 ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n");
6831
6832 DestroyWindow(hgrandparent);
6833
6834 cls.style = 0;
6836 cls.cbClsExtra = 0;
6837 cls.cbWndExtra = 0;
6838 cls.hInstance = GetModuleHandleA(0);
6839 cls.hIcon = 0;
6842 cls.lpszMenuName = NULL;
6843 cls.lpszClassName = classNameA;
6844
6845 if(!RegisterClassA(&cls)) {
6846 trace("Register failed %d\n", GetLastError());
6847 return;
6848 }
6849
6850 hgrandparent = CreateWindowA(classNameA, "grandparent", WS_OVERLAPPEDWINDOW,
6851 0, 0, 100, 100, NULL, NULL, 0, NULL);
6852
6853 hparent = CreateWindowA(classNameA, "parent", WS_CHILD|WS_VISIBLE,
6854 0, 0, 100, 100, hgrandparent, NULL, 0, NULL);
6855
6856 hchild = CreateWindowA(classNameA, "child", WS_CHILD|WS_VISIBLE,
6857 10, 10, 30, 30, hparent, NULL, 0, NULL);
6858
6859 ShowWindow(hgrandparent, SW_SHOW);
6860 UpdateWindow(hgrandparent);
6861 flush_events( TRUE );
6862
6863 ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
6864 ok(!ret, "GetUpdateRect returned not empty region\n");
6865
6866 ShowWindow(hchild, SW_HIDE);
6867
6868 SetRectEmpty(&rc2);
6869 ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
6870 ok(!ret, "GetUpdateRect returned not empty region\n");
6871 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
6873
6874 SetRect(&rc2, 10, 10, 40, 40);
6875 ret = GetUpdateRect(hparent, &rc1, FALSE);
6876 ok(ret, "GetUpdateRect returned empty region\n");
6877 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
6879
6880 parent_wm_paint = FALSE;
6881 grandparent_wm_paint = FALSE;
6882 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6883 {
6884 if (msg.message == WM_PAINT)
6885 {
6886 if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE;
6887 if (msg.hwnd == hparent) parent_wm_paint = TRUE;
6888 }
6890 }
6891 ok(parent_wm_paint, "WM_PAINT should have been received in parent\n");
6892 ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n");
6893
6894 DestroyWindow(hgrandparent);
6895}
6896
6897
6899{
6900 if(msg == WM_PAINT)
6901 {
6902 PAINTSTRUCT ps;
6903 RECT updateRect;
6904 DWORD waitResult;
6905 HWND win;
6906 const int waitTime = 2000;
6907
6908 BeginPaint(hwnd, &ps);
6909
6910 /* create and destroy window to create an exposed region on this window */
6911 win = CreateWindowA("static", "win", WS_VISIBLE,
6912 10,10,50,50, NULL, NULL, 0, NULL);
6914
6915 waitResult = MsgWaitForMultipleObjects( 0, NULL, FALSE, waitTime, QS_PAINT );
6916
6918 EndPaint(hwnd, &ps);
6919
6920 if(waitResult != WAIT_TIMEOUT)
6921 {
6922 GetUpdateRect(hwnd, &updateRect, FALSE);
6923 ok(IsRectEmpty(&updateRect), "Exposed rect should be empty\n");
6924 }
6925
6926 return 1;
6927 }
6928 return DefWindowProcA(hwnd, msg, wParam, lParam);
6929}
6930
6931static void test_Expose(void)
6932{
6933 WNDCLASSA cls;
6934 HWND mw;
6935
6936 memset(&cls, 0, sizeof(WNDCLASSA));
6939 cls.lpszClassName = "TestExposeClass";
6940 RegisterClassA(&cls);
6941
6942 mw = CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE|WS_OVERLAPPEDWINDOW,
6943 0, 0, 200, 100, NULL, NULL, 0, NULL);
6944
6945 UpdateWindow(mw);
6946 DestroyWindow(mw);
6947}
6948
6950{
6951 static UINT ncredrawflags;
6952 PAINTSTRUCT ps;
6953
6954 switch(msg)
6955 {
6956 case WM_CREATE:
6957 ncredrawflags = *(UINT *) (((CREATESTRUCTA *)lParam)->lpCreateParams);
6958 return 0;
6959 case WM_NCPAINT:
6960 RedrawWindow(hwnd, NULL, NULL, ncredrawflags);
6961 break;
6962 case WM_PAINT:
6963 BeginPaint(hwnd, &ps);
6964 EndPaint(hwnd, &ps);
6965 return 0;
6966 }
6967 return DefWindowProcA(hwnd, msg, wParam, lParam);
6968}
6969
6971{
6972 HWND hwnd;
6973 MSG msg;
6974
6975 UINT loopcount = 0;
6976
6977 hwnd = CreateWindowA("TestNCRedrawClass", "MainWindow",
6978 WS_OVERLAPPEDWINDOW, 0, 0, 200, 100,
6979 NULL, NULL, 0, &flags);
6983 while (PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE))
6984 {
6985 if (msg.message == WM_PAINT) loopcount++;
6986 if (loopcount >= 100) break;
6990 }
6992 ok(loopcount < 100, "Detected infinite WM_PAINT loop (%x).\n", flags);
6994}
6995
6996static void test_NCRedraw(void)
6997{
6998 WNDCLASSA wndclass;
6999
7000 wndclass.lpszClassName = "TestNCRedrawClass";
7001 wndclass.style = CS_HREDRAW | CS_VREDRAW;
7003 wndclass.cbClsExtra = 0;
7004 wndclass.cbWndExtra = 0;
7005 wndclass.hInstance = 0;
7006 wndclass.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
7007 wndclass.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
7009 wndclass.lpszMenuName = NULL;
7010
7011 RegisterClassA(&wndclass);
7012
7015}
7016
7018{
7019 HWND hwnd;
7021 UINT ret1, ret2;
7022 char buf1[MAX_PATH], buf2[MAX_PATH];
7023
7024 if (!pGetWindowModuleFileNameA)
7025 {
7026 win_skip("GetWindowModuleFileNameA is not available\n");
7027 return;
7028 }
7029
7030 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL);
7031 assert(hwnd);
7032
7034 ok(hinst == 0 || broken(hinst == GetModuleHandleA(NULL)), /* win9x */ "expected 0, got %p\n", hinst);
7035
7036 buf1[0] = 0;
7037 SetLastError(0xdeadbeef);
7038 ret1 = GetModuleFileNameA(hinst, buf1, sizeof(buf1));
7039 ok(ret1, "GetModuleFileName error %u\n", GetLastError());
7040
7041 buf2[0] = 0;
7042 SetLastError(0xdeadbeef);
7043 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, sizeof(buf2));
7044 ok(ret2 || broken(!ret2), /* nt4 sp 3 */
7045 "GetWindowModuleFileNameA error %u\n", GetLastError());
7046
7047 if (ret2)
7048 {
7049 ok(ret1 == ret2 || broken(ret2 == ret1 + 1), /* win98 */ "%u != %u\n", ret1, ret2);
7050 ok(!strcmp(buf1, buf2), "%s != %s\n", buf1, buf2);
7051 }
7053
7054 SetLastError(0xdeadbeef);
7055 ret2 = GetModuleFileNameA(hinst, buf2, ret1 - 2);
7056 ok(ret2 == ret1 - 2 || broken(ret2 == ret1 - 3), /* win98 */
7057 "expected %u, got %u\n", ret1 - 2, ret2);
7058 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7059 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
7060 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7061
7062 SetLastError(0xdeadbeef);
7063 ret2 = GetModuleFileNameA(hinst, buf2, 0);
7064 ok(!ret2, "GetModuleFileName should return 0\n");
7065 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7066 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
7067 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7068
7069 SetLastError(0xdeadbeef);
7070 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, ret1 - 2);
7071 ok(ret2 == ret1 - 2 || broken(ret2 == ret1 - 3) /* win98 */ || broken(!ret2), /* nt4 sp3 */
7072 "expected %u, got %u\n", ret1 - 2, ret2);
7073 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7074 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
7075 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7076
7077 SetLastError(0xdeadbeef);
7078 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, 0);
7079 ok(!ret2, "expected 0, got %u\n", ret2);
7080 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7081 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
7082 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7083
7085
7086 buf2[0] = 0;
7087 hwnd = (HWND)0xdeadbeef;
7088 SetLastError(0xdeadbeef);
7089 ret1 = pGetWindowModuleFileNameA(hwnd, buf1, sizeof(buf1));
7090 ok(!ret1, "expected 0, got %u\n", ret1);
7091 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef), /* win9x */
7092 "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
7093
7094 hwnd = FindWindowA("Shell_TrayWnd", NULL);
7095 ok(IsWindow(hwnd) || broken(!hwnd), "got invalid tray window %p\n", hwnd);
7096 SetLastError(0xdeadbeef);
7097 ret1 = pGetWindowModuleFileNameA(hwnd, buf1, sizeof(buf1));
7098 ok(!ret1 || broken(ret1), /* win98 */ "expected 0, got %u\n", ret1);
7099
7100 if (!ret1) /* inter-process GetWindowModuleFileName works on win9x, so don't test the desktop there */
7101 {
7102 ret1 = GetModuleFileNameA(0, buf1, sizeof(buf1));
7104 ok(IsWindow(hwnd), "got invalid desktop window %p\n", hwnd);
7105 SetLastError(0xdeadbeef);
7106 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, sizeof(buf2));
7107 ok(!ret2 ||
7108 ret1 == ret2 || /* vista */
7109 broken(ret2), /* some win98 return user.exe as file name */
7110 "expected 0 or %u, got %u %s\n", ret1, ret2, buf2);
7111 }
7112}
7113
7114static void test_hwnd_message(void)
7115{
7116 static const WCHAR mainwindowclassW[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
7117 static const WCHAR message_windowW[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
7118
7119 HWND parent = 0, hwnd, found;
7120 RECT rect;
7121
7122 /* HWND_MESSAGE is not supported below w2k, but win9x return != 0
7123 on CreateWindowExA and crash later in the test.
7124 Use UNICODE here to fail on win9x */
7125 hwnd = CreateWindowExW(0, mainwindowclassW, message_windowW, WS_CAPTION | WS_VISIBLE,
7126 100, 100, 200, 200, HWND_MESSAGE, 0, 0, NULL);
7127 if (!hwnd)
7128 {
7129 win_skip("CreateWindowExW with parent HWND_MESSAGE failed\n");
7130 return;
7131 }
7132
7133 ok( !GetParent(hwnd), "GetParent should return 0 for message only windows\n" );
7134 if (pGetAncestor)
7135 {
7136 char buffer[100];
7137 HWND root, desktop = GetDesktopWindow();
7138
7139 parent = pGetAncestor(hwnd, GA_PARENT);
7140 ok(parent != 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
7141 ok(parent != desktop, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
7142 root = pGetAncestor(hwnd, GA_ROOT);
7143 ok(root == hwnd, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
7144 ok( !pGetAncestor(parent, GA_PARENT) || broken(pGetAncestor(parent, GA_PARENT) != 0), /* win2k */
7145 "parent shouldn't have parent %p\n", pGetAncestor(parent, GA_PARENT) );
7146 trace("parent %p root %p desktop %p\n", parent, root, desktop);
7147 if (!GetClassNameA( parent, buffer, sizeof(buffer) )) buffer[0] = 0;
7148 ok( !lstrcmpiA( buffer, "Message" ), "wrong parent class '%s'\n", buffer );
7150 ok( rect.left == 0 && rect.right == 100 && rect.top == 0 && rect.bottom == 100,
7151 "wrong parent rect %s\n", wine_dbgstr_rect( &rect ));
7152 }
7153 GetWindowRect( hwnd, &rect );
7154 ok( rect.left == 100 && rect.right == 300 && rect.top == 100 && rect.bottom == 300,
7155 "wrong window rect %s\n", wine_dbgstr_rect( &rect ));
7156
7157 /* test FindWindow behavior */
7158
7159 found = FindWindowExA( 0, 0, 0, "message window" );
7160 ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd );
7161 SetLastError(0xdeadbeef);
7162 found = FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
7163 ok( found == 0, "found message window %p/%p\n", found, hwnd );
7164 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
7165 if (parent)
7166 {
7167 found = FindWindowExA( parent, 0, 0, "message window" );
7168 ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd );
7169 }
7170
7171 /* test IsChild behavior */
7172
7173 if (parent) ok( !IsChild( parent, hwnd ), "HWND_MESSAGE is child of top window\n" );
7174
7175 /* test IsWindowVisible behavior */
7176
7177 ok( !IsWindowVisible( hwnd ), "HWND_MESSAGE window is visible\n" );
7178 if (parent) ok( !IsWindowVisible( parent ), "HWND_MESSAGE parent is visible\n" );
7179
7181}
7182
7183static void test_layered_window(void)
7184{
7185 HWND hwnd;
7186 COLORREF key = 0;
7187 BYTE alpha = 0;
7188 DWORD flags = 0;
7189 POINT pt = { 0, 0 };
7190 SIZE sz = { 200, 200 };
7191 HDC hdc;
7192 HBITMAP hbm;
7193 BOOL ret;
7194
7195 if (!pGetLayeredWindowAttributes || !pSetLayeredWindowAttributes || !pUpdateLayeredWindow)
7196 {
7197 win_skip( "layered windows not supported\n" );
7198 return;
7199 }
7200
7201 hdc = CreateCompatibleDC( 0 );
7202 hbm = CreateCompatibleBitmap( hdc, 200, 200 );
7203 SelectObject( hdc, hbm );
7204
7205 hwnd = CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION,
7206 100, 100, 200, 200, 0, 0, 0, NULL);
7207 assert( hwnd );
7208 SetLastError( 0xdeadbeef );
7209 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
7210 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
7211 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
7212 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7213 ok( !ret, "GetLayeredWindowAttributes should fail on non-layered window\n" );
7214 ret = pSetLayeredWindowAttributes( hwnd, 0, 0, LWA_ALPHA );
7215 ok( !ret, "SetLayeredWindowAttributes should fail on non-layered window\n" );
7217 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7218 ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
7219 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
7220 ok( ret, "UpdateLayeredWindow should succeed on layered window\n" );
7221 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7222 ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
7223 ret = pSetLayeredWindowAttributes( hwnd, 0x123456, 44, LWA_ALPHA );
7224 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
7225 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7226 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
7227 ok( key == 0x123456 || key == 0, "wrong color key %x\n", key );
7228 ok( alpha == 44, "wrong alpha %u\n", alpha );
7229 ok( flags == LWA_ALPHA, "wrong flags %x\n", flags );
7230 SetLastError( 0xdeadbeef );
7231 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
7232 ok( !ret, "UpdateLayeredWindow should fail on layered but initialized window\n" );
7233 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
7234
7235 /* clearing WS_EX_LAYERED resets attributes */
7237 SetLastError( 0xdeadbeef );
7238 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
7239 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
7240 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7241 ok( !ret, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
7243 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7244 ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
7245 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
7246 ok( ret, "UpdateLayeredWindow should succeed on layered window\n" );
7247 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE | ULW_EX_NORESIZE );
7248 ok( !ret, "UpdateLayeredWindow should fail with ex flag\n" );
7249 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
7250 if (pUpdateLayeredWindowIndirect)
7251 {
7252 UPDATELAYEREDWINDOWINFO info;
7253 info.cbSize = sizeof(info);
7254 info.hdcDst = 0;
7255 info.pptDst = NULL;
7256 info.psize = &sz;
7257 info.hdcSrc = hdc;
7258 info.pptSrc = &pt;
7259 info.crKey = 0;
7260 info.pblend = NULL;
7261 info.dwFlags = ULW_OPAQUE | ULW_EX_NORESIZE;
7262 info.prcDirty = NULL;
7263 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
7264 ok( ret, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
7265 sz.cx--;
7266 SetLastError(0);
7267 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
7268 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
7269 /* particular error code differs from version to version, could be ERROR_INCORRECT_SIZE,
7270 ERROR_MR_MID_NOT_FOUND or ERROR_GEN_FAILURE (Win8/Win10) */
7271 ok( GetLastError() != 0, "wrong error %u\n", GetLastError() );
7272 info.dwFlags = ULW_OPAQUE;
7273 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
7274 ok( ret, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
7275 sz.cx++;
7276 info.dwFlags = ULW_OPAQUE | 0xf00;
7277 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
7278 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
7279 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
7280 info.cbSize--;
7281 info.dwFlags = ULW_OPAQUE;
7282 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
7283 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
7284 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
7285 ret = pUpdateLayeredWindowIndirect( hwnd, NULL );
7286 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
7287 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
7288 }
7289
7290 ret = pSetLayeredWindowAttributes( hwnd, 0x654321, 22, LWA_COLORKEY | LWA_ALPHA );
7291 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
7292 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7293 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
7294 ok( key == 0x654321, "wrong color key %x\n", key );
7295 ok( alpha == 22, "wrong alpha %u\n", alpha );
7296 ok( flags == (LWA_COLORKEY | LWA_ALPHA), "wrong flags %x\n", flags );
7297 SetLastError( 0xdeadbeef );
7298 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
7299 ok( !ret, "UpdateLayeredWindow should fail on layered but initialized window\n" );
7300 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
7301
7302 ret = pSetLayeredWindowAttributes( hwnd, 0x888888, 33, LWA_COLORKEY );
7303 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
7304 alpha = 0;
7305 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7306 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
7307 ok( key == 0x888888, "wrong color key %x\n", key );
7308 /* alpha not changed on vista if LWA_ALPHA is not set */
7309 ok( alpha == 22 || alpha == 33, "wrong alpha %u\n", alpha );
7310 ok( flags == LWA_COLORKEY, "wrong flags %x\n", flags );
7311
7312 /* color key may or may not be changed without LWA_COLORKEY */
7313 ret = pSetLayeredWindowAttributes( hwnd, 0x999999, 44, 0 );
7314 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
7315 alpha = 0;
7316 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7317 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
7318 ok( key == 0x888888 || key == 0x999999, "wrong color key %x\n", key );
7319 ok( alpha == 22 || alpha == 44, "wrong alpha %u\n", alpha );
7320 ok( flags == 0, "wrong flags %x\n", flags );
7321
7322 /* default alpha and color key is 0 */
7325 ret = pSetLayeredWindowAttributes( hwnd, 0x222222, 55, 0 );
7326 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
7327 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
7328 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
7329 ok( key == 0 || key == 0x222222, "wrong color key %x\n", key );
7330 ok( alpha == 0 || alpha == 55, "wrong alpha %u\n", alpha );
7331 ok( flags == 0, "wrong flags %x\n", flags );
7332
7334 DeleteDC( hdc );
7335 DeleteObject( hbm );
7336}
7337
7339
7341{
7342 switch (msg)
7343 {
7344 case WM_NCCREATE:
7345 {
7347 ok(cs->x == mi.rcMonitor.left && cs->y == mi.rcMonitor.top &&
7348 cs->cx == mi.rcMonitor.right && cs->cy == mi.rcMonitor.bottom,
7349 "expected %s, got (%d,%d)-(%d,%d)\n", wine_dbgstr_rect(&mi.rcMonitor),
7350 cs->x, cs->y, cs->cx, cs->cy);
7351 break;
7352 }
7353 case WM_GETMINMAXINFO:
7354 {
7355 MINMAXINFO *minmax = (MINMAXINFO *)lp;
7356 ok(minmax->ptMaxPosition.x <= mi.rcMonitor.left, "%d <= %d\n", minmax->ptMaxPosition.x, mi.rcMonitor.left);
7357 ok(minmax->ptMaxPosition.y <= mi.rcMonitor.top, "%d <= %d\n", minmax->ptMaxPosition.y, mi.rcMonitor.top);
7358 ok(minmax->ptMaxSize.x >= mi.rcMonitor.right, "%d >= %d\n", minmax->ptMaxSize.x, mi.rcMonitor.right);
7359 ok(minmax->ptMaxSize.y >= mi.rcMonitor.bottom, "%d >= %d\n", minmax->ptMaxSize.y, mi.rcMonitor.bottom);
7360 break;
7361 }
7362 }
7363 return DefWindowProcA(hwnd, msg, wp, lp);
7364}
7365
7366static void test_fullscreen(void)
7367{
7368 static const DWORD t_style[] = {
7370 };
7371 static const DWORD t_ex_style[] = {
7373 };
7374 WNDCLASSA cls;
7375 HWND hwnd;
7376 int i, j;
7377 POINT pt;
7378 RECT rc;
7379 HMONITOR hmon;
7380 LRESULT ret;
7381
7382 if (!pGetMonitorInfoA || !pMonitorFromPoint)
7383 {
7384 win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
7385 return;
7386 }
7387
7388 pt.x = pt.y = 0;
7389 SetLastError(0xdeadbeef);
7390 hmon = pMonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
7391 ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
7392
7393 mi.cbSize = sizeof(mi);
7394 SetLastError(0xdeadbeef);
7395 ret = pGetMonitorInfoA(hmon, &mi);
7396 ok(ret, "GetMonitorInfo error %u\n", GetLastError());
7397 trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi.rcMonitor), wine_dbgstr_rect(&mi.rcWork));
7398
7399 cls.style = 0;
7401 cls.cbClsExtra = 0;
7402 cls.cbWndExtra = 0;
7404 cls.hIcon = 0;
7407 cls.lpszMenuName = NULL;
7408 cls.lpszClassName = "fullscreen_class";
7409 RegisterClassA(&cls);
7410
7411 for (i = 0; i < sizeof(t_style)/sizeof(t_style[0]); i++)
7412 {
7413 DWORD style, ex_style;
7414
7415 /* avoid a WM interaction */
7416 assert(!(t_style[i] & WS_VISIBLE));
7417
7418 for (j = 0; j < sizeof(t_ex_style)/sizeof(t_ex_style[0]); j++)
7419 {
7420 int fixup;
7421
7422 style = t_style[i];
7423 ex_style = t_ex_style[j];
7424
7425 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
7428 ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
7429 GetWindowRect(hwnd, &rc);
7430 trace("%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7431 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
7433 "%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7435
7436 style = t_style[i] | WS_MAXIMIZE;
7437 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
7440 ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
7441 GetWindowRect(hwnd, &rc);
7442 trace("%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7443 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
7445 "%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7447
7448 style = t_style[i] | WS_MAXIMIZE | WS_CAPTION;
7449 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
7452 ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
7453 GetWindowRect(hwnd, &rc);
7454 trace("%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7455 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
7457 "%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7459
7460 style = t_style[i] | WS_CAPTION | WS_MAXIMIZEBOX;
7461 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
7464 ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
7465 GetWindowRect(hwnd, &rc);
7466 trace("%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7467 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
7469 "%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7471
7472 style = t_style[i] | WS_MAXIMIZE | WS_CAPTION | WS_MAXIMIZEBOX;
7473 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
7476 ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
7477 GetWindowRect(hwnd, &rc);
7478 trace("%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7479 /* Windows makes a maximized window slightly larger (to hide the borders?) */
7480 fixup = min(abs(rc.left), abs(rc.top));
7481 InflateRect(&rc, -fixup, -fixup);
7482 ok(rc.left >= mi.rcMonitor.left && rc.top >= mi.rcMonitor.top &&
7484 "%#x/%#x: window rect %s must be in %s\n", ex_style, style, wine_dbgstr_rect(&rc),
7487
7488 style = t_style[i] | WS_MAXIMIZE | WS_MAXIMIZEBOX;
7489 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
7492 ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
7493 GetWindowRect(hwnd, &rc);
7494 trace("%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7495 /* Windows makes a maximized window slightly larger (to hide the borders?) */
7496 fixup = min(abs(rc.left), abs(rc.top));
7497 InflateRect(&rc, -fixup, -fixup);
7498 if (style & (WS_CHILD | WS_POPUP))
7499 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
7501 "%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7502 else
7503 ok(rc.left >= mi.rcMonitor.left && rc.top >= mi.rcMonitor.top &&
7505 "%#x/%#x: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
7507 }
7508 }
7509
7510 UnregisterClassA("fullscreen_class", GetModuleHandleA(NULL));
7511}
7512
7514static const char * test_thick_child_name;
7517
7519{
7520 MINMAXINFO* minmax;
7521 int expectedMinTrackX;
7522 int expectedMinTrackY;
7523 int actualMinTrackX;
7524 int actualMinTrackY;
7525 int expectedMaxTrackX;
7526 int expectedMaxTrackY;
7527 int actualMaxTrackX;
7528 int actualMaxTrackY;
7529 int expectedMaxSizeX;
7530 int expectedMaxSizeY;
7531 int actualMaxSizeX;
7532 int actualMaxSizeY;
7533 int expectedPosX;
7534 int expectedPosY;
7535 int actualPosX;
7536 int actualPosY;
7537 LONG adjustedStyle;
7538 RECT rect;
7539 switch (msg)
7540 {
7541 case WM_GETMINMAXINFO:
7542 {
7543 minmax = (MINMAXINFO *)lparam;
7544 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd, wparam, lparam);
7545 dump_minmax_info( minmax );
7546
7548
7549
7550 adjustedStyle = test_thick_child_style;
7551 if ((adjustedStyle & WS_CAPTION) == WS_CAPTION)
7552 adjustedStyle &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
7555
7557 {
7558 expectedMinTrackX = GetSystemMetrics(SM_CXMINTRACK);
7559 expectedMinTrackY = GetSystemMetrics(SM_CYMINTRACK);
7560 }
7561 else
7562 {
7563 expectedMinTrackX = -2 * rect.left;
7564 expectedMinTrackY = -2 * rect.top;
7565 }
7566 actualMinTrackX = minmax->ptMinTrackSize.x;
7567 actualMinTrackY = minmax->ptMinTrackSize.y;
7568
7569 ok(actualMinTrackX == expectedMinTrackX && actualMinTrackY == expectedMinTrackY,
7570 "expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
7571 expectedMinTrackX, expectedMinTrackY, actualMinTrackX, actualMinTrackY,
7573
7574 actualMaxTrackX = minmax->ptMaxTrackSize.x;
7575 actualMaxTrackY = minmax->ptMaxTrackSize.y;
7576 expectedMaxTrackX = GetSystemMetrics(SM_CXMAXTRACK);
7577 expectedMaxTrackY = GetSystemMetrics(SM_CYMAXTRACK);
7578 ok(actualMaxTrackX == expectedMaxTrackX && actualMaxTrackY == expectedMaxTrackY,
7579 "expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
7580 expectedMaxTrackX, expectedMaxTrackY, actualMaxTrackX, actualMaxTrackY,
7582
7583 expectedMaxSizeX = rect.right - rect.left;
7584 expectedMaxSizeY = rect.bottom - rect.top;
7585 actualMaxSizeX = minmax->ptMaxSize.x;
7586 actualMaxSizeY = minmax->ptMaxSize.y;
7587
7588 ok(actualMaxSizeX == expectedMaxSizeX && actualMaxSizeY == expectedMaxSizeY,
7589 "expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
7590 expectedMaxSizeX, expectedMaxSizeY, actualMaxSizeX, actualMaxSizeY,
7592
7593
7594 expectedPosX = rect.left;
7595 expectedPosY = rect.top;
7596 actualPosX = minmax->ptMaxPosition.x;
7597 actualPosY = minmax->ptMaxPosition.y;
7598 ok(actualPosX == expectedPosX && actualPosY == expectedPosY,
7599 "expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
7600 expectedPosX, expectedPosY, actualPosX, actualPosY, test_thick_child_name);
7601
7602 break;
7603 }
7604 }
7605
7606 return DefWindowProcA(hwnd, msg, wparam, lparam);
7607}
7608
7609#define NUMBER_OF_THICK_CHILD_TESTS 16
7610static void test_thick_child_size(HWND parentWindow)
7611{
7612 BOOL success;
7613 RECT childRect;
7614 RECT adjustedParentRect;
7615 HWND childWindow;
7616 LONG childWidth;
7617 LONG childHeight;
7618 LONG expectedWidth;
7619 LONG expectedHeight;
7620 WNDCLASSA cls;
7621 static const char className[] = "THICK_CHILD_CLASS";
7622 int i;
7623 LONG adjustedStyle;
7624 static const LONG styles[NUMBER_OF_THICK_CHILD_TESTS] = {
7641 };
7642
7643 static const LONG exStyles[NUMBER_OF_THICK_CHILD_TESTS] = {
7644 0,
7645 0,
7646 0,
7647 0,
7660 };
7661 static const char *styleName[NUMBER_OF_THICK_CHILD_TESTS] = {
7662 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
7663 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
7664 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
7665 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
7666 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
7667 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
7668 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
7669 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
7670 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
7671 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
7672 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
7673 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
7674 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7675 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7676 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7677 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7678 };
7679
7680 cls.style = 0;
7682 cls.cbClsExtra = 0;
7683 cls.cbWndExtra = 0;
7684 cls.hInstance = GetModuleHandleA(0);
7685 cls.hIcon = 0;
7688 cls.lpszMenuName = NULL;
7689 cls.lpszClassName = className;
7690 SetLastError(0xdeadbeef);
7691 success = RegisterClassA(&cls);
7692 ok(success,"RegisterClassA failed, error: %u\n", GetLastError());
7693
7694 for(i = 0; i < NUMBER_OF_THICK_CHILD_TESTS; i++)
7695 {
7696 test_thick_child_name = styleName[i];
7697 test_thick_child_style = styles[i];
7698 test_thick_child_exStyle = exStyles[i];
7700
7701 SetLastError(0xdeadbeef);
7702 childWindow = CreateWindowExA( exStyles[i], className, "", styles[i], 0, 0, 0, 0, parentWindow, 0, GetModuleHandleA(0), NULL );
7703 ok(childWindow != NULL, "Failed to create child window, error: %u\n", GetLastError());
7704
7705 ok(test_thick_child_got_minmax, "Got no WM_GETMINMAXINFO\n");
7706
7707 SetLastError(0xdeadbeef);
7708 success = GetWindowRect(childWindow, &childRect);
7709 ok(success,"GetWindowRect call failed, error: %u\n", GetLastError());
7710 childWidth = childRect.right - childRect.left;
7711 childHeight = childRect.bottom - childRect.top;
7712
7713 adjustedStyle = styles[i];
7714 if ((adjustedStyle & WS_CAPTION) == WS_CAPTION)
7715 adjustedStyle &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
7716 GetClientRect(GetParent(childWindow), &adjustedParentRect);
7717 AdjustWindowRectEx(&adjustedParentRect, adjustedStyle, FALSE, test_thick_child_exStyle);
7718
7719
7721 {
7722 expectedWidth = GetSystemMetrics(SM_CXMINTRACK);
7723 expectedHeight = GetSystemMetrics(SM_CYMINTRACK);
7724 }
7725 else
7726 {
7727 expectedWidth = -2 * adjustedParentRect.left;
7728 expectedHeight = -2 * adjustedParentRect.top;
7729 }
7730
7731 ok((childWidth == expectedWidth) && (childHeight == expectedHeight),
7732 "size of window (%s) is wrong: expected size %dx%d != actual size %dx%d\n",
7733 test_thick_child_name, expectedWidth, expectedHeight, childWidth, childHeight);
7734
7735 SetLastError(0xdeadbeef);
7736 success = DestroyWindow(childWindow);
7737 ok(success,"DestroyWindow call failed, error: %u\n", GetLastError());
7738 }
7739 ok(UnregisterClassA(className, GetModuleHandleA(NULL)),"UnregisterClass call failed\n");
7740}
7741
7742static void test_handles( HWND full_hwnd )
7743{
7744 HWND hwnd = full_hwnd;
7745 BOOL ret;
7746 RECT rect;
7747
7748 SetLastError( 0xdeadbeef );
7749 ret = GetWindowRect( hwnd, &rect );
7750 ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() );
7751
7752#ifdef _WIN64
7753 if ((ULONG_PTR)full_hwnd >> 32)
7754 hwnd = (HWND)((ULONG_PTR)full_hwnd & ~0u);
7755 else
7756 hwnd = (HWND)((ULONG_PTR)full_hwnd | ((ULONG_PTR)~0u << 32));
7757 SetLastError( 0xdeadbeef );
7758 ret = GetWindowRect( hwnd, &rect );
7759 ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() );
7760
7761 hwnd = (HWND)(((ULONG_PTR)full_hwnd & ~0u) | ((ULONG_PTR)0x1234 << 32));
7762 SetLastError( 0xdeadbeef );
7763 ret = GetWindowRect( hwnd, &rect );
7764 ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() );
7765
7766 hwnd = (HWND)(((ULONG_PTR)full_hwnd & 0xffff) | ((ULONG_PTR)0x9876 << 16));
7767 SetLastError( 0xdeadbeef );
7768 ret = GetWindowRect( hwnd, &rect );
7769 ok( !ret, "GetWindowRect succeeded for %p\n", hwnd );
7770 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
7771
7772 hwnd = (HWND)(((ULONG_PTR)full_hwnd & 0xffff) | ((ULONG_PTR)0x12345678 << 16));
7773 SetLastError( 0xdeadbeef );
7774 ret = GetWindowRect( hwnd, &rect );
7775 ok( !ret, "GetWindowRect succeeded for %p\n", hwnd );
7776 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
7777#endif
7778}
7779
7780static void test_winregion(void)
7781{
7782 HWND hwnd;
7783 RECT r;
7784 int ret, width;
7785 HRGN hrgn;
7786
7787 if (!pGetWindowRgnBox)
7788 {
7789 win_skip("GetWindowRgnBox not supported\n");
7790 return;
7791 }
7792
7793 hwnd = CreateWindowExA(0, "static", NULL, WS_VISIBLE, 10, 10, 10, 10, NULL, 0, 0, NULL);
7794 /* NULL prect */
7795 SetLastError(0xdeadbeef);
7796 ret = pGetWindowRgnBox(hwnd, NULL);
7797 ok( ret == ERROR, "Expected ERROR, got %d\n", ret);
7798 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
7799
7800 hrgn = CreateRectRgn(2, 3, 10, 15);
7801 ok( hrgn != NULL, "Region creation failed\n");
7802 if (hrgn)
7803 {
7805
7806 SetLastError(0xdeadbeef);
7807 ret = pGetWindowRgnBox(hwnd, NULL);
7808 ok( ret == ERROR, "Expected ERROR, got %d\n", ret);
7809 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
7810
7811 SetRectEmpty(&r);
7812 ret = pGetWindowRgnBox(hwnd, &r);
7813 ok( ret == SIMPLEREGION, "Expected SIMPLEREGION, got %d\n", ret);
7814 ok( r.left == 2 && r.top == 3 && r.right == 10 && r.bottom == 15,
7815 "Expected (2,3)-(10,15), got %s\n", wine_dbgstr_rect( &r ));
7816 if (pMirrorRgn)
7817 {
7818 hrgn = CreateRectRgn(2, 3, 10, 15);
7819 ret = pMirrorRgn( hwnd, hrgn );
7820 ok( ret == TRUE, "MirrorRgn failed %u\n", ret );
7821 SetRectEmpty(&r);
7822 GetWindowRect( hwnd, &r );
7823 width = r.right - r.left;
7824 SetRectEmpty(&r);
7825 ret = GetRgnBox( hrgn, &r );
7826 ok( ret == SIMPLEREGION, "GetRgnBox failed %u\n", ret );
7827 ok( r.left == width - 10 && r.top == 3 && r.right == width - 2 && r.bottom == 15,
7828 "Wrong rectangle %s for width %d\n", wine_dbgstr_rect( &r ), width );
7829 }
7830 else win_skip( "MirrorRgn not supported\n" );
7831 }
7833}
7834
7835static void test_rtl_layout(void)
7836{
7837 HWND parent, child;
7838 RECT r;
7839 POINT pt;
7840
7841 if (!pSetProcessDefaultLayout)
7842 {
7843 win_skip( "SetProcessDefaultLayout not supported\n" );
7844 return;
7845 }
7846
7847 parent = CreateWindowExA(WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, 100, 100, 300, 300, NULL, 0, 0, NULL);
7848 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 10, 10, 20, 20, parent, 0, 0, NULL);
7849
7850 GetWindowRect( parent, &r );
7851 ok( r.left == 100 && r.right == 400, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7852 GetClientRect( parent, &r );
7853 ok( r.left == 0 && r.right == 300, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7854 GetClientRect( child, &r );
7855 ok( r.left == 0 && r.right == 20, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7856 MapWindowPoints( child, parent, (POINT *)&r, 2 );
7857 ok( r.left == 10 && r.right == 30, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7858 GetWindowRect( child, &r );
7859 ok( r.left == 370 && r.right == 390, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7860 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
7861 ok( r.left == 10 && r.right == 30, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7862 GetWindowRect( child, &r );
7863 MapWindowPoints( NULL, parent, (POINT *)&r, 1 );
7864 MapWindowPoints( NULL, parent, (POINT *)&r + 1, 1 );
7865 ok( r.left == 30 && r.right == 10, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7866 pt.x = pt.y = 12;
7867 MapWindowPoints( child, parent, &pt, 1 );
7868 ok( pt.x == 22 && pt.y == 22, "wrong point %d,%d\n", pt.x, pt.y );
7869 SetWindowPos( parent, 0, 0, 0, 250, 250, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
7870 GetWindowRect( parent, &r );
7871 ok( r.left == 100 && r.right == 350, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7872 GetWindowRect( child, &r );
7873 ok( r.left == 320 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7875 GetWindowRect( child, &r );
7876 ok( r.left == 320 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7877 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
7878 ok( r.left == 220 && r.right == 240, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7880 GetWindowRect( child, &r );
7881 ok( r.left == 320 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7882 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
7883 ok( r.left == 10 && r.right == 30, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7884 SetWindowPos( child, 0, 0, 0, 30, 30, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
7885 GetWindowRect( child, &r );
7886 ok( r.left == 310 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7887 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
7888 ok( r.left == 10 && r.right == 40, "wrong rect %s\n", wine_dbgstr_rect( &r ));
7891}
7892
7893static void test_FlashWindow(void)
7894{
7895 HWND hwnd;
7896 BOOL ret;
7897 if (!pFlashWindow)
7898 {
7899 win_skip( "FlashWindow not supported\n" );
7900 return;
7901 }
7902
7903 hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP,
7904 0, 0, 0, 0, 0, 0, 0, NULL );
7905 ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
7906
7907 SetLastError( 0xdeadbeef );
7908 ret = pFlashWindow( NULL, TRUE );
7910 "FlashWindow returned with %d\n", GetLastError() );
7911
7913
7914 SetLastError( 0xdeadbeef );
7915 ret = pFlashWindow( hwnd, TRUE );
7917 "FlashWindow returned with %d\n", GetLastError() );
7918}
7919
7920static void test_FlashWindowEx(void)
7921{
7922 HWND hwnd;
7923 FLASHWINFO finfo;
7924 BOOL prev, ret;
7925
7926 if (!pFlashWindowEx)
7927 {
7928 win_skip( "FlashWindowEx not supported\n" );
7929 return;
7930 }
7931
7932 hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP,
7933 0, 0, 0, 0, 0, 0, 0, NULL );
7934 ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
7935
7936 finfo.cbSize = sizeof(FLASHWINFO);
7937 finfo.dwFlags = FLASHW_TIMER;
7938 finfo.uCount = 3;
7939 finfo.dwTimeout = 200;
7940 finfo.hwnd = NULL;
7941 SetLastError(0xdeadbeef);
7942 ret = pFlashWindowEx(&finfo);
7944 "FlashWindowEx returned with %d\n", GetLastError());
7945
7946 finfo.hwnd = hwnd;
7947 SetLastError(0xdeadbeef);
7948 ret = pFlashWindowEx(NULL);
7950 "FlashWindowEx returned with %d\n", GetLastError());
7951
7952 SetLastError(0xdeadbeef);
7953 ret = pFlashWindowEx(&finfo);
7954 todo_wine ok(!ret, "previous window state should not be active\n");
7955
7956 finfo.cbSize = sizeof(FLASHWINFO) - 1;
7957 SetLastError(0xdeadbeef);
7958 ret = pFlashWindowEx(&finfo);
7960 "FlashWindowEx succeeded\n");
7961
7962 finfo.cbSize = sizeof(FLASHWINFO) + 1;
7963 SetLastError(0xdeadbeef);
7964 ret = pFlashWindowEx(&finfo);
7966 "FlashWindowEx succeeded\n");
7967 finfo.cbSize = sizeof(FLASHWINFO);
7968
7970
7971 SetLastError(0xdeadbeef);
7972 ret = pFlashWindowEx(&finfo);
7974 "FlashWindowEx returned with %d\n", GetLastError());
7975
7976 ok(finfo.cbSize == sizeof(FLASHWINFO), "FlashWindowEx modified cdSize to %x\n", finfo.cbSize);
7977 ok(finfo.hwnd == hwnd, "FlashWindowEx modified hwnd to %p\n", finfo.hwnd);
7978 ok(finfo.dwFlags == FLASHW_TIMER, "FlashWindowEx modified dwFlags to %x\n", finfo.dwFlags);
7979 ok(finfo.uCount == 3, "FlashWindowEx modified uCount to %x\n", finfo.uCount);
7980 ok(finfo.dwTimeout == 200, "FlashWindowEx modified dwTimeout to %x\n", finfo.dwTimeout);
7981
7982 hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE | WS_POPUPWINDOW,
7983 0, 0, 0, 0, 0, 0, 0, NULL );
7984 ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
7985 finfo.hwnd = hwnd;
7986
7987 SetLastError(0xdeadbeef);
7988 ret = pFlashWindowEx(NULL);
7990 "FlashWindowEx returned with %d\n", GetLastError());
7991
7992 SetLastError(0xdeadbeef);
7993 prev = pFlashWindowEx(&finfo);
7994
7995 ok(finfo.cbSize == sizeof(FLASHWINFO), "FlashWindowEx modified cdSize to %x\n", finfo.cbSize);
7996 ok(finfo.hwnd == hwnd, "FlashWindowEx modified hwnd to %p\n", finfo.hwnd);
7997 ok(finfo.dwFlags == FLASHW_TIMER, "FlashWindowEx modified dwFlags to %x\n", finfo.dwFlags);
7998 ok(finfo.uCount == 3, "FlashWindowEx modified uCount to %x\n", finfo.uCount);
7999 ok(finfo.dwTimeout == 200, "FlashWindowEx modified dwTimeout to %x\n", finfo.dwTimeout);
8000
8001 finfo.dwFlags = FLASHW_STOP;
8002 SetLastError(0xdeadbeef);
8003 ret = pFlashWindowEx(&finfo);
8004 ok(prev != ret, "previous window state should be different\n");
8005
8007}
8008
8009static void test_FindWindowEx(void)
8010{
8011 HWND hwnd, found;
8012
8013 hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
8014 ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
8015
8016 num_gettext_msgs = 0;
8017 found = FindWindowExA( 0, 0, "MainWindowClass", "" );
8018 ok( found == NULL, "expected a NULL hwnd\n" );
8019 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
8020
8021 num_gettext_msgs = 0;
8022 found = FindWindowExA( 0, 0, "MainWindowClass", NULL );
8023 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
8024 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
8025
8026 num_gettext_msgs = 0;
8027 found = FindWindowExA( 0, 0, "MainWindowClass", "caption" );
8028 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
8029 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
8030
8032
8033 hwnd = CreateWindowExA( 0, "MainWindowClass", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
8034 ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
8035
8036 num_gettext_msgs = 0;
8037 found = FindWindowExA( 0, 0, "MainWindowClass", "" );
8038 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
8039 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
8040
8041 num_gettext_msgs = 0;
8042 found = FindWindowExA( 0, 0, "MainWindowClass", NULL );
8043 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
8044 ok( num_gettext_msgs == 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
8045
8047
8048 /* test behaviour with a window title that is an empty character */
8049 found = FindWindowExA( 0, 0, "Shell_TrayWnd", "" );
8050 ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
8051 found = FindWindowExA( 0, 0, "Shell_TrayWnd", NULL );
8052 ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
8053}
8054
8056{
8057 HWND hwndOwner, hwndPopup1, hwndPopup2;
8058
8059 hwndOwner = CreateWindowExA(0, "MainWindowClass", NULL,
8061 100, 100, 200, 200,
8063 hwndPopup1 = CreateWindowExA(0, "MainWindowClass", NULL,
8065 100, 100, 200, 200,
8066 hwndOwner, 0, GetModuleHandleA(NULL), NULL);
8067 hwndPopup2 = CreateWindowExA(0, "MainWindowClass", NULL,
8069 100, 100, 200, 200,
8070 hwndPopup1, 0, GetModuleHandleA(NULL), NULL);
8071 ok( GetLastActivePopup(hwndOwner) == hwndPopup2, "wrong last active popup\n" );
8072 DestroyWindow( hwndPopup2 );
8073 DestroyWindow( hwndPopup1 );
8074 DestroyWindow( hwndOwner );
8075}
8076
8078{
8079 if (msg == WM_NCHITTEST) return HTTRANSPARENT;
8080 return DefWindowProcA(hwnd, msg, wp, lp);
8081}
8082
8084{
8085 return DefWindowProcA(hwnd, msg, wp, lp);
8086}
8087
8089{
8090 static const DWORD style[] = { 0, WS_VISIBLE, WS_DISABLED, WS_VISIBLE | WS_DISABLED };
8091 int i, pos;
8092
8093 memset(window, 0, size * sizeof(window[0]));
8094
8095 pos = 0;
8096 for (i = 0; i < sizeof(style)/sizeof(style[0]); i++)
8097 {
8098 assert(pos < size);
8099 window[pos] = CreateWindowExA(0, "my_window", NULL, style[i] | WS_CHILD,
8100 0, 0, 100, 100, parent, 0, 0, NULL);
8101 ok(window[pos] != 0, "CreateWindowEx failed\n");
8102 pos++;
8103 assert(pos < size);
8105 0, 0, 100, 100, parent, 0, 0, NULL);
8106 ok(window[pos] != 0, "CreateWindowEx failed\n");
8107 pos++;
8108
8109 assert(pos < size);
8110 window[pos] = CreateWindowExA(0, "my_httrasparent", NULL, style[i] | WS_CHILD,
8111 0, 0, 100, 100, parent, 0, 0, NULL);
8112 ok(window[pos] != 0, "CreateWindowEx failed\n");
8113 pos++;
8114 assert(pos < size);
8115 window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "my_httrasparent", NULL, style[i] | WS_CHILD,
8116 0, 0, 100, 100, parent, 0, 0, NULL);
8117 ok(window[pos] != 0, "CreateWindowEx failed\n");
8118 pos++;
8119
8120 assert(pos < size);
8121 window[pos] = CreateWindowExA(0, "my_button", NULL, style[i] | WS_CHILD | BS_GROUPBOX,
8122 0, 0, 100, 100, parent, 0, 0, NULL);
8123 ok(window[pos] != 0, "CreateWindowEx failed\n");
8124 pos++;
8125 assert(pos < size);
8127 0, 0, 100, 100, parent, 0, 0, NULL);
8128 ok(window[pos] != 0, "CreateWindowEx failed\n");
8129 pos++;
8130 assert(pos < size);
8131 window[pos] = CreateWindowExA(0, "my_button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON,
8132 0, 0, 100, 100, parent, 0, 0, NULL);
8133 ok(window[pos] != 0, "CreateWindowEx failed\n");
8134 pos++;
8135 assert(pos < size);
8137 0, 0, 100, 100, parent, 0, 0, NULL);
8138 ok(window[pos] != 0, "CreateWindowEx failed\n");
8139 pos++;
8140
8141 assert(pos < size);
8142 window[pos] = CreateWindowExA(0, "Button", NULL, style[i] | WS_CHILD | BS_GROUPBOX,
8143 0, 0, 100, 100, parent, 0, 0, NULL);
8144 ok(window[pos] != 0, "CreateWindowEx failed\n");
8145 pos++;
8146 assert(pos < size);
8148 0, 0, 100, 100, parent, 0, 0, NULL);
8149 ok(window[pos] != 0, "CreateWindowEx failed\n");
8150 pos++;
8151 assert(pos < size);
8153 0, 0, 100, 100, parent, 0, 0, NULL);
8154 ok(window[pos] != 0, "CreateWindowEx failed\n");
8155 pos++;
8156 assert(pos < size);
8158 0, 0, 100, 100, parent, 0, 0, NULL);
8159 ok(window[pos] != 0, "CreateWindowEx failed\n");
8160 pos++;
8161
8162 assert(pos < size);
8163 window[pos] = CreateWindowExA(0, "Static", NULL, style[i] | WS_CHILD,
8164 0, 0, 100, 100, parent, 0, 0, NULL);
8165 ok(window[pos] != 0, "CreateWindowEx failed\n");
8166 pos++;
8167 assert(pos < size);
8169 0, 0, 100, 100, parent, 0, 0, NULL);
8170 ok(window[pos] != 0, "CreateWindowEx failed\n");
8171 pos++;
8172 }
8173}
8174
8176{
8177 char class_name[128];
8179};
8180
8182{
8183 DWORD style, ex_style, hittest;
8184
8186 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
8187 attrs->class_name[0] = 0;
8188 GetClassNameA(hwnd, attrs->class_name, sizeof(attrs->class_name));
8189 hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, 0);
8190
8191 attrs->is_visible = (style & WS_VISIBLE) != 0;
8192 attrs->is_enabled = (style & WS_DISABLED) == 0;
8193 attrs->is_groupbox = !lstrcmpiA(attrs->class_name, "Button") && (style & BS_TYPEMASK) == BS_GROUPBOX;
8194 attrs->is_httransparent = hittest == HTTRANSPARENT;
8195 attrs->is_extransparent = (ex_style & WS_EX_TRANSPARENT) != 0;
8196}
8197
8199{
8200 int i;
8201
8202 for (i = 0; i < size; i++)
8203 {
8204 if (!window[i]) break;
8205 if (window[i] == hwnd) return i;
8206 }
8207 return -1;
8208}
8209
8211{
8212 static const int real_child_pos[] = { 14,15,16,17,18,19,20,21,24,25,26,27,42,43,
8213 44,45,46,47,48,49,52,53,54,55,51,50,23,22,-1 };
8214 static const int real_child_pos_nt4[] = { 14,15,16,17,20,21,24,25,26,27,42,43,44,45,
8215 48,49,52,53,54,55,51,50,47,46,23,22,19,18,-1 };
8216 WNDCLASSA cls;
8217 HWND hwnd, parent, window[100];
8218 POINT pt;
8219 int found_invisible, found_disabled, found_groupbox, found_httransparent, found_extransparent;
8220 int ret, i;
8221
8222 ret = GetClassInfoA(0, "Button", &cls);
8223 ok(ret, "GetClassInfo(Button) failed\n");
8224 cls.lpszClassName = "my_button";
8225 ret = RegisterClassA(&cls);
8226 ok(ret, "RegisterClass(my_button) failed\n");
8227
8228 cls.lpszClassName = "my_httrasparent";
8230 ret = RegisterClassA(&cls);
8231 ok(ret, "RegisterClass(my_httrasparent) failed\n");
8232
8233 cls.lpszClassName = "my_window";
8235 ret = RegisterClassA(&cls);
8236 ok(ret, "RegisterClass(my_window) failed\n");
8237
8238 parent = CreateWindowExA(0, "MainWindowClass", NULL,
8240 100, 100, 200, 200,
8241 0, 0, GetModuleHandleA(NULL), NULL);
8242 ok(parent != 0, "CreateWindowEx failed\n");
8243 trace("parent %p\n", parent);
8244
8245 create_window_tree(parent, window, sizeof(window)/sizeof(window[0]));
8246
8247 found_invisible = 0;
8248 found_disabled = 0;
8249 found_groupbox = 0;
8250 found_httransparent = 0;
8251 found_extransparent = 0;
8252
8253 /* FIXME: also test WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx */
8254 for (i = 0; i < sizeof(real_child_pos)/sizeof(real_child_pos[0]); i++)
8255 {
8256 struct window_attributes attrs;
8257
8258 pt.x = pt.y = 50;
8260 ok(hwnd != 0, "RealChildWindowFromPoint failed\n");
8261 ret = window_to_index(hwnd, window, sizeof(window)/sizeof(window[0]));
8262 /* FIXME: remove once Wine is fixed */
8263 todo_wine_if (ret != real_child_pos[i])
8264 ok(ret == real_child_pos[i] || broken(ret == real_child_pos_nt4[i]), "expected %d, got %d\n", real_child_pos[i], ret);
8265
8266 get_window_attributes(hwnd, &attrs);
8267 if (!attrs.is_visible) found_invisible++;
8268 if (!attrs.is_enabled) found_disabled++;
8269 if (attrs.is_groupbox) found_groupbox++;
8270 if (attrs.is_httransparent) found_httransparent++;
8271 if (attrs.is_extransparent) found_extransparent++;
8272
8273 if (ret != real_child_pos[i] && ret != -1)
8274 {
8275 trace("found hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
8276 hwnd, attrs.class_name, attrs.is_visible, attrs.is_enabled, attrs.is_groupbox, attrs.is_httransparent, attrs.is_extransparent);
8277 get_window_attributes(window[real_child_pos[i]], &attrs);
8278 trace("expected hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
8279 window[real_child_pos[i]], attrs.class_name, attrs.is_visible, attrs.is_enabled, attrs.is_groupbox, attrs.is_httransparent, attrs.is_extransparent);
8280 }
8281 if (ret == -1)
8282 {
8283 ok(hwnd == parent, "expected %p, got %p\n", parent, hwnd);
8284 break;
8285 }
8287 }
8288
8290
8291 ok(!found_invisible, "found %d invisible windows\n", found_invisible);
8292 ok(found_disabled, "found %d disabled windows\n", found_disabled);
8294 ok(found_groupbox == 4, "found %d groupbox windows\n", found_groupbox);
8295 ok(found_httransparent, "found %d httransparent windows\n", found_httransparent);
8297 ok(found_extransparent, "found %d extransparent windows\n", found_extransparent);
8298
8299 ret = UnregisterClassA("my_button", cls.hInstance);
8300 ok(ret, "UnregisterClass(my_button) failed\n");
8301 ret = UnregisterClassA("my_httrasparent", cls.hInstance);
8302 ok(ret, "UnregisterClass(my_httrasparent) failed\n");
8303 ret = UnregisterClassA("my_window", cls.hInstance);
8304 ok(ret, "UnregisterClass(my_window) failed\n");
8305}
8306
8307static void simulate_click(int x, int y)
8308{
8309 INPUT input[2];
8310 UINT events_no;
8311
8312 SetCursorPos(x, y);
8313 memset(input, 0, sizeof(input));
8314 input[0].type = INPUT_MOUSE;
8315 U(input[0]).mi.dx = x;
8316 U(input[0]).mi.dy = y;
8317 U(input[0]).mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
8318 input[1].type = INPUT_MOUSE;
8319 U(input[1]).mi.dx = x;
8320 U(input[1]).mi.dy = y;
8321 U(input[1]).mi.dwFlags = MOUSEEVENTF_LEFTUP;
8322 events_no = SendInput(2, input, sizeof(input[0]));
8323 ok(events_no == 2, "SendInput returned %d\n", events_no);
8324}
8325
8329{
8330 if(msg == WM_NCHITTEST)
8331 got_hittest = TRUE;
8332 if(msg == WM_LBUTTONDOWN)
8333 ok(0, "unexpected call\n");
8334
8335 return def_static_proc(hwnd, msg, wp, lp);
8336}
8337
8339{
8340 HANDLE start_event, end_event;
8341 HANDLE win, child_static, child_button;
8342 BOOL got_click;
8343 DWORD ret;
8344 POINT pt;
8345 MSG msg;
8346
8347 start_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_wfp_start");
8348 ok(start_event != 0, "OpenEvent failed\n");
8349 end_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_wfp_end");
8350 ok(end_event != 0, "OpenEvent failed\n");
8351
8352 child_static = CreateWindowExA(0, "static", "static", WS_CHILD | WS_VISIBLE,
8353 0, 0, 100, 100, parent, 0, NULL, NULL);
8354 ok(child_static != 0, "CreateWindowEx failed\n");
8355 pt.x = pt.y = 150;
8357 ok(win == parent, "WindowFromPoint returned %p, expected %p\n", win, parent);
8358
8359 child_button = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
8360 100, 0, 100, 100, parent, 0, NULL, NULL);
8361 ok(child_button != 0, "CreateWindowEx failed\n");
8362 pt.x = 250;
8364 ok(win == child_button, "WindowFromPoint returned %p, expected %p\n", win, child_button);
8365
8366 /* without this window simulate click test keeps sending WM_NCHITTEST
8367 * message to child_static in an infinite loop */
8368 win = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
8369 0, 0, 100, 100, parent, 0, NULL, NULL);
8370 ok(win != 0, "CreateWindowEx failed\n");
8371 def_static_proc = (void*)SetWindowLongPtrA(child_static,
8375
8377 got_click = FALSE;
8378 while(!got_click && wait_for_message(&msg)) {
8379 if(msg.message == WM_LBUTTONUP) {
8380 ok(msg.hwnd == win, "msg.hwnd = %p, expected %p\n", msg.hwnd, win);
8381 got_click = TRUE;
8382 }
8384 }
8385 ok(got_hittest, "transparent window didn't get WM_NCHITTEST message\n");
8386 ok(got_click, "button under static window didn't get WM_LBUTTONUP\n");
8387
8388 ret = WaitForSingleObject(end_event, 5000);
8389 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", ret);
8390
8392 CloseHandle(end_event);
8393}
8394
8395static void test_window_from_point(const char *argv0)
8396{
8397 HWND hwnd, child, win;
8398 POINT pt;
8401 char cmd[MAX_PATH];
8402 HANDLE start_event, end_event;
8403
8404 hwnd = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP | WS_VISIBLE,
8405 100, 100, 200, 100, 0, 0, NULL, NULL);
8406 ok(hwnd != 0, "CreateWindowEx failed\n");
8407
8408 pt.x = pt.y = 150;
8410 pt.x = 250;
8411 if(win == hwnd)
8413 if(win != hwnd) {
8414 skip("there's another window covering test window\n");
8416 return;
8417 }
8418
8419 child = CreateWindowExA(0, "static", "static", WS_CHILD | WS_VISIBLE,
8420 0, 0, 100, 100, hwnd, 0, NULL, NULL);
8421 ok(child != 0, "CreateWindowEx failed\n");
8422 pt.x = pt.y = 150;
8424 ok(win == hwnd, "WindowFromPoint returned %p, expected %p\n", win, hwnd);
8426
8427 child = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
8428 0, 0, 100, 100, hwnd, 0, NULL, NULL);
8429 ok(child != 0, "CreateWindowEx failed\n");
8431 ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
8433
8434 start_event = CreateEventA(NULL, FALSE, FALSE, "test_wfp_start");
8435 ok(start_event != 0, "CreateEvent failed\n");
8436 end_event = CreateEventA(NULL, FALSE, FALSE, "test_wfp_end");
8437 ok(start_event != 0, "CreateEvent failed\n");
8438
8439 sprintf(cmd, "%s win create_children %p\n", argv0, hwnd);
8440 memset(&startup, 0, sizeof(startup));
8441 startup.cb = sizeof(startup);
8443 &startup, &info), "CreateProcess failed.\n");
8444 ok(wait_for_event(start_event, 1000), "didn't get start_event\n");
8445
8448 ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
8449
8450 simulate_click(150, 150);
8452
8454 pt.x = 250;
8456 ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
8457
8458 SetEvent(end_event);
8461 CloseHandle(end_event);
8462 CloseHandle(info.hProcess);
8463 CloseHandle(info.hThread);
8464
8466}
8467
8468static void test_map_points(void)
8469{
8470 BOOL ret;
8471 POINT p;
8472 HWND wnd, wnd0, dwnd;
8473 INT n;
8474 DWORD err;
8475 POINT pos = { 100, 200 };
8476 int width = 150;
8477 int height = 150;
8478 RECT window_rect;
8479 RECT client_rect;
8480
8481 /* Create test windows */
8482 wnd = CreateWindowA("static", "test1", WS_POPUP, pos.x, pos.y, width, height, NULL, NULL, NULL, NULL);
8483 ok(wnd != NULL, "Failed %p\n", wnd);
8484 wnd0 = CreateWindowA("static", "test2", WS_POPUP, 0, 0, width, height, NULL, NULL, NULL, NULL);
8485 ok(wnd0 != NULL, "Failed %p\n", wnd);
8486 dwnd = CreateWindowA("static", "test3", 0, 200, 300, 150, 150, NULL, NULL, NULL, NULL);
8487 DestroyWindow(dwnd);
8488 ok(dwnd != NULL, "Failed %p\n", dwnd);
8489
8490 /* Verify window rect and client rect (they should have the same width and height) */
8491 GetWindowRect(wnd, &window_rect);
8492 ok(window_rect.left == pos.x, "left is %d instead of %d\n", window_rect.left, pos.x);
8493 ok(window_rect.top == pos.y, "top is %d instead of %d\n", window_rect.top, pos.y);
8494 ok(window_rect.right == pos.x + width, "right is %d instead of %d\n", window_rect.right, pos.x + width);
8495 ok(window_rect.bottom == pos.y + height, "bottom is %d instead of %d\n", window_rect.bottom, pos.y + height);
8496 GetClientRect(wnd, &client_rect);
8497 ok(client_rect.left == 0, "left is %d instead of 0\n", client_rect.left);
8498 ok(client_rect.top == 0, "top is %d instead of 0\n", client_rect.top);
8499 ok(client_rect.right == width, "right is %d instead of %d\n", client_rect.right, width);
8500 ok(client_rect.bottom == height, "bottom is %d instead of %d\n", client_rect.bottom, height);
8501
8502 /* Test MapWindowPoints */
8503
8504 /* MapWindowPoints(NULL or wnd, NULL or wnd, NULL, 1); crashes on Windows */
8505
8506 SetLastError(0xdeadbeef);
8507 n = MapWindowPoints(NULL, NULL, NULL, 0);
8508 err = GetLastError();
8509 ok(n == 0, "Got %d, expected %d\n", n, 0);
8510 ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef);
8511
8512 SetLastError(0xdeadbeef);
8513 n = MapWindowPoints(wnd, wnd, NULL, 0);
8514 err = GetLastError();
8515 ok(n == 0, "Got %d, expected %d\n", n, 0);
8516 ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef);
8517
8518 n = MapWindowPoints(wnd, NULL, NULL, 0);
8519 ok(n == MAKELONG(window_rect.left, window_rect.top), "Got %x, expected %x\n",
8520 n, MAKELONG(window_rect.left, window_rect.top));
8521
8522 n = MapWindowPoints(NULL, wnd, NULL, 0);
8523 ok(n == MAKELONG(-window_rect.left, -window_rect.top), "Got %x, expected %x\n",
8524 n, MAKELONG(-window_rect.left, -window_rect.top));
8525
8526 SetLastError(0xdeadbeef);
8527 p.x = p.y = 100;
8528 n = MapWindowPoints(dwnd, NULL, &p, 1);
8529 err = GetLastError();
8530 ok(n == 0, "Got %d, expected %d\n", n, 0);
8531 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8532 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8533
8534 SetLastError(0xdeadbeef);
8535 p.x = p.y = 100;
8536 n = MapWindowPoints(dwnd, wnd, &p, 1);
8537 err = GetLastError();
8538 ok(n == 0, "Got %d, expected %d\n", n, 0);
8539 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8540 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8541
8542 SetLastError(0xdeadbeef);
8543 p.x = p.y = 100;
8544 n = MapWindowPoints(NULL, dwnd, &p, 1);
8545 err = GetLastError();
8546 ok(n == 0, "Got %d, expected %d\n", n, 0);
8547 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8548 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8549
8550 SetLastError(0xdeadbeef);
8551 p.x = p.y = 100;
8552 n = MapWindowPoints(wnd, dwnd, &p, 1);
8553 err = GetLastError();
8554 ok(n == 0, "Got %d, expected %d\n", n, 0);
8555 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8556 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8557
8558 SetLastError(0xdeadbeef);
8559 p.x = p.y = 100;
8560 n = MapWindowPoints(dwnd, dwnd, &p, 1);
8561 err = GetLastError();
8562 ok(n == 0, "Got %d, expected %d\n", n, 0);
8563 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8564 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8565
8566 SetLastError(0xdeadbeef);
8567 p.x = p.y = 100;
8568 n = MapWindowPoints(NULL, NULL, &p, 1);
8569 err = GetLastError();
8570 ok(n == 0, "Got %d, expected %d\n", n, 0);
8571 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8572 ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef);
8573
8574 SetLastError(0xdeadbeef);
8575 p.x = p.y = 100;
8576 n = MapWindowPoints(wnd, wnd, &p, 1);
8577 err = GetLastError();
8578 ok(n == 0, "Got %d, expected %d\n", n, 0);
8579 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8580 ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef);
8581
8582 p.x = p.y = 100;
8583 n = MapWindowPoints(wnd, NULL, &p, 1);
8584 ok(n == MAKELONG(window_rect.left, window_rect.top), "Got %x, expected %x\n",
8585 n, MAKELONG(window_rect.left, window_rect.top));
8586 ok((p.x == (window_rect.left + 100)) && (p.y == (window_rect.top + 100)), "Failed got (%d, %d), expected (%d, %d)\n",
8587 p.x, p.y, window_rect.left + 100, window_rect.top + 100);
8588
8589 p.x = p.y = 100;
8590 n = MapWindowPoints(NULL, wnd, &p, 1);
8591 ok(n == MAKELONG(-window_rect.left, -window_rect.top), "Got %x, expected %x\n",
8592 n, MAKELONG(-window_rect.left, -window_rect.top));
8593 ok((p.x == (-window_rect.left + 100)) && (p.y == (-window_rect.top + 100)), "Failed got (%d, %d), expected (%d, %d)\n",
8594 p.x, p.y, -window_rect.left + 100, -window_rect.top + 100);
8595
8596 SetLastError(0xdeadbeef);
8597 p.x = p.y = 0;
8598 n = MapWindowPoints(wnd0, NULL, &p, 1);
8599 err = GetLastError();
8600 ok(n == 0, "Got %x, expected 0\n", n);
8601 ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y);
8602 ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef);
8603
8604 SetLastError(0xdeadbeef);
8605 p.x = p.y = 0;
8606 n = MapWindowPoints(NULL, wnd0, &p, 1);
8607 err = GetLastError();
8608 ok(n == 0, "Got %x, expected 0\n", n);
8609 ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y);
8610 ok(err == 0xdeadbeef, "Got %x, expected %x\n", err, 0xdeadbeef);
8611
8612 /* Test ClientToScreen */
8613
8614 /* ClientToScreen(wnd, NULL); crashes on Windows */
8615
8616 SetLastError(0xdeadbeef);
8618 err = GetLastError();
8619 ok(!ret, "Should fail\n");
8620 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8621
8622 SetLastError(0xdeadbeef);
8623 p.x = p.y = 100;
8624 ret = ClientToScreen(NULL, &p);
8625 err = GetLastError();
8626 ok(!ret, "Should fail\n");
8627 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8628 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8629
8630 SetLastError(0xdeadbeef);
8631 p.x = p.y = 100;
8632 ret = ClientToScreen(dwnd, &p);
8633 err = GetLastError();
8634 ok(!ret, "Should fail\n");
8635 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8636 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8637
8638 p.x = p.y = 100;
8639 ret = ClientToScreen(wnd, &p);
8640 ok(ret, "Failed with error %u\n", GetLastError());
8641 ok((p.x == (window_rect.left + 100)) && (p.y == (window_rect.top + 100)), "Failed got (%d, %d), expected (%d, %d)\n",
8642 p.x, p.y, window_rect.left + 100, window_rect.top + 100);
8643
8644 p.x = p.y = 0;
8645 ret = ClientToScreen(wnd0, &p);
8646 ok(ret, "Failed with error %u\n", GetLastError());
8647 ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y);
8648
8649 /* Test ScreenToClient */
8650
8651 /* ScreenToClient(wnd, NULL); crashes on Windows */
8652
8653 SetLastError(0xdeadbeef);
8655 err = GetLastError();
8656 ok(!ret, "Should fail\n");
8657 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8658
8659 SetLastError(0xdeadbeef);
8660 p.x = p.y = 100;
8661 ret = ScreenToClient(NULL, &p);
8662 err = GetLastError();
8663 ok(!ret, "Should fail\n");
8664 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8665 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8666
8667 SetLastError(0xdeadbeef);
8668 p.x = p.y = 100;
8669 ret = ScreenToClient(dwnd, &p);
8670 err = GetLastError();
8671 ok(!ret, "Should fail\n");
8672 ok(p.x == 100 && p.y == 100, "Failed got(%d, %d), expected (%d, %d)\n", p.x, p.y, 100, 100);
8673 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %x, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
8674
8675 p.x = p.y = 100;
8676 ret = ScreenToClient(wnd, &p);
8677 ok(ret, "Failed with error %u\n", GetLastError());
8678 ok((p.x == (-window_rect.left + 100)) && (p.y == (-window_rect.top + 100)), "Failed got(%d, %d), expected (%d, %d)\n",
8679 p.x, p.y, -window_rect.left + 100, -window_rect.top + 100);
8680
8681 p.x = p.y = 0;
8682 ret = ScreenToClient(wnd0, &p);
8683 ok(ret, "Failed with error %u\n", GetLastError());
8684 ok((p.x == 0) && (p.y == 0), "Failed got (%d, %d), expected (0, 0)\n", p.x, p.y);
8685
8686 DestroyWindow(wnd);
8687 DestroyWindow(wnd0);
8688}
8689
8690static void test_update_region(void)
8691{
8693 HRGN rgn1, rgn2;
8694 const RECT rc = {15, 15, 40, 40};
8695 const POINT wnd_orig = {30, 20};
8696 const POINT child_orig = {10, 5};
8697
8698 parent = CreateWindowExA(0, "MainWindowClass", NULL,
8700 0, 0, 300, 150, NULL, NULL, GetModuleHandleA(0), 0);
8701 hwnd = CreateWindowExA(0, "MainWindowClass", NULL,
8703 0, 0, 200, 100, parent, NULL, GetModuleHandleA(0), 0);
8704 child = CreateWindowExA(0, "MainWindowClass", NULL,
8706 child_orig.x, child_orig.y, 100, 50,
8707 hwnd, NULL, GetModuleHandleA(0), 0);
8708 assert(parent && hwnd && child);
8709
8712 InvalidateRect(hwnd, &rc, FALSE);
8714
8715 rgn1 = CreateRectRgn(0, 0, 0, 0);
8717 "has invalid area after ValidateRgn(NULL)\n");
8718 GetUpdateRgn(hwnd, rgn1, FALSE);
8719 rgn2 = CreateRectRgnIndirect(&rc);
8720 ok(EqualRgn(rgn1, rgn2), "assigned and retrieved update regions are different\n");
8722 "has invalid area after ValidateRgn(NULL)\n");
8723
8724 SetWindowPos(hwnd, 0, wnd_orig.x, wnd_orig.y, 0, 0,
8726
8727 /* parent now has non-simple update region, it consist of
8728 * two rects, that was exposed after hwnd moving ... */
8729 SetRectRgn(rgn1, 0, 0, 200, wnd_orig.y);
8730 SetRectRgn(rgn2, 0, 0, wnd_orig.x, 100);
8731 CombineRgn(rgn1, rgn1, rgn2, RGN_OR);
8732 /* ... and mapped hwnd's invalid area, that hwnd has before moving */
8733 SetRectRgn(rgn2, rc.left + wnd_orig.x, rc.top + wnd_orig.y,
8734 rc.right + wnd_orig.x, rc.bottom + wnd_orig.y);
8735 CombineRgn(rgn1, rgn1, rgn2, RGN_OR);
8736 GetUpdateRgn(parent, rgn2, FALSE);
8738 ok(EqualRgn(rgn1, rgn2), "wrong update region\n");
8739
8740 /* hwnd has the same invalid region as before moving */
8741 SetRectRgn(rgn1, rc.left, rc.top, rc.right, rc.bottom);
8742 GetUpdateRgn(hwnd, rgn2, FALSE);
8743 ok(EqualRgn(rgn1, rgn2), "wrong update region\n");
8744
8745 /* hwnd's invalid area maps to child during moving */
8746 SetRectRgn(rgn1, rc.left - child_orig.x , rc.top - child_orig.y,
8747 rc.right - child_orig.x, rc.bottom - child_orig.y);
8748 GetUpdateRgn(child, rgn2, FALSE);
8750 ok(EqualRgn(rgn1, rgn2), "wrong update region\n");
8751
8752 DeleteObject(rgn1);
8753 DeleteObject(rgn2);
8755}
8756
8758{
8759 HWND hwnd;
8760
8762 0, 0, 50, 50, hwndMain, NULL, 0, NULL);
8763 ok(hwnd != NULL, "CreateWindow failed\n");
8764
8766 "can't remove WS_CHILD style\n");
8767
8773
8775}
8776
8777
8779{
8786};
8787
8788
8790{
8791 switch (msg)
8792 {
8793 case WM_APP:
8794 {
8796
8797 ok(hwnd == data->thread_hwnd, "unexpected hwnd %p\n", hwnd);
8798
8799 SendNotifyMessageA(data->main_hwnd, WM_APP+1, 0, lparam);
8800
8801 /* Don't return until the main thread is processing our sent message. */
8802 ok(WaitForSingleObject(data->main_in_wm_app_1, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8803
8804 /* Break the PeekMessage loop so we can notify the main thread after we return. */
8805 SetEvent(data->thread_got_wm_app);
8806
8807 return 0x240408ea;
8808 }
8809 case WM_APP+1:
8810 {
8812 LRESULT res;
8813
8814 ok(hwnd == data->main_hwnd, "unexpected hwnd %p\n", hwnd);
8815
8816 /* Ask the thread to reply to our WM_APP message. */
8817 SetEvent(data->main_in_wm_app_1);
8818
8819 /* Wait until the thread has sent a reply. */
8820 ok(WaitForSingleObject(data->thread_replied, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8821
8822 /* Send another message while we have a reply queued for the current one. */
8823 res = SendMessageA(data->thread_hwnd, WM_APP+2, 0, lparam);
8824 ok(res == 0x449b0190, "unexpected result %lx\n", res);
8825
8826 return 0;
8827 }
8828 case WM_APP+2:
8829 {
8831
8832 ok(hwnd == data->thread_hwnd, "unexpected hwnd %p\n", hwnd);
8833
8834 /* Don't return until we know the main thread is processing sent messages. */
8835 SendMessageA(data->main_hwnd, WM_NULL, 0, 0);
8836
8837 return 0x449b0190;
8838 }
8839 case WM_CLOSE:
8840 PostQuitMessage(0);
8841 break;
8842 }
8843 return DefWindowProcA(hwnd, msg, wparam, lparam);
8844}
8845
8847{
8848 MSG msg;
8850
8851 data->thread_hwnd = CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW,
8852 100, 100, 200, 200, 0, 0, 0, NULL);
8853 ok(data->thread_hwnd != 0, "Failed to create overlapped window\n");
8854
8855 SetEvent(data->thread_started);
8856
8857 /* Loop until we've processed WM_APP. */
8858 while (WaitForSingleObject(data->thread_got_wm_app, 0) != WAIT_OBJECT_0)
8859 {
8860 if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
8861 {
8864 }
8865 else
8866 {
8867 MsgWaitForMultipleObjects(1, &data->thread_got_wm_app, FALSE, INFINITE, QS_SENDMESSAGE);
8868 }
8869 }
8870
8871 /* Notify the main thread that we replied to its WM_APP message. */
8872 SetEvent(data->thread_replied);
8873
8874 while (GetMessageA(&msg, 0, 0, 0))
8875 {
8878 }
8879
8880 return 0;
8881}
8882
8883static void test_smresult(void)
8884{
8885 WNDCLASSA cls;
8887 DWORD tid;
8889 BOOL ret;
8890 LRESULT res;
8891
8892 cls.style = CS_DBLCLKS;
8894 cls.cbClsExtra = 0;
8895 cls.cbWndExtra = 0;
8896 cls.hInstance = GetModuleHandleA(0);
8897 cls.hIcon = 0;
8900 cls.lpszMenuName = NULL;
8901 cls.lpszClassName = "SmresultClass";
8902
8903 ret = RegisterClassA(&cls);
8904 ok(ret, "RegisterClassA failed\n");
8905
8906 data.thread_started = CreateEventA(NULL, TRUE, FALSE, NULL);
8907 ok(data.thread_started != NULL, "CreateEventA failed\n");
8908
8909 data.thread_got_wm_app = CreateEventA(NULL, TRUE, FALSE, NULL);
8910 ok(data.thread_got_wm_app != NULL, "CreateEventA failed\n");
8911
8912 data.main_in_wm_app_1 = CreateEventA(NULL, TRUE, FALSE, NULL);
8913 ok(data.main_in_wm_app_1 != NULL, "CreateEventA failed\n");
8914
8915 data.thread_replied = CreateEventA(NULL, TRUE, FALSE, NULL);
8916 ok(data.thread_replied != NULL, "CreateEventA failed\n");
8917
8918 data.main_hwnd = CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW,
8919 100, 100, 200, 200, 0, 0, 0, NULL);
8920
8922 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
8923
8924 ok(WaitForSingleObject(data.thread_started, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8925
8926 res = SendMessageA(data.thread_hwnd, WM_APP, 0, (LPARAM)&data);
8927 ok(res == 0x240408ea, "unexpected result %lx\n", res);
8928
8929 SendMessageA(data.thread_hwnd, WM_CLOSE, 0, 0);
8930
8931 DestroyWindow(data.main_hwnd);
8932
8933 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8934
8935 CloseHandle(data.thread_started);
8936 CloseHandle(data.thread_got_wm_app);
8937 CloseHandle(data.main_in_wm_app_1);
8938 CloseHandle(data.thread_replied);
8939}
8940
8941static void test_GetMessagePos(void)
8942{
8943 HWND button;
8944 DWORD pos;
8945 MSG msg;
8946
8947 button = CreateWindowExA(0, "button", "button", WS_VISIBLE,
8948 100, 100, 100, 100, 0, 0, 0, NULL);
8949 ok(button != 0, "CreateWindowExA failed\n");
8950
8951 SetCursorPos(120, 140);
8953 pos = GetMessagePos();
8954 ok(pos == MAKELONG(120, 140), "pos = %08x\n", pos);
8955
8956 SetCursorPos(340, 320);
8957 pos = GetMessagePos();
8958 ok(pos == MAKELONG(120, 140), "pos = %08x\n", pos);
8959
8960 SendMessageW(button, WM_APP, 0, 0);
8961 pos = GetMessagePos();
8962 ok(pos == MAKELONG(120, 140), "pos = %08x\n", pos);
8963
8964 PostMessageA(button, WM_APP, 0, 0);
8965 GetMessageA(&msg, button, 0, 0);
8966 ok(msg.message == WM_APP, "msg.message = %x\n", msg.message);
8967 pos = GetMessagePos();
8968 ok(pos == MAKELONG(340, 320), "pos = %08x\n", pos);
8969
8970 PostMessageA(button, WM_APP, 0, 0);
8971 SetCursorPos(350, 330);
8972 GetMessageA(&msg, button, 0, 0);
8973 ok(msg.message == WM_APP, "msg.message = %x\n", msg.message);
8974 pos = GetMessagePos();
8975 ok(pos == MAKELONG(340, 320), "pos = %08x\n", pos);
8976
8977 PostMessageA(button, WM_APP, 0, 0);
8978 SetCursorPos(320, 340);
8979 PostMessageA(button, WM_APP+1, 0, 0);
8980 pos = GetMessagePos();
8981 ok(pos == MAKELONG(340, 320), "pos = %08x\n", pos);
8982 GetMessageA(&msg, button, 0, 0);
8983 ok(msg.message == WM_APP, "msg.message = %x\n", msg.message);
8984 pos = GetMessagePos();
8985 ok(pos == MAKELONG(350, 330), "pos = %08x\n", pos);
8986 GetMessageA(&msg, button, 0, 0);
8987 ok(msg.message == WM_APP+1, "msg.message = %x\n", msg.message);
8988 pos = GetMessagePos();
8989 ok(pos == MAKELONG(320, 340), "pos = %08x\n", pos);
8990
8991 SetTimer(button, 1, 250, NULL);
8992 SetCursorPos(330, 350);
8993 GetMessageA(&msg, button, 0, 0);
8994 while (msg.message == WM_PAINT)
8995 {
8997 GetMessageA(&msg, button, 0, 0);
8998 }
8999 ok(msg.message == WM_TIMER, "msg.message = %x\n", msg.message);
9000 pos = GetMessagePos();
9001 ok(pos == MAKELONG(330, 350), "pos = %08x\n", pos);
9002 KillTimer(button, 1);
9003
9005}
9006
9007#define SET_FOREGROUND_STEAL_1 0x01
9008#define SET_FOREGROUND_SET_1 0x02
9009#define SET_FOREGROUND_STEAL_2 0x04
9010#define SET_FOREGROUND_SET_2 0x08
9011#define SET_FOREGROUND_INJECT 0x10
9012
9014{
9018};
9019
9021{
9023 MSG msg;
9024
9025 p->thread_window = CreateWindowExA(0, "static", "thread window", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9026 0, 0, 10, 10, 0, 0, 0, NULL);
9027 SetEvent(p->command_executed);
9028
9029 while(GetMessageA(&msg, 0, 0, 0))
9030 {
9031 if (msg.message == p->msg_quit)
9032 break;
9033
9034 if (msg.message == p->msg_command)
9035 {
9036 if (msg.wParam & SET_FOREGROUND_STEAL_1)
9037 {
9038 SetForegroundWindow(p->thread_window);
9039 check_wnd_state(p->thread_window, p->thread_window, p->thread_window, 0);
9040 }
9041 if (msg.wParam & SET_FOREGROUND_INJECT)
9042 {
9043 SendNotifyMessageA(p->window1, WM_ACTIVATEAPP, 0, 0);
9044 }
9045 if (msg.wParam & SET_FOREGROUND_SET_1)
9046 {
9047 SetForegroundWindow(p->window1);
9048 check_wnd_state(0, p->window1, 0, 0);
9049 }
9050 if (msg.wParam & SET_FOREGROUND_STEAL_2)
9051 {
9052 SetForegroundWindow(p->thread_window);
9053 check_wnd_state(p->thread_window, p->thread_window, p->thread_window, 0);
9054 }
9055 if (msg.wParam & SET_FOREGROUND_SET_2)
9056 {
9057 SetForegroundWindow(p->window2);
9058 check_wnd_state(0, p->window2, 0, 0);
9059 }
9060
9061 SetEvent(p->command_executed);
9062 continue;
9063 }
9064
9067 }
9068
9069 DestroyWindow(p->thread_window);
9070 return 0;
9071}
9072
9074{
9076 HANDLE thread;
9077 struct set_foreground_thread_params thread_params;
9078 DWORD tid;
9079 MSG msg;
9080
9081 window2 = CreateWindowExA(0, "static", "window 2", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9082 300, 0, 10, 10, 0, 0, 0, NULL);
9083 thread_params.msg_quit = WM_USER;
9084 thread_params.msg_command = WM_USER + 1;
9085 thread_params.window1 = window1;
9086 thread_params.window2 = window2;
9087 thread_params.command_executed = CreateEventW(NULL, FALSE, FALSE, NULL);
9088
9089 thread = CreateThread(NULL, 0, set_foreground_thread, &thread_params, 0, &tid);
9091
9094 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9095
9096 /* Steal foreground: WM_ACTIVATEAPP(0) is delivered. */
9101 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
9102 thread_params.thread_window, test_window);
9103 /* Active and Focus window are sometimes 0 on KDE. Ignore them.
9104 * check_wnd_state(window1, thread_params.thread_window, window1, 0); */
9105 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9106 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9107 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9108 check_wnd_state(0, thread_params.thread_window, 0, 0);
9110 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
9111 thread_params.thread_window, test_window);
9112 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9113 /* This message is reliable on Windows and inside a virtual desktop.
9114 * It is unreliable on KDE (50/50) and never arrives on FVWM.
9115 * ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n"); */
9116
9117 /* Set foreground: WM_ACTIVATEAPP (1) is delivered. */
9121 check_wnd_state(0, 0, 0, 0);
9123 ok(!test_window, "Expected foreground window 0, got %p\n", test_window);
9124 ok(!app_activated, "Received WM_ACTIVATEAPP(!= 0), did not expect it.\n");
9125 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9126 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9129 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9131 ok(app_activated, "Expected WM_ACTIVATEAPP(1), did not receive it.\n");
9132 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9133
9134 /* Steal foreground then set it back: No messages are delivered. */
9139 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9142 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9143 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9144 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9146 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9149 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9150 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9151
9152 /* This is not implemented with a plain WM_ACTIVATEAPP filter. */
9158 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9161 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9162 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9163 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9165 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9168 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9169 ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n");
9170
9171 SetForegroundWindow(thread_params.thread_window);
9172
9173 /* Set foreground then remove: Both messages are delivered. */
9178 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
9179 thread_params.thread_window, test_window);
9180 check_wnd_state(0, thread_params.thread_window, 0, 0);
9181 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9182 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9183 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9185 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
9186 thread_params.thread_window, test_window);
9187 /* Active and focus are window1 on wine because the internal WM_WINE_SETACTIVEWINDOW(0)
9188 * message is never generated. GetCapture() returns 0 though, so we'd get a test success
9189 * in todo_wine in the line below.
9190 * todo_wine check_wnd_state(0, thread_params.thread_window, 0, 0); */
9191 ok(app_activated, "Expected WM_ACTIVATEAPP(1), did not receive it.\n");
9192 todo_wine ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n");
9193
9196 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9199
9200 /* Switch to a different window from the same thread? No messages. */
9205 ok(test_window == window1, "Expected foreground window %p, got %p\n",
9208 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9209 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9210 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
9212 ok(test_window == window2, "Expected foreground window %p, got %p\n",
9215 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9216 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9217
9218 PostThreadMessageA(tid, thread_params.msg_quit, 0, 0);
9220
9221 CloseHandle(thread_params.command_executed);
9223}
9224
9226{
9227 if(!hwnd) {
9228 int *count = (int*)lparam;
9229 (*count)++;
9230 }
9231 return 0;
9232}
9233
9235{
9236 if(msg == WM_SETTEXT)
9237 {
9238 const char *text = (const char*)lparam;
9239
9240 ok(!wparam, "wparam = %08lx\n", wparam);
9241 ok(!strcmp(text, "text"), "WM_SETTEXT lparam = %s\n", text);
9242 return 1;
9243 }
9244 return 0;
9245}
9246
9247static const WCHAR textW[] = {'t','e','x','t',0};
9249{
9250 if(msg == WM_SETTEXT)
9251 {
9252 const WCHAR *text = (const WCHAR*)lparam;
9253
9254 ok(!wparam, "wparam = %08lx\n", wparam);
9255 ok(!lstrcmpW(text, textW), "WM_SETTEXT lparam = %s\n", wine_dbgstr_w(text));
9256 return 1;
9257 }
9258 return 0;
9259}
9260
9261static void test_winproc_handles(const char *argv0)
9262{
9263 static const WCHAR winproc_testW[] = {'w','i','n','p','r','o','c','_','t','e','s','t',0};
9264
9266 WNDCLASSA wnd_classA;
9267 WNDCLASSW wnd_classW;
9268 int count, ret;
9271 char cmd[MAX_PATH];
9272
9273 memset(&wnd_classA, 0, sizeof(wnd_classA));
9274 wnd_classA.lpszClassName = "winproc_test";
9275 wnd_classA.lpfnWndProc = winproc;
9276 ret = RegisterClassA(&wnd_classA);
9277 ok(ret, "RegisterClass failed with error %d\n", GetLastError());
9278
9279 ret = GetClassInfoW(hinst, winproc_testW, &wnd_classW);
9280 ok(ret, "GetClassInfoW failed with error %d\n", GetLastError());
9281 ok(wnd_classA.lpfnWndProc != wnd_classW.lpfnWndProc,
9282 "winproc pointers should not be identical\n");
9283
9284 count = 0;
9285 CallWindowProcA(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
9286 ok(count == 1, "winproc should be called once (%d)\n", count);
9287 count = 0;
9288 CallWindowProcW(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
9289 ok(count == 1, "winproc should be called once (%d)\n", count);
9290
9291 ret = UnregisterClassW(winproc_testW, hinst);
9292 ok(ret, "UnregisterClass failed with error %d\n", GetLastError());
9293
9294 /* crashes on 64-bit windows because lpfnWndProc handle is already freed */
9295 if (sizeof(void*) == 4)
9296 {
9297 count = 0;
9298 CallWindowProcA(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
9299 todo_wine ok(!count, "winproc should not be called (%d)\n", count);
9300 CallWindowProcW(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
9301 todo_wine ok(!count, "winproc should not be called (%d)\n", count);
9302 }
9303
9304 sprintf(cmd, "%s win winproc_limit", argv0);
9305 memset(&startup, 0, sizeof(startup));
9306 startup.cb = sizeof(startup);
9308 &startup, &info), "CreateProcess failed.\n");
9310 CloseHandle(info.hProcess);
9311 CloseHandle(info.hThread);
9312}
9313
9314static void test_winproc_limit(void)
9315{
9316 WNDPROC winproc_handle;
9317 LONG_PTR ret;
9318 HWND hwnd;
9319 int i;
9320
9321 hwnd = CreateWindowExA(0, "static", "test", WS_POPUP, 0, 0, 0, 0, 0, 0, 0, 0);
9322 ok(hwnd != 0, "CreateWindowEx failed\n");
9323
9325 "SetWindowLongPtr failed\n");
9326 winproc_handle = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
9327 ok(winproc_handle != winproc, "winproc pointers should not be identical\n");
9328
9329 /* run out of winproc slots */
9330 for(i = 2; i<0xffff; i++)
9331 {
9332 ok(SetWindowLongPtrA(hwnd, GWLP_WNDPROC, i), "SetWindowLongPtr failed (%d)\n", i);
9334 break;
9335 }
9336 ok(i != 0xffff, "unable to run out of winproc slots\n");
9337
9339 ok(ret, "SetWindowLongPtr failed with error %d\n", GetLastError());
9340 ok(SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"text"), "WM_SETTEXT failed\n");
9341 ok(SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)textW), "WM_SETTEXT with conversion failed\n");
9342
9344 ok(ret, "SetWindowLongPtr failed with error %d\n", GetLastError());
9345 ok(SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"text"), "WM_SETTEXT failed\n");
9346 ok(SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)textW), "WM_SETTEXT with conversion failed\n");
9347
9348 /* Show that there's no message conversion when CallWindowProc is used */
9350 "winproc_convW returned error\n");
9352 "winproc_convW returned error\n");
9353
9354 i = 0;
9355 CallWindowProcA(winproc_handle, 0, 0, 0, (LPARAM)&i);
9356 ok(i == 1, "winproc should be called once (%d)\n", i);
9357 i = 0;
9358 CallWindowProcW(winproc_handle, 0, 0, 0, (LPARAM)&i);
9359 ok(i == 1, "winproc should be called once (%d)\n", i);
9360
9362
9363 i = 0;
9364 CallWindowProcA(winproc_handle, 0, 0, 0, (LPARAM)&i);
9365 ok(i == 1, "winproc should be called once (%d)\n", i);
9366 i = 0;
9367 CallWindowProcW(winproc_handle, 0, 0, 0, (LPARAM)&i);
9368 ok(i == 1, "winproc should be called once (%d)\n", i);
9369}
9370
9371static void test_deferwindowpos(void)
9372{
9373 HDWP hdwp, hdwp2;
9374 BOOL ret;
9375
9376 hdwp = BeginDeferWindowPos(0);
9377 ok(hdwp != NULL, "got %p\n", hdwp);
9378
9380 ok(!ret, "got %d\n", ret);
9381
9382 hdwp2 = DeferWindowPos(NULL, NULL, NULL, 0, 0, 10, 10, 0);
9384 ok(hdwp2 == NULL && ((GetLastError() == ERROR_INVALID_DWP_HANDLE) ||
9385 broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE) /* before win8 */), "got %p, error %d\n", hdwp2, GetLastError());
9386
9387 hdwp2 = DeferWindowPos((HDWP)0xdead, GetDesktopWindow(), NULL, 0, 0, 10, 10, 0);
9389 ok(hdwp2 == NULL && ((GetLastError() == ERROR_INVALID_DWP_HANDLE) ||
9390 broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE) /* before win8 */), "got %p, error %d\n", hdwp2, GetLastError());
9391
9392 hdwp2 = DeferWindowPos(hdwp, NULL, NULL, 0, 0, 10, 10, 0);
9393 ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %d\n", hdwp2, GetLastError());
9394
9395 hdwp2 = DeferWindowPos(hdwp, GetDesktopWindow(), NULL, 0, 0, 10, 10, 0);
9396 ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %d\n", hdwp2, GetLastError());
9397
9398 hdwp2 = DeferWindowPos(hdwp, (HWND)0xdead, NULL, 0, 0, 10, 10, 0);
9399 ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %d\n", hdwp2, GetLastError());
9400
9401 ret = EndDeferWindowPos(hdwp);
9402 ok(ret, "got %d\n", ret);
9403}
9404
9406{
9407 char **argv;
9409 HMODULE user32 = GetModuleHandleA( "user32.dll" );
9410 HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
9411 pGetAncestor = (void *)GetProcAddress( user32, "GetAncestor" );
9412 pGetWindowInfo = (void *)GetProcAddress( user32, "GetWindowInfo" );
9413 pGetWindowModuleFileNameA = (void *)GetProcAddress( user32, "GetWindowModuleFileNameA" );
9414 pGetLayeredWindowAttributes = (void *)GetProcAddress( user32, "GetLayeredWindowAttributes" );
9415 pSetLayeredWindowAttributes = (void *)GetProcAddress( user32, "SetLayeredWindowAttributes" );
9416 pUpdateLayeredWindow = (void *)GetProcAddress( user32, "UpdateLayeredWindow" );
9417 pUpdateLayeredWindowIndirect = (void *)GetProcAddress( user32, "UpdateLayeredWindowIndirect" );
9418 pGetMonitorInfoA = (void *)GetProcAddress( user32, "GetMonitorInfoA" );
9419 pMonitorFromPoint = (void *)GetProcAddress( user32, "MonitorFromPoint" );
9420 pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
9421 pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
9422 pGetProcessDefaultLayout = (void *)GetProcAddress( user32, "GetProcessDefaultLayout" );
9423 pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" );
9424 pFlashWindow = (void *)GetProcAddress( user32, "FlashWindow" );
9425 pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" );
9426 pGetLayout = (void *)GetProcAddress( gdi32, "GetLayout" );
9427 pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" );
9428 pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" );
9429
9430 if (argc==4 && !strcmp(argv[2], "create_children"))
9431 {
9432 HWND hwnd;
9433
9434 sscanf(argv[3], "%p", &hwnd);
9436 return;
9437 }
9438
9439 if (argc==3 && !strcmp(argv[2], "winproc_limit"))
9440 {
9442 return;
9443 }
9444
9445 if (!RegisterWindowClasses()) assert(0);
9446
9447 hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
9450 100, 100, 200, 200,
9451 0, 0, GetModuleHandleA(NULL), NULL);
9452 assert( hwndMain );
9453
9455 /* workaround for foreground lock timeout */
9456 simulate_click(101, 101);
9457 ok(SetForegroundWindow(hwndMain), "SetForegroundWindow failed\n");
9458 }
9459
9460 SetLastError(0xdeafbeef);
9463
9465 if (!hhook) win_skip( "Cannot set CBT hook, skipping some tests\n" );
9466
9467 /* make sure that these tests are executed first */
9470
9471 hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
9474 100, 100, 200, 200,
9475 0, 0, GetModuleHandleA(NULL), NULL);
9476 assert( hwndMain2 );
9477
9479
9480 /* Add the tests below this line */
9487 test_params();
9496
9500
9501 test_mdi();
9502 test_icons();
9507 test_NCRedraw();
9508
9520 test_scroll();
9523
9533 test_gettext();
9535 test_Expose();
9537
9545 test_smresult();
9547
9551
9552 /* add the tests above this line */
9554
9557}
#define SYSRGN
Definition: GetRandomRgn.c:13
static int argc
Definition: ServiceArgs.c:12
@ lparam
Definition: SystemMenu.c:31
@ hook
Definition: SystemMenu.c:35
@ wparam
Definition: SystemMenu.c:30
static void flush_events(void)
Definition: SystemMenu.c:167
#define broken(x)
Definition: _sntprintf.h:21
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static void startup(void)
Arabic default style
Definition: afstyles.h:94
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_(x1, x2)
Definition: atltest.h:61
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define msg(x)
Definition: auth_time.c:54
HANDLE HMONITOR
Definition: axextend.idl:431
HWND hWnd
Definition: settings.c:17
#define U(x)
Definition: wordpad.c:45
static HANDLE thread
Definition: service.c:33
#define UlongToHandle(ul)
Definition: basetsd.h:97
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
struct _root root
HINSTANCE hInstance
Definition: charmap.c:19
Definition: _stack.h:55
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HWND hwndParent
Definition: cryptui.c:300
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR rc2[]
Definition: oid.c:1216
#define CloseHandle
Definition: compat.h:739
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
HANDLE HWND
Definition: compat.h:19
#define GetProcAddress(x, y)
Definition: compat.h:753
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4741
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
const WCHAR * text
Definition: package.c:1799
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define assert(x)
Definition: debug.h:53
static void test_window(IHTMLDocument2 *doc)
Definition: dom.c:6306
#define pt(x, y)
Definition: drawing.c:79
r parent
Definition: btrfs.c:3010
int main()
Definition: test.c:6
#define INFINITE
Definition: serial.h:102
RECT rect2
Definition: edittest.c:51
void test2()
Definition: ehthrow.cxx:284
void test1()
Definition: ehthrow.cxx:277
void test4()
Definition: ehthrow.cxx:298
void test3()
Definition: ehthrow.cxx:291
void test5()
Definition: ehthrow.cxx:305
void test7()
Definition: ehthrow.cxx:346
void test6()
Definition: ehthrow.cxx:312
#define ERROR(name)
Definition: error_private.h:53
#define WM_APP
Definition: eventvwr.h:73
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
pKey DeleteObject()
size_t total
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble t
Definition: gl.h:2047
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
struct _cl_event * event
Definition: glext.h:7739
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLenum const GLfloat * params
Definition: glext.h:5645
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
GLenum GLenum GLenum input
Definition: glext.h:9031
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static GUITHREADINFO gti
Definition: guithreadinfo.c:5
static const WCHAR titleW[]
Definition: htmlelem.c:1067
#define ss
Definition: i386-dis.c:441
#define cs
Definition: i386-dis.c:442
WNDPROC old_wnd_proc
Definition: imm32.c:367
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define wine_dbgstr_w
Definition: kernel32.h:34
static real win[4][36]
static HANDLE hmon
Definition: localmon.c:41
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
static struct test_info tests[]
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
DWORD button
Definition: button.c:166
static HINSTANCE hinst
Definition: edit.c:551
static HICON
Definition: imagelist.c:84
BOOL expected
Definition: store.c:2063
static HANDLE start_event
Definition: thread.c:135
static TfClientId tid
static IHTMLWindow2 * window
Definition: events.c:77
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define todo_wine
Definition: custom.c:79
#define check_error(a)
Definition: misc.c:38
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
static WNDPROC old_proc
Definition: clipboard.c:183
static HWND child
Definition: cursoricon.c:298
static void test_SetFocus(void)
Definition: msg.c:16974
static void test_SetForegroundWindow(void)
Definition: msg.c:14299
static HWND mdi_client
Definition: msg.c:3639
static void test_SetActiveWindow(void)
Definition: msg.c:14232
static HWND dialog
Definition: gui.c:33
#define min(a, b)
Definition: monoChain.cc:55
int k
Definition: mpi.c:3369
#define argv
Definition: mplay32.c:18
int other
Definition: msacm.c:1376
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
#define BOOL
Definition: nt_native.h:43
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define LBS_SORT
Definition: pedump.c:679
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define BS_GROUPBOX
Definition: pedump.c:658
#define WS_DISABLED
Definition: pedump.c:621
#define WS_DLGFRAME
Definition: pedump.c:626
#define WS_EX_TRANSPARENT
Definition: pedump.c:649
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
unsigned short USHORT
Definition: pedump.c:61
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_POPUPWINDOW
Definition: pedump.c:638
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define WS_THICKFRAME
Definition: pedump.c:630
static unsigned __int64 next
Definition: rand_nt.c:6
#define err(...)
#define test
Definition: rosglue.h:37
int winetest_debug
#define ros_skip_flaky
Definition: test.h:177
#define win_skip
Definition: test.h:160
int winetest_get_mainargs(char ***pargv)
void winetest_wait_child_process(HANDLE process)
#define disable_success_count
Definition: test.h:181
#define memset(x, y, z)
Definition: compat.h:39
static FILE * client
Definition: client.c:41
static char argv0[MAX_PATH]
Definition: shlexec.c:49
& rect
Definition: startmenu.cpp:1413
WORD cdit
Definition: winuser.h:3061
short y
Definition: winuser.h:3063
short cy
Definition: winuser.h:3065
DWORD style
Definition: winuser.h:3059
DWORD dwExtendedStyle
Definition: winuser.h:3060
short x
Definition: winuser.h:3062
short cx
Definition: winuser.h:3064
LONG cx
Definition: kdterminal.h:27
HWND hwnd
Definition: winuser.h:3588
UINT flags
Definition: winuser.h:3594
HWND hwndInsertAfter
Definition: winuser.h:3589
HBRUSH hbrBackground
Definition: winuser.h:3170
HICON hIcon
Definition: winuser.h:3168
HINSTANCE hInstance
Definition: winuser.h:3167
HCURSOR hCursor
Definition: winuser.h:3169
int cbWndExtra
Definition: winuser.h:3166
UINT style
Definition: winuser.h:3163
LPCSTR lpszMenuName
Definition: winuser.h:3171
LPCSTR lpszClassName
Definition: winuser.h:3172
WNDPROC lpfnWndProc
Definition: winuser.h:3164
int cbClsExtra
Definition: winuser.h:3165
int cbClsExtra
Definition: winuser.h:3204
HINSTANCE hInstance
Definition: winuser.h:3206
HCURSOR hCursor
Definition: winuser.h:3208
LPCSTR lpszMenuName
Definition: winuser.h:3210
HICON hIconSm
Definition: winuser.h:3212
UINT style
Definition: winuser.h:3202
int cbWndExtra
Definition: winuser.h:3205
UINT cbSize
Definition: winuser.h:3201
WNDPROC lpfnWndProc
Definition: winuser.h:3203
LPCSTR lpszClassName
Definition: winuser.h:3211
HICON hIcon
Definition: winuser.h:3207
HBRUSH hbrBackground
Definition: winuser.h:3209
LPCWSTR lpszClassName
Definition: winuser.h:3185
LPCWSTR lpszMenuName
Definition: winuser.h:3184
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
int cbClsExtra
Definition: winuser.h:3178
UINT style
Definition: winuser.h:3176
WNDPROC lpfnWndProc
Definition: winuser.h:3177
int cbWndExtra
Definition: winuser.h:3179
HCURSOR hCursor
Definition: winuser.h:3182
Definition: ftp_var.h:139
HWND parent
Definition: win.c:4383
DLGTEMPLATE * dlg_data
Definition: win.c:4384
HWND grand_parent
Definition: win.c:4383
HWND ga_parent
Definition: win.c:4663
HWND owner
Definition: win.c:4666
HWND gwl_parent
Definition: win.c:4664
HWND get_parent
Definition: win.c:4665
HWND ga_root_owner
Definition: win.c:4668
Definition: fci.c:127
Definition: copy.c:22
Definition: parser.c:49
Definition: tftpd.h:60
RECT paint
Definition: win.c:5435
RECT client
Definition: win.c:5433
RECT clip
Definition: win.c:5434
struct parentdc_stat child2 child2_todo
Definition: win.c:5441
struct parentdc_stat child1 child1_todo
Definition: win.c:5440
struct parentdc_stat main main_todo
Definition: win.c:5439
HANDLE thread_got_wm_app
Definition: win.c:8783
HANDLE thread_started
Definition: win.c:8782
HANDLE thread_replied
Definition: win.c:8785
HANDLE main_in_wm_app_1
Definition: win.c:8784
Definition: ps.c:97
LPCREATESTRUCTA lpcs
Definition: winuser.h:2970
HWND hwndInsertAfter
Definition: winuser.h:2971
LPVOID lpCreateParams
Definition: winuser.h:2940
DWORD cbSize
Definition: winable.h:70
POINT ptMaxPosition
Definition: winuser.h:3629
POINT ptMaxSize
Definition: winuser.h:3628
POINT ptMinTrackSize
Definition: winuser.h:3630
POINT ptReserved
Definition: winuser.h:3627
POINT ptMaxTrackSize
Definition: winuser.h:3631
RECT rcMonitor
Definition: winuser.h:3785
DWORD cbSize
Definition: winuser.h:3784
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
DWORD styleNew
Definition: winuser.h:3693
DWORD styleOld
Definition: winuser.h:3692
Definition: dhcpd.h:245
BOOL is_groupbox
Definition: win.c:8178
BOOL is_visible
Definition: win.c:8178
char class_name[128]
Definition: win.c:8177
BOOL is_httransparent
Definition: win.c:8178
BOOL is_extransparent
Definition: win.c:8178
BOOL is_enabled
Definition: win.c:8178
#define max(a, b)
Definition: svc.c:63
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:669
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
HANDLE HINSTANCE
Definition: typedefs.h:77
int32_t INT_PTR
Definition: typedefs.h:64
uint32_t DWORD_PTR
Definition: typedefs.h:65
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL WINAPI SetShellWindow(HWND)
Definition: desktop.c:641
static const WCHAR classW[]
Definition: lex.c:40
int ret
#define POINT
Definition: precomp.h:30
HWND WINAPI GetShellWindow(VOID)
Definition: desktop.c:651
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1330
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
static void test_activateapp(HWND window1)
Definition: win.c:9073
static INT_PTR WINAPI reparent_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4686
static void test_GetUpdateRect(void)
Definition: win.c:6783
static BOOL test_thick_child_got_minmax
Definition: win.c:7513
static void test_MDI_child_stack(HWND mdi_client)
Definition: win.c:1718
static void test_dialog_parent(void)
Definition: win.c:4744
static LRESULT WINAPI check_style_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win.c:6349
static void nccalchelper(HWND hwnd, INT x, INT y, RECT *prc)
Definition: win.c:3921
static LRESULT WINAPI destroy_dialog_owner_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4735
#define SET_FOREGROUND_SET_1
Definition: win.c:9008
static ATOM atomStyleCheckClass
Definition: win.c:4184
static void FixedAdjustWindowRectEx(RECT *rc, LONG style, BOOL menu, LONG exstyle)
Definition: win.c:994
static int window_to_index(HWND hwnd, HWND *window, int size)
Definition: win.c:8198
static void window_from_point_proc(HWND parent)
Definition: win.c:8338
static void test_smresult(void)
Definition: win.c:8883
static void test_FindWindowEx(void)
Definition: win.c:8009
static void create_window_tree(HWND parent, HWND *window, int size)
Definition: win.c:8088
static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner, BOOL topmost, const char *file, int line)
Definition: win.c:2795
static DWORD CALLBACK gettext_msg_thread(LPVOID arg)
Definition: win.c:6577
static DWORD WINAPI smresult_thread_proc(void *param)
Definition: win.c:8846
static void test_capture_1(void)
Definition: win.c:3347
static DWORD CALLBACK settext_msg_thread(LPVOID arg)
Definition: win.c:6594
static BOOL got_hittest
Definition: win.c:8327
static void test_AdjustWindowRect(void)
Definition: win.c:5345
static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_out, DWORD ex_style_out)
Definition: win.c:4470
static void test_nonclient_area(HWND hwnd)
Definition: win.c:1055
static void test_window_without_child_style(void)
Definition: win.c:8757
static DWORD our_pid
Definition: win.c:67
static LRESULT CALLBACK minmax_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:5793
#define TEST_MOUSEACTIVATE(A, B)
static void test_gettext(void)
Definition: win.c:6608
static BOOL mdi_RegisterWindowClasses(void)
Definition: win.c:2075
static const WCHAR mainclassW[]
Definition: win.c:895
static void test_layered_window(void)
Definition: win.c:7183
static LRESULT CALLBACK fullscreen_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:7340
static INT_PTR WINAPI empty_dlg_proc2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4387
static void get_window_attributes(HWND hwnd, struct window_attributes *attrs)
Definition: win.c:8181
static LRESULT WINAPI main_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:851
#define COUNTOF(arr)
Definition: win.c:71
static BOOL wait_for_event(HANDLE event, int timeout)
Definition: win.c:101
static void test_validatergn(HWND hwnd)
Definition: win.c:3883
static char mdi_lParam_test_message[]
Definition: win.c:1366
static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:8328
static const char * szAWRClass
Definition: win.c:65
static void check_wnd_state_(const char *file, int line, HWND active, HWND foreground, HWND focus, HWND capture)
Definition: win.c:144
static void wine_AdjustWindowRectEx(RECT *rect, LONG style, BOOL menu, LONG exStyle)
Definition: win.c:1010
static int WMPAINT_count
Definition: win.c:5374
static void run_NCRedrawLoop(UINT flags)
Definition: win.c:6970
static RECT broken_rect
Definition: win.c:5821
static void test_winregion(void)
Definition: win.c:7780
static const char * test_thick_child_name
Definition: win.c:7514
static void zero_parentdc_stat(struct parentdc_stat *t)
Definition: win.c:5471
static COLORREF BYTE DWORD *static BYTE
Definition: win.c:42
static void test_winproc_handles(const char *argv0)
Definition: win.c:9261
static MONITORINFO mi
Definition: win.c:7338
static DWORD layout
Definition: win.c:53
static LRESULT WINAPI winproc_convA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:9234
static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut)
Definition: win.c:4206
#define ULONG_PTR
Definition: win.c:34
static void test_SetParent(void)
Definition: win.c:3970
static void test_scrolldc(HWND parent)
Definition: win.c:5136
static LRESULT WINAPI smresult_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:8789
static void test_SetWindowLong(void)
Definition: win.c:6306
static LRESULT expected_id
Definition: win.c:4343
static void test_children_zorder(HWND parent)
Definition: win.c:2758
static DWORD WINAPI set_foreground_thread(void *params)
Definition: win.c:9020
static DWORD WINAPI create_window_thread(void *param)
Definition: win.c:3146
static BOOL ignore_message(UINT message)
Definition: win.c:173
static BOOL app_activated
Definition: win.c:63
static LRESULT WINAPI parentdc_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5444
static BOOL CALLBACK enum_proc(HWND hwnd, LPARAM lParam)
Definition: win.c:671
static WINDOWINFO *static LPSTR
Definition: win.c:40
static void test_keyboard_input(HWND hwnd)
Definition: win.c:3588
static void simulate_click(int x, int y)
Definition: win.c:8307
static HHOOK hhook
Definition: win.c:62
static BOOL AWR_init(void)
Definition: win.c:5262
static void check_parents(HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent, HWND gw_owner, HWND ga_root, HWND ga_root_owner)
Definition: win.c:118
static BOOL app_deactivated
Definition: win.c:63
static WNDPROC old_button_proc
Definition: win.c:3289
static void test_redrawnow(void)
Definition: win.c:5395
void dump_region(HRGN hrgn)
Definition: msg.c:7695
static void test_Expose(void)
Definition: win.c:6931
static INT_PTR WINAPI parent_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4671
#define expect_gle_broken_9x(gle)
static LRESULT WINAPI winproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:9225
static LPRECT
Definition: win.c:47
static DWORD num_gettext_msgs
Definition: win.c:58
#define check_active_state(a, b, c)
Definition: win.c:159
static LRESULT WINAPI def_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5669
static void test_scrollwindow(HWND hwnd)
Definition: win.c:4888
static INT_PTR WINAPI empty_dlg_proc3(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4345
static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4151
static void test_mdi(void)
Definition: win.c:2102
static BOOL wait_for_message(MSG *msg)
Definition: win.c:3664
static BOOL peek_message(MSG *msg)
Definition: win.c:3578
static void register_style_check_class(void)
Definition: win.c:4186
static void test_dialog_styles(void)
Definition: win.c:4574
#define WM_SYSTIMER
Definition: win.c:30
static void test_FlashWindowEx(void)
Definition: win.c:7920
static LRESULT WINAPI mdi_child_wnd_proc_2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:1917
static void test_GetWindowModuleFileName(void)
Definition: win.c:7017
static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *info)
Definition: win.c:944
static HWND hwndMain2
Definition: win.c:61
static LRESULT WINAPI button_hook_proc(HWND button, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:3291
#define check_wnd_state(a, b, c, d)
Definition: win.c:143
static HWND hwndMain
Definition: win.c:61
static int redrawComplete
Definition: win.c:5374
#define expect_style(window, style)
static void test_nccalcscroll(HWND parent)
Definition: win.c:3931
static HRGN hrgn
Definition: win.c:55
static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
Definition: win.c:1368
#define check_z_order(hwnd, next, prev, owner, topmost)
Definition: win.c:2791
static int expected_cy
Definition: win.c:5820
static void test_rtl_layout(void)
Definition: win.c:7835
static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style)
Definition: win.c:2833
static WNDPROC def_static_proc
Definition: win.c:8326
static HWND create_tool_window(LONG style, HWND parent)
Definition: win.c:201
static void test_AWR_window_size(BOOL menu)
Definition: win.c:5292
static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: win.c:1118
static LRESULT WINAPI def_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5664
static DWORD CALLBACK enum_thread(void *arg)
Definition: win.c:677
static COLORREF BYTE DWORD *static DWORD
Definition: win.c:42
static void test_SetWindowPos(HWND hwnd, HWND hwnd2)
Definition: win.c:2436
static void test_enum_thread_windows(void)
Definition: win.c:734
static void test_deferwindowpos(void)
Definition: win.c:9371
#define parentdc_ok(t, got)
Definition: win.c:5505
static LONG test_thick_child_exStyle
Definition: win.c:7516
static LRESULT WINAPI reparent_dialog_owner_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4711
static LRESULT WINAPI test_thick_child_size_winproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:7518
static LRESULT WINAPI nccalcsize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:2423
static void test_capture_2(void)
Definition: win.c:3372
static LRESULT WINAPI my_window_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:8083
static void test_icons(void)
Definition: win.c:2359
static LONG test_thick_child_style
Definition: win.c:7515
static void test_window_from_point(const char *argv0)
Definition: win.c:8395
#define nothing_todo
static void test_CreateWindow(void)
Definition: win.c:5871
static BOOL CALLBACK EnumChildProc1(HWND hwndChild, LPARAM lParam)
Definition: win.c:194
static void test_IsWindowUnicode(void)
Definition: win.c:5674
static BOOL test_lbuttondown_flag
Definition: win.c:57
static void test_GetLastActivePopup(void)
Definition: win.c:8055
static INT_PTR WINAPI reparent_owned_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4696
static RECT expected_rect
Definition: win.c:5821
static void test_capture_3(HWND hwnd1, HWND hwnd2)
Definition: win.c:3431
#define SET_FOREGROUND_STEAL_2
Definition: win.c:9009
static void test_parent_owner(void)
Definition: win.c:210
static HMENU hmenu
Definition: win.c:66
static void test_scrollvalidate(HWND parent)
Definition: win.c:4941
static BOOL is_win9x
Definition: win.c:69
static const WCHAR textW[]
Definition: win.c:9247
static void test_child_window_from_point(void)
Definition: win.c:8210
static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5376
#define SET_FOREGROUND_SET_2
Definition: win.c:9010
static const UPDATELAYEREDWINDOWINFO *static LPMONITORINFO
Definition: win.c:45
static void test_mouse_input(HWND hwnd)
Definition: win.c:3682
static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:870
static LRESULT WINAPI winproc_convW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:9248
static UINT
Definition: win.c:38
static LRESULT WINAPI my_httrasparent_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:8077
static LRESULT CALLBACK test_capture_4_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:3456
static void test_ShowWindow(void)
Definition: win.c:6441
static void test_AWR_flags(void)
Definition: win.c:5316
static LRESULT CALLBACK TestNCRedraw_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:6949
static void test_SetMenu(HWND parent)
Definition: win.c:2621
static void test_params(void)
Definition: win.c:5204
#define SHOWSYSMETRIC(SM)
Definition: win.c:5343
static void test_map_points(void)
Definition: win.c:8468
static LRESULT CALLBACK TestExposedRegion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:6898
static LRESULT WINAPI post_quit_dialog_owner_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4726
static COLORREF BYTE DWORD *static COLORREF
Definition: win.c:42
static void test_NCRedraw(void)
Definition: win.c:6996
static HWND root_dialog(HWND hwnd)
Definition: win.c:4318
static void zero_parentdc_test(struct parentdc_test *t)
Definition: win.c:5478
#define SET_FOREGROUND_INJECT
Definition: win.c:9011
static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:2960
static void test_winproc_limit(void)
Definition: win.c:9314
#define SET_FOREGROUND_STEAL_1
Definition: win.c:9007
static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total)
Definition: win.c:2713
static void test_GetMessagePos(void)
Definition: win.c:8941
static DWORD num_settext_msgs
Definition: win.c:59
static void test_shell_window(void)
Definition: win.c:1234
#define NUMBER_OF_THICK_CHILD_TESTS
Definition: win.c:7609
static BOOL RegisterWindowClasses(void)
Definition: win.c:897
static void MDI_ChildGetMinMaxInfo(HWND client, HWND hwnd, MINMAXINFO *lpMinMax)
Definition: win.c:1789
static void test_thick_child_size(HWND parentWindow)
Definition: win.c:7610
static HWND hwndMessage
Definition: win.c:60
static void test_capture_4(void)
Definition: win.c:3522
static void check_active_state_(const char *file, int line, HWND active, HWND foreground, HWND focus)
Definition: win.c:160
static void test_vis_rgn(HWND hwnd)
Definition: win.c:2931
#define expect_menu(window, menu)
static void test_window_styles(void)
Definition: win.c:4271
static void test_csparentdc(void)
Definition: win.c:5510
static void test_FlashWindow(void)
Definition: win.c:7893
static struct wm_gettext_override_data g_wm_gettext_override
static void test_hwnd_message(void)
Definition: win.c:7114
static LRESULT CALLBACK winsizes_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:5823
static void test_set_window_style(void)
Definition: win.c:6372
static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:2017
static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
Definition: win.c:185
static void dump_minmax_info(const MINMAXINFO *minmax)
Definition: win.c:73
#define expect_ex_style(window, ex_style)
static HDC
Definition: win.c:43
static void test_update_region(void)
Definition: win.c:8690
static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)
Definition: win.c:5240
static INT_PTR WINAPI empty_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4338
static int expected_cx
Definition: win.c:5820
static void test_fullscreen(void)
Definition: win.c:7366
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:749
static BOOL bInvert
Definition: win.c:51
static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:1808
static void test_scroll(void)
Definition: win.c:5097
#define success(from, fromstr, to, tostr)
struct tagGUITHREADINFO GUITHREADINFO
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
#define GUI_INMENUMODE
Definition: winable.h:29
#define INPUT_MOUSE
Definition: winable.h:9
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define MAKEINTATOM(i)
Definition: winbase.h:1463
#define WAIT_OBJECT_0
Definition: winbase.h:406
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
int * LPINT
Definition: windef.h:178
DWORD COLORREF
Definition: windef.h:300
void * arg
Definition: msvc.h:10
#define WINAPI
Definition: msvc.h:6
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:887
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#define ERROR_INVALID_DWP_HANDLE
Definition: winerror.h:886
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:882
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define ERROR_NOACCESS
Definition: winerror.h:578
static void test_handles(void)
Definition: winstation.c:109
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define NULLREGION
Definition: wingdi.h:361
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCSTR lpString, _In_ int c)
BOOL WINAPI EqualRgn(_In_ HRGN, _In_ HRGN)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define WHITE_BRUSH
Definition: wingdi.h:902
#define SIMPLEREGION
Definition: wingdi.h:362
#define RGN_OR
Definition: wingdi.h:359
#define BLACK_BRUSH
Definition: wingdi.h:896
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI GetRandomRgn(_In_ HDC, _In_ HRGN, _In_ INT)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
#define SW_SHOWNORMAL
Definition: winuser.h:770
#define WM_PAINT
Definition: winuser.h:1620
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
HWND WINAPI GetFocus(void)
Definition: window.c:1893
#define HWND_MESSAGE
Definition: winuser.h:1210
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define HTTOPRIGHT
Definition: winuser.h:2492
#define GW_OWNER
Definition: winuser.h:766
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define HTCLOSE
Definition: winuser.h:2499
#define CS_VREDRAW
Definition: winuser.h:658
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
LRESULT WINAPI DefFrameProcA(_In_ HWND, _In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HCBT_MINMAX
Definition: winuser.h:56
#define WM_MDISETMENU
Definition: winuser.h:1822
#define GW_HWNDFIRST
Definition: winuser.h:764
#define SetWindowLongPtrA
Definition: winuser.h:5345
#define WS_EX_STATICEDGE
Definition: winuser.h:403
BOOL WINAPI IsWindow(_In_opt_ HWND)
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define SetClassLongPtrW
Definition: winuser.h:5265
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define SW_HIDE
Definition: winuser.h:768
#define WM_CLOSE
Definition: winuser.h:1621
LRESULT WINAPI DefMDIChildProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SWP_NOACTIVATE
Definition: winuser.h:1242
#define DM_SETDEFID
Definition: winuser.h:2099
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
#define WM_SYSCOMMAND
Definition: winuser.h:1741
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define QS_SENDMESSAGE
Definition: winuser.h:880
#define GW_HWNDLAST
Definition: winuser.h:765
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define SM_CYEDGE
Definition: winuser.h:1009
#define GA_ROOT
Definition: winuser.h:2789
#define SetClassLongPtrA
Definition: winuser.h:5264
#define SWP_FRAMECHANGED
Definition: winuser.h:1240
#define WM_QUIT
Definition: winuser.h:1623
BOOL WINAPI TranslateMessage(_In_ const MSG *)
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define IDI_QUESTION
Definition: winuser.h:706
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
DWORD WINAPI GetMessagePos(void)
Definition: message.c:1351
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
#define HTCAPTION
Definition: winuser.h:2476
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define WM_MDICREATE
Definition: winuser.h:1812
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1185
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
#define HWND_TOPMOST
Definition: winuser.h:1208
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SM_CXEDGE
Definition: winuser.h:1008
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_CAPTURECHANGED
Definition: winuser.h:1808
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1661
#define HTTOPLEFT
Definition: winuser.h:2491
#define SW_SCROLLCHILDREN
Definition: winuser.h:2578
#define IDI_HAND
Definition: winuser.h:705
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetLastActivePopup(_In_ HWND)
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
#define WM_CREATE
Definition: winuser.h:1608
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define SM_CXMINTRACK
Definition: winuser.h:997
#define SW_MINIMIZE
Definition: winuser.h:776
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WS_EX_CONTROLPARENT
Definition: winuser.h:387
struct tagWINDOWINFO WINDOWINFO
#define SM_CXVSCROLL
Definition: winuser.h:961
#define HTBOTTOM
Definition: winuser.h:2493
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define VK_SPACE
Definition: winuser.h:2219
#define HCBT_ACTIVATE
Definition: winuser.h:60
#define HTBORDER
Definition: winuser.h:2497
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define WM_SIZE
Definition: winuser.h:1611
int WINAPI SetWindowRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
#define SB_VERT
Definition: winuser.h:553
int WINAPI GetClassNameA(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPSTR lpClassName, _In_ int nMaxCount)
#define HWND_BROADCAST
Definition: winuser.h:1204
#define HTERROR
Definition: winuser.h:2472
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
HMENU WINAPI CreateMenu(void)
Definition: menu.c:829
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1778
#define SM_CXFRAME
Definition: winuser.h:994
#define BS_TYPEMASK
Definition: winuser.h:270
#define SWP_NOMOVE
Definition: winuser.h:1244
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
#define WM_COMMAND
Definition: winuser.h:1740
#define SW_INVALIDATE
Definition: winuser.h:2579
#define CS_HREDRAW
Definition: winuser.h:653
#define MF_STRING
Definition: winuser.h:138
struct tagCREATESTRUCTA * LPCREATESTRUCTA
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define HTVSCROLL
Definition: winuser.h:2482
#define GA_ROOTOWNER
Definition: winuser.h:2790
#define MA_ACTIVATE
Definition: winuser.h:2501
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define HTHSCROLL
Definition: winuser.h:2481
#define IDC_ARROW
Definition: winuser.h:687
#define SM_CYMENU
Definition: winuser.h:976
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2670
#define GCLP_WNDPROC
Definition: winuser.h:678
#define WM_NCHITTEST
Definition: winuser.h:1686
#define HCBT_DESTROYWND
Definition: winuser.h:59
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define SM_CYSMICON
Definition: winuser.h:1013
#define DC_HASDEFID
Definition: winuser.h:2609
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SW_SHOWNOACTIVATE
Definition: winuser.h:774
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define GA_PARENT
Definition: winuser.h:2788
#define DS_3DLOOK
Definition: winuser.h:367
#define QS_ALLINPUT
Definition: winuser.h:903
#define SIF_PAGE
Definition: winuser.h:1233
#define SWP_NOSIZE
Definition: winuser.h:1245
#define WM_MOUSEMOVE
Definition: winuser.h:1775
HWND WINAPI CreateMDIWindowA(_In_ LPCSTR, _In_ LPCSTR, _In_ DWORD, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HWND, _In_opt_ HINSTANCE, _In_ LPARAM)
#define WM_GETTEXT
Definition: winuser.h:1618
#define RDW_UPDATENOW
Definition: winuser.h:1220
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define WM_MDINEXT
Definition: winuser.h:1816
BOOL WINAPI IsMenu(_In_ HMENU)
#define GetWindowLongPtrA
Definition: winuser.h:4828
#define CS_DBLCLKS
Definition: winuser.h:651
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
HWND WINAPI FindWindowExA(_In_opt_ HWND, _In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR)
#define WM_DEVICECHANGE
Definition: winuser.h:1811
#define WH_CBT
Definition: winuser.h:35
#define HTMAXBUTTON
Definition: winuser.h:2484
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2662
#define HTOBJECT
Definition: winuser.h:2498
#define WM_MDIACTIVATE
Definition: winuser.h:1814
LRESULT WINAPI DefDlgProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define ULW_OPAQUE
Definition: winuser.h:2786
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define GWLP_HINSTANCE
Definition: winuser.h:856
#define HCBT_CREATEWND
Definition: winuser.h:58
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define SM_CYFRAME
Definition: winuser.h:996
#define SM_CYHSCROLL
Definition: winuser.h:962
#define IDOK
Definition: winuser.h:830
#define MDIS_ALLCHILDSTYLES
Definition: winuser.h:253
#define GW_HWNDNEXT
Definition: winuser.h:761
BOOL WINAPI GetScrollRange(_In_ HWND, _In_ int, _Out_ LPINT, _Out_ LPINT)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_NCCREATE
Definition: winuser.h:1683
#define IDI_APPLICATION
Definition: winuser.h:704
#define HTMENU
Definition: winuser.h:2480
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
#define WM_ACTIVATE
Definition: winuser.h:1612
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
#define WM_TIMECHANGE
Definition: winuser.h:1634
#define SC_MINIMIZE
Definition: winuser.h:2586
#define WM_SETTEXT
Definition: winuser.h:1617
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1183
BOOL WINAPI IsWindowUnicode(_In_ HWND)
#define SW_SHOWMINIMIZED
Definition: winuser.h:771
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1184
#define SM_CYBORDER
Definition: winuser.h:965
#define SM_CXSMICON
Definition: winuser.h:1012
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define HWND_TOP
Definition: winuser.h:1207
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define SM_CXMAXTRACK
Definition: winuser.h:1022
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
BOOL WINAPI SendNotifyMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETMINMAXINFO
Definition: winuser.h:1640
#define HTHELP
Definition: winuser.h:2500
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SIZE_MAXIMIZED
Definition: winuser.h:2507
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
BOOL WINAPI IsChild(_In_ HWND, _In_ HWND)
HWND WINAPI SetActiveWindow(_In_ HWND)
#define WM_MDIDESTROY
Definition: winuser.h:1813
#define HCBT_SETFOCUS
Definition: winuser.h:64
#define ULW_EX_NORESIZE
Definition: winuser.h:2787
#define GWLP_HWNDPARENT
Definition: winuser.h:858
#define RDW_ALLCHILDREN
Definition: winuser.h:1221
#define WM_TIMER
Definition: winuser.h:1742
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HWND WINAPI CreateDialogIndirectParamA(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2060
#define LBS_STANDARD
Definition: winuser.h:321
#define SM_CXBORDER
Definition: winuser.h:964
#define PM_REMOVE
Definition: winuser.h:1196
BOOL WINAPI ScrollDC(_In_ HDC, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT)
#define HTRIGHT
Definition: winuser.h:2489
#define RDW_FRAME
Definition: winuser.h:1212
#define SM_CYMAXTRACK
Definition: winuser.h:1023
int WINAPI GetUpdateRgn(_In_ HWND, _In_ HRGN, _In_ BOOL)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SIF_ALL
Definition: winuser.h:1232
#define HTCLIENT
Definition: winuser.h:2475
#define SWP_SHOWWINDOW
Definition: winuser.h:1248
#define WM_NULL
Definition: winuser.h:1607
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
BOOL WINAPI ValidateRgn(_In_ HWND, _In_opt_ HRGN)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define HCBT_MOVESIZE
Definition: winuser.h:55
#define HTBOTTOMRIGHT
Definition: winuser.h:2495
HDC WINAPI GetDC(_In_opt_ HWND)
#define HTNOWHERE
Definition: winuser.h:2474
#define SC_CLOSE
Definition: winuser.h:2592
#define WS_EX_LAYERED
Definition: winuser.h:389
#define LR_SHARED
Definition: winuser.h:1100
#define SM_CXDLGFRAME
Definition: winuser.h:966
BOOL WINAPI AppendMenuA(_In_ HMENU, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCSTR)
VOID WINAPI keybd_event(_In_ BYTE, _In_ BYTE, _In_ DWORD, _In_ ULONG_PTR)
BOOL WINAPI GetClassInfoA(_In_opt_ HINSTANCE, _In_ LPCSTR, _Out_ LPWNDCLASSA)
INT_PTR WINAPI DialogBoxIndirectParamA(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define HTSIZE
Definition: winuser.h:2479
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WA_ACTIVE
Definition: winuser.h:2623
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI DestroyMenu(_In_ HMENU)
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define SWP_HIDEWINDOW
Definition: winuser.h:1241
#define SIZE_RESTORED
Definition: winuser.h:2505
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE hInst, _In_ LPCSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2178
#define HTBOTTOMLEFT
Definition: winuser.h:2494
#define HTTOP
Definition: winuser.h:2490
#define HTTRANSPARENT
Definition: winuser.h:2473
HWND WINAPI WindowFromPoint(_In_ POINT)
#define GWLP_ID
Definition: winuser.h:860
#define SW_RESTORE
Definition: winuser.h:779
#define SW_ERASE
Definition: winuser.h:2580
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define WM_USER
Definition: winuser.h:1895
#define SM_CYSMCAPTION
Definition: winuser.h:1014
#define QS_PAINT
Definition: winuser.h:879
#define WM_ACTIVATEAPP
Definition: winuser.h:1632
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GW_HWNDPREV
Definition: winuser.h:762
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SM_CYDLGFRAME
Definition: winuser.h:968
DWORD WINAPI GetClassLongA(_In_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:775
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
HWND WINAPI RealChildWindowFromPoint(_In_ HWND, _In_ POINT)
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392
#define WM_KEYDOWN
Definition: winuser.h:1715
#define WM_MDIGETACTIVE
Definition: winuser.h:1821
#define GW_CHILD
Definition: winuser.h:763
#define HTMINBUTTON
Definition: winuser.h:2483
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
#define DM_GETDEFID
Definition: winuser.h:2098
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TPM_RETURNCMD
Definition: winuser.h:2387
#define SWP_NOZORDER
Definition: winuser.h:1247
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
#define HTSYSMENU
Definition: winuser.h:2477
#define HTLEFT
Definition: winuser.h:2487
BOOL WINAPI GetClassInfoW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSW)
#define SetWindowLongPtrW
Definition: winuser.h:5346
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_ACTIVECAPTION
Definition: winuser.h:2659
#define WM_NCCALCSIZE
Definition: winuser.h:1685
#define GWL_STYLE
Definition: winuser.h:852
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define CS_PARENTDC
Definition: winuser.h:656
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
HWND WINAPI FindWindowA(_In_opt_ LPCSTR, _In_opt_ LPCSTR)
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1662
#define SC_RESTORE
Definition: winuser.h:2598
#define WM_ENTERIDLE
Definition: winuser.h:1749
#define HWND_NOTOPMOST
Definition: winuser.h:1206
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_KILLFOCUS
Definition: winuser.h:1614
#define SM_CYCAPTION
Definition: winuser.h:963
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define PM_NOREMOVE
Definition: winuser.h:1195
int WINAPI GetSystemMetrics(_In_ int)
#define WM_SYSKEYDOWN
Definition: winuser.h:1719
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1692
#define GCW_ATOM
Definition: winuser.h:661
#define SM_CYMINTRACK
Definition: winuser.h:998
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
LRESULT WINAPI CallWindowProcA(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DS_CONTROL
Definition: winuser.h:372
#define RDW_INVALIDATE
Definition: winuser.h:1214
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396
#define HWND_BOTTOM
Definition: winuser.h:1205
HWND WINAPI CreateMDIWindowW(_In_ LPCWSTR, _In_ LPCWSTR, _In_ DWORD, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HWND, _In_opt_ HINSTANCE, _In_ LPARAM)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HMENU WINAPI GetMenu(_In_ HWND)
#define SC_MAXIMIZE
Definition: winuser.h:2588
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2090
#define SB_HORZ
Definition: winuser.h:552
SHORT WINAPI GetKeyState(_In_ int)
#define COLOR_BTNFACE
Definition: winuser.h:928
#define WM_NCPAINT
Definition: winuser.h:1687
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
HDWP WINAPI BeginDeferWindowPos(_In_ int)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define GWL_EXSTYLE
Definition: winuser.h:851
#define VK_LBUTTON
Definition: winuser.h:2190
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193