ReactOS 0.4.16-dev-2491-g3dc6630
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 <assert.h>
24#include <limits.h>
25#include <stdlib.h>
26#include <stdarg.h>
27#include <stdio.h>
28
29#include "windef.h"
30#include "winbase.h"
31#include "wingdi.h"
32#include "winuser.h"
33#include "winreg.h"
34
35#include "wine/test.h"
36
37#ifndef WM_SYSTIMER
38#define WM_SYSTIMER 0x0118
39#endif
40
41#define LONG_PTR INT_PTR
42#define ULONG_PTR UINT_PTR
43#ifdef __REACTOS__
44/* Not in Windows SDK, but is in Wine headers */
45#define DCX_USESTYLE 0x00010000
46#endif
47
48void dump_region(HRGN hrgn);
49
50static BOOL (WINAPI *pGetWindowInfo)(HWND,WINDOWINFO*);
51static UINT (WINAPI *pGetWindowModuleFileNameA)(HWND,LPSTR,UINT);
52static BOOL (WINAPI *pGetLayeredWindowAttributes)(HWND,COLORREF*,BYTE*,DWORD*);
53static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
54static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
55static BOOL (WINAPI *pUpdateLayeredWindowIndirect)(HWND,const UPDATELAYEREDWINDOWINFO*);
56static int (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
57static BOOL (WINAPI *pGetGUIThreadInfo)(DWORD, GUITHREADINFO*);
58static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout );
59static BOOL (WINAPI *pSetProcessDefaultLayout)( DWORD layout );
60static BOOL (WINAPI *pFlashWindow)( HWND hwnd, BOOL bInvert );
61static BOOL (WINAPI *pFlashWindowEx)( PFLASHWINFO pfwi );
62static BOOL (WINAPI *pMirrorRgn)(HWND hwnd, HRGN hrgn);
63static BOOL (WINAPI *pGetWindowDisplayAffinity)(HWND hwnd, DWORD *affinity);
64static BOOL (WINAPI *pSetWindowDisplayAffinity)(HWND hwnd, DWORD affinity);
65static BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
66static BOOL (WINAPI *pSystemParametersInfoForDpi)(UINT,UINT,void*,UINT,UINT);
67static HICON (WINAPI *pInternalGetWindowIcon)(HWND window, UINT type);
68
74static HHOOK hhook;
76
77static const char* szAWRClass = "Winsize";
78static HMENU hmenu;
80
81static void hold_key( int vk )
82{
83 BYTE kstate[256];
84 BOOL res;
85
86 res = GetKeyboardState( kstate );
87 ok(res, "GetKeyboardState failed.\n");
88 kstate[vk] |= 0x80;
89 res = SetKeyboardState( kstate );
90 ok(res, "SetKeyboardState failed.\n");
91}
92
93static void release_key( int vk )
94{
95 BYTE kstate[256];
96 BOOL res;
97
98 res = GetKeyboardState( kstate );
99 ok(res, "GetKeyboardState failed.\n");
100 kstate[vk] &= ~0x80;
101 res = SetKeyboardState( kstate );
102 ok(res, "SetKeyboardState failed.\n");
103}
104
105static void dump_minmax_info( const MINMAXINFO *minmax )
106{
107 trace("Reserved=%ld,%ld MaxSize=%ld,%ld MaxPos=%ld,%ld MinTrack=%ld,%ld MaxTrack=%ld,%ld\n",
108 minmax->ptReserved.x, minmax->ptReserved.y,
109 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
110 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
111 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
112 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
113}
114
115/* try to make sure pending X events have been processed before continuing */
116static void flush_events( BOOL remove_messages )
117{
118 MSG msg;
119 int diff = 200;
120 int min_timeout = 100;
121 DWORD time = GetTickCount() + diff;
122
123 while (diff > 0)
124 {
125 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
126 if (remove_messages)
127 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
128 diff = time - GetTickCount();
129 min_timeout = 50;
130 }
131}
132
133/* check the values returned by the various parent/owner functions on a given window */
134static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
135 HWND gw_owner, HWND ga_root, HWND ga_root_owner )
136{
137 HWND res;
138
140 ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent );
142 ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res, gwl_parent );
143 res = GetParent( hwnd );
144 ok( res == get_parent, "Wrong result for GetParent %p expected %p\n", res, get_parent );
146 ok( res == gw_owner, "Wrong result for GW_OWNER %p expected %p\n", res, gw_owner );
148 ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p\n", res, ga_root );
150 ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p\n", res, ga_root_owner );
151}
152
153#define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
154static void check_wnd_state_(const char *file, int line,
155 HWND active, HWND foreground, HWND focus, HWND capture)
156{
157 ok_(file, line)(active == GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
158 /* only check foreground if it belongs to the current thread */
159 /* foreground can be moved to a different app pretty much at any time */
160 if (foreground && GetForegroundWindow() &&
162 ok_(file, line)(foreground == GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
163 ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus());
164 ok_(file, line)(capture == GetCapture(), "GetCapture() = %p\n", GetCapture());
165}
166
167/* same as above but without capture test */
168#define check_active_state(a,b,c) check_active_state_(__FILE__,__LINE__,a,b,c)
169static void check_active_state_(const char *file, int line,
170 HWND active, HWND foreground, HWND focus)
171{
172 ok_(file, line)(active == GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
173 /* only check foreground if it belongs to the current thread */
174 /* foreground can be moved to a different app pretty much at any time */
175 if (foreground && GetForegroundWindow() &&
177 ok_(file, line)(foreground == GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
178 ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus());
179}
180
182{
183 WCHAR buffer[256];
184
185 if (GetClassNameW( hwnd, buffer, ARRAY_SIZE(buffer) ) == 22 &&
186 !wcscmp( buffer, L"UserAdapterWindowClass" ))
187 return TRUE;
188
189 /* these are always ignored */
190 return (message >= 0xc000 ||
191 message == 0x0060 || /* Internal undocumented message introduced by Win11 */
192 message == WM_GETICON ||
193 message == WM_GETOBJECT ||
194 message == WM_TIMER ||
195 message == WM_SYSTIMER ||
198}
199
201{
203 MSG msg;
204
206 {
207 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ))
208 {
211 }
212 if (ret < count) return ret;
213 if (timeout == INFINITE) continue;
214 if (end <= GetTickCount()) timeout = 0;
215 else timeout = end - GetTickCount();
216 }
217
218 ok( ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %#lx\n", ret );
219 return ret;
220}
221
223{
224 (*(LPINT)lParam)++;
225 if (*(LPINT)lParam > 1) return FALSE;
226 return TRUE;
227}
228
229/* will search for the given window */
231{
232 if ((HWND)lParam == hwndChild) return FALSE;
233 return TRUE;
234}
235
237{
238 HWND ret = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style,
239 0, 0, 100, 100, parent, 0, 0, NULL );
240 ok( ret != 0, "Creation failed\n" );
241 return ret;
242}
243
244/* test parent and owner values for various combinations */
245static void test_parent_owner(void)
246{
247 LONG style;
248 HWND test, owner, ret;
249 HWND desktop = GetDesktopWindow();
251 INT numChildren;
252
253 if (winetest_debug > 1)
254 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain, hwndMain2, desktop, child );
255
256 /* child without parent, should fail */
257 SetLastError(0xdeadbeef);
258 test = CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
259 WS_CHILD, 0, 0, 100, 100, 0, 0, 0, NULL );
260 ok( !test, "WS_CHILD without parent created\n" );
261 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD, "CreateWindowExA error %lu\n", GetLastError() );
262
263 /* desktop window */
264 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
265 style = GetWindowLongA( desktop, GWL_STYLE );
266 ok( !SetWindowLongA( desktop, GWL_STYLE, WS_POPUP ), "Set GWL_STYLE on desktop succeeded\n" );
267 ok( !SetWindowLongA( desktop, GWL_STYLE, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
268 ok( GetWindowLongA( desktop, GWL_STYLE ) == style, "Desktop style changed\n" );
269
270 /* normal child window */
272 if (winetest_debug > 1) trace( "created child %p\n", test );
282
283 /* normal child window with WS_MAXIMIZE */
286
287 /* normal child window with WS_THICKFRAME */
290
291 /* popup window with WS_THICKFRAME */
294
295 /* child of desktop */
296 test = create_tool_window( WS_CHILD, desktop );
297 if (winetest_debug > 1) trace( "created child of desktop %p\n", test );
298 check_parents( test, desktop, 0, desktop, 0, test, desktop );
300 check_parents( test, desktop, 0, 0, 0, test, test );
302 check_parents( test, desktop, 0, 0, 0, test, test );
304
305 /* child of desktop with WS_MAXIMIZE */
308
309 /* child of desktop with WS_MINIMIZE */
312
313 /* child of child */
315 if (winetest_debug > 1) trace( "created child of child %p\n", test );
322
323 /* child of child with WS_MAXIMIZE */
326
327 /* child of child with WS_MINIMIZE */
330
331 /* not owned top-level window */
332 test = create_tool_window( 0, 0 );
333 if (winetest_debug > 1) trace( "created top-level %p\n", test );
334 check_parents( test, desktop, 0, 0, 0, test, test );
336 check_parents( test, desktop, 0, 0, 0, test, test );
338 check_parents( test, desktop, 0, desktop, 0, test, desktop );
340
341 /* not owned top-level window with WS_MAXIMIZE */
344
345 /* owned top-level window */
347 if (winetest_debug > 1) trace( "created owned top-level %p\n", test );
348 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
352 check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
354
355 /* owned top-level window with WS_MAXIMIZE */
358
359 /* not owned popup */
361 if (winetest_debug > 1) trace( "created popup %p\n", test );
362 check_parents( test, desktop, 0, 0, 0, test, test );
364 check_parents( test, desktop, 0, desktop, 0, test, desktop );
366 check_parents( test, desktop, 0, 0, 0, test, test );
368
369 /* not owned popup with WS_MAXIMIZE */
372
373 /* owned popup */
375 if (winetest_debug > 1) trace( "created owned popup %p\n", test );
378 check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
380 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
382
383 /* owned popup with WS_MAXIMIZE */
386
387 /* top-level window owned by child (same as owned by top-level) */
389 if (winetest_debug > 1) trace( "created top-level owned by child %p\n", test );
390 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
392
393 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
396
397 /* popup owned by desktop (same as not owned) */
398 test = create_tool_window( WS_POPUP, desktop );
399 if (winetest_debug > 1) trace( "created popup owned by desktop %p\n", test );
400 check_parents( test, desktop, 0, 0, 0, test, test );
402
403 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
406
407 /* popup owned by child (same as owned by top-level) */
409 if (winetest_debug > 1) trace( "created popup owned by child %p\n", test );
412
413 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
416
417 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
419 if (winetest_debug > 1) trace( "created WS_CHILD popup %p\n", test );
420 check_parents( test, desktop, 0, 0, 0, test, test );
422
423 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
426
427 /* owned popup with WS_CHILD (same as WS_POPUP only) */
429 if (winetest_debug > 1) trace( "created owned WS_CHILD popup %p\n", test );
432
433 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
436
437 /******************** parent changes *************************/
438
439 /* desktop window */
440 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
442 ok( !ret, "Set GWL_HWNDPARENT succeeded on desktop\n" );
443 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
444 ok( !SetParent( desktop, hwndMain ), "SetParent succeeded on desktop\n" );
445 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
446 /* normal child window */
448 if (winetest_debug > 1) trace( "created child %p\n", test );
449
451 ok( ret == hwndMain, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain );
453
455 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
457
459 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
460 check_parents( test, desktop, 0, desktop, 0, test, desktop );
461
462 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
464 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
465 check_parents( test, desktop, 0, desktop, 0, test, desktop );
466
468 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
469 check_parents( test, desktop, child, desktop, child, test, desktop );
470
472 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
473 check_parents( test, desktop, 0, desktop, 0, test, desktop );
475
476 /* not owned top-level window */
477 test = create_tool_window( 0, 0 );
478 if (winetest_debug > 1) trace( "created top-level %p\n", test );
479
481 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
482 check_parents( test, desktop, hwndMain2, 0, hwndMain2, test, test );
483
485 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
486 check_parents( test, desktop, child, 0, child, test, test );
487
489 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
490 check_parents( test, desktop, 0, 0, 0, test, test );
492
493 /* not owned popup */
495 if (winetest_debug > 1) trace( "created popup %p\n", test );
496
498 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
500
502 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
504
506 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
507 check_parents( test, desktop, 0, 0, 0, test, test );
509
510 /* normal child window */
512 if (winetest_debug > 1) trace( "created child %p\n", test );
513
514 ret = SetParent( test, desktop );
515 ok( ret == hwndMain, "SetParent return value %p expected %p\n", ret, hwndMain );
516 check_parents( test, desktop, 0, desktop, 0, test, desktop );
517
518 ret = SetParent( test, child );
519 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
521
523 ok( ret == child, "SetParent return value %p expected %p\n", ret, child );
526
527 /* not owned top-level window */
528 test = create_tool_window( 0, 0 );
529 if (winetest_debug > 1) trace( "created top-level %p\n", test );
530
531 ret = SetParent( test, child );
532 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
534
536 ret = SetParent( test, test );
537 ok( ret == NULL, "SetParent return value %p expected %p\n", ret, NULL );
538 ok( GetWindowLongA( test, GWL_STYLE ) & WS_VISIBLE, "window is not visible after SetParent\n" );
541
542 /* owned popup */
544 if (winetest_debug > 1) trace( "created owned popup %p\n", test );
545
546 ret = SetParent( test, child );
547 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
549
551 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
554
555 /**************** test owner destruction *******************/
556
557 /* owned child popup */
558 owner = create_tool_window( 0, 0 );
559 test = create_tool_window( WS_POPUP, owner );
560 if (winetest_debug > 1) trace( "created owner %p and popup %p\n", owner, test );
561 ret = SetParent( test, child );
562 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
563 check_parents( test, child, child, owner, owner, hwndMain, owner );
564 /* window is now child of 'child' but owned by 'owner' */
565 DestroyWindow( owner );
566 ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
567 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
568 * while Win95, Win2k, WinXP do.
569 */
570 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
571 ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
573
574 /* owned top-level popup */
575 owner = create_tool_window( 0, 0 );
576 test = create_tool_window( WS_POPUP, owner );
577 if (winetest_debug > 1) trace( "created owner %p and popup %p\n", owner, test );
578 check_parents( test, desktop, owner, owner, owner, test, owner );
579 DestroyWindow( owner );
580 ok( !IsWindow(test), "Window %p not destroyed by owner destruction\n", test );
581
582 /* top-level popup owned by child */
585 if (winetest_debug > 1) trace( "created owner %p and popup %p\n", owner, test );
587 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
588 check_parents( test, desktop, owner, owner, owner, test, hwndMain2 );
589 DestroyWindow( owner );
590 ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
591 ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
592 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
593 * while Win95, Win2k, WinXP do.
594 */
595 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
597
598 /* final cleanup */
600
601
602 owner = create_tool_window( WS_OVERLAPPED, 0 );
603 test = create_tool_window( WS_POPUP, desktop );
604
605 ok( !GetWindow( test, GW_OWNER ), "Wrong owner window\n" );
606 numChildren = 0;
607 ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
608 "EnumChildWindows should have returned FALSE\n" );
609 ok( numChildren == 0, "numChildren should be 0 got %d\n", numChildren );
610
612 ret = SetParent( test, owner );
613 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
614
615 numChildren = 0;
616 ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
617 "EnumChildWindows should have returned TRUE\n" );
618 ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
619
621 numChildren = 0;
622 ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
623 "EnumChildWindows should have returned FALSE\n" );
624 ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
626
628 ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
629 numChildren = 0;
630 ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
631 "EnumChildWindows should have returned TRUE\n" );
632 ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
633
634 ret = SetParent( child, owner );
635 ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
636 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
637 numChildren = 0;
638 ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
639 "EnumChildWindows should have returned FALSE\n" );
640 ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
641
642 ret = SetParent( child, NULL );
643 ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
644 ok( ret == owner, "SetParent return value %p expected %p\n", ret, owner );
645 numChildren = 0;
646 ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
647 "EnumChildWindows should have returned TRUE\n" );
648 ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
649
650 /* even GW_OWNER == owner it's still a desktop's child */
652 "EnumChildWindows should have found %p and returned FALSE\n", child );
653
656
658 "EnumChildWindows should have found %p and returned FALSE\n", child );
659
662 DestroyWindow( owner );
663
664 /* Test that owner window takes into account WS_CHILD flag even if parent is set by SetParent. */
666 SetParent(owner, hwndMain);
667 check_parents( owner, hwndMain, hwndMain, NULL, NULL, hwndMain, owner );
669 check_parents( test, desktop, owner, NULL, owner, test, test );
670 DestroyWindow( owner );
672
673 owner = create_tool_window( WS_VISIBLE | WS_CHILD, desktop );
674 SetParent(owner, hwndMain);
678 DestroyWindow( owner );
680
681 owner = create_tool_window( WS_VISIBLE | WS_POPUP | WS_CHILD, desktop );
682 SetParent(owner, hwndMain);
683 check_parents( owner, hwndMain, hwndMain, NULL, NULL, hwndMain, owner );
685 check_parents( test, desktop, owner, NULL, owner, test, test );
686 DestroyWindow( owner );
688}
689
691{
692 (*(LPINT)lParam)++;
693 if (*(LPINT)lParam > 2) return FALSE;
694 return TRUE;
695}
697{
698 INT count;
699 HWND hwnd[3];
700 BOOL ret;
701 MSG msg;
702
703 if (pGetGUIThreadInfo)
704 {
706 info.cbSize = sizeof(info);
707 ret = pGetGUIThreadInfo( GetCurrentThreadId(), &info );
708 ok( ret, "GetGUIThreadInfo failed without message queue\n" );
709 SetLastError( 0xdeadbeef );
710 info.cbSize = sizeof(info) + 1;
711 ret = pGetGUIThreadInfo( GetCurrentThreadId(), &info );
712 ok( !ret, "GetGUIThreadInfo succeeded with wrong size\n" );
713 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
714 }
715
716 PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */
717
718 count = 0;
720 ok( ret, "EnumThreadWindows should have returned TRUE\n" );
721 ok( count == 0, "count should be 0 got %d\n", count );
722
723 hwnd[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP,
724 0, 0, 100, 100, 0, 0, 0, NULL );
725 count = 0;
727 ok( ret, "EnumThreadWindows should have returned TRUE\n" );
728 if (count != 2) /* Vista gives us two windows for the price of one */
729 {
730 ok( count == 1, "count should be 1 got %d\n", count );
731 hwnd[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP,
732 0, 0, 100, 100, 0, 0, 0, NULL );
733 }
734 else hwnd[2] = 0;
735
736 hwnd[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP,
737 0, 0, 100, 100, 0, 0, 0, NULL );
738 count = 0;
740 ok( !ret, "EnumThreadWindows should have returned FALSE\n" );
741 ok( count == 3, "count should be 3 got %d\n", count );
742
743 if (hwnd[2]) DestroyWindow(hwnd[2]);
746 return 0;
747}
748
749/* test EnumThreadWindows in a separate thread */
751{
752 DWORD id;
753 HANDLE handle = CreateThread( NULL, 0, enum_thread, 0, 0, &id );
754 ok( !WaitForSingleObject( handle, 10000 ), "wait failed\n" );
756}
757
759{
763};
764
766{
768 DWORD ret;
769 MSG msg;
770
771 params->hwnd = CreateWindowW( L"static", L"parent", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
772 100, 100, 200, 200, 0, 0, 0, NULL );
773 ok( params->hwnd != 0, "CreateWindowExW failed, error %lu\n", GetLastError() );
775 SetEvent( params->created_event );
776
777 do
778 {
779 while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg );
781 }
782 while (ret != WAIT_OBJECT_0);
783
784 return 0;
785}
786
788{
789 if (msg == WM_USER) return 0xdeadbeef;
790 if (msg == WM_USER + 1) return 0xfeedcafe;
791 return DefWindowProcW( hwnd, msg, wp, lp );
792}
793
795{
797 HWND adopter, child1, child2, child3, child;
798 WNDPROC old_wndproc, wndproc;
801 DWORD ret;
802 HRGN rgn;
803 HWND tmp;
804 MSG msg;
805
806 params.created_event = CreateEventW( NULL, FALSE, FALSE, NULL );
807 params.stop_event = CreateEventW( NULL, FALSE, FALSE, NULL );
808
809 adopter = CreateWindowW( L"static", L"adopter", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
810 300, 100, 200, 200, 0, 0, 0, NULL );
811 ok( adopter != 0, "CreateWindowExW failed, error %lu\n", GetLastError() );
813
815 ok( thread != 0, "CreateThread failed, error %lu\n", GetLastError() );
816 WaitForSingleObject( params.created_event, INFINITE );
817
818 child1 = CreateWindowW( L"static", L"child1", WS_CHILD|WS_VISIBLE,
819 50, 50, 50, 50, params.hwnd, 0, 0, NULL );
820 ok( child1 != 0, "CreateWindowExW failed, error %lu\n", GetLastError() );
821 child2 = CreateWindowW( L"static", L"child2", WS_CHILD|WS_VISIBLE,
822 100, 50, 50, 50, params.hwnd, 0, 0, NULL );
823 ok( child2 != 0, "CreateWindowExW failed, error %lu\n", GetLastError() );
824 child3 = CreateWindowW( L"static", L"child3", WS_CHILD|WS_VISIBLE,
825 50, 100, 50, 50, params.hwnd, 0, 0, NULL );
826 ok( child3 != 0, "CreateWindowExW failed, error %lu\n", GetLastError() );
828
829 trace("parent %p adopter %p child1 %p child2 %p child3 %p\n", params.hwnd, adopter, child1, child2, child3);
830
831 SetActiveWindow( child1 );
832 SetFocus( child1 );
833 SetCapture( child1 );
834
835 ok( GetActiveWindow() == params.hwnd, "GetActiveWindow %p, expected %p\n", GetActiveWindow(), params.hwnd );
836 ok( GetFocus() == child1, "GetFocus %p, expected %p\n", GetFocus(), child1 );
837 ok( GetCapture() == child1, "GetCapture %p, expected %p\n", GetCapture(), child1 );
838
839 ret = SetPropW( child1, L"myprop", UlongToHandle(0xdeadbeef) );
840 ok( ret, "SetPropW failed, error %lu\n", GetLastError() );
841 ret = SetPropW( child2, L"myprop", UlongToHandle(0xdeadbeef) );
842 ok( ret, "SetPropW failed, error %lu\n", GetLastError() );
843
844 old_wndproc = (WNDPROC)GetWindowLongPtrW( child1, GWLP_WNDPROC );
845 ok( old_wndproc != NULL, "GetWindowLongPtrW GWLP_WNDPROC failed, error %lu\n", GetLastError() );
846
847 ret = GetWindowLongW( child1, GWL_STYLE );
848 ok( ret == (WS_CHILD|WS_VISIBLE), "GetWindowLongW returned %#lx\n", ret );
849
850 SetEvent( params.stop_event );
852 ok( ret == WAIT_OBJECT_0, "WaitForSingleObject returned %#lx\n", ret );
854
855 /* child windows should all still be alive but hidden */
856 ret = IsWindow( child1 );
857 ok( ret, "IsWindow returned %lu\n", ret );
858 ret = IsWindow( child2 );
859 ok( ret, "IsWindow returned %lu\n", ret );
860 ret = IsWindow( child3 );
861 ok( ret, "IsWindow returned %lu\n", ret );
862
864 ok( GetActiveWindow() == adopter, "GetActiveWindow %p, expected %p\n", GetActiveWindow(), adopter );
866 ok( GetFocus() == adopter, "GetFocus %p, expected %p\n", GetFocus(), adopter );
867 ok( GetCapture() == child1, "GetCapture %p, expected %p\n", GetCapture(), child1 );
868
869 SetActiveWindow( child1 );
870 SetFocus( child1 );
871 SetCapture( child1 );
872
874 ok( GetActiveWindow() == adopter, "GetActiveWindow %p, expected %p\n", GetActiveWindow(), adopter );
876 ok( GetFocus() == adopter, "GetFocus %p, expected %p\n", GetFocus(), adopter );
877 ok( GetCapture() == child1, "GetCapture %p, expected %p\n", GetCapture(), child1 );
878
879 SetLastError( 0xdeadbeef );
880 ret = GetWindowLongW( child1, GWL_STYLE );
882 ok( ret == WS_CHILD, "GetWindowLongW returned %#lx\n", ret );
883 ok( GetLastError() == 0xdeadbeef, "GetWindowLongW error %lu\n", GetLastError() );
885 ok( ret, "SetWindowLongW failed, error %lu\n", GetLastError() );
886 ret = GetWindowLongW( child1, GWL_STYLE );
887 ok( ret == (WS_CHILD|WS_VISIBLE), "GetWindowLongW returned %#lx\n", ret );
888
889 /* and cannot be adopted */
890 SetLastError( 0xdeadbeef );
891 tmp = GetParent( child1 );
892 ok( tmp == params.hwnd, "GetParent returned %p, error %lu\n", tmp, GetLastError() );
893 ok( GetLastError() == 0xdeadbeef, "GetWindowLongW error %lu\n", GetLastError() );
894 SetLastError( 0xdeadbeef );
895 tmp = SetParent( child1, adopter );
896 ok( tmp == 0, "SetParent returned %p\n", tmp );
897#ifdef __REACTOS__
898 ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* WS03 */, "got error %lu\n", GetLastError() );
899#else
900 ok( GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError() );
901#endif
902 SetLastError( 0xdeadbeef );
903 tmp = SetParent( child3, adopter );
904 ok( tmp == 0, "SetParent returned %p\n", tmp );
905#ifdef __REACTOS__
906 ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* WS03 */, "got error %lu\n", GetLastError() );
907#else
908 ok( GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError() );
909#endif
910 SetLastError( 0xdeadbeef );
911 tmp = GetParent( child1 );
912 ok( tmp == params.hwnd, "GetParent returned %p, error %lu\n", tmp, GetLastError() );
913 ok( GetLastError() == 0xdeadbeef, "GetWindowLongW error %lu\n", GetLastError() );
914
915 SetLastError( 0xdeadbeef );
917 ok( ret == 0, "GetWindowLongW returned %#lx\n", ret );
918 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "GetWindowLongW error %lu\n", GetLastError() );
919
920 wndproc = (WNDPROC)GetWindowLongPtrW( child1, GWLP_WNDPROC );
921 ok( wndproc != NULL, "GetWindowLongPtrW GWLP_WNDPROC failed, error %lu\n", GetLastError() );
922 ok( wndproc == old_wndproc, "GetWindowLongPtrW GWLP_WNDPROC returned %p\n", wndproc );
923
924 tmp = GetPropW( child1, L"myprop" );
925 ok( HandleToULong(tmp) == 0xdeadbeef, "GetPropW returned %p\n", tmp );
926 tmp = GetPropW( child2, L"myprop" );
927 ok( HandleToULong(tmp) == 0xdeadbeef, "GetPropW returned %p\n", tmp );
928
929 child = CreateWindowExA( 0, "ToolWindowClass", "Tool window 1", WS_CHILD,
930 0, 0, 100, 100, child1, 0, 0, NULL );
931#ifdef __REACTOS__
932 ok( GetLastError() == ERROR_INVALID_PARAMETER /* MSVC test builds return child, GCC test builds don't on Windows */
933 || broken(child && GetLastError() == ERROR_SUCCESS) /* WS03 */,
934 "CreateWindowExA returned %p %lu\n", child, GetLastError() );
935#else
937 "CreateWindowExA returned %p %lu\n", child, GetLastError() );
938#endif
939
940 ret = MoveWindow( child1, 5, 5, 10, 10, FALSE );
941 ok( ret, "MoveWindow failed: %lu\n", GetLastError() );
942
943 /* destroying child1 ourselves succeeds */
944 ret = DestroyWindow( child1 );
945 ok( ret, "DestroyWindow returned %lu\n", ret );
946 ret = DestroyWindow( child1 );
947 ok( !ret, "DestroyWindow returned %lu\n", ret );
948 ret = IsWindow( child1 );
949 ok( !ret, "IsWindow returned %lu\n", ret );
950
951 tmp = GetPropW( child1, L"myprop" );
952 ok( HandleToULong(tmp) == 0, "GetPropW returned %p\n", tmp );
953
954 /* child2 is still alive, for now */
955 ret = IsWindow( child2 );
956 ok( ret, "IsWindow returned %lu\n", ret );
957
958 SetLastError( 0xdeadbeef );
959 ret = SetWindowPos( child2, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOSIZE|SWP_NOMOVE );
961#ifdef __REACTOS__
962 ok( !ret || broken(ret) /* WS03 */, "SetWindowPos succeeded\n" );
963#else
964 ok( !ret, "SetWindowPos succeeded\n" );
965#endif
967#ifdef __REACTOS__
968 ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* WS03 */, "SetWindowPos returned error %lu\n", GetLastError() );
969#else
970 ok( GetLastError() == ERROR_INVALID_PARAMETER, "SetWindowPos returned error %lu\n", GetLastError() );
971#endif
972 SetLastError( 0xdeadbeef );
973 ret = SetWindowPos( child2, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE );
975#ifdef __REACTOS__
976 ok( !ret || broken(ret) /* WS03 */, "SetWindowPos succeeded\n" );
977#else
978 ok( !ret, "SetWindowPos succeeded\n" );
979#endif
981#ifdef __REACTOS__
982 ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* WS03 */, "SetWindowPos returned error %lu\n", GetLastError() );
983#else
984 ok( GetLastError() == ERROR_INVALID_PARAMETER, "SetWindowPos returned error %lu\n", GetLastError() );
985#endif
986
987 rgn = CreateRectRgn( 5, 5, 15, 15 );
988 SetLastError( 0xdeadbeef );
989 ret = SetWindowRgn( child2, rgn, TRUE );
990 ok( ret, "SetWindowRgn failed, error %lu\n", GetLastError() );
991 DeleteObject( rgn );
992
994 ret = SendMessageW( child2, WM_USER, 0, 0 );
995 ok( ret == 0xdeadbeef, "SendMessageW returned %lu, error %lu\n", ret, GetLastError() );
996 ret = SendMessageW( child2, WM_USER + 1, 0, 0 );
997 ok( ret == 0xfeedcafe, "SendMessageW returned %lu, error %lu\n", ret, GetLastError() );
998 ret = SendMessageW( child2, WM_USER + 2, 0, 0 );
999 ok( ret == 0, "SendMessageW returned %lu, error %lu\n", ret, GetLastError() );
1000
1001 ret = GetWindowTextW( child2, buffer, ARRAY_SIZE(buffer) );
1002 ok( ret == 6, "GetWindowTextW returned %lu\n", ret );
1003 ok( !wcscmp( buffer, L"child2" ), "GetWindowTextW returned %s\n", debugstr_w( buffer ) );
1004 ret = IsWindow( child2 );
1005 ok( ret, "IsWindow returned %lu\n", ret );
1006
1007 /* but peeking any message should reap them all */
1008 PeekMessageW( &msg, child2, 0, 0, PM_REMOVE );
1009
1010 tmp = GetPropW( child2, L"myprop" );
1011 ok( HandleToULong(tmp) == 0, "GetPropW returned %p\n", tmp );
1012
1013 ret = IsWindow( child2 );
1014 ok( !ret, "IsWindow returned %lu\n", ret );
1015 ret = IsWindow( child3 );
1016 todo_wine
1017 ok( !ret, "IsWindow returned %lu\n", ret );
1018 ret = DestroyWindow( child2 );
1019 ok( !ret, "DestroyWindow returned %lu\n", ret );
1020
1021 DestroyWindow( adopter );
1022
1023 CloseHandle( params.created_event );
1024 CloseHandle( params.stop_event );
1025}
1026
1028{
1029 BOOL enabled; /* when 1 bypasses default procedure */
1030 BOOL dont_terminate; /* don't null terminate returned string in WM_GETTEXT handler */
1031 char *buff; /* expected text buffer pointer */
1032 WCHAR *buffW; /* same, for W test */
1034
1036{
1037 switch (msg)
1038 {
1039 case WM_GETMINMAXINFO:
1040 {
1041 SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021);
1042 break;
1043 }
1045 {
1046 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1047 if (!(winpos->flags & SWP_NOMOVE))
1048 {
1049 ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
1050 ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
1051 }
1052 if (!(winpos->flags & SWP_NOSIZE))
1053 {
1054 ok((winpos->cx >= 0 && winpos->cx <= 32767) ||
1055 winpos->cx == 32768, /* win7 doesn't truncate */
1056 "bad winpos->cx %d\n", winpos->cx);
1057 ok((winpos->cy >= 0 && winpos->cy <= 32767) ||
1058 winpos->cy == 40000, /* win7 doesn't truncate */
1059 "bad winpos->cy %d\n", winpos->cy);
1060 }
1061 break;
1062 }
1064 {
1065 LRESULT ret;
1066 RECT rc1, rc2;
1067 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1068 ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
1069 ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
1070
1071 ok((winpos->cx >= 0 && winpos->cx <= 32767) ||
1072 winpos->cx == 32768, /* win7 doesn't truncate */
1073 "bad winpos->cx %d\n", winpos->cx);
1074 ok((winpos->cy >= 0 && winpos->cy <= 32767) ||
1075 winpos->cy == 40000, /* win7 doesn't truncate */
1076 "bad winpos->cy %d\n", winpos->cy);
1077
1078 GetWindowRect(hwnd, &rc1);
1079 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
1080 /* note: winpos coordinates are relative to parent */
1082 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
1084
1087 ok(!ret, "got %08Ix\n", ret);
1088 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
1089 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
1091 break;
1092 }
1093 case WM_NCCREATE:
1094 {
1095 BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021;
1097
1098 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
1099 ok(got_getminmaxinfo, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
1100 else
1101 ok(!got_getminmaxinfo, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
1102 break;
1103 }
1104 case WM_COMMAND:
1106 {
1109 }
1110 break;
1111 case WM_GETTEXT:
1113 if (g_wm_gettext_override.enabled)
1114 {
1115 char *text = (char*)lparam;
1116 ok(g_wm_gettext_override.buff == text, "expected buffer %p, got %p\n", g_wm_gettext_override.buff, text);
1117 ok(*text == 0, "expected empty string buffer %x\n", *text);
1118 return 0;
1119 }
1120 else if (g_wm_gettext_override.dont_terminate)
1121 {
1122 char *text = (char *)lparam;
1123 if (text)
1124 {
1125 memcpy(text, "text", 4);
1126 return 4;
1127 }
1128 return 0;
1129 }
1130 break;
1131 case WM_SETTEXT:
1133 break;
1134 case WM_ACTIVATEAPP:
1135 if (wparam) app_activated = TRUE;
1136 else app_deactivated = TRUE;
1137 break;
1138 case WM_MOUSEACTIVATE:
1139 return MA_ACTIVATE;
1140
1141 case WM_NCCALCSIZE:
1142 {
1144 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wparam, lparam);
1145 return ret;
1146 }
1147 }
1148
1149 return DefWindowProcA(hwnd, msg, wparam, lparam);
1150}
1151
1153{
1154 switch (msg)
1155 {
1156 case WM_GETTEXT:
1158 if (g_wm_gettext_override.enabled)
1159 {
1160 WCHAR *text = (WCHAR*)lparam;
1161 ok(g_wm_gettext_override.buffW == text, "expected buffer %p, got %p\n", g_wm_gettext_override.buffW, text);
1162 ok(*text == 0, "expected empty string buffer %x\n", *text);
1163 return 0;
1164 }
1165 else if (g_wm_gettext_override.dont_terminate)
1166 {
1167 static const WCHAR textW[] = {'t','e','x','t'};
1168 WCHAR *text = (WCHAR *)lparam;
1169 if (text)
1170 {
1171 memcpy(text, textW, sizeof(textW));
1172 return 4;
1173 }
1174 return 0;
1175 }
1176 break;
1177
1178 case WM_NCCALCSIZE:
1179 {
1181 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wparam, lparam);
1182 return ret;
1183 }
1184 }
1185
1186 return DefWindowProcA(hwnd, msg, wparam, lparam);
1187}
1188
1190{
1191 switch (msg)
1192 {
1193 case WM_GETMINMAXINFO:
1194 {
1195 SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021);
1196 break;
1197 }
1198 case WM_NCCREATE:
1199 {
1200 BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021;
1202
1203 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
1204 ok(got_getminmaxinfo, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
1205 else
1206 ok(!got_getminmaxinfo, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
1207 break;
1208 }
1209
1210 case WM_NCCALCSIZE:
1211 {
1213 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wparam, lparam);
1214 return ret;
1215 }
1216 }
1217
1218 return DefWindowProcA(hwnd, msg, wparam, lparam);
1219}
1220
1221static const WCHAR mainclassW[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s','W',0};
1222
1224{
1225 WNDCLASSW clsW;
1226 WNDCLASSA cls;
1227
1228 cls.style = CS_DBLCLKS;
1230 cls.cbClsExtra = 0;
1231 cls.cbWndExtra = 0;
1232 cls.hInstance = GetModuleHandleA(0);
1233 cls.hIcon = 0;
1236 cls.lpszMenuName = NULL;
1237 cls.lpszClassName = "MainWindowClass";
1238
1239 if(!RegisterClassA(&cls)) return FALSE;
1240
1241 clsW.style = CS_DBLCLKS;
1243 clsW.cbClsExtra = 0;
1244 clsW.cbWndExtra = 0;
1245 clsW.hInstance = GetModuleHandleA(0);
1246 clsW.hIcon = 0;
1247 clsW.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
1249 clsW.lpszMenuName = NULL;
1251
1252 if(!RegisterClassW(&clsW)) return FALSE;
1253
1254 cls.style = 0;
1256 cls.cbClsExtra = 0;
1257 cls.cbWndExtra = 0;
1258 cls.hInstance = GetModuleHandleA(0);
1259 cls.hIcon = 0;
1262 cls.lpszMenuName = NULL;
1263 cls.lpszClassName = "ToolWindowClass";
1264
1265 if(!RegisterClassA(&cls)) return FALSE;
1266
1267 return TRUE;
1268}
1269
1270static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *info)
1271{
1272 RECT rcWindow, rcClient;
1273 DWORD status;
1274
1275 ok(IsWindow(hwnd), "bad window handle %p in hook %s\n", hwnd, hook);
1276
1277 GetWindowRect(hwnd, &rcWindow);
1278 ok(EqualRect(&rcWindow, &info->rcWindow), "wrong rcWindow for %p in hook %s\n", hwnd, hook);
1279
1280 GetClientRect(hwnd, &rcClient);
1281 /* translate to screen coordinates */
1282 MapWindowPoints(hwnd, 0, (LPPOINT)&rcClient, 2);
1283 ok(EqualRect(&rcClient, &info->rcClient), "wrong rcClient for %p in hook %s\n", hwnd, hook);
1284
1285 ok(info->dwStyle == (DWORD)GetWindowLongA(hwnd, GWL_STYLE),
1286 "wrong dwStyle: %08lx != %08lx for %p in hook %s\n",
1287 info->dwStyle, GetWindowLongA(hwnd, GWL_STYLE), hwnd, hook);
1288 /* Windows reports some undocumented exstyles in WINDOWINFO, but
1289 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
1290 */
1291 ok((info->dwExStyle & ~0xe0000800) == (DWORD)GetWindowLongA(hwnd, GWL_EXSTYLE),
1292 "wrong dwExStyle: %08lx != %08lx for %p in hook %s\n",
1293 info->dwExStyle, GetWindowLongA(hwnd, GWL_EXSTYLE), hwnd, hook);
1295 if (GetForegroundWindow())
1296 ok(info->dwWindowStatus == status, "wrong dwWindowStatus: %04lx != %04lx active %p fg %p in hook %s\n",
1297 info->dwWindowStatus, status, GetActiveWindow(), GetForegroundWindow(), hook);
1298
1299 /* win2k and XP return broken border info in GetWindowInfo most of
1300 * the time, so there is no point in testing it.
1301 */
1302if (0)
1303{
1304 UINT border;
1305 ok(info->cxWindowBorders == (unsigned)(rcClient.left - rcWindow.left),
1306 "wrong cxWindowBorders %d != %ld\n", info->cxWindowBorders, rcClient.left - rcWindow.left);
1307 border = min(rcWindow.bottom - rcClient.bottom, rcClient.top - rcWindow.top);
1308 ok(info->cyWindowBorders == border,
1309 "wrong cyWindowBorders %d != %d\n", info->cyWindowBorders, border);
1310}
1311 ok(info->atomWindowType == GetClassLongA(hwnd, GCW_ATOM), "wrong atomWindowType for %p in hook %s\n",
1312 hwnd, hook);
1313 ok(info->wCreatorVersion == 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
1314 info->wCreatorVersion == 0x0500 /* Vista */,
1315 "wrong wCreatorVersion %04x for %p in hook %s\n", info->wCreatorVersion, hwnd, hook);
1316}
1317
1318static void test_window_info(const char *hook, HWND hwnd)
1319{
1320 WINDOWINFO info, info2;
1321
1322 if (0) /* crashes on Win10 */
1323 ok(!pGetWindowInfo(hwnd, NULL), "GetWindowInfo should fail\n");
1324
1325 if (0) { /* crashes on XP, 2003 */
1326 SetLastError(0xdeadbeef);
1327 ok(!pGetWindowInfo(0, NULL), "GetWindowInfo should fail\n");
1329 "got error %ld expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
1330 }
1331
1332 SetLastError(0xdeadbeef);
1333 ok(!pGetWindowInfo(0, &info), "GetWindowInfo should fail\n");
1335 "got error %ld expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
1336
1337 info.cbSize = sizeof(WINDOWINFO);
1338 ok(pGetWindowInfo(hwnd, &info), "GetWindowInfo should not fail\n");
1340
1341 /* test different cbSize values.
1342 * Windows ignores it (except for Win98, according to an old comment).
1343 */
1344 memset(&info, 0xcc, sizeof(WINDOWINFO));
1345 memset(&info2, 0xcc, sizeof(WINDOWINFO));
1346
1347 info.cbSize = sizeof(WINDOWINFO);
1348 info2.cbSize = sizeof(WINDOWINFO);
1349
1350 ok(pGetWindowInfo(hwnd, &info), "GetWindowInfo should not fail\n");
1351 ok(pGetWindowInfo(hwnd, &info2), "GetWindowInfo should not fail\n");
1352 ok(memcmp(&info, &info2, sizeof(WINDOWINFO)) == 0, "identical GetWindowInfo calls produce different result\n");
1353
1354 memset(&info2, 0xcc, sizeof(WINDOWINFO));
1355 info2.cbSize = 0;
1356 ok(pGetWindowInfo(hwnd, &info2), "GetWindowInfo should not fail\n");
1357 info2.cbSize = sizeof(WINDOWINFO);
1358 ok(memcmp(&info, &info2, sizeof(WINDOWINFO)) == 0, "GetWindowInfo cbSize should be ignored\n");
1359
1360 memset(&info2, 0xcc, sizeof(WINDOWINFO));
1361 info2.cbSize = sizeof(WINDOWINFO)/2;
1362 ok(pGetWindowInfo(hwnd, &info2), "GetWindowInfo should not fail\n");
1363 info2.cbSize = sizeof(WINDOWINFO);
1364 ok(memcmp(&info, &info2, sizeof(WINDOWINFO)) == 0, "GetWindowInfo cbSize should be ignored\n");
1365
1366 memset(&info2, 0xcc, sizeof(WINDOWINFO));
1367 info2.cbSize = UINT_MAX;
1368 ok(pGetWindowInfo(hwnd, &info2), "GetWindowInfo should not fail\n");
1369 info2.cbSize = sizeof(WINDOWINFO);
1370 ok(memcmp(&info, &info2, sizeof(WINDOWINFO)) == 0, "GetWindowInfo cbSize should be ignored\n");
1371}
1372
1374{
1375 AdjustWindowRectEx(rc, style, menu, exstyle);
1376 /* AdjustWindowRectEx does not include scroll bars */
1377 if (style & WS_VSCROLL)
1378 {
1379 if(exstyle & WS_EX_LEFTSCROLLBAR)
1381 else
1383 }
1384 if (style & WS_HSCROLL)
1386}
1387
1388/* reimplement it to check that the Wine algorithm gives the correct result */
1390{
1391 NONCLIENTMETRICSW ncm;
1392 int adjust = 0;
1393
1394 ncm.cbSize = offsetof( NONCLIENTMETRICSW, iPaddedBorderWidth );
1395 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
1396
1398 adjust = 1; /* for the outer frame always present */
1399 else if ((exStyle & WS_EX_DLGMODALFRAME) || (style & (WS_THICKFRAME|WS_DLGFRAME)))
1400 adjust = 2; /* outer */
1401
1402 if (style & WS_THICKFRAME) adjust += ncm.iBorderWidth; /* The resize border */
1403 if ((style & (WS_BORDER|WS_DLGFRAME)) || (exStyle & WS_EX_DLGMODALFRAME))
1404 adjust++; /* The other border */
1405
1406 InflateRect (rect, adjust, adjust);
1407
1408 if ((style & WS_CAPTION) == WS_CAPTION)
1409 {
1410 if (exStyle & WS_EX_TOOLWINDOW)
1411 rect->top -= ncm.iSmCaptionHeight + 1;
1412 else
1413 rect->top -= ncm.iCaptionHeight + 1;
1414 }
1415 if (menu) rect->top -= ncm.iMenuHeight + 1;
1416
1417 if (exStyle & WS_EX_CLIENTEDGE)
1419
1420 if (style & WS_VSCROLL)
1421 {
1422 if((exStyle & WS_EX_LEFTSCROLLBAR) != 0)
1424 else
1426 }
1428}
1429
1431{
1432 NONCLIENTMETRICSW ncm;
1433 int adjust = 0;
1434
1435 ncm.cbSize = sizeof(ncm);
1436 pSystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0, dpi );
1437
1439 adjust = 1; /* for the outer frame always present */
1440 else if ((exStyle & WS_EX_DLGMODALFRAME) || (style & (WS_THICKFRAME|WS_DLGFRAME)))
1441 adjust = 2; /* outer */
1442
1443 if (style & WS_THICKFRAME) adjust += ncm.iBorderWidth + ncm.iPaddedBorderWidth;
1444
1445 if ((style & (WS_BORDER|WS_DLGFRAME)) || (exStyle & WS_EX_DLGMODALFRAME))
1446 adjust++; /* The other border */
1447
1448 InflateRect (rect, adjust, adjust);
1449
1450 if ((style & WS_CAPTION) == WS_CAPTION)
1451 {
1452 if (exStyle & WS_EX_TOOLWINDOW)
1453 rect->top -= ncm.iSmCaptionHeight + 1;
1454 else
1455 rect->top -= ncm.iCaptionHeight + 1;
1456 }
1457 if (menu) rect->top -= ncm.iMenuHeight + 1;
1458
1459 if (exStyle & WS_EX_CLIENTEDGE)
1461}
1462
1463static int offset;
1464
1466{
1467 switch (msg)
1468 {
1469 case WM_NCPAINT:
1470 {
1471 HRGN region;
1472 RECT rect;
1473
1475 region = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom - offset);
1476 DefWindowProcA(hwnd, msg, (WPARAM)region, lp);
1477 DeleteObject(region);
1478 return 0;
1479 }
1480
1481 case WM_NCCALCSIZE:
1482 {
1484 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wp, lp);
1485 return ret;
1486 }
1487
1488 default:
1489 return DefWindowProcA(hwnd, msg, wp, lp);
1490 }
1491}
1492
1494{
1496 POINT point, old_cursor_pos;
1497 COLORREF color, old_color;
1498 BOOL is_theme_active;
1499 DWORD style, exstyle;
1500 RECT rc_window, rc_client, rc;
1501 HWND child, parent;
1502 HMODULE uxtheme;
1503 WNDCLASSA cls;
1504 BOOL menu;
1505 LRESULT ret;
1506 HDC hdc;
1507
1509 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1510 menu = !(style & WS_CHILD) && GetMenu(hwnd) != 0;
1511
1512 GetWindowRect(hwnd, &rc_window);
1513 GetClientRect(hwnd, &rc_client);
1514
1515 /* avoid some cases when things go wrong */
1516 if (IsRectEmpty(&rc_window) || IsRectEmpty(&rc_client) ||
1517 rc_window.right > 32768 || rc_window.bottom > 32768) return;
1518
1519 rc = rc_client;
1520 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
1521 FixedAdjustWindowRectEx(&rc, style, menu, exstyle);
1522
1523 ok(EqualRect(&rc, &rc_window),
1524 "window rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d, win=%s, calc=%s\n",
1525 style, exstyle, menu, wine_dbgstr_rect(&rc_window), wine_dbgstr_rect(&rc));
1526
1527 rc = rc_client;
1528 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
1529 wine_AdjustWindowRectEx(&rc, style, menu, exstyle);
1530 ok(EqualRect(&rc, &rc_window),
1531 "window rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d, win=%s, calc=%s\n",
1532 style, exstyle, menu, wine_dbgstr_rect(&rc_window), wine_dbgstr_rect(&rc));
1533
1534
1535 rc = rc_window;
1537 ok(!ret, "got %08Ix\n", ret);
1538 MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
1539 ok(EqualRect(&rc, &rc_client),
1540 "client rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d client=%s, calc=%s\n",
1541 style, exstyle, menu, wine_dbgstr_rect(&rc_client), wine_dbgstr_rect(&rc));
1542
1543 /* NULL rectangle shouldn't crash */
1545 ok(ret == 0, "NULL rectangle returned %Id instead of 0\n", ret);
1546
1547 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
1548 SetRect(&rc_client, 0, 0, 250, 150);
1549 rc_window = rc_client;
1550 MapWindowPoints(hwnd, 0, (LPPOINT)&rc_window, 2);
1551 FixedAdjustWindowRectEx(&rc_window, style, menu, exstyle);
1552
1553 rc = rc_window;
1555 ok(!ret, "got %08Ix\n", ret);
1556 MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
1557 ok(EqualRect(&rc, &rc_client),
1558 "synthetic rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d, client=%s, calc=%s\n",
1559 style, exstyle, menu, wine_dbgstr_rect(&rc_client), wine_dbgstr_rect(&rc));
1560
1561 /* Test standard scroll bars */
1562 uxtheme = LoadLibraryA("uxtheme.dll");
1563 ok(!!uxtheme, "Failed to load uxtheme.dll, error %lu.\n", GetLastError());
1564 pIsThemeActive = (void *)GetProcAddress(uxtheme, "IsThemeActive");
1565 ok(!!pIsThemeActive, "Failed to load IsThemeActive, error %lu.\n", GetLastError());
1566 is_theme_active = pIsThemeActive();
1567
1568 memset(&cls, 0, sizeof(cls));
1570 cls.hInstance = GetModuleHandleA(0);
1573 cls.lpszClassName = "TestStandardScrollbarParentClass";
1574 RegisterClassA(&cls);
1575
1578 cls.lpszClassName = "TestStandardScrollbarClass";
1579 RegisterClassA(&cls);
1580
1581 parent = CreateWindowA("TestStandardScrollbarParentClass", "parent", WS_POPUP | WS_VISIBLE, 100,
1582 100, 100, 100, NULL, NULL, 0, NULL);
1583 ok(!!parent, "Failed to create a parent window, error %lu.\n", GetLastError());
1584 GetCursorPos(&old_cursor_pos);
1585
1586 /* Place the cursor on the standard scroll bar arrow button when not painting it at all.
1587 * Expects the standard scroll bar not to appear before and after the cursor position change */
1589 child = CreateWindowA("TestStandardScrollbarClass", "test", WS_CHILD | WS_HSCROLL | WS_VISIBLE,
1590 0, 0, 50, 50, parent, NULL, 0, NULL);
1591 ok(!!child, "Failed to create a test window, error %lu.\n", GetLastError());
1592 hdc = GetDC(parent);
1593 ok(!!hdc, "GetDC failed, error %ld.\n", GetLastError());
1594
1595 SetCursorPos(0, 0);
1598 old_color = GetPixel(hdc, 50 - GetSystemMetrics(SM_CXVSCROLL) / 2,
1599 50 - GetSystemMetrics(SM_CYHSCROLL) / 2);
1600 ok(old_color == 0xc0c0c0, "Expected color %#x, got %#lx.\n", 0xc0c0c0, old_color);
1601
1609 50 - GetSystemMetrics(SM_CYHSCROLL) / 2);
1610 ok(color == old_color, "Expected color %#lx, got %#lx.\n", old_color, color);
1611
1614
1615 /* Place the cursor on standard scroll bar arrow button when painting 1 pixel of the scroll bar.
1616 * Expects the scroll bar to appear after the cursor position change */
1618 child = CreateWindowA("TestStandardScrollbarClass", "test", WS_CHILD | WS_HSCROLL | WS_VISIBLE,
1619 0, 0, 50, 50, parent, NULL, 0, NULL);
1620 ok(!!child, "Failed to create a test window, error %lu.\n", GetLastError());
1621 hdc = GetDC(parent);
1622 ok(!!hdc, "GetDC failed, error %ld.\n", GetLastError());
1623
1624 SetCursorPos(0, 0);
1627 old_color = GetPixel(hdc, 50 - GetSystemMetrics(SM_CXVSCROLL) / 2,
1628 50 - GetSystemMetrics(SM_CYHSCROLL) / 2);
1629
1637 50 - GetSystemMetrics(SM_CYHSCROLL) / 2);
1638 if (is_theme_active)
1639 ok(color != old_color || broken(color == old_color), /* Win 10 1507 64-bit */
1640 "Got unexpected color %#lx.\n", color);
1641 else
1642 todo_wine
1643 ok(color == old_color, "Expected color %#lx, got %#lx.\n", old_color, color);
1644
1645 SetCursorPos(old_cursor_pos.x, old_cursor_pos.y);
1648 UnregisterClassA("TestStandardScrollbarClass", GetModuleHandleA(0));
1649 UnregisterClassA("TestStandardScrollbarParentClass", GetModuleHandleA(0));
1650 FreeLibrary(uxtheme);
1651}
1652
1654{
1655 static const char *CBT_code_name[10] = {
1656 "HCBT_MOVESIZE",
1657 "HCBT_MINMAX",
1658 "HCBT_QS",
1659 "HCBT_CREATEWND",
1660 "HCBT_DESTROYWND",
1661 "HCBT_ACTIVATE",
1662 "HCBT_CLICKSKIPPED",
1663 "HCBT_KEYSKIPPED",
1664 "HCBT_SYSCOMMAND",
1665 "HCBT_SETFOCUS" };
1666 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
1667 HWND hwnd = (HWND)wParam;
1668
1669 switch (nCode)
1670 {
1671 case HCBT_CREATEWND:
1672 {
1673 static const RECT rc_null;
1674 RECT rc;
1675 LONG style;
1676 CBT_CREATEWNDA *createwnd = (CBT_CREATEWNDA *)lParam;
1677 ok(createwnd->hwndInsertAfter == HWND_TOP, "hwndInsertAfter should be always HWND_TOP\n");
1678
1679 if (pGetWindowInfo)
1680 test_window_info(code_name, hwnd);
1681
1682 /* WS_VISIBLE should be turned off yet */
1683 style = createwnd->lpcs->style & ~WS_VISIBLE;
1685 "style of hwnd and style in the CREATESTRUCT do not match: %08lx != %08lx\n",
1687
1688 if (0)
1689 {
1690 /* Uncomment this once the test succeeds in all cases */
1691 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1692 {
1694 "wrong result from GetParent %p: message window %p\n",
1696 }
1697 else
1698 ok(!GetParent(hwnd), "GetParent should return 0 at this point\n");
1699
1700 ok(!GetWindow(hwnd, GW_OWNER), "GW_OWNER should be set to 0 at this point\n");
1701 }
1702 if (0)
1703 {
1704 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
1705 * Win9x still has them set to 0.
1706 */
1707 ok(GetWindow(hwnd, GW_HWNDFIRST) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
1708 ok(GetWindow(hwnd, GW_HWNDLAST) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
1709 }
1710 ok(!GetWindow(hwnd, GW_HWNDPREV), "GW_HWNDPREV should be set to 0 at this point\n");
1711 ok(!GetWindow(hwnd, GW_HWNDNEXT), "GW_HWNDNEXT should be set to 0 at this point\n");
1712
1713 if (0)
1714 {
1715 /* Uncomment this once the test succeeds in all cases */
1716 ok(GetAncestor(hwnd, GA_PARENT) == hwndMessage, "GA_PARENT should be set to hwndMessage at this point\n");
1718 "GA_ROOT is set to %p, expected %p\n", GetAncestor(hwnd, GA_ROOT), hwnd);
1719
1720 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
1722 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
1723 else
1725 "GA_ROOTOWNER is set to %p, expected %p\n", GetAncestor(hwnd, GA_ROOTOWNER), hwnd);
1726
1727 ok(GetWindowRect(hwnd, &rc), "GetWindowRect failed\n");
1728 ok(EqualRect(&rc, &rc_null), "window rect should be set to 0 HCBT_CREATEWND\n");
1729 ok(GetClientRect(hwnd, &rc), "GetClientRect failed\n");
1730 ok(EqualRect(&rc, &rc_null), "client rect should be set to 0 on HCBT_CREATEWND\n");
1731 }
1732 break;
1733 }
1734 case HCBT_MOVESIZE:
1735 case HCBT_MINMAX:
1736 case HCBT_ACTIVATE:
1737 if (pGetWindowInfo && IsWindow(hwnd))
1738 test_window_info(code_name, hwnd);
1739 break;
1740 /* window state is undefined */
1741 case HCBT_SETFOCUS:
1742 case HCBT_DESTROYWND:
1743 break;
1744 default:
1745 break;
1746 }
1747
1748 return CallNextHookEx(hhook, nCode, wParam, lParam);
1749}
1750
1752{
1753 BOOL ret;
1754 HMODULE hinst, hUser32;
1756 HWND hwnd1, hwnd2, hwnd3, hwnd4, hwnd5;
1757 HWND shellWindow, nextWnd;
1758 HDESK testDesktop = (HDESK)param;
1759
1760 SetThreadDesktop(testDesktop);
1761
1762 shellWindow = GetShellWindow();
1764 hUser32 = GetModuleHandleA("user32");
1765
1766 ok(shellWindow == NULL, "Newly created desktop has a shell window %p\n", shellWindow);
1767
1768 SetShellWindow = (void *)GetProcAddress(hUser32, "SetShellWindow");
1769
1770 hwnd1 = CreateWindowExA(0, "#32770", "TEST1", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst, 0);
1771
1772 ret = SetShellWindow(hwnd1);
1773 ok(ret, "first call to SetShellWindow(hwnd1)\n");
1774 shellWindow = GetShellWindow();
1775 ok(shellWindow==hwnd1, "wrong shell window: %p/%p\n", shellWindow,hwnd1);
1776
1777 ret = SetShellWindow(hwnd1);
1778 ok(!ret, "second call to SetShellWindow(hwnd1)\n");
1779
1780 ret = SetShellWindow(0);
1781 /* passes on Win XP, but not on Win98
1782 DWORD error = GetLastError();
1783 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1784 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1785
1786 ret = SetShellWindow(hwnd1);
1787 /* passes on Win XP, but not on Win98
1788 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1789
1791 ret = (GetWindowLongA(hwnd1,GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
1792 ok(!ret, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1793
1794 ret = DestroyWindow(hwnd1);
1795 ok(ret, "DestroyWindow(hwnd1)\n");
1796
1797 hwnd2 = CreateWindowExA(WS_EX_TOPMOST, "#32770", "TEST2", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst, 0);
1798 ret = SetShellWindow(hwnd2);
1799 ok(!ret, "SetShellWindow(%p) with WS_EX_TOPMOST\n", hwnd2);
1800
1801 hwnd3 = CreateWindowExA(0, "#32770", "TEST3", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst, 0);
1802
1803 hwnd4 = CreateWindowExA(0, "#32770", "TEST4", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst, 0);
1804
1805 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
1806 ok(nextWnd==hwnd3, "wrong next window for hwnd4 %p: %p - expected %p\n", hwnd4, nextWnd, hwnd3);
1807
1808 ret = SetShellWindow(hwnd4);
1809 ok(ret, "SetShellWindow(hwnd4)\n");
1810 shellWindow = GetShellWindow();
1811 ok(shellWindow==hwnd4, "wrong shell window: %p - expected %p\n", shellWindow, hwnd4);
1812
1813 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
1814 ok(nextWnd==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd);
1815
1816 ret = SetWindowPos(hwnd4, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
1817 ok(ret, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1818
1819 ret = SetWindowPos(hwnd4, hwnd3, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
1820 ok(ret, "SetWindowPos(hwnd4, hwnd3\n");
1821
1822 ret = SetShellWindow(hwnd3);
1823 ok(!ret, "SetShellWindow(hwnd3)\n");
1824 shellWindow = GetShellWindow();
1825 ok(shellWindow==hwnd4, "wrong shell window: %p - expected %p\n", shellWindow, hwnd4);
1826
1827 hwnd5 = CreateWindowExA(0, "#32770", "TEST5", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst, 0);
1828 ret = SetWindowPos(hwnd4, hwnd5, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
1829 ok(ret, "SetWindowPos(hwnd4, hwnd5)\n");
1830
1831 todo_wine
1832 {
1833 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
1834 ok(nextWnd==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd);
1835 }
1836
1837 /* destroy test windows */
1838 DestroyWindow(hwnd2);
1839 DestroyWindow(hwnd3);
1840 DestroyWindow(hwnd4);
1841 DestroyWindow(hwnd5);
1842
1843 return 0;
1844}
1845
1846static void test_shell_window(void)
1847{
1848 HDESK hdesk;
1849 HWND orig_shell_window;
1850 HANDLE hthread;
1851
1852 orig_shell_window = GetShellWindow();
1853 ok(orig_shell_window != NULL, "default desktop doesn't have a shell window\n");
1854
1855 hdesk = CreateDesktopA("winetest", NULL, NULL, 0, GENERIC_ALL, NULL);
1856
1857 hthread = CreateThread(NULL, 0, test_shell_window_thread, (LPVOID)hdesk, 0, NULL);
1858
1859 WaitForSingleObject(hthread, INFINITE);
1860
1861 CloseHandle(hthread);
1862
1863 CloseDesktop(hdesk);
1864
1865 if (!orig_shell_window)
1866 skip("no shell window on default desktop\n");
1867 else
1868 ok(GetShellWindow() == orig_shell_window, "changing shell window on another desktop effected the default\n");
1869}
1870
1871/************** MDI test ****************/
1872
1873static char mdi_lParam_test_message[] = "just a test string";
1874
1876{
1877 MDICREATESTRUCTA mdi_cs;
1878 HWND mdi_child, hwnd, exp_hwnd;
1879 INT_PTR id;
1880 static const WCHAR classW[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1881 static const WCHAR titleW[] = {'M','D','I',' ','c','h','i','l','d',0};
1882 HMENU frame_menu = GetMenu(parent);
1883
1884 ok(frame_menu != NULL, "Frame window didn't have a menu\n");
1885
1886 mdi_cs.szClass = "MDI_child_Class_1";
1887 mdi_cs.szTitle = "MDI child";
1888 mdi_cs.hOwner = GetModuleHandleA(NULL);
1889 mdi_cs.x = CW_USEDEFAULT;
1890 mdi_cs.y = CW_USEDEFAULT;
1891 mdi_cs.cx = CW_USEDEFAULT;
1892 mdi_cs.cy = CW_USEDEFAULT;
1893 mdi_cs.style = 0;
1895 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1896 ok(mdi_child != 0, "MDI child creation failed\n");
1897 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1898 ok(id == first_id, "wrong child id %Id\n", id);
1900 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1901 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1903 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1904
1905 mdi_cs.style = 0x7fffffff; /* without WS_POPUP */
1906 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1907 ok(mdi_child != 0, "MDI child creation failed\n");
1908 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1909 ok(id == first_id, "wrong child id %Id\n", id);
1911 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1913 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1914
1915 mdi_cs.style = 0xffffffff; /* with WS_POPUP */
1916 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1918 {
1919 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1920 }
1921 else
1922 {
1923 ok(mdi_child != 0, "MDI child creation failed\n");
1924 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1925 ok(id == first_id, "wrong child id %Id\n", id);
1927 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1928 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1930 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1931 }
1932
1933 /* test MDICREATESTRUCT A<->W mapping */
1934 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1935 mdi_cs.style = 0;
1936 mdi_cs.szClass = (LPCSTR)classW;
1937 mdi_cs.szTitle = (LPCSTR)titleW;
1938 SetLastError(0xdeadbeef);
1939 mdi_child = (HWND)SendMessageW(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
1940 ok(mdi_child != 0, "MDI child creation failed\n");
1941 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1942 ok(id == first_id, "wrong child id %Id\n", id);
1944 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1945 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1946 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1948 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1949
1950 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1951 0,
1956 ok(mdi_child != 0, "MDI child creation failed\n");
1957 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1958 ok(id == first_id, "wrong child id %Id\n", id);
1960 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
1961 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
1962 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1964 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1965
1966 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1967 0x7fffffff, /* without WS_POPUP */
1972 ok(mdi_child != 0, "MDI child creation failed\n");
1973 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1974 ok(id == first_id, "wrong child id %Id\n", id);
1976 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1977 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
1979 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
1980
1981 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1982 0xffffffff, /* with WS_POPUP */
1988 {
1989 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1990 }
1991 else
1992 {
1993 ok(mdi_child != 0, "MDI child creation failed\n");
1994 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
1995 ok(id == first_id, "wrong child id %Id\n", id);
1997 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
1998 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2000 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2001 }
2002
2003 /* test MDICREATESTRUCT A<->W mapping */
2004 SetLastError(0xdeadbeef);
2005 mdi_child = CreateMDIWindowW(classW, titleW,
2006 0,
2011 ok(mdi_child != 0, "MDI child creation failed\n");
2012 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2013 ok(id == first_id, "wrong child id %Id\n", id);
2015 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
2016 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
2017 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2019 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2020
2021 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2022 0,
2027 ok(mdi_child != 0, "MDI child creation failed\n");
2028 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2029 ok(id == first_id, "wrong child id %Id\n", id);
2031 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
2032 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
2033 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2035 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2036
2037 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2043 ok(mdi_child != 0, "MDI child creation failed\n");
2044 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2045 ok(id == first_id, "wrong child id %Id\n", id);
2047 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
2048 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
2050 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2051 else
2052 ok(GetMenuItemCount(frame_menu) == 4, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2054 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2055
2056 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2057 0x7fffffff, /* without WS_POPUP */
2062 ok(mdi_child != 0, "MDI child creation failed\n");
2063 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2064 ok(id == first_id, "wrong child id %Id\n", id);
2066 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2067 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2069 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2070
2071 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2072 0xffffffff, /* with WS_POPUP */
2078 {
2079 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
2080 }
2081 else
2082 {
2083 ok(mdi_child != 0, "MDI child creation failed\n");
2084 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2085 ok(id == first_id, "wrong child id %Id\n", id);
2087 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2088 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2090 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2091 }
2092
2093 /* test MDICREATESTRUCT A<->W mapping */
2094 SetLastError(0xdeadbeef);
2096 0,
2101 ok(mdi_child != 0, "MDI child creation failed\n");
2102 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2103 ok(id == first_id, "wrong child id %Id\n", id);
2105 exp_hwnd = (GetWindowLongW(mdi_child, GWL_STYLE) & WS_VISIBLE) ? mdi_child : 0;
2106 ok(hwnd == exp_hwnd, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd, hwnd);
2107 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2109 ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
2110
2111 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_2", "MDI child",
2112 WS_CHILD,
2117 ok(!mdi_child, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
2118
2119 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
2120 WS_CHILD, /* without WS_POPUP */
2125 ok(mdi_child != 0, "MDI child creation failed\n");
2126 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2127 ok(id == 0, "wrong child id %Id\n", id);
2128 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2130 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2131 DestroyWindow(mdi_child);
2132
2133 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
2134 WS_CHILD | WS_POPUP, /* with WS_POPUP */
2139 ok(mdi_child != 0, "MDI child creation failed\n");
2140 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2141 ok(id == 0, "wrong child id %Id\n", id);
2143 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2144 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2145 DestroyWindow(mdi_child);
2146
2147 /* maximized child */
2148 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
2154 ok(mdi_child != 0, "MDI child creation failed\n");
2155 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2156 ok(id == 0, "wrong child id %Id\n", id);
2158 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2159 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2160 DestroyWindow(mdi_child);
2161
2162 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
2168 ok(mdi_child != 0, "MDI child creation failed\n");
2169 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2170 ok(id == 0, "wrong child id %Id\n", id);
2172 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2173 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2174 DestroyWindow(mdi_child);
2175
2176 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
2182 ok(mdi_child != 0, "MDI child creation failed\n");
2183 id = GetWindowLongPtrA(mdi_child, GWLP_ID);
2184 ok(id == 0, "wrong child id %Id\n", id);
2186 ok(!hwnd, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd);
2187 ok(GetMenuItemCount(frame_menu) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu));
2188 DestroyWindow(mdi_child);
2189}
2190
2192{
2193 HWND child_1, child_2, child_3, child_4;
2194 HWND stack[4];
2196
2197 cs.szClass = "MDI_child_Class_1";
2198 cs.szTitle = "MDI child";
2199 cs.hOwner = GetModuleHandleA(0);
2200 cs.x = CW_USEDEFAULT;
2201 cs.y = CW_USEDEFAULT;
2202 cs.cx = CW_USEDEFAULT;
2203 cs.cy = CW_USEDEFAULT;
2204 cs.style = 0;
2206
2207 child_1 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
2208 ok(child_1 != 0, "expected child_1 to be non NULL\n");
2209 child_2 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
2210 ok(child_2 != 0, "expected child_2 to be non NULL\n");
2211 child_3 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
2212 ok(child_3 != 0, "expected child_3 to be non NULL\n");
2213 child_4 = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&cs);
2214 ok(child_4 != 0, "expected child_4 to be non NULL\n");
2215
2217 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
2218 stack[2] = GetWindow(stack[1], GW_HWNDNEXT);
2219 stack[3] = GetWindow(stack[2], GW_HWNDNEXT);
2220 ok(stack[0] == child_4 && stack[1] == child_3 &&
2221 stack[2] == child_2 && stack[3] == child_1,
2222 "Unexpected initial order, should be: %p->%p->%p->%p\n",
2223 child_4, child_3, child_2, child_1);
2224
2226
2228 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
2229 stack[2] = GetWindow(stack[1], GW_HWNDNEXT);
2230 stack[3] = GetWindow(stack[2], GW_HWNDNEXT);
2231 ok(stack[0] == child_2 && stack[1] == child_4 &&
2232 stack[2] == child_1 && stack[3] == child_3,
2233 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
2234 child_2, child_4, child_1, child_3, stack[0], stack[1], stack[2], stack[3]);
2235
2237
2239 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
2240 stack[2] = GetWindow(stack[1], GW_HWNDNEXT);
2241 stack[3] = GetWindow(stack[2], GW_HWNDNEXT);
2242 ok(stack[0] == child_4 && stack[1] == child_2 &&
2243 stack[2] == child_1 && stack[3] == child_3,
2244 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
2245 child_4, child_2, child_1, child_3, stack[0], stack[1], stack[2], stack[3]);
2246
2247 ShowWindow(child_4, SW_MINIMIZE);
2248
2250 stack[1] = GetWindow(stack[0], GW_HWNDNEXT);
2251 todo_wine ok(stack[0] == child_4, "Expected %p, got %p\n", child_4, stack[0]);
2252 todo_wine ok(stack[1] == NULL, "Expected NULL, got %p\n", stack[1]);
2253
2254 DestroyWindow(child_1);
2255 DestroyWindow(child_2);
2256 DestroyWindow(child_3);
2257 DestroyWindow(child_4);
2258}
2259
2260/**********************************************************************
2261 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
2262 *
2263 * Note: The rule here is that client rect of the maximized MDI child
2264 * is equal to the client rect of the MDI client window.
2265 */
2267{
2268 RECT rect;
2269
2273
2274 rect.right -= rect.left;
2275 rect.bottom -= rect.top;
2276 lpMinMax->ptMaxSize.x = rect.right;
2277 lpMinMax->ptMaxSize.y = rect.bottom;
2278
2279 lpMinMax->ptMaxPosition.x = rect.left;
2280 lpMinMax->ptMaxPosition.y = rect.top;
2281}
2282
2284{
2285 switch (msg)
2286 {
2287 case WM_NCCREATE:
2288 case WM_CREATE:
2289 {
2291 MDICREATESTRUCTA *mdi_cs = cs->lpCreateParams;
2292
2293 ok(cs->dwExStyle & WS_EX_MDICHILD, "WS_EX_MDICHILD should be set\n");
2294 ok(mdi_cs->lParam == (LPARAM)mdi_lParam_test_message, "wrong mdi_cs->lParam\n");
2295
2296 ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_1"), "wrong class name\n");
2297 ok(!lstrcmpA(cs->lpszClass, mdi_cs->szClass), "class name does not match\n");
2298 ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
2299 ok(!lstrcmpA(cs->lpszName, mdi_cs->szTitle), "title does not match\n");
2300 ok(cs->hInstance == mdi_cs->hOwner, "%p != %p\n", cs->hInstance, mdi_cs->hOwner);
2301
2302 /* MDICREATESTRUCT should have original values */
2303 ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff || mdi_cs->style == WS_MAXIMIZE,
2304 "mdi_cs->style does not match (%08lx)\n", mdi_cs->style);
2305 ok(mdi_cs->x == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->x);
2306 ok(mdi_cs->y == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->y);
2307 ok(mdi_cs->cx == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cx);
2308 ok(mdi_cs->cy == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cy);
2309
2310 /* CREATESTRUCT should have fixed values */
2311 ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);
2312 ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
2313
2314 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
2315 ok(cs->cx != CW_USEDEFAULT && cs->cx != 0, "%d == CW_USEDEFAULT\n", cs->cx);
2316 ok(cs->cy != CW_USEDEFAULT && cs->cy != 0, "%d == CW_USEDEFAULT\n", cs->cy);
2317
2318 ok(!(cs->style & WS_POPUP), "WS_POPUP is not allowed\n");
2319
2320 if (GetWindowLongA(cs->hwndParent, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
2321 {
2322 LONG style = mdi_cs->style | WS_CHILD | WS_CLIPSIBLINGS;
2323 ok(cs->style == style,
2324 "cs->style does not match (%08lx)\n", cs->style);
2325 }
2326 else
2327 {
2328 LONG style = mdi_cs->style;
2329 style &= ~WS_POPUP;
2332 ok(cs->style == style,
2333 "cs->style does not match (%08lx)\n", cs->style);
2334 }
2335 break;
2336 }
2337
2338 case WM_GETMINMAXINFO:
2339 {
2341 RECT rc;
2342 MINMAXINFO *minmax = (MINMAXINFO *)lparam;
2343 MINMAXINFO my_minmax;
2344 LONG style, exstyle;
2345
2347 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2348
2349 GetClientRect(client, &rc);
2350
2351 GetClientRect(client, &rc);
2352 if ((style & WS_CAPTION) == WS_CAPTION)
2353 style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
2354 AdjustWindowRectEx(&rc, style, 0, exstyle);
2355 if (winetest_debug > 1)
2356 {
2357 trace("MDI child: calculated max window size = (%ld x %ld)\n", rc.right-rc.left, rc.bottom-rc.top);
2358 dump_minmax_info( minmax );
2359 }
2360
2361 ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %ld != %ld\n",
2362 minmax->ptMaxSize.x, rc.right - rc.left);
2363 ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %ld != %ld\n",
2364 minmax->ptMaxSize.y, rc.bottom - rc.top);
2365
2367
2368 if (winetest_debug > 1)
2369 {
2370 trace("DefMDIChildProc returned:\n");
2371 dump_minmax_info( minmax );
2372 }
2373
2374 MDI_ChildGetMinMaxInfo(client, hwnd, &my_minmax);
2375 ok(minmax->ptMaxSize.x == my_minmax.ptMaxSize.x, "default width of maximized child %ld != %ld\n",
2376 minmax->ptMaxSize.x, my_minmax.ptMaxSize.x);
2377 ok(minmax->ptMaxSize.y == my_minmax.ptMaxSize.y, "default height of maximized child %ld != %ld\n",
2378 minmax->ptMaxSize.y, my_minmax.ptMaxSize.y);
2379
2380 return 1;
2381 }
2382
2383 case WM_MDIACTIVATE:
2384 {
2385 HWND active, client = GetParent(hwnd);
2386 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
2387 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2388 if (hwnd == (HWND)lparam) /* if we are being activated */
2389 ok (active == (HWND)lparam, "new active %p != active %p\n", (HWND)lparam, active);
2390 else
2391 ok (active == (HWND)wparam, "old active %p != active %p\n", (HWND)wparam, active);
2392 break;
2393 }
2394 }
2396}
2397
2399{
2400 switch (msg)
2401 {
2402 case WM_NCCREATE:
2403 case WM_CREATE:
2404 {
2406
2407 if (winetest_debug > 1)
2408 trace("%s: x %d, y %d, cx %d, cy %d\n", (msg == WM_NCCREATE) ? "WM_NCCREATE" : "WM_CREATE",
2409 cs->x, cs->y, cs->cx, cs->cy);
2410
2411 ok(!(cs->dwExStyle & WS_EX_MDICHILD), "WS_EX_MDICHILD should not be set\n");
2412 ok(cs->lpCreateParams == mdi_lParam_test_message, "wrong cs->lpCreateParams\n");
2413
2414 ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_2"), "wrong class name\n");
2415 ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
2416
2417 /* CREATESTRUCT should have fixed values */
2418 ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);
2419 ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
2420
2421 /* cx/cy == CW_USEDEFAULT are translated to 0 */
2422 ok(cs->cx == 0, "%d != 0\n", cs->cx);
2423 ok(cs->cy == 0, "%d != 0\n", cs->cy);
2424 break;
2425 }
2426
2427 case WM_GETMINMAXINFO:
2428 {
2430 RECT rc;
2431 MINMAXINFO *minmax = (MINMAXINFO *)lparam;
2432 LONG style, exstyle;
2433
2435 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2436
2437 GetClientRect(parent, &rc);
2438 if (winetest_debug > 1)
2439 {
2440 trace("WM_GETMINMAXINFO: parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
2441 dump_minmax_info( minmax );
2442 }
2443 GetClientRect(parent, &rc);
2444 if ((style & WS_CAPTION) == WS_CAPTION)
2445 style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
2446 AdjustWindowRectEx(&rc, style, 0, exstyle);
2447
2448 ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %ld != %ld\n",
2449 minmax->ptMaxSize.x, rc.right - rc.left);
2450 ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %ld != %ld\n",
2451 minmax->ptMaxSize.y, rc.bottom - rc.top);
2452 break;
2453 }
2454
2456 {
2457 LRESULT ret;
2458 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
2459 RECT rc1, rc2;
2460
2461 GetWindowRect(hwnd, &rc1);
2462 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
2463 /* note: winpos coordinates are relative to parent */
2465 ok(EqualRect(&rc1, &rc2), "rects do not match, window=%s pos=%s\n",
2467 GetWindowRect(hwnd, &rc1);
2470 ok(!ret, "got %08Ix\n", ret);
2471 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
2472 ok(EqualRect(&rc1, &rc2), "rects do not match, window=%s client=%s\n",
2474 }
2475 /* fall through */
2477 {
2478 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
2479 WINDOWPOS my_winpos = *winpos;
2480
2481 if (winetest_debug > 1)
2482 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2483 (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
2484 winpos->hwnd, winpos->hwndInsertAfter,
2485 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2486
2488
2489 ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
2490 "DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2491 winpos->hwnd, winpos->hwndInsertAfter,
2492 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2493
2494 return 1;
2495 }
2496
2497 case WM_NCCALCSIZE:
2498 {
2500 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wparam, lparam);
2501 return ret;
2502 }
2503 }
2504
2505 return DefWindowProcA(hwnd, msg, wparam, lparam);
2506}
2507
2509{
2510 static HWND mdi_client;
2511
2512 switch (msg)
2513 {
2514 case WM_CREATE:
2515 return 1;
2516
2518 {
2519 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
2520 RECT rc1, rc2;
2521
2522 GetWindowRect(hwnd, &rc1);
2523 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
2524 /* note: winpos coordinates are relative to parent */
2526 ok(EqualRect(&rc1, &rc2), "rects %s %s do not match\n",
2528
2529 GetWindowRect(hwnd, &rc1);
2532 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
2533 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
2534 }
2535 /* fall through */
2537 {
2538 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
2539 WINDOWPOS my_winpos = *winpos;
2540
2541 if (winetest_debug > 1)
2542 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2543 (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
2544 winpos->hwnd, winpos->hwndInsertAfter,
2545 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2546
2548
2549 if (winetest_debug > 1)
2550 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2551 winpos->hwnd, winpos->hwndInsertAfter,
2552 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2553
2554 ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
2555 "DefWindowProc should not change WINDOWPOS values\n");
2556
2557 return 1;
2558 }
2559
2560 case WM_NCCALCSIZE:
2561 {
2563 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wparam, lparam);
2564 return ret;
2565 }
2566
2567 case WM_CLOSE:
2568 PostQuitMessage(0);
2569 break;
2570 }
2572}
2573
2575{
2576 WNDCLASSA cls;
2577
2578 cls.style = 0;
2580 cls.cbClsExtra = 0;
2581 cls.cbWndExtra = 0;
2582 cls.hInstance = GetModuleHandleA(0);
2583 cls.hIcon = 0;
2586 cls.lpszMenuName = NULL;
2587 cls.lpszClassName = "MDI_parent_Class";
2588 if(!RegisterClassA(&cls)) return FALSE;
2589
2591 cls.lpszClassName = "MDI_child_Class_1";
2592 if(!RegisterClassA(&cls)) return FALSE;
2593
2595 cls.lpszClassName = "MDI_child_Class_2";
2596 if(!RegisterClassA(&cls)) return FALSE;
2597
2598 return TRUE;
2599}
2600
2601static void test_mdi(void)
2602{
2603 static const DWORD style[] = { 0, WS_HSCROLL, WS_VSCROLL, WS_HSCROLL | WS_VSCROLL };
2604 HWND mdi_hwndMain, mdi_client, mdi_child;
2605 CLIENTCREATESTRUCT client_cs;
2606 RECT rc;
2607 DWORD i;
2608 MSG msg;
2609 HMENU frame_menu, child_menu;
2610
2612
2613 mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
2615 WS_MAXIMIZEBOX /*| WS_VISIBLE*/,
2616 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2617 GetDesktopWindow(), 0,
2619 assert(mdi_hwndMain);
2620
2621 frame_menu = CreateMenu();
2622
2623 GetClientRect(mdi_hwndMain, &rc);
2624
2625 client_cs.hWindowMenu = 0;
2626 client_cs.idFirstChild = 1;
2627
2628 for (i = 0; i < ARRAY_SIZE(style); i++)
2629 {
2630 SCROLLINFO si;
2631 BOOL ret, gotit;
2632
2633 winetest_push_context("style %#lx", style[i]);
2634 mdi_client = CreateWindowExA(0, "mdiclient", NULL,
2635 WS_CHILD | style[i],
2636 0, 0, rc.right, rc.bottom,
2637 mdi_hwndMain, 0, 0, &client_cs);
2638 ok(mdi_client != 0, "MDI client creation failed\n");
2639
2640 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2641 0,
2644 mdi_client, 0, 0,
2646 ok(mdi_child != 0, "MDI child creation failed\n");
2647
2648 SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
2649 SetMenu(mdi_hwndMain, frame_menu);
2650
2651 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child maximize, but has %u\n",
2652 GetMenuItemCount(frame_menu));
2653
2654 child_menu = CreateMenu();
2655 SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
2656
2657 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after WM_MDISETMENU, but has %u\n",
2658 GetMenuItemCount(frame_menu));
2659
2660 SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
2661
2662 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
2663 GetMenuItemCount(frame_menu));
2664
2665 SetMenu(mdi_hwndMain, NULL);
2666
2667 si.cbSize = sizeof(si);
2668 si.fMask = SIF_ALL;
2670 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2671 {
2672 ok(ret, "GetScrollInfo(SB_HORZ) failed\n");
2673 ok(si.nPage == 0, "expected 0\n");
2674 ok(si.nPos == 0, "expected 0\n");
2675 ok(si.nTrackPos == 0, "expected 0\n");
2676 ok(si.nMin == 0, "expected 0\n");
2677 ok(si.nMax == 100, "expected 100\n");
2678 }
2679 else
2680 ok(!ret, "GetScrollInfo(SB_HORZ) should fail\n");
2681
2683 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2684 {
2685 ok(ret, "GetScrollInfo(SB_VERT) failed\n");
2686 ok(si.nPage == 0, "expected 0\n");
2687 ok(si.nPos == 0, "expected 0\n");
2688 ok(si.nTrackPos == 0, "expected 0\n");
2689 ok(si.nMin == 0, "expected 0\n");
2690 ok(si.nMax == 100, "expected 100\n");
2691 }
2692 else
2693 ok(!ret, "GetScrollInfo(SB_VERT) should fail\n");
2694
2695 SetWindowPos(mdi_child, 0, -100, -100, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
2696
2697 si.cbSize = sizeof(si);
2698 si.fMask = SIF_ALL;
2700 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2701 {
2702 ok(ret, "GetScrollInfo(SB_HORZ) failed\n");
2703 ok(si.nPage == 0, "expected 0\n");
2704 ok(si.nPos == 0, "expected 0\n");
2705 ok(si.nTrackPos == 0, "expected 0\n");
2706 ok(si.nMin == 0, "expected 0\n");
2707 ok(si.nMax == 100, "expected 100\n");
2708 }
2709 else
2710 ok(!ret, "GetScrollInfo(SB_HORZ) should fail\n");
2711
2713 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2714 {
2715 ok(ret, "GetScrollInfo(SB_VERT) failed\n");
2716 ok(si.nPage == 0, "expected 0\n");
2717 ok(si.nPos == 0, "expected 0\n");
2718 ok(si.nTrackPos == 0, "expected 0\n");
2719 ok(si.nMin == 0, "expected 0\n");
2720 ok(si.nMax == 100, "expected 100\n");
2721 }
2722 else
2723 ok(!ret, "GetScrollInfo(SB_VERT) should fail\n");
2724
2725 gotit = FALSE;
2726 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
2727 {
2728 if (msg.message == WM_MOUSEMOVE || msg.message == WM_PAINT)
2729 {
2731 continue;
2732 }
2733
2734 if (msg.message == 0x003f) /* WM_MDICALCCHILDSCROLL ??? */
2735 {
2736 ok(msg.hwnd == mdi_client, "message 0x003f should be posted to mdiclient\n");
2737 gotit = TRUE;
2738 }
2739 else
2740 ok(msg.hwnd != mdi_client, "message %04x should not be posted to mdiclient\n", msg.message);
2742 }
2743 ok(gotit, "message 0x003f should appear after SetWindowPos\n");
2744
2745 si.cbSize = sizeof(si);
2746 si.fMask = SIF_ALL;
2748 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2749 {
2750 ok(ret, "GetScrollInfo(SB_HORZ) failed\n");
2751 todo_wine
2752 ok(si.nPage != 0, "expected !0\n");
2753 ok(si.nPos == 0, "expected 0\n");
2754 ok(si.nTrackPos == 0, "expected 0\n");
2755 ok(si.nMin != 0, "expected !0\n");
2756 ok(si.nMax != 100, "expected !100\n");
2757 }
2758 else
2759 ok(!ret, "GetScrollInfo(SB_HORZ) should fail\n");
2760
2762 if (style[i] & (WS_HSCROLL | WS_VSCROLL))
2763 {
2764 ok(ret, "GetScrollInfo(SB_VERT) failed\n");
2765 todo_wine
2766 ok(si.nPage != 0, "expected !0\n");
2767 ok(si.nPos == 0, "expected 0\n");
2768 ok(si.nTrackPos == 0, "expected 0\n");
2769 ok(si.nMin != 0, "expected !0\n");
2770 ok(si.nMax != 100, "expected !100\n");
2771 }
2772 else
2773 ok(!ret, "GetScrollInfo(SB_VERT) should fail\n");
2774
2775 DestroyMenu(child_menu);
2776 DestroyWindow(mdi_child);
2779 }
2780
2781 SetMenu(mdi_hwndMain, frame_menu);
2782
2783 mdi_client = CreateWindowExA(0, "mdiclient", NULL,
2784 WS_CHILD,
2785 0, 0, rc.right, rc.bottom,
2786 mdi_hwndMain, 0, 0, &client_cs);
2787 ok(mdi_client != 0, "MDI client creation failed\n");
2788
2789 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
2790 0,
2793 mdi_client, 0, 0,
2795 ok(mdi_child != 0, "MDI child creation failed\n");
2796
2797 SendMessageW(mdi_child, WM_SIZE, SIZE_MAXIMIZED, 0);
2798 ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after child maximize, but has %u\n",
2799 GetMenuItemCount(frame_menu));
2800
2801 child_menu = CreateMenu();
2802 SendMessageW(mdi_client, WM_MDISETMENU, 0, (LPARAM)child_menu);
2803
2804 ok(GetMenuItemCount(frame_menu) == 4, "Frame menu should have 4 items after WM_MDISETMENU, but has %u\n",
2805 GetMenuItemCount(frame_menu));
2806
2807 SendMessageW(mdi_child, WM_SIZE, SIZE_RESTORED, 0);
2808
2809 ok(GetMenuItemCount(frame_menu) == 0, "Frame menu should be empty after child restored, but has %u items\n",
2810 GetMenuItemCount(frame_menu));
2811
2812 DestroyMenu(child_menu);
2813 DestroyWindow(mdi_child);
2815
2816 /* MDIClient without MDIS_ALLCHILDSTYLES */
2817 mdi_client = CreateWindowExA(0, "mdiclient",
2818 NULL,
2819 WS_CHILD /*| WS_VISIBLE*/,
2820 /* tests depend on a not zero MDIClient size */
2821 0, 0, rc.right, rc.bottom,
2822 mdi_hwndMain, 0, GetModuleHandleA(NULL),
2823 &client_cs);
2825 test_MDI_create(mdi_hwndMain, mdi_client, client_cs.idFirstChild);
2827
2828 /* MDIClient with MDIS_ALLCHILDSTYLES */
2829 mdi_client = CreateWindowExA(0, "mdiclient",
2830 NULL,
2831 WS_CHILD | MDIS_ALLCHILDSTYLES /*| WS_VISIBLE*/,
2832 /* tests depend on a not zero MDIClient size */
2833 0, 0, rc.right, rc.bottom,
2834 mdi_hwndMain, 0, GetModuleHandleA(NULL),
2835 &client_cs);
2837 test_MDI_create(mdi_hwndMain, mdi_client, client_cs.idFirstChild);
2839
2840 /* Test child window stack management */
2841 mdi_client = CreateWindowExA(0, "mdiclient",
2842 NULL,
2843 WS_CHILD,
2844 0, 0, rc.right, rc.bottom,
2845 mdi_hwndMain, 0, GetModuleHandleA(NULL),
2846 &client_cs);
2850/*
2851 while(GetMessage(&msg, 0, 0, 0))
2852 {
2853 TranslateMessage(&msg);
2854 DispatchMessage(&msg);
2855 }
2856*/
2857 DestroyWindow(mdi_hwndMain);
2858}
2859
2860#define check_icon_size(a, b, c) check_icon_size_(__LINE__, a, b, c)
2861static void check_icon_size_( int line, HICON icon, LONG width, LONG height )
2862{
2863 ICONINFO info = {sizeof(info)};
2864 BITMAP bitmap;
2865 BOOL ret;
2866
2867 ret = GetIconInfo( icon, &info );
2868 ok_(__FILE__, line)(ret, "failed to get icon info, error %lu\n", GetLastError());
2869 ret = GetObjectW(info.hbmColor, sizeof(bitmap), &bitmap);
2870 ok_(__FILE__, line)(ret, "failed to get bitmap, error %lu\n", GetLastError());
2871 ok_(__FILE__, line)(bitmap.bmWidth == width, "expected width %ld, got %d\n", width, bitmap.bmWidth);
2872 ok_(__FILE__, line)(bitmap.bmHeight == height, "expected height %ld, got %d\n", height, bitmap.bmHeight);
2873}
2874
2875#define check_internal_icon_size(a, b, c, d) check_internal_icon_size_(__LINE__, a, b, c, d)
2877{
2878 HICON icon;
2879 BOOL ret;
2880
2881 icon = pInternalGetWindowIcon( window, type );
2882 ok_(__FILE__, line)(icon != 0, "expected nonzero icon\n");
2883 check_icon_size_( line, icon, width, height );
2884 ret = DestroyIcon( icon );
2885 ok_(__FILE__, line)(ret, "failed to destroy icon, error %lu\n", GetLastError());
2886}
2887
2889{
2890 HICON icon;
2891 BOOL ret;
2892
2893 icon = pInternalGetWindowIcon( arg, ICON_BIG );
2894 ok( icon != 0, "expected nonzero icon\n" );
2895 ret = DestroyIcon( icon );
2896 ok( ret, "got error %lu\n", GetLastError() );
2897
2898 return 0;
2899}
2900
2901static void test_icons(void)
2902{
2903 static const BYTE bitmap_bits[50 * 50 * 4];
2904 HICON icon = CreateIcon( 0, 10, 10, 1, 32, bitmap_bits, bitmap_bits );
2905 HICON icon2 = CreateIcon( 0, 20, 20, 1, 32, bitmap_bits, bitmap_bits );
2906 HICON icon3 = CreateIcon( 0, 30, 30, 1, 32, bitmap_bits, bitmap_bits );
2907 HICON icon4 = CreateIcon( 0, 40, 40, 1, 32, bitmap_bits, bitmap_bits );
2908 HICON icon5 = CreateIcon( 0, 50, 50, 1, 32, bitmap_bits, bitmap_bits );
2909 LONG big_width = GetSystemMetrics( SM_CXICON ), big_height = GetSystemMetrics( SM_CYICON );
2910 LONG small_width = GetSystemMetrics( SM_CXSMICON ), small_height = GetSystemMetrics( SM_CYSMICON );
2911 WNDCLASSEXA cls = {sizeof(cls)};
2912 HICON res, res2;
2913 HANDLE thread;
2914 HWND hwnd;
2915 BOOL ret;
2916
2917#ifdef __REACTOS__
2919 skip("test_icons() crashes on Windows Server 2003 and ReactOS.\n");
2920 return;
2921 }
2922#endif
2924 cls.hIcon = icon4;
2925 cls.hIconSm = icon5;
2926 cls.lpszClassName = "IconWindowClass";
2927 RegisterClassExA(&cls);
2928
2929 hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
2930 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
2931 ok( hwnd != NULL, "failed to create window\n" );
2932
2933 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2934 ok( res == 0, "wrong big icon %p/0\n", res );
2935 SetLastError( 0xdeadbeef );
2936 res = pInternalGetWindowIcon( hwnd, ICON_BIG );
2937 ok( res != 0, "expected nonzero icon\n" );
2938 ok( GetLastError() == 0xdeadbeef, "got error %lu\n", GetLastError() );
2939 check_icon_size( res, 40, 40 );
2940 res2 = pInternalGetWindowIcon( hwnd, ICON_BIG );
2941 ok( res2 && res2 != res, "got %p\n", res2 );
2942 check_icon_size( res2, 40, 40 );
2943 ret = DestroyIcon( res2 );
2944 ok( ret, "got error %lu\n", GetLastError() );
2945 ret = DestroyIcon( res );
2946 ok( ret, "got error %lu\n", GetLastError() );
2947
2948 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
2949 ok( !res, "wrong small icon %p\n", res );
2950 res = pInternalGetWindowIcon( hwnd, ICON_SMALL );
2951 ok( res != 0, "expected nonzero icon\n" );
2952 check_icon_size( res, 50, 50 );
2953 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL );
2954 ok( res2 && res2 != res, "got %p\n", res2 );
2955 check_icon_size( res2, 50, 50 );
2956 ret = DestroyIcon( res2 );
2957 ok( ret, "got error %lu\n", GetLastError() );
2958 ret = DestroyIcon( res );
2959 ok( ret, "got error %lu\n", GetLastError() );
2960
2961 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2962 ok( !res, "wrong small2 icon %p\n", res );
2963 res = pInternalGetWindowIcon( hwnd, ICON_SMALL2 );
2964 ok( res != 0, "expected nonzero icon\n" );
2965 check_icon_size( res, 50, 50 );
2966 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL2 );
2967 ok( res2 && res2 != res, "got %p\n", res2 );
2968 check_icon_size( res2, 50, 50 );
2969 ret = DestroyIcon( res2 );
2970 ok( ret, "got error %lu\n", GetLastError() );
2971 ret = DestroyIcon( res );
2972 ok( ret, "got error %lu\n", GetLastError() );
2973
2974 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon );
2975 ok( res == 0, "wrong previous big icon %p/0\n", res );
2976 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2977 ok( res == icon, "wrong big icon after set %p/%p\n", res, icon );
2978 res2 = pInternalGetWindowIcon( hwnd, ICON_BIG );
2979 ok( res2 && res2 != icon, "got %p\n", res2 );
2980 check_icon_size( res2, 10, 10 );
2981 ret = DestroyIcon( res2 );
2982 ok( ret, "got error %lu\n", GetLastError() );
2983
2984 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon2 );
2985 ok( res == icon, "wrong previous big icon %p/%p\n", res, icon );
2986 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
2987 ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
2988 res2 = pInternalGetWindowIcon( hwnd, ICON_BIG );
2989 ok( res2 && res2 != icon2, "got %p\n", res2 );
2990 check_icon_size( res2, 20, 20 );
2991 ret = DestroyIcon( res2 );
2992 ok( ret, "got error %lu\n", GetLastError() );
2993
2994 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
2995 ok( res == 0, "wrong small icon %p/0\n", res );
2996 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL );
2997 ok( res2 != 0, "expected nonzero icon\n" );
2998 check_icon_size( res2, small_width, small_height );
2999 ret = DestroyIcon( res2 );
3000 ok( ret, "got error %lu\n", GetLastError() );
3001
3002 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
3003 ok( res && res != icon3 && res != icon2, "wrong small2 icon %p\n", res );
3004 res2 = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
3005 ok( res2 == res, "expected icon to match\n" );
3006 check_icon_size( res, small_width, small_height );
3007 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL2 );
3008 ok( res2 && res2 != icon3 && res2 != icon2 && res2 != res, "got %p\n", res2 );
3009 check_icon_size( res2, small_width, small_height );
3010 ret = DestroyIcon( res2 );
3011 ok( ret, "got error %lu\n", GetLastError() );
3012
3013 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon );
3014 ok( res == 0, "wrong previous small icon %p/0\n", res );
3015 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
3016 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );
3017 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL );
3018 ok( res2 && res2 != icon, "got %p\n", res2 );
3019 check_icon_size( res2, 10, 10 );
3020 ret = DestroyIcon( res2 );
3021 ok( ret, "got error %lu\n", GetLastError() );
3022
3023 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
3024 ok( res == icon, "wrong small2 icon after set %p/%p\n", res, icon );
3025 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL2 );
3026 ok( res2 && res2 != icon && res2 != res, "got %p\n", res2 );
3027 check_icon_size( res2, 10, 10 );
3028 ret = DestroyIcon( res2 );
3029 ok( ret, "got error %lu\n", GetLastError() );
3030
3031 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon3 );
3032 ok( res == icon, "wrong previous small icon %p/%p\n", res, icon );
3033 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
3034 ok( res == icon3, "wrong small icon after set %p/%p\n", res, icon3 );
3035 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL );
3036 ok( res2 && res2 != icon3, "got %p\n", res2 );
3037 check_icon_size( res2, 30, 30 );
3038 ret = DestroyIcon( res2 );
3039 ok( ret, "got error %lu\n", GetLastError() );
3040
3041 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
3042 ok( res == icon3, "wrong small2 icon after set %p/%p\n", res, icon3 );
3043 res2 = pInternalGetWindowIcon( hwnd, ICON_SMALL2 );
3044 ok( res2 && res2 != icon3 && res2 != res, "got %p\n", res2 );
3045 check_icon_size( res2, 30, 30 );
3046 ret = DestroyIcon( res2 );
3047 ok( ret, "got error %lu\n", GetLastError() );
3048
3049 /* make sure the big icon hasn't changed */
3050 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
3051 ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
3052 res2 = pInternalGetWindowIcon( hwnd, ICON_BIG );
3053 ok( res2 && res2 != icon2, "got %p\n", res2 );
3054 check_icon_size( res2, 20, 20 );
3055 ret = DestroyIcon( res2 );
3056 ok( ret, "got error %lu\n", GetLastError() );
3057
3058 SetLastError( 0xdeadbeef );
3059 res = pInternalGetWindowIcon( NULL, ICON_BIG );
3060 ok( !res, "got %p\n", res );
3061 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got error %lu\n", GetLastError() );
3062
3063 SetLastError( 0xdeadbeef );
3064 res = pInternalGetWindowIcon( hwnd, 0xdeadbeef );
3065 ok( !res, "got %p\n", res );
3066 ok( GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError() );
3067
3069 ret = WaitForSingleObject( thread, 1000 );
3070 ok( !ret, "wait timed out\n" );
3072
3074 UnregisterClassA( "IconWindowClass", GetModuleHandleA( NULL ) );
3075
3076 /* check when the big class icon is missing */
3077
3078 cls.hIcon = 0;
3079 cls.hIconSm = icon5;
3080 RegisterClassExA(&cls);
3081
3082 hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
3083 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
3084 ok( hwnd != NULL, "failed to create window\n" );
3085
3086 check_internal_icon_size( hwnd, ICON_BIG, big_width, big_height );
3088 check_internal_icon_size( hwnd, ICON_SMALL2, 50, 50 );
3089
3091 UnregisterClassA( "IconWindowClass", GetModuleHandleA( NULL ) );
3092
3093 /* and when the small class icon is missing */
3094
3095 cls.hIcon = icon4;
3096 cls.hIconSm = 0;
3097 RegisterClassExA(&cls);
3098 hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
3099 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
3100 ok( hwnd != NULL, "failed to create window\n" );
3101
3103 check_internal_icon_size( hwnd, ICON_SMALL, small_width, small_width );
3104 check_internal_icon_size( hwnd, ICON_SMALL2, small_width, small_width );
3105
3107 UnregisterClassA( "IconWindowClass", GetModuleHandleA( NULL ) );
3108
3109 /* and when both are missing */
3110
3111 cls.hIcon = 0;
3112 cls.hIconSm = 0;
3113 RegisterClassExA(&cls);
3114 hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
3115 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
3116 ok( hwnd != NULL, "failed to create window\n" );
3117
3118 check_internal_icon_size( hwnd, ICON_BIG, big_width, big_height );
3119 check_internal_icon_size( hwnd, ICON_SMALL, big_width, big_height );
3120 check_internal_icon_size( hwnd, ICON_SMALL2, big_width, big_height );
3121
3123 UnregisterClassA( "IconWindowClass", GetModuleHandleA( NULL ) );
3124
3125 DestroyIcon( icon );
3126 DestroyIcon( icon2 );
3127 DestroyIcon( icon3 );
3128 DestroyIcon( icon4 );
3129 DestroyIcon( icon5 );
3130}
3131
3133{
3134 if (msg == WM_NCCALCSIZE)
3135 {
3136 RECT *rect = (RECT *)lparam;
3137 /* first time around increase the rectangle, next time decrease it */
3138 if (rect->left == 100) InflateRect( rect, 10, 10 );
3139 else InflateRect( rect, -10, -10 );
3140 return 0;
3141 }
3142 return DefWindowProcA( hwnd, msg, wparam, lparam );
3143}
3144
3145static void test_SetWindowPos(HWND hwnd, HWND hwnd2)
3146{
3147 RECT orig_win_rc, rect;
3149 HWND hwnd_grandchild, hwnd_child, hwnd_child2;
3150 HWND hwnd_desktop;
3151 RECT rc_expected;
3152 RECT rc1, rc2;
3153 BOOL ret;
3154
3155 SetRect(&rect, 111, 222, 333, 444);
3156 ok(!GetWindowRect(0, &rect), "GetWindowRect succeeded\n");
3157 ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444,
3158 "wrong window rect %s\n", wine_dbgstr_rect(&rect));
3159
3160 SetRect(&rect, 111, 222, 333, 444);
3161 ok(!GetClientRect(0, &rect), "GetClientRect succeeded\n");
3162 ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444,
3163 "wrong window rect %s\n", wine_dbgstr_rect(&rect));
3164
3165 GetWindowRect(hwnd, &orig_win_rc);
3166
3168 ret = SetWindowPos(hwnd, 0, 100, 100, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED);
3169 ok(ret, "Got %d\n", ret);
3170 GetWindowRect( hwnd, &rect );
3171 ok( rect.left == 100 && rect.top == 100 && rect.right == 100 && rect.bottom == 100,
3172 "invalid window rect %s\n", wine_dbgstr_rect(&rect));
3173 GetClientRect( hwnd, &rect );
3174 MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 );
3175 ok( rect.left == 90 && rect.top == 90 && rect.right == 110 && rect.bottom == 110,
3176 "invalid client rect %s\n", wine_dbgstr_rect(&rect));
3177
3178 flush_events( TRUE ); /* needed by Win10 1709+ */
3179
3180 ret = SetWindowPos(hwnd, 0, 200, 200, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED);
3181 ok(ret, "Got %d\n", ret);
3182 GetWindowRect( hwnd, &rect );
3183 ok( rect.left == 200 && rect.top == 200 && rect.right == 200 && rect.bottom == 200,
3184 "invalid window rect %s\n", wine_dbgstr_rect(&rect));
3185 GetClientRect( hwnd, &rect );
3186 MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 );
3187 ok( rect.left == 210 && rect.top == 210 && rect.right == 190 && rect.bottom == 190,
3188 "invalid client rect %s\n", wine_dbgstr_rect(&rect));
3189
3190 ret = SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top,
3191 orig_win_rc.right, orig_win_rc.bottom, 0);
3192 ok(ret, "Got %d\n", ret);
3194
3195 ret = SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE);
3196 ok(ret, "Got %d\n", ret);
3197 ret = SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE);
3198 ok(ret, "Got %d\n", ret);
3199
3200 ret = SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE);
3201 ok(ret, "Got %d\n", ret);
3202 ret = SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE);
3203 ok(ret, "Got %d\n", ret);
3204
3205 ret = SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top,
3206 orig_win_rc.right, orig_win_rc.bottom, 0);
3207 ok(ret, "Got %d\n", ret);
3208
3209 hwnd_desktop = GetDesktopWindow();
3210 ok(!!hwnd_desktop, "Failed to get hwnd_desktop window (%ld).\n", GetLastError());
3212 ok(!!hwnd_child, "Failed to create child window (%ld)\n", GetLastError());
3213 hwnd_grandchild = create_tool_window(WS_VISIBLE|WS_CHILD, hwnd_child);
3214 ok(!!hwnd_child, "Failed to create child window (%ld)\n", GetLastError());
3216 ok(!!hwnd_child2, "Failed to create second child window (%ld)\n", GetLastError());
3217
3218 ret = SetWindowPos(hwnd, hwnd2, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3219 ok(ret, "Got %d\n", ret);
3221
3222 ret = SetWindowPos(hwnd2, hwnd, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3223 ok(ret, "Got %d\n", ret);
3224 check_active_state(hwnd2, hwnd2, hwnd2);
3225
3226 /* Returns TRUE also for windows that are not siblings */
3227 ret = SetWindowPos(hwnd_child, hwnd2, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3228 ok(ret, "Got %d\n", ret);
3229 check_active_state(hwnd2, hwnd2, hwnd2);
3230
3231 ret = SetWindowPos(hwnd2, hwnd_child, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3232 ok(ret, "Got %d\n", ret);
3233 check_active_state(hwnd2, hwnd2, hwnd2);
3234
3235 /* Does not seem to do anything even without passing flags, still returns TRUE */
3236 GetWindowRect(hwnd_child, &rc1);
3237 ret = SetWindowPos(hwnd_child, hwnd2, 1, 2, 3, 4, 0);
3238 ok(ret, "Got %d.\n", ret);
3239 GetWindowRect(hwnd_child, &rc2);
3240 ok(EqualRect(&rc1, &rc2), "%s != %s.\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
3241 check_active_state(hwnd2, hwnd2, hwnd2);
3242
3243 GetWindowRect(hwnd_child, &rc1);
3244 ret = SetWindowPos(hwnd_child, HWND_NOTOPMOST, 1, 2, 3, 4, 0);
3245 ok(ret, "Got %d.\n", ret);
3246 GetWindowRect(hwnd_child, &rc2);
3247 todo_wine ok(EqualRect(&rc1, &rc2), "%s != %s.\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
3248 check_active_state(hwnd2, hwnd2, hwnd2);
3249 SetWindowPos(hwnd_child, HWND_NOTOPMOST, 0, 0, rc1.right - rc1.left, rc1.bottom - rc1.top, 0);
3250
3251 GetWindowRect(hwnd_child, &rc1);
3252 ret = SetWindowPos(hwnd_child, HWND_TOPMOST, 1, 2, 3, 4, 0);
3253 ok(ret, "Got %d.\n", ret);
3254 GetWindowRect(hwnd_child, &rc2);
3255 todo_wine ok(EqualRect(&rc1, &rc2), "%s != %s.\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
3256 check_active_state(hwnd2, hwnd2, hwnd2);
3257 SetWindowPos(hwnd_child, HWND_TOPMOST, 0, 0, rc1.right - rc1.left, rc1.bottom - rc1.top, 0);
3258
3259 /* HWND_TOP / HWND_BOTTOM are different. */
3260 GetWindowRect(hwnd_child, &rc1);
3261 rc_expected.left = rc1.left + 1;
3262 rc_expected.top = rc1.top + 2;
3263 rc_expected.right = rc1.left + 4;
3264 rc_expected.bottom = rc1.top + 6;
3265 ret = SetWindowPos(hwnd_child, HWND_TOP, 1, 2, 3, 4, 0);
3266 ok(ret, "Got %d.\n", ret);
3267 GetWindowRect(hwnd_child, &rc2);
3268 ok(EqualRect(&rc_expected, &rc2), "%s != %s.\n",
3269 wine_dbgstr_rect(&rc_expected), wine_dbgstr_rect(&rc2));
3270 check_active_state(hwnd2, hwnd2, hwnd2);
3271 SetWindowPos(hwnd_child, HWND_TOP, 0, 0, rc1.right - rc1.left, rc1.bottom - rc1.top, 0);
3272
3273 GetWindowRect(hwnd_child, &rc1);
3274 ret = SetWindowPos(hwnd_child, HWND_BOTTOM, 1, 2, 3, 4, 0);
3275 ok(ret, "Got %d.\n", ret);
3276 GetWindowRect(hwnd_child, &rc2);
3277 ok(EqualRect(&rc_expected, &rc2), "%s != %s.\n",
3278 wine_dbgstr_rect(&rc_expected), wine_dbgstr_rect(&rc2));
3279 check_active_state(hwnd2, hwnd2, hwnd2);
3280 SetWindowPos(hwnd_child, HWND_BOTTOM, 0, 0, rc1.right - rc1.left, rc1.bottom - rc1.top, 0);
3281
3282 GetWindowRect(hwnd_child, &rc1);
3283 ret = SetWindowPos(hwnd_child, NULL, 1, 2, 3, 4, 0);
3284 ok(ret, "Got %d.\n", ret);
3285 GetWindowRect(hwnd_child, &rc2);
3286 ok(EqualRect(&rc_expected, &rc2), "%s != %s.\n",
3287 wine_dbgstr_rect(&rc_expected), wine_dbgstr_rect(&rc2));
3288 check_active_state(hwnd2, hwnd2, hwnd2);
3289 SetWindowPos(hwnd_child, NULL, 0, 0, rc1.right - rc1.left, rc1.bottom - rc1.top, 0);
3290
3291 /* Same thing the other way around. */
3292 GetWindowRect(hwnd2, &rc1);
3293 ret = SetWindowPos(hwnd2, hwnd_child, 1, 2, 3, 4, 0);
3294 ok(ret, "Got %d\n", ret);
3295 GetWindowRect(hwnd2, &rc2);
3296 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
3297 check_active_state(hwnd2, hwnd2, hwnd2);
3298
3299 /* .. and with these windows. */
3300 GetWindowRect(hwnd_grandchild, &rc1);
3301 ret = SetWindowPos(hwnd_grandchild, hwnd_child2, 1, 2, 3, 4, 0);
3302 ok(ret, "Got %d\n", ret);
3303 GetWindowRect(hwnd_grandchild, &rc2);
3304 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
3305 check_active_state(hwnd2, hwnd2, hwnd2);
3306
3307 /* Add SWP_NOZORDER and it will be properly resized. */
3308 GetWindowRect(hwnd_grandchild, &rc1);
3309 ret = SetWindowPos(hwnd_grandchild, hwnd_child2, 1, 2, 3, 4, SWP_NOZORDER);
3310 ok(ret, "Got %d\n", ret);
3311 GetWindowRect(hwnd_grandchild, &rc2);
3312 ok(EqualRect(&rc_expected, &rc2),
3313 "%s != %s.\n", wine_dbgstr_rect(&rc_expected), wine_dbgstr_rect(&rc2));
3314 check_active_state(hwnd2, hwnd2, hwnd2);
3315
3316 /* Given a sibling window, the window is properly resized. */
3317 GetWindowRect(hwnd_child, &rc1);
3318 ret = SetWindowPos(hwnd_child, hwnd_child2, 1, 2, 3, 4, 0);
3319 ok(ret, "Got %d\n", ret);
3320 GetWindowRect(hwnd_child, &rc2);
3321 ok(EqualRect(&rc_expected, &rc2),
3322 "%s != %s.\n", wine_dbgstr_rect(&rc_expected), wine_dbgstr_rect(&rc2));
3323 check_active_state(hwnd2, hwnd2, hwnd2);
3324
3325 /* Involving the desktop window changes things. */
3326 ret = SetWindowPos(hwnd_child, hwnd_desktop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3327 ok(!ret, "Got %d\n", ret);
3328 check_active_state(hwnd2, hwnd2, hwnd2);
3329
3330 GetWindowRect(hwnd_child, &rc1);
3331 ret = SetWindowPos(hwnd_child, hwnd_desktop, 0, 0, 0, 0, 0);
3332 ok(!ret, "Got %d\n", ret);
3333 GetWindowRect(hwnd_child, &rc2);
3334 ok(EqualRect(&rc1, &rc2), "%s != %s\n", wine_dbgstr_rect(&rc1), wine_dbgstr_rect(&rc2));
3335 check_active_state(hwnd2, hwnd2, hwnd2);
3336
3337 ret = SetWindowPos(hwnd_desktop, hwnd_child, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3338 ok(!ret, "Got %d\n", ret);
3339 check_active_state(hwnd2, hwnd2, hwnd2);
3340
3341 ret = SetWindowPos(hwnd_desktop, hwnd, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3342 ok(!ret, "Got %d\n", ret);
3343 check_active_state(hwnd2, hwnd2, hwnd2);
3344
3345 ret = SetWindowPos(hwnd, hwnd_desktop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
3346 ok(!ret, "Got %d\n", ret);
3347 check_active_state(hwnd2, hwnd2, hwnd2);
3348
3349 DestroyWindow(hwnd_grandchild);
3350 DestroyWindow(hwnd_child);
3351 DestroyWindow(hwnd_child2);
3352
3353 hwnd_child = create_tool_window(WS_CHILD|WS_POPUP|WS_SYSMENU, hwnd2);
3354 ok(!!hwnd_child, "Failed to create child window (%ld)\n", GetLastError());
3356 ok(ret, "Got %d\n", ret);
3357 flush_events( TRUE );
3358 flaky todo_wine check_active_state(hwnd2, hwnd2, hwnd2);
3359 DestroyWindow(hwnd_child);
3360}
3361
3363{
3364 HWND child;
3365 HMENU hMenu, ret;
3366 BOOL retok;
3367 DWORD style;
3368
3369 hMenu = CreateMenu();
3370 assert(hMenu);
3371
3372 ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
3373 if (0)
3374 {
3375 /* fails on (at least) Wine, NT4, XP SP2 */
3377 }
3378 ret = GetMenu(parent);
3379 ok(ret == hMenu, "unexpected menu id %p\n", ret);
3380 /* test whether we can destroy a menu assigned to a window */
3381 retok = DestroyMenu(hMenu);
3382 ok( retok, "DestroyMenu error %ld\n", GetLastError());
3383 retok = IsMenu(hMenu);
3384 ok(!retok, "menu handle should be not valid after DestroyMenu\n");
3385 ret = GetMenu(parent);
3386 ok(ret == hMenu, "unexpected menu id %p\n", ret);
3387 ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
3389
3390 hMenu = CreateMenu();
3391 assert(hMenu);
3392
3393 /* parent */
3394 ret = GetMenu(parent);
3395 ok(ret == 0, "unexpected menu id %p\n", ret);
3396
3397 ok(!SetMenu(parent, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
3399 ret = GetMenu(parent);
3400 ok(ret == 0, "unexpected menu id %p\n", ret);
3401
3402 ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
3403 if (0)
3404 {
3405 /* fails on (at least) Wine, NT4, XP SP2 */
3407 }
3408 ret = GetMenu(parent);
3409 ok(ret == hMenu, "unexpected menu id %p\n", ret);
3410
3411 ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
3413 ret = GetMenu(parent);
3414 ok(ret == 0, "unexpected menu id %p\n", ret);
3415
3416 /* child */
3417 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, parent, (HMENU)10, 0, NULL);
3418 assert(child);
3419
3420 ret = GetMenu(child);
3421 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
3422
3423 ok(!SetMenu(child, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
3425 ret = GetMenu(child);
3426 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
3427
3428 ok(!SetMenu(child, hMenu), "SetMenu on a child window should fail\n");
3430 ret = GetMenu(child);
3431 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
3432
3433 ok(!SetMenu(child, 0), "SetMenu(0) on a child window should fail\n");
3435 ret = GetMenu(child);
3436 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
3437
3440 ok(SetMenu(child, hMenu), "SetMenu on a popup child window should not fail\n");
3441 ok(SetMenu(child, 0), "SetMenu on a popup child window should not fail\n");
3443
3445 ok(!SetMenu(child, hMenu), "SetMenu on an overlapped child window should fail\n");
3447
3449 DestroyMenu(hMenu);
3450}
3451
3452static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total)
3453{
3454 HWND child[5], hwnd;
3455 INT_PTR i;
3456
3457 assert(total <= 5);
3458
3460 ok(!hwnd, "have to start without children to perform the test\n");
3461
3462 for (i = 0; i < total; i++)
3463 {
3464 if (style[i] & DS_CONTROL)
3465 {
3466 child[i] = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(32770), "", style[i] & ~WS_VISIBLE,
3467 0,0,0,0, parent, (HMENU)i, 0, NULL);
3468 if (style[i] & WS_VISIBLE)
3470
3472 }
3473 else
3474 child[i] = CreateWindowExA(0, "static", "", style[i], 0,0,10,10,
3475 parent, (HMENU)i, 0, NULL);
3476 ok(child[i] != 0, "CreateWindowEx failed to create child window\n");
3477 }
3478
3480 ok(hwnd != 0, "GetWindow(GW_CHILD) failed\n");
3481 ok(hwnd == GetWindow(child[total - 1], GW_HWNDFIRST), "GW_HWNDFIRST is wrong\n");
3482 ok(child[order[total - 1]] == GetWindow(child[0], GW_HWNDLAST), "GW_HWNDLAST is wrong\n");
3483
3484 for (i = 0; i < total; i++)
3485 {
3486 ok(child[order[i]] == hwnd, "Z order of child #%Id is wrong\n", i);
3488 }
3489
3490 for (i = 0; i < total; i++)
3491 ok(DestroyWindow(child[i]), "DestroyWindow failed\n");
3492}
3493
3495{
3496 const DWORD simple_style[5] = { WS_CHILD, WS_CHILD, WS_CHILD, WS_CHILD,
3497 WS_CHILD };
3498 const int simple_order[5] = { 0, 1, 2, 3, 4 };
3499
3500 const DWORD complex_style[5] = { WS_CHILD, WS_CHILD | WS_MAXIMIZE,
3503 const int complex_order_1[1] = { 0 };
3504 const int complex_order_2[2] = { 1, 0 };
3505 const int complex_order_3[3] = { 1, 0, 2 };
3506 const int complex_order_4[4] = { 1, 0, 2, 3 };
3507 const int complex_order_5[5] = { 4, 1, 0, 2, 3 };
3508 const DWORD complex_style_6[3] = { WS_CHILD | WS_VISIBLE,
3510 WS_CHILD | WS_VISIBLE };
3511 const int complex_order_6[3] = { 0, 1, 2 };
3512
3513 /* simple WS_CHILD */
3514 test_window_tree(parent, simple_style, simple_order, 5);
3515
3516 /* complex children styles */
3517 test_window_tree(parent, complex_style, complex_order_1, 1);
3518 test_window_tree(parent, complex_style, complex_order_2, 2);
3519 test_window_tree(parent, complex_style, complex_order_3, 3);
3520 test_window_tree(parent, complex_style, complex_order_4, 4);
3521 test_window_tree(parent, complex_style, complex_order_5, 5);
3522
3523 /* another set of complex children styles */
3524 test_window_tree(parent, complex_style_6, complex_order_6, 3);
3525}
3526
3527#define check_z_order(hwnd, next, prev, owner, topmost) \
3528 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
3529 __FILE__, __LINE__)
3530
3531static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner,
3532 BOOL topmost, const char *file, int line)
3533{
3534 HWND test;
3535 DWORD ex_style;
3536
3538 /* skip foreign windows */
3539 while (test && test != next &&
3543 {
3545 }
3546 ok_(file, line)(next == test, "%p: expected next %p, got %p\n", hwnd, next, test);
3547
3549 /* skip foreign windows */
3550 while (test && test != prev &&
3554 {
3556 }
3557 ok_(file, line)(prev == test, "%p: expected prev %p, got %p\n", hwnd, prev, test);
3558
3560 ok_(file, line)(owner == test, "%p: expected owner %p, got %p\n", hwnd, owner, test);
3561
3562 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
3563 ok_(file, line)(!(ex_style & WS_EX_TOPMOST) == !topmost, "%p: expected %stopmost\n",
3564 hwnd, topmost ? "" : "NOT ");
3565}
3566
3567static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style)
3568{
3569 HWND hwnd_A, hwnd_B, hwnd_C, hwnd_F;
3570
3571 /* Give current thread foreground state otherwise the tests may fail. */
3572 if (!SetForegroundWindow(hwnd_D))
3573 {
3574 skip("SetForegroundWindow not working\n");
3575 return;
3576 }
3577
3578 SetWindowPos(hwnd_E, hwnd_D, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3579
3580 check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
3581 check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
3582
3583 hwnd_F = CreateWindowExA(0, "MainWindowClass", "Owner window",
3585 100, 100, 100, 100,
3586 0, 0, GetModuleHandleA(NULL), NULL);
3587 check_z_order(hwnd_F, hwnd_D, 0, 0, FALSE);
3588
3589 SetWindowPos(hwnd_F, hwnd_E, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3590 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
3591 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
3592 check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
3593
3594 hwnd_C = CreateWindowExA(0, "MainWindowClass", NULL,
3595 style,
3596 100, 100, 100, 100,
3597 hwnd_F, 0, GetModuleHandleA(NULL), NULL);
3598 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
3599 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
3600 check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
3601 check_z_order(hwnd_C, hwnd_D, 0, hwnd_F, FALSE);
3602
3603 hwnd_B = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", NULL,
3604 style,
3605 100, 100, 100, 100,
3606 hwnd_F, 0, GetModuleHandleA(NULL), NULL);
3607 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
3608 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
3609 check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
3610 check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE);
3611 check_z_order(hwnd_B, hwnd_C, 0, hwnd_F, TRUE);
3612
3613 hwnd_A = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", NULL,
3614 style,
3615 100, 100, 100, 100,
3616 0, 0, GetModuleHandleA(NULL), NULL);
3617 check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
3618 check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
3619 check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
3620 check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE);
3621 check_z_order(hwnd_B, hwnd_C, hwnd_A, hwnd_F, TRUE);
3622 check_z_order(hwnd_A, hwnd_B, 0, 0, TRUE);
3623
3624 if (winetest_debug > 1)
3625 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);
3626
3627 /* move hwnd_F and its popups up */
3629 check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
3630 check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE);
3631 check_z_order(hwnd_F, hwnd_D, hwnd_C, 0, FALSE);
3632 check_z_order(hwnd_C, hwnd_F, hwnd_B, hwnd_F, FALSE);
3633 check_z_order(hwnd_B, hwnd_C, hwnd_A, hwnd_F, TRUE);
3634 check_z_order(hwnd_A, hwnd_B, 0, 0, TRUE);
3635
3636 /* move hwnd_F and its popups down */
3637#if 0 /* enable once Wine is fixed to pass this test */
3639 check_z_order(hwnd_F, 0, hwnd_C, 0, FALSE);
3640 check_z_order(hwnd_C, hwnd_F, hwnd_B, hwnd_F, FALSE);
3641 check_z_order(hwnd_B, hwnd_C, hwnd_E, hwnd_F, FALSE);
3642 check_z_order(hwnd_E, hwnd_B, hwnd_D, 0, FALSE);
3643 check_z_order(hwnd_D, hwnd_E, hwnd_A, 0, FALSE);
3644 check_z_order(hwnd_A, hwnd_D, 0, 0, TRUE);
3645#endif
3646
3647 /* make hwnd_C owned by a topmost window */
3648 DestroyWindow( hwnd_C );
3649 hwnd_C = CreateWindowExA(0, "MainWindowClass", NULL,
3650 style,
3651 100, 100, 100, 100,
3652 hwnd_A, 0, GetModuleHandleA(NULL), NULL);
3653 check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
3654 check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE);
3655 check_z_order(hwnd_F, hwnd_D, hwnd_B, 0, FALSE);
3656 check_z_order(hwnd_B, hwnd_F, hwnd_A, hwnd_F, TRUE);
3657 check_z_order(hwnd_A, hwnd_B, hwnd_C, 0, TRUE);
3658 check_z_order(hwnd_C, hwnd_A, 0, hwnd_A, TRUE);
3659
3660 DestroyWindow(hwnd_A);
3661 DestroyWindow(hwnd_B);
3662 DestroyWindow(hwnd_C);
3663 DestroyWindow(hwnd_F);
3664}
3665
3666static void test_vis_rgn( HWND hwnd )
3667{
3668 RECT win_rect, rgn_rect;
3669 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
3670 HDC hdc;
3671
3673 hdc = GetDC( hwnd );
3674 ok( GetRandomRgn( hdc, hrgn, SYSRGN ) != 0, "GetRandomRgn failed\n" );
3675 GetWindowRect( hwnd, &win_rect );
3676 GetRgnBox( hrgn, &rgn_rect );
3677 ok( win_rect.left <= rgn_rect.left &&
3678 win_rect.top <= rgn_rect.top &&
3679 win_rect.right >= rgn_rect.right &&
3680 win_rect.bottom >= rgn_rect.bottom,
3681 "rgn %s not inside win %s\n", wine_dbgstr_rect(&rgn_rect), wine_dbgstr_rect(&win_rect));
3682 ReleaseDC( hwnd, hdc );
3683}
3684
3686{
3687 if (msg == WM_ACTIVATE && LOWORD(wp) == WA_ACTIVE)
3688 {
3690 ok(child != 0, "couldn't find child window\n");
3691 SetFocus(child);
3692 ok(GetFocus() == child, "Focus should be on child %p\n", child);
3693 return 0;
3694 }
3695 return DefWindowProcA(hwnd, msg, wp, lp);
3696}
3697
3699{
3700 HWND child, child2, ret;
3702
3703 /* check if we can set focus to non-visible windows */
3704
3706 SetFocus(0);
3707 SetFocus(hwnd);
3708 ok( GetFocus() == hwnd, "Failed to set focus to visible window %p\n", hwnd );
3709 ok( GetWindowLongA(hwnd,GWL_STYLE) & WS_VISIBLE, "Window %p not visible\n", hwnd );
3711 SetFocus(0);
3712 SetFocus(hwnd);
3713 ok( GetFocus() == hwnd, "Failed to set focus to invisible window %p\n", hwnd );
3714 ok( !(GetWindowLongA(hwnd,GWL_STYLE) & WS_VISIBLE), "Window %p still visible\n", hwnd );
3715 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3716 assert(child);
3717 SetFocus(child);
3718 ok( GetFocus() == child, "Failed to set focus to invisible child %p\n", child );
3719 ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
3721 ok( GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE, "Child %p is not visible\n", child );
3722 ok( GetFocus() == child, "Focus no longer on child %p\n", child );
3724 ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
3725 ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
3727 child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, 0, 0, NULL);
3728 assert(child2);
3729 ShowWindow(child2, SW_SHOW);
3730 SetFocus(child2);
3732 ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
3733 ok( GetFocus() == child2, "Focus should be on %p, not %p\n", child2, GetFocus() );
3735 SetFocus(child);
3736 ok( GetFocus() == child, "Focus should be on child %p\n", child );
3738 ok( GetFocus() == child, "Focus should still be on child %p\n", child );
3739
3741 SetFocus(hwnd);
3742 ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
3744 ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
3746 ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
3747
3750 SetFocus(child);
3751 ok( GetFocus() == child, "Focus should be on child %p\n", child );
3752 SetLastError(0xdeadbeef);
3754 ok(GetLastError() == 0xdeadbeef, "got error %lu in EnableWindow call\n", GetLastError());
3755 ok( GetFocus() == child, "Focus should still be on child %p\n", child );
3757
3758 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3760 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3761 todo_wine
3762 ok( GetFocus() != child, "Focus should not be on child %p\n", child );
3763 ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd );
3765 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3766 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3768 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3769 ok( GetFocus() != child, "Focus should not be on child %p\n", child );
3770 ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd );
3773 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3774 ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() );
3776
3777 SetFocus( hwnd );
3779 SetParent( child2, child );
3780 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3781 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3782 ret = SetFocus( child2 );
3783 ok( ret == 0, "SetFocus %p should fail\n", child2);
3784 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3785 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3786 ret = SetFocus( child );
3787 ok( ret == 0, "SetFocus %p should fail\n", child);
3788 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3789 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3791 SetFocus( child2 );
3792 ok( GetActiveWindow() == child, "child window %p should be active\n", child);
3793 ok( GetFocus() == child2, "Focus should be on child2 %p\n", child2 );
3794 SetFocus( hwnd );
3795 ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
3796 ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
3797 SetFocus( child );
3798 ok( GetActiveWindow() == child, "child window %p should be active\n", child);
3799 ok( GetFocus() == child, "Focus should be on child %p\n", child );
3800
3801 DestroyWindow( child2 );
3803}
3804
3806{
3808 HWND hwnd, other, tmp;
3809 BOOL ret;
3810
3811 sscanf( argv[3], "%p", &other );
3812 start_event = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_start" );
3813 ok( start_event != 0, "CreateEventW failed, error %lu\n", GetLastError() );
3814 stop_event = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_stop" );
3815 ok( stop_event != 0, "CreateEventW failed, error %lu\n", GetLastError() );
3816
3817 hwnd = CreateWindowExA( 0, "static", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, NULL, NULL );
3818 ok( !!hwnd, "CreateWindowExA failed, error %lu\n", GetLastError() );
3819 flush_events( TRUE );
3820
3822 ok( ret, "SetForegroundWindow failed, error %lu\n", GetLastError() );
3823
3824 tmp = GetForegroundWindow();
3825 ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp );
3826 tmp = GetActiveWindow();
3827 ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp );
3828 tmp = GetFocus();
3829 ok( tmp == hwnd, "GetFocus returned %p\n", tmp );
3830
3831 SetLastError( 0xdeadbeef );
3832 tmp = SetActiveWindow( 0 );
3833 if (!tmp) ok( GetLastError() == 0xdeadbeef, "got error %lu\n", GetLastError() );
3834 else /* < Win10 */
3835 {
3836 ok( tmp == hwnd, "SetActiveWindow returned %p\n", tmp );
3837 ok( GetLastError() == 0, "got error %lu\n", GetLastError() );
3838
3839 tmp = GetForegroundWindow();
3840 ok( tmp == other || tmp == 0, "GetForegroundWindow returned %p\n", tmp );
3841 tmp = GetActiveWindow();
3842 ok( tmp == 0, "GetActiveWindow returned %p\n", tmp );
3843 tmp = GetFocus();
3844 ok( tmp == 0, "GetFocus returned %p\n", tmp );
3845
3848
3849 tmp = GetForegroundWindow();
3850 todo_wine
3851 ok( tmp == other, "GetForegroundWindow returned %p\n", tmp );
3852 tmp = GetActiveWindow();
3853 ok( tmp == 0, "GetActiveWindow returned %p\n", tmp );
3854 tmp = GetFocus();
3855 ok( tmp == 0, "GetFocus returned %p\n", tmp );
3856 }
3857
3858 tmp = SetActiveWindow( 0 );
3859 ok( tmp == 0, "SetActiveWindow returned %p\n", tmp );
3860 tmp = GetForegroundWindow();
3861 todo_wine
3862 ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp );
3863 tmp = GetActiveWindow();
3864 todo_wine
3865 ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp );
3866 tmp = GetFocus();
3867 todo_wine
3868 ok( tmp == hwnd, "GetFocus returned %p\n", tmp );
3869
3873}
3874
3875static void test_SetActiveWindow_0( char **argv )
3876{
3877 STARTUPINFOA startup = {.cb = sizeof(STARTUPINFOA)};
3879 char cmdline[MAX_PATH];
3880 HANDLE events[3];
3881 HWND hwnd, tmp;
3882 BOOL ret;
3883
3884 hwnd = CreateWindowExA( 0, "static", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, 0, 0, NULL, NULL );
3885 ok( !!hwnd, "CreateWindowExA failed, error %lu\n", GetLastError() );
3887 flush_events( TRUE );
3888
3889 tmp = GetForegroundWindow();
3891 ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp );
3892 tmp = GetActiveWindow();
3894 ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp );
3895 tmp = GetFocus();
3897 ok( tmp == hwnd, "GetFocus returned %p\n", tmp );
3898
3899 events[1] = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_start" );
3900 ok( events[1] != 0, "CreateEventW failed, error %lu\n", GetLastError() );
3901 events[2] = CreateEventW( NULL, FALSE, FALSE, L"test_SetActiveWindow_0_stop" );
3902 ok( events[2] != 0, "CreateEventW failed, error %lu\n", GetLastError() );
3903
3904 sprintf( cmdline, "%s %s SetActiveWindow_0 %p", argv[0], argv[1], hwnd );
3906 ok( ret, "CreateProcessA failed, error %lu\n", GetLastError() );
3907
3908 events[0] = info.hProcess;
3909 if (wait_for_events( 2, events, INFINITE ) == 1)
3910 {
3911 tmp = GetForegroundWindow();
3912 todo_wine
3913 ok( tmp == hwnd, "GetForegroundWindow returned %p\n", tmp );
3914 tmp = GetActiveWindow();
3915 todo_wine
3916 ok( tmp == hwnd, "GetActiveWindow returned %p\n", tmp );
3917 tmp = GetFocus();
3918 todo_wine
3919 ok( tmp == hwnd, "GetFocus returned %p\n", tmp );
3920 SetEvent( events[2] );
3921 }
3922
3923 wait_child_process( info.hProcess );
3924 CloseHandle( info.hProcess );
3925 CloseHandle( info.hThread );
3926 CloseHandle( events[1] );
3927 CloseHandle( events[2] );
3928
3930}
3931
3933{
3934 HWND hwnd2, ret;
3935
3936 flush_events( TRUE );
3938 check_wnd_state(0, 0, 0, 0);
3939
3942
3945
3948
3950 check_wnd_state(0, 0, 0, 0);
3951
3952 /* Invisible window. */
3955
3958
3959 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3960 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3961
3964
3965 DestroyWindow(hwnd2);
3967
3968 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
3969 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3970
3972 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
3973
3974 DestroyWindow(hwnd2);
3976
3977 /* try to activate the desktop */
3978 SetLastError(0xdeadbeef);
3980 ok(ret == NULL, "expected NULL, got %p\n", ret);
3981 todo_wine
3982 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %lu\n", GetLastError());
3984
3985 /* activating a child should activate the parent */
3986 hwnd2 = CreateWindowExA(0, "MainWindowClass", "Child window", WS_CHILD, 0, 0, 0, 0, hwnd, 0, GetModuleHandleA(NULL), NULL);
3988 ret = SetActiveWindow(hwnd2);
3989 ok(ret == hwnd, "expected %p, got %p\n", hwnd, ret);
3991
3992 DestroyWindow(hwnd2);
3993}
3994
3996{
4000};
4001
4003{
4005 DWORD res;
4006 BOOL ret;
4007
4008 p->window = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
4009
4010 ret = SetEvent(p->window_created);
4011 ok(ret, "SetEvent failed, last error %#lx.\n", GetLastError());
4012
4013 res = WaitForSingleObject(p->test_finished, INFINITE);
4014 ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
4015
4016 DestroyWindow(p->window);
4017 return 0;
4018}
4019
4021{
4022 struct create_window_thread_params thread_params;
4023 HANDLE thread;
4024 DWORD res, tid;
4025 BOOL ret;
4026 HWND hwnd2;
4027 MSG msg;
4028 LONG style;
4029
4030 flush_events( TRUE );
4032 check_wnd_state(0, 0, 0, 0);
4033
4036
4038 if (!ret)
4039 {
4040 skip( "SetForegroundWindow not working\n" );
4041 return;
4042 }
4044
4045 SetLastError(0xdeadbeef);
4047 ok(!ret, "SetForegroundWindow returned TRUE instead of FALSE\n");
4049 "got error %ld expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
4051
4054
4057
4058 hwnd2 = GetForegroundWindow();
4059 ok(hwnd2 == hwnd, "Wrong foreground window %p\n", hwnd2);
4061 ok(ret, "SetForegroundWindow(desktop) error: %ld\n", GetLastError());
4062 hwnd2 = GetForegroundWindow();
4063 ok(hwnd2 != hwnd, "Wrong foreground window %p\n", hwnd2);
4064
4066 check_wnd_state(0, 0, 0, 0);
4067
4068 /* Invisible window. */
4070 ok(ret, "SetForegroundWindow returned FALSE instead of TRUE\n");
4072
4075
4076 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
4077 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4078
4079 DestroyWindow(hwnd2);
4081
4082 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
4083 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4084
4086 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4087
4088 DestroyWindow(hwnd2);
4090
4091 hwnd2 = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
4092 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4093
4094 thread_params.window_created = CreateEventW(NULL, FALSE, FALSE, NULL);
4095 ok(!!thread_params.window_created, "CreateEvent failed, last error %#lx.\n", GetLastError());
4096 thread_params.test_finished = CreateEventW(NULL, FALSE, FALSE, NULL);
4097 ok(!!thread_params.test_finished, "CreateEvent failed, last error %#lx.\n", GetLastError());
4098 thread = CreateThread(NULL, 0, create_window_thread, &thread_params, 0, &tid);
4099 ok(!!thread, "Failed to create thread, last error %#lx.\n", GetLastError());
4101 ok(res == WAIT_OBJECT_0, "Wait failed (%#lx), last error %#lx.\n", res, GetLastError());
4102 check_wnd_state(hwnd2, thread_params.window, hwnd2, 0);
4103
4104 SetForegroundWindow(hwnd2);
4105 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4106
4107 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
4108 if (0) check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4109
4110 ok(GetActiveWindow() == hwnd2, "Expected active window %p, got %p.\n", hwnd2, GetActiveWindow());
4111 ok(GetFocus() == hwnd2, "Expected focus window %p, got %p.\n", hwnd2, GetFocus());
4112
4116 ok(SetWindowLongA(hwnd2, GWL_STYLE, style), "SetWindowLong failed\n");
4117 ok(SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n");
4118 check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
4119
4122 ok(SetWindowLongA(hwnd2, GWL_STYLE, style & (~WS_POPUP)), "SetWindowLong failed\n");
4123 ok(!SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n");
4125
4126 SetEvent(thread_params.test_finished);
4128 CloseHandle(thread_params.test_finished);
4129 CloseHandle(thread_params.window_created);
4131 DestroyWindow(hwnd2);
4132
4134}
4135
4137
4139{
4140 LRESULT ret;
4142
4144 ok(!(key_state & 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state);
4145
4147
4148 if (msg == WM_LBUTTONDOWN)
4149 {
4150 HWND hwnd, capture;
4151
4153
4154 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
4155 assert(hwnd);
4156
4158
4160
4162
4164
4165 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
4166 assert(hwnd);
4167
4169
4170 /* button wnd proc should release capture on WM_KILLFOCUS if it does
4171 * match internal button state.
4172 */
4175
4178
4179 capture = SetCapture(hwnd);
4180 ok(capture == 0, "SetCapture() = %p\n", capture);
4181
4183
4185
4187 }
4188
4189 return ret;
4190}
4191
4192static void test_capture_1(void)
4193{
4194 HWND button, capture;
4195
4196 capture = GetCapture();
4197 ok(capture == 0, "GetCapture() = %p\n", capture);
4198
4199 button = CreateWindowExA(0, "button", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
4200 assert(button);
4201
4203
4205
4206 capture = SetCapture(button);
4207 ok(capture == 0, "SetCapture() = %p\n", capture);
4209
4211 /* old active window test depends on previously executed window
4212 * activation tests, and fails under NT4.
4213 check_wnd_state(oldActive, 0, oldFocus, 0);*/
4214}
4215
4216static void test_capture_2(void)
4217{
4218 HWND button, hwnd, capture, oldFocus, oldActive;
4219
4220 oldFocus = GetFocus();
4221 oldActive = GetActiveWindow();
4222 check_wnd_state(oldActive, 0, oldFocus, 0);
4223
4224 button = CreateWindowExA(0, "button", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
4225 assert(button);
4226
4228
4229 capture = SetCapture(button);
4230 ok(capture == 0, "SetCapture() = %p\n", capture);
4231
4233
4234 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
4235 * internal button state.
4236 */
4239
4240 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
4241 assert(hwnd);
4242
4244
4246
4248
4250
4251 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
4252 assert(hwnd);
4253
4255
4257
4259
4260 capture = SetCapture(hwnd);
4261 ok(capture == button, "SetCapture() = %p\n", capture);
4262
4264
4267
4269 check_wnd_state(oldActive, 0, oldFocus, 0);
4270}
4271
4272static void test_capture_3(HWND hwnd1, HWND hwnd2)
4273{
4274 BOOL ret;
4275
4276 ShowWindow(hwnd1, SW_HIDE);
4277 ShowWindow(hwnd2, SW_HIDE);
4278
4279 ok(!IsWindowVisible(hwnd1), "%p should be invisible\n", hwnd1);
4280 ok(!IsWindowVisible(hwnd2), "%p should be invisible\n", hwnd2);
4281
4282 SetCapture(hwnd1);
4283 check_wnd_state(0, 0, 0, hwnd1);
4284
4285 SetCapture(hwnd2);
4286 check_wnd_state(0, 0, 0, hwnd2);
4287
4288 ShowWindow(hwnd1, SW_SHOW);
4289 check_wnd_state(hwnd1, hwnd1, hwnd1, hwnd2);
4290
4291 ret = ReleaseCapture();
4292 ok (ret, "releasecapture did not return TRUE.\n");
4293 ret = ReleaseCapture();
4294 ok (ret, "releasecapture did not return TRUE after second try.\n");
4295}
4296
4298{
4300 HWND cap_wnd, cap_wnd2, set_cap_wnd;
4301 BOOL status;
4302 switch (msg)
4303 {
4304 case WM_CAPTURECHANGED:
4305
4306 /* now try to release capture from menu. this should fail */
4307 if (pGetGUIThreadInfo)
4308 {
4309 memset(&gti, 0, sizeof(GUITHREADINFO));
4310 gti.cbSize = sizeof(GUITHREADINFO);
4311 status = pGetGUIThreadInfo(GetCurrentThreadId(), &gti);
4312 ok(status, "GetGUIThreadInfo() failed!\n");
4313 ok(gti.flags & GUI_INMENUMODE, "Thread info incorrect (flags=%08lX)!\n", gti.flags);
4314 }
4315 cap_wnd = GetCapture();
4316
4317 ok(cap_wnd == (HWND)lParam, "capture window %p does not match lparam %Ix\n", cap_wnd, lParam);
4318 todo_wine ok(cap_wnd == hWnd, "capture window %p does not match hwnd %p\n", cap_wnd, hWnd);
4319
4320 /* check that re-setting the capture for the menu fails */
4321 set_cap_wnd = SetCapture(cap_wnd);
4322 ok(!set_cap_wnd, "SetCapture should have failed!\n");
4323 if (set_cap_wnd)
4324 {
4326 break;
4327 }
4328
4329 /* check that SetCapture fails for another window and that it does not touch the error code */
4330 set_cap_wnd = SetCapture(hWnd);
4331 ok(!set_cap_wnd, "SetCapture should have failed!\n");
4332
4333 /* check that ReleaseCapture fails and does not touch the error code */
4335 ok(!status, "ReleaseCapture should have failed!\n");
4336
4337 /* check that thread info did not change */
4338 if (pGetGUIThreadInfo)
4339 {
4340 memset(&gti, 0, sizeof(GUITHREADINFO));
4341 gti.cbSize = sizeof(GUITHREADINFO);
4342 status = pGetGUIThreadInfo(GetCurrentThreadId(), &gti);
4343 ok(status, "GetGUIThreadInfo() failed!\n");
4344 ok(gti.flags & GUI_INMENUMODE, "Thread info incorrect (flags=%08lX)!\n", gti.flags);
4345 }
4346
4347 /* verify that no capture change took place */
4348 cap_wnd2 = GetCapture();
4349 ok(cap_wnd2 == cap_wnd, "Capture changed!\n");
4350
4351 /* we are done. kill the window */
4353 break;
4354
4355 default:
4356 return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
4357 }
4358 return 0;
4359}
4360
4361/* Test that no-one can mess around with the current capture while a menu is open */
4362static void test_capture_4(void)
4363{
4364 BOOL ret;
4365 HMENU hmenu;
4366 HWND hwnd;
4367 WNDCLASSA wclass;
4369 ATOM aclass;
4370
4371 if (!pGetGUIThreadInfo)
4372 {
4373 win_skip("GetGUIThreadInfo is not available\n");
4374 return;
4375 }
4376 wclass.lpszClassName = "TestCapture4Class";
4377 wclass.style = CS_HREDRAW | CS_VREDRAW;
4379 wclass.hInstance = hInstance;
4380 wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
4381 wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW );
4382 wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
4383 wclass.lpszMenuName = 0;
4384 wclass.cbClsExtra = 0;
4385 wclass.cbWndExtra = 0;
4386 aclass = RegisterClassA( &wclass );
4387 ok( aclass, "RegisterClassA failed with error %ld\n", GetLastError());
4388 hwnd = CreateWindowA( wclass.lpszClassName, "MenuTest",
4390 400, 200, NULL, NULL, hInstance, NULL);
4391 ok(hwnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError());
4392 if (!hwnd) return;
4394
4395 ret = AppendMenuA( hmenu, MF_STRING, 1, "winetest2");
4396 ok( ret, "AppendMenuA has failed!\n");
4397
4398 /* set main window to have initial capture */
4400
4401 /* create popup (it will self-destruct) */
4402 ret = TrackPopupMenu(hmenu, TPM_RETURNCMD, 100, 100, 0, hwnd, NULL);
4403 ok( ret == 0, "TrackPopupMenu returned %d expected zero\n", ret);
4404
4405 /* clean up */
4408}
4409
4410/* PeekMessage wrapper that ignores the messages we don't care about */
4412{
4413 BOOL ret;
4414 do
4415 {
4416 ret = PeekMessageA(msg, 0, 0, 0, PM_REMOVE);
4417 } while (ret && ignore_message(msg->message, msg->hwnd));
4418 return ret;
4419}
4420
4422{
4423 MSG msg;
4424 BOOL ret;
4425
4426 flush_events( TRUE );
4429 flush_events( TRUE );
4430
4431 ok(GetActiveWindow() == hwnd, "wrong active window %p\n", GetActiveWindow());
4432
4433 SetFocus(hwnd);
4434 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4435
4436 flush_events( TRUE );
4437
4439 ret = peek_message(&msg);
4440 ok( ret, "no message available\n");
4441 ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4442 ret = peek_message(&msg);
4443 ok( !ret, "message %04x available\n", msg.message);
4444
4445 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4446
4448 ret = peek_message(&msg);
4449 ok(ret, "no message available\n");
4450 ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4451 ret = peek_message(&msg);
4452 ok( !ret, "message %04x available\n", msg.message);
4453
4454 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4455
4456 keybd_event(VK_SPACE, 0, 0, 0);
4457 if (!peek_message(&msg))
4458 {
4459 skip( "keybd_event didn't work, skipping keyboard test\n" );
4460 return;
4461 }
4462 ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4463 ret = peek_message(&msg);
4464 ok( !ret, "message %04x available\n", msg.message);
4465
4466 SetFocus(0);
4467 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
4468
4469 flush_events( TRUE );
4470
4472 ret = peek_message(&msg);
4473 ok(ret, "no message available\n");
4474 ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4475 ret = peek_message(&msg);
4476 ok( !ret, "message %04x available\n", msg.message);
4477
4478 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
4479
4481 ret = peek_message(&msg);
4482 ok(ret, "no message available\n");
4483 ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4484 ret = peek_message(&msg);
4485 ok( !ret, "message %04x available\n", msg.message);
4486
4487 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
4488
4489 keybd_event(VK_SPACE, 0, 0, 0);
4490 ret = peek_message(&msg);
4491 ok(ret, "no message available\n");
4492 ok(msg.hwnd == hwnd && msg.message == WM_SYSKEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4493 ret = peek_message(&msg);
4494 ok( !ret, "message %04x available\n", msg.message);
4495}
4496
4498{
4499 BOOL ret;
4500
4501 for (;;)
4502 {
4503 ret = peek_message(msg);
4504 if (ret)
4505 {
4506 if (msg->message == WM_PAINT) DispatchMessageA(msg);
4507 else break;
4508 }
4509 else if (MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
4510 }
4511 if (!ret) msg->message = 0;
4512 return ret;
4513}
4514
4516{
4517 RECT rc;
4518 POINT pt;
4519 int x, y;
4520 HWND popup, child = NULL;
4521 MSG msg;
4522 BOOL ret;
4523
4527
4528 GetWindowRect(hwnd, &rc);
4529
4530 popup = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP,
4531 rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
4532 hwnd, 0, 0, NULL);
4533 assert(popup != 0);
4534 ShowWindow(popup, SW_SHOW);
4535 UpdateWindow(popup);
4536 SetWindowPos( popup, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
4537
4538 GetWindowRect(popup, &rc);
4539
4540 x = rc.left + (rc.right - rc.left) / 2;
4541 y = rc.top + (rc.bottom - rc.top) / 2;
4542
4543 SetCursorPos(x, y);
4544 GetCursorPos(&pt);
4545 if (x != pt.x || y != pt.y)
4546 {
4547 skip( "failed to set mouse position, skipping mouse input tests\n" );
4548 goto done;
4549 }
4550
4551 flush_events( TRUE );
4552
4553 /* Check that setting the same position may generate WM_MOUSEMOVE */
4554 SetCursorPos(x, y);
4555 msg.message = 0;
4556 ret = peek_message(&msg);
4557 if (ret)
4558 {
4559 ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n",
4560 msg.hwnd, msg.message);
4561 ok(msg.pt.x == x && msg.pt.y == y, "wrong message coords (%d,%d)/(%ld,%ld)\n",
4562 x, y, msg.pt.x, msg.pt.y);
4563 }
4564
4565 /* force the system to update its internal queue mouse position,
4566 * otherwise it won't generate relative mouse movements below.
4567 */
4568 mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
4569 flush_events( TRUE );
4570
4571 msg.message = 0;
4572 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
4574 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
4575 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
4576 {
4577 if (ignore_message(msg.message, msg.hwnd)) continue;
4578 ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE,
4579 "hwnd %p message %04x\n", msg.hwnd, msg.message);
4581 }
4582 ret = peek_message(&msg);
4583 ok( !ret, "message %04x available\n", msg.message);
4584
4585 mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
4586 ShowWindow(popup, SW_HIDE);
4587 ret = wait_for_message( &msg );
4588 if (ret)
4589 ok(msg.hwnd == hwnd && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message);
4590 flush_events( TRUE );
4591
4592 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
4594 ret = wait_for_message( &msg );
4595 ok( !ret, "message %04x available\n", msg.message);
4596 flush_events( TRUE );
4597
4598 /* test mouse clicks */
4599
4602 flush_events( TRUE );
4603 ShowWindow(popup, SW_SHOW);
4604 SetWindowPos( popup, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
4605 flush_events( TRUE );
4606
4607 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4608 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4609 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4610 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4611
4612 ret = wait_for_message( &msg );
4613 if (!ret)
4614 {
4615 skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
4616 goto done;
4617 }
4618 if (msg.message == WM_MOUSEMOVE) /* win2k has an extra WM_MOUSEMOVE here */
4619 {
4620 ret = wait_for_message( &msg );
4621 ok(ret, "no message available\n");
4622 }
4623
4624 ok(msg.hwnd == popup && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
4625 msg.hwnd, popup, msg.message);
4626
4627 ret = wait_for_message( &msg );
4628 ok(ret, "no message available\n");
4629 ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
4630 msg.hwnd, popup, msg.message);
4631
4632 ret = wait_for_message( &msg );
4633 ok(ret, "no message available\n");
4634 ok(msg.hwnd == popup && msg.message == WM_LBUTTONDBLCLK, "hwnd %p/%p message %04x\n",
4635 msg.hwnd, popup, msg.message);
4636
4637 ret = wait_for_message( &msg );
4638 ok(ret, "no message available\n");
4639 ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
4640 msg.hwnd, popup, msg.message);
4641
4642 ret = peek_message(&msg);
4643 ok(!ret, "message %04x available\n", msg.message);
4644
4645 ShowWindow(popup, SW_HIDE);
4646 flush_events( TRUE );
4647
4648 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4649 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4650 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4651 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4652
4653 ret = wait_for_message( &msg );
4654 ok(ret, "no message available\n");
4655 ok(msg.hwnd == hwnd && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
4656 msg.hwnd, hwnd, msg.message);
4657 ret = wait_for_message( &msg );
4658 ok(ret, "no message available\n");
4659 ok(msg.hwnd == hwnd && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
4660 msg.hwnd, hwnd, msg.message);
4661
4663 SendMessageA(hwnd, WM_COMMAND, (WPARAM)popup, 0);
4665
4666 ret = wait_for_message( &msg );
4667 ok(ret, "no message available\n");
4668 ok(msg.hwnd == popup && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
4669 msg.hwnd, popup, msg.message);
4670 ok(peek_message(&msg), "no message available\n");
4671 ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
4672 msg.hwnd, popup, msg.message);
4673 ok(peek_message(&msg), "no message available\n");
4674
4675 ShowWindow(popup, SW_HIDE);
4676
4677 /* Test sending double click to the non-client area, while capturing the window after
4678 the first click has been processed. Use a child window to ensure that Wine's graphics
4679 driver isn't managing the non-client area. */
4680
4681 GetWindowRect(hwnd, &rc);
4682 child = CreateWindowExA(0, "MainWindowClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_VISIBLE,
4683 rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
4684 hwnd, 0, 0, NULL);
4685 GetWindowRect(child, &rc);
4686
4688 SetCursorPos( rc.left + 5, rc.top + 5 );
4689 flush_events( TRUE );
4690
4691 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4692 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4693 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4694 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4695
4696 ret = wait_for_message( &msg );
4697 ok(ret, "no message available\n");
4698 if (msg.message == WM_NCMOUSEMOVE) /* not sent by Win10 1709+ */
4699 {
4700 ok(msg.hwnd == child, "expected %p, got %p\n", child, msg.hwnd);
4701 ret = wait_for_message( &msg );
4702 ok(ret, "no message available\n");
4703 }
4704 ok(msg.hwnd == child && msg.message == WM_NCLBUTTONDOWN, "hwnd %p/%p message %04x\n",
4705 msg.hwnd, child, msg.message);
4706 ok(msg.wParam == HTSYSMENU, "wparam %Id\n", msg.wParam);
4707
4708 ret = wait_for_message( &msg );
4709 ok(ret, "no message available\n");
4710 ok(msg.hwnd == child && msg.message == WM_NCLBUTTONUP, "hwnd %p/%p message %04x\n",
4711 msg.hwnd, child, msg.message);
4712
4713 SetCapture( child );
4714
4715 ret = wait_for_message( &msg );
4716 ok(ret, "no message available\n");
4717 ok(msg.hwnd == child && msg.message == WM_LBUTTONDBLCLK, "hwnd %p/%p message %04x\n",
4718 msg.hwnd, child, msg.message);
4719 ok(msg.wParam == MK_LBUTTON, "wparam %Id\n", msg.wParam);
4720
4721 ret = wait_for_message( &msg );
4722 ok(ret, "no message available\n");
4723 todo_wine
4724 ok(msg.hwnd == child && (msg.message == WM_NCMOUSELEAVE || broken(msg.message == WM_LBUTTONUP)),
4725 "hwnd %p/%p message %04x\n", msg.hwnd, child, msg.message);
4726
4727 if (msg.message == WM_NCMOUSELEAVE)
4728 ret = wait_for_message( &msg );
4729 ok(ret, "no message available\n");
4730 ok(msg.hwnd == child && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
4731 msg.hwnd, child, msg.message);
4732
4733 ret = peek_message(&msg);
4734 ok(!ret, "message %04x available\n", msg.message);
4735
4736done:
4737 flush_events( TRUE );
4738
4740 DestroyWindow(popup);
4741
4743}
4744
4746{
4747 HWND child;
4748 RECT rc, rc2;
4749 HRGN rgn;
4750 int ret;
4751 child = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE, 10, 10, 10, 10, hwnd, 0, 0, NULL);
4754 /* test that ValidateRect validates children*/
4756 GetWindowRect( child, &rc);
4757 MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
4758 ret = GetUpdateRect( child, &rc2, 0);
4759 ok( ret == 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret);
4760 ok( rc2.right > rc2.left && rc2.bottom > rc2.top,
4761 "Update rectangle is empty!\n");
4762 ValidateRect( hwnd, &rc);
4763 ret = GetUpdateRect( child, &rc2, 0);
4764 ok( !ret, "Expected GetUpdateRect to return zero, got %d\n", ret);
4765 ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
4766 "Update rectangle %s is not empty!\n", wine_dbgstr_rect(&rc2));
4767
4768 /* now test ValidateRgn */
4770 GetWindowRect( child, &rc);
4771 MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
4772 rgn = CreateRectRgnIndirect( &rc);
4773 ValidateRgn( hwnd, rgn);
4774 ret = GetUpdateRect( child, &rc2, 0);
4775 ok( !ret, "Expected GetUpdateRect to return zero, got %d\n", ret);
4776 ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
4777 "Update rectangle %s is not empty!\n", wine_dbgstr_rect(&rc2));
4778
4779 DeleteObject( rgn);
4781}
4782
4784{
4785 LRESULT ret;
4786 RECT rc;
4787 MoveWindow( hwnd, 0, 0, x, y, 0);
4789 rc = *prc;
4791 ok(!ret, "got %08Ix\n", ret);
4792 if (winetest_debug > 1)
4793 trace("window rect is %s, nccalc rect is %s\n", wine_dbgstr_rect(&rc), wine_dbgstr_rect(prc));
4794}
4795
4797{
4798 RECT rc1;
4799 INT sbheight = GetSystemMetrics( SM_CYHSCROLL);
4800 INT sbwidth = GetSystemMetrics( SM_CXVSCROLL);
4801 HWND hwnd = CreateWindowExA(0, "static", NULL,
4803 10, 10, 200, 200, parent, 0, 0, NULL);
4806
4807 /* test window too low for a horizontal scroll bar */
4808 nccalchelper( hwnd, 100, sbheight, &rc1);
4809 ok( rc1.bottom - rc1.top == sbheight, "Height should be %d size is %s\n", sbheight,
4810 wine_dbgstr_rect(&rc1));
4811
4812 /* test window just high enough for a horizontal scroll bar */
4813 nccalchelper( hwnd, 100, sbheight + 1, &rc1);
4814 ok( rc1.bottom - rc1.top == 1, "Height should be 1 size is %s\n", wine_dbgstr_rect(&rc1));
4815
4816 /* test window too narrow for a vertical scroll bar */
4817 nccalchelper( hwnd, sbwidth - 1, 100, &rc1);
4818 ok( rc1.right - rc1.left == sbwidth - 1 , "Width should be %d size is %s\n", sbwidth - 1,
4819 wine_dbgstr_rect(&rc1));
4820
4821 /* test window just wide enough for a vertical scroll bar */
4822 nccalchelper( hwnd, sbwidth, 100, &rc1);
4823 ok( rc1.right - rc1.left == 0, "Width should be 0 size is %s\n", wine_dbgstr_rect(&rc1));
4824
4825 /* same test, but with client edge: not enough width */
4827 nccalchelper( hwnd, sbwidth, 100, &rc1);
4828 ok( rc1.right - rc1.left == sbwidth - 2 * GetSystemMetrics(SM_CXEDGE),
4829 "Width should be %d size is %s\n", sbwidth - 2 * GetSystemMetrics(SM_CXEDGE),
4830 wine_dbgstr_rect(&rc1));
4831
4833}
4834
4835static void test_SetParent(void)
4836{
4837 HWND desktop = GetDesktopWindow();
4838 HMENU hMenu;
4839 HWND ret, parent, child1, child2, child3, child4, sibling, popup;
4840 BOOL bret;
4841
4843 100, 100, 200, 200, 0, 0, 0, NULL);
4844 assert(parent != 0);
4845 child1 = CreateWindowExA(0, "static", NULL, WS_CHILD,
4846 0, 0, 50, 50, parent, 0, 0, NULL);
4847 assert(child1 != 0);
4848 child2 = CreateWindowExA(0, "static", NULL, WS_POPUP,
4849 0, 0, 50, 50, child1, 0, 0, NULL);
4850 assert(child2 != 0);
4851 child3 = CreateWindowExA(0, "static", NULL, WS_CHILD,
4852 0, 0, 50, 50, child2, 0, 0, NULL);
4853 assert(child3 != 0);
4854 child4 = CreateWindowExA(0, "static", NULL, WS_POPUP,
4855 0, 0, 50, 50, child3, 0, 0, NULL);
4856 assert(child4 != 0);
4857
4858 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
4859 parent, child1, child2, child3, child4);
4860
4861 check_parents(parent, desktop, 0, 0, 0, parent, parent);
4863 check_parents(child2, desktop, parent, parent, parent, child2, parent);
4864 check_parents(child3, child2, child2, child2, 0, child2, parent);
4865 check_parents(child4, desktop, child2, child2, child2, child4, parent);
4866
4867 ok(!IsChild(desktop, parent), "wrong parent/child %p/%p\n", desktop, parent);
4868 ok(!IsChild(desktop, child1), "wrong parent/child %p/%p\n", desktop, child1);
4869 ok(!IsChild(desktop, child2), "wrong parent/child %p/%p\n", desktop, child2);
4870 ok(!IsChild(desktop, child3), "wrong parent/child %p/%p\n", desktop, child3);
4871 ok(!IsChild(desktop, child4), "wrong parent/child %p/%p\n", desktop, child4);
4872
4873 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
4874 ok(!IsChild(desktop, child2), "wrong parent/child %p/%p\n", desktop, child2);
4875 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
4876 ok(!IsChild(child1, child2), "wrong parent/child %p/%p\n", child1, child2);
4877 ok(!IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
4878 ok(IsChild(child2, child3), "wrong parent/child %p/%p\n", child2, child3);
4879 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
4880 ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
4881 ok(!IsChild(desktop, child4), "wrong parent/child %p/%p\n", desktop, child4);
4882
4883 ok(!SetParent(parent, child1), "SetParent should fail\n");
4884 ok(!SetParent(child2, child3), "SetParent should fail\n");
4885 ok(SetParent(child1, parent) != 0, "SetParent should not fail\n");
4886 ret = SetParent(parent, child2);
4887 todo_wine ok( !ret || broken( ret != 0 ), "SetParent should fail\n");
4888 if (ret) /* nt4, win2k */
4889 {
4890 ret = SetParent(parent, child3);
4891 ok(ret != 0, "SetParent should not fail\n");
4892 ret = SetParent(child2, parent);
4893 ok(!ret, "SetParent should fail\n");
4894 ret = SetParent(parent, child4);
4895 ok(ret != 0, "SetParent should not fail\n");
4896 check_parents(parent, child4, child4, 0, 0, child4, parent);
4897 check_parents(child1, parent, parent, parent, 0, child4, parent);
4898 check_parents(child2, desktop, parent, parent, parent, child2, parent);
4899 check_parents(child3, child2, child2, child2, 0, child2, parent);
4900 check_parents(child4, desktop, child2, child2, child2, child4, parent);
4901 }
4902 else
4903 {
4904 ret = SetParent(parent, child3);
4905 ok(ret != 0, "SetParent should not fail\n");
4906 ret = SetParent(child2, parent);
4907 ok(!ret, "SetParent should fail\n");
4908 ret = SetParent(parent, child4);
4909 ok(!ret, "SetParent should fail\n");
4910 check_parents(parent, child3, child3, 0, 0, child2, parent);
4911 check_parents(child1, parent, parent, parent, 0, child2, parent);
4912 check_parents(child2, desktop, parent, parent, parent, child2, parent);
4913 check_parents(child3, child2, child2, child2, 0, child2, parent);
4914 check_parents(child4, desktop, child2, child2, child2, child4, parent);
4915 }
4916
4917 hMenu = CreateMenu();
4918 sibling = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
4919 100, 100, 200, 200, 0, hMenu, 0, NULL);
4920 assert(sibling != 0);
4921
4922 ok(SetParent(sibling, parent) != 0, "SetParent should not fail\n");
4923 ok(GetMenu(sibling) == hMenu, "SetParent should not remove menu\n");
4924
4925 ok(SetParent(parent, desktop) != 0, "SetParent should not fail\n");
4926 ok(SetParent(child4, child3) != 0, "SetParent should not fail\n");
4927 ok(SetParent(child3, child2) != 0, "SetParent should not fail\n");
4928 ok(SetParent(child2, child1) != 0, "SetParent should not fail\n");
4929 ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
4931 ok(IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
4932 ok(IsChild(child2, child4), "wrong parent/child %p/%p\n", child2, child4);
4933 ok(!IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4);
4935 ok(IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4);
4936 ok(IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
4937
4938 ok(DestroyWindow(parent), "DestroyWindow() failed\n");
4939
4940 ok(!IsWindow(parent), "parent still exists\n");
4941 ok(!IsWindow(sibling), "sibling still exists\n");
4942 ok(!IsWindow(child1), "child1 still exists\n");
4943 ok(!IsWindow(child2), "child2 still exists\n");
4944 ok(!IsWindow(child3), "child3 still exists\n");
4945 ok(!IsWindow(child4), "child4 still exists\n");
4946
4948 100, 100, 200, 200, 0, 0, 0, NULL);
4949 assert(parent != 0);
4950 child1 = CreateWindowExA(0, "static", NULL, WS_CHILD,
4951 0, 0, 50, 50, parent, 0, 0, NULL);
4952 assert(child1 != 0);
4953 popup = CreateWindowExA(0, "static", NULL, WS_POPUP,
4954 0, 0, 50, 50, 0, 0, 0, NULL);
4955 assert(popup != 0);
4956
4957 trace("parent %p, child %p, popup %p\n", parent, child1, popup);
4958
4959 check_parents(parent, desktop, 0, 0, 0, parent, parent);
4961 check_parents(popup, desktop, 0, 0, 0, popup, popup);
4962
4966
4967 ret = SetParent(popup, child1);
4968 ok(ret == desktop, "expected %p, got %p\n", desktop, ret);
4969 check_parents(popup, child1, child1, 0, 0, parent, popup);
4970 check_active_state(popup, 0, popup);
4971
4973 SetFocus(popup);
4974 check_active_state(popup, 0, popup);
4975
4976 EnableWindow(child1, FALSE);
4977 check_active_state(popup, 0, popup);
4980 SetFocus(popup);
4981 check_active_state(popup, 0, popup);
4982 EnableWindow(child1, TRUE);
4983
4984 ShowWindow(child1, SW_MINIMIZE);
4987 SetFocus(popup);
4988 check_active_state(popup, 0, popup);
4989 ShowWindow(child1, SW_HIDE);
4990
4994
4995 bret = SetForegroundWindow(popup);
4996 ok(bret, "SetForegroundWindow() failed\n");
4997 check_active_state(popup, popup, popup);
4998
5000 SetActiveWindow(popup);
5001 ok(DestroyWindow(popup), "DestroyWindow() failed\n");
5003
5004 ok(DestroyWindow(parent), "DestroyWindow() failed\n");
5005
5006 ok(!IsWindow(parent), "parent still exists\n");
5007 ok(!IsWindow(child1), "child1 still exists\n");
5008 ok(!IsWindow(popup), "popup still exists\n");
5009}
5010
5011typedef struct
5012{
5017} test_style;
5018
5020{
5022 HWND hwnd = (HWND)wparam;
5023 test_style *ts;
5024 DWORD style;
5025
5026 if (ncode != HCBT_CREATEWND)
5027 return CallNextHookEx(NULL, ncode, wparam, lparam);
5028
5029 ts = c->lpcs->lpCreateParams;
5030 ok(ts != NULL, "lpCreateParams not set\n");
5031 ok(c->lpcs->style == ts->cs_style, "style = 0x%08lx, expected 0x%08lx\n",
5032 c->lpcs->style, ts->cs_style);
5033 ok(c->lpcs->dwExStyle == ts->cs_exstyle, "exstyle = 0x%08lx, expected 0x%08lx\n",
5034 c->lpcs->dwExStyle, ts->cs_exstyle);
5035
5037 ok(style == ts->cs_style, "style = 0x%08lx, expected 0x%08lx\n",
5038 style, ts->cs_style);
5040 ok(style == (ts->cs_exstyle & ~WS_EX_LAYERED),
5041 "exstyle = 0x%08lx, expected 0x%08lx\n", style, ts->cs_exstyle);
5042 return CallNextHookEx(NULL, ncode, wparam, lparam);
5043}
5044
5046{
5048 test_style *ts;
5049 DWORD style;
5050
5051 switch (msg)
5052 {
5053 case WM_NCCREATE:
5054 case WM_CREATE:
5056 ts = cs->lpCreateParams;
5057
5058 ok(ts != NULL, "lpCreateParams not set\n");
5059 ok(cs->style == ts->cs_style, "style = 0x%08lx, expected 0x%08lx\n",
5060 cs->style, ts->cs_style);
5061 ok(cs->dwExStyle == ts->cs_exstyle, "exstyle = 0x%08lx, expected 0x%08lx\n",
5062 cs->dwExStyle, ts->cs_exstyle);
5063
5065 ok(style == ts->style, "style = 0x%08lx, expected 0x%08lx\n",
5066 style, ts->style);
5068 ok(style == ts->exstyle, "exstyle = 0x%08lx, expected 0x%08lx\n",
5069 style, ts->exstyle);
5070 break;
5071 }
5072 return DefWindowProcA(hwnd, msg, wparam, lparam);
5073}
5074
5076
5078{
5079 WNDCLASSA wc =
5080 {
5081 0,
5083 0,
5084 0,
5086 NULL,
5088 (HBRUSH)(COLOR_BTNFACE+1),
5089 NULL,
5090 "WineStyleCheck",
5091 };
5092
5095}
5096
5097static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut)
5098{
5099 DWORD dwActualStyle;
5100 DWORD dwActualExStyle;
5101 test_style ts;
5102 HWND hwnd;
5104 HHOOK hook;
5105
5106 ts.cs_style = dwStyleIn;
5107 ts.cs_exstyle = dwExStyleIn;
5108 if ((dwExStyleIn & WS_EX_DLGMODALFRAME) ||
5109 ((!(dwExStyleIn & WS_EX_STATICEDGE)) &&
5110 (dwStyleIn & (WS_DLGFRAME | WS_THICKFRAME))))
5112 else
5113 ts.cs_exstyle &= ~WS_EX_WINDOWEDGE;
5114 ts.style = dwStyleOut;
5115 ts.exstyle = dwExStyleOut;
5116
5117 if (dwStyleIn & WS_CHILD)
5118 {
5119 hwndParent = CreateWindowExA(0, "static", NULL,
5120 WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
5121 ok(hwndParent != NULL, "CreateWindowExA failed\n");
5122 }
5123
5126 dwStyleIn, 0, 0, 0, 0, hwndParent, NULL, NULL, &ts);
5127 ok(hwnd != NULL, "CreateWindowExA failed\n");
5129
5130 flush_events( TRUE );
5131
5132 dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE);
5133 dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
5134 ok(dwActualStyle == dwStyleOut, "expected style %#lx, got %#lx\n", dwStyleOut, dwActualStyle);
5135 ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#lx, got %#lx\n", dwExStyleOut, dwActualExStyle);
5136
5137 /* try setting the styles explicitly */
5138 SetWindowLongA( hwnd, GWL_EXSTYLE, dwExStyleIn );
5139 dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE);
5140 dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
5141 /* WS_EX_WINDOWEDGE can't always be changed */
5142 if (dwExStyleIn & WS_EX_DLGMODALFRAME)
5143 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
5144 else if ((dwActualStyle & (WS_DLGFRAME | WS_THICKFRAME)) && !(dwExStyleIn & WS_EX_STATICEDGE))
5145 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
5146 else
5147 dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE;
5148 ok(dwActualStyle == dwStyleOut, "expected style %#lx, got %#lx\n", dwStyleOut, dwActualStyle);
5149 ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#lx, got %#lx\n", dwExStyleOut, dwActualExStyle);
5150
5151 SetWindowLongA( hwnd, GWL_STYLE, dwStyleIn );
5152 dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE);
5153 dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
5154 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
5155 if ((dwStyleIn & (WS_CHILD|WS_POPUP)) == WS_CHILD) dwStyleOut = dwStyleIn;
5156 else dwStyleOut = dwStyleIn | WS_CLIPSIBLINGS;
5157 /* WS_EX_WINDOWEDGE can't always be changed */
5158 if (dwExStyleIn & WS_EX_DLGMODALFRAME)
5159 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
5160 else if ((dwActualStyle & (WS_DLGFRAME | WS_THICKFRAME)) && !(dwExStyleIn & WS_EX_STATICEDGE))
5161 dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE;
5162 else
5163 dwExStyleOut = dwExStyleIn & ~WS_EX_WINDOWEDGE;
5164 ok(dwActualStyle == dwStyleOut, "expected style %#lx, got %#lx\n", dwStyleOut, dwActualStyle);
5165 ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#lx, got %#lx\n", dwExStyleOut, dwActualExStyle);
5166
5169}
5170
5171/* tests what window styles the window manager automatically adds */
5172static void test_window_styles(void)
5173{
5174 static const struct
5175 {
5176 DWORD style_in;
5177 DWORD exstyle_in;
5178 DWORD style_out;
5179 DWORD exstyle_out;
5180 } tests[] = {
5187 {WS_CHILD, 0, WS_CHILD, 0},
5218 };
5219 int i;
5220
5222
5223 for (i = 0; i < ARRAY_SIZE(tests); i++)
5224 {
5225 if ((tests[i].exstyle_in & WS_EX_LAYERED) && !pGetLayeredWindowAttributes)
5226 continue;
5227
5228 winetest_push_context("style %#lx exstyle %#lx", tests[i].style_in, tests[i].exstyle_in);
5229 check_window_style(tests[i].style_in, tests[i].exstyle_in, tests[i].style_out, tests[i].exstyle_out);
5231 }
5232}
5233
5235{
5236 return 0;
5237}
5238
5240{
5241 if (msg == WM_INITDIALOG)
5242 EndDialog(hwnd, 0);
5243
5244 return 0;
5245}
5246
5248{
5251};
5252
5254{
5255 if (msg == WM_INITDIALOG)
5256 {
5258 struct dialog_param *param = (struct dialog_param *)lparam;
5259 BOOL parent_is_child;
5260 HWND disabled_hwnd;
5261
5262 parent_is_child = (GetWindowLongA(param->parent, GWL_STYLE) & (WS_POPUP | WS_CHILD)) == WS_CHILD;
5263
5264 ok(IsWindowEnabled(hwnd), "wrong state for %p\n", hwnd);
5265 if (parent_is_child)
5266 {
5267 ok(IsWindowEnabled(param->parent), "wrong state for %08lx\n", style);
5268 disabled_hwnd = param->grand_parent;
5269 }
5270 else
5271 {
5272 ok(!IsWindowEnabled(param->parent), "wrong state for %08lx\n", style);
5273 disabled_hwnd = param->parent;
5274 }
5275
5276 if (param->grand_parent)
5277 {
5278 if (parent_is_child)
5279 ok(!IsWindowEnabled(param->grand_parent), "wrong state for %08lx\n", style);
5280 else
5281 ok(IsWindowEnabled(param->grand_parent), "wrong state for %08lx\n", style);
5282 }
5283
5284 DialogBoxIndirectParamA(GetModuleHandleA(NULL), param->dlg_data, disabled_hwnd, empty_dlg_proc3, 0);
5285 ok(IsWindowEnabled(disabled_hwnd), "wrong state for %08lx\n", style);
5286
5287 ok(IsWindowEnabled(hwnd), "wrong state for %p\n", hwnd);
5288 ok(IsWindowEnabled(param->parent), "wrong state for %p\n", param->parent);
5289 if (param->grand_parent)
5290 ok(IsWindowEnabled(param->grand_parent), "wrong state for %p (%08lx)\n", param->grand_parent, style);
5291
5293 ok(IsWindowEnabled(hwnd), "wrong state for %p\n", hwnd);
5294 ok(IsWindowEnabled(param->parent), "wrong state for %p\n", param->parent);
5295 if (param->grand_parent)
5296 ok(IsWindowEnabled(param->grand_parent), "wrong state for %p (%08lx)\n", param->grand_parent, style);
5297
5298 param->dlg_data->style |= WS_CHILD;
5300 ok(IsWindowEnabled(hwnd), "wrong state for %p (%08lx)\n", hwnd, style);
5301
5302 EndDialog(hwnd, 0);
5303 }
5304 return 0;
5305}
5306
5307static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_out, DWORD ex_style_out)
5308{
5309 struct
5310 {
5311 DLGTEMPLATE dt;
5312 WORD menu_name;
5313 WORD class_id;
5314 WORD class_atom;
5315 WCHAR caption[1];
5316 } dlg_data;
5317 DWORD style, ex_style;
5318 HWND hwnd, grand_parent = 0, parent = 0;
5319 struct dialog_param param;
5320
5321 if (style_in & WS_CHILD)
5322 {
5324 0, 0, 0, 0, NULL, NULL, NULL, NULL);
5325 ok(grand_parent != 0, "grand_parent creation failed\n");
5326 }
5327
5328 parent = CreateWindowExA(0, "static", NULL, style_in,
5329 0, 0, 0, 0, grand_parent, NULL, NULL, NULL);
5330 ok(parent != 0, "parent creation failed, style %#lx\n", style_in);
5331
5332 dlg_data.dt.style = style_in;
5333 dlg_data.dt.dwExtendedStyle = ex_style_in;
5334 dlg_data.dt.cdit = 0;
5335 dlg_data.dt.x = 0;
5336 dlg_data.dt.y = 0;
5337 dlg_data.dt.cx = 100;
5338 dlg_data.dt.cy = 100;
5339 dlg_data.menu_name = 0;
5340 dlg_data.class_id = 0;
5341 dlg_data.class_atom = 0;
5342 dlg_data.caption[0] = 0;
5343
5345 ok(hwnd != 0, "dialog creation failed, style %#lx, exstyle %#lx\n", style_in, ex_style_in);
5346
5347 flush_events( TRUE );
5348
5350 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
5351 ok(style == (style_out | DS_3DLOOK), "got %#lx\n", style);
5352 ok(ex_style == ex_style_out, "expected ex_style %#lx, got %#lx\n", ex_style_out, ex_style);
5353
5354 ok(IsWindowEnabled(parent), "wrong parent state (dialog style %#lx)\n", style_in);
5355
5356 /* try setting the styles explicitly */
5357 SetWindowLongA(hwnd, GWL_EXSTYLE, ex_style_in);
5359 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
5360 ok(style == (style_out | DS_3DLOOK), "got %#lx\n", style);
5361 /* WS_EX_WINDOWEDGE can't always be changed */
5362 if (ex_style_in & WS_EX_DLGMODALFRAME)
5363 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
5364 else if ((style & (WS_DLGFRAME | WS_THICKFRAME)) && !(ex_style_in & WS_EX_STATICEDGE))
5365 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
5366 else
5367 ex_style_out = ex_style_in & ~WS_EX_WINDOWEDGE;
5368 ok(ex_style == ex_style_out, "expected ex_style %#lx, got %#lx\n", ex_style_out, ex_style);
5369
5370 SetWindowLongA(hwnd, GWL_STYLE, style_in);
5372 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
5373 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
5374 if ((style_in & (WS_CHILD | WS_POPUP)) == WS_CHILD) style_out = style_in;
5375 else style_out = style_in | WS_CLIPSIBLINGS;
5376 ok(style == style_out, "expected style %#lx, got %#lx\n", style_out, style);
5377 /* WS_EX_WINDOWEDGE can't always be changed */
5378 if (ex_style_in & WS_EX_DLGMODALFRAME)
5379 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
5380 else if ((style & (WS_DLGFRAME | WS_THICKFRAME)) && !(ex_style_in & WS_EX_STATICEDGE))
5381 ex_style_out = ex_style_in | WS_EX_WINDOWEDGE;
5382 else
5383 ex_style_out = ex_style_in & ~WS_EX_WINDOWEDGE;
5384 ok(ex_style == ex_style_out, "expected ex_style %#lx, got %#lx\n", ex_style_out, ex_style);
5385
5387
5388 param.parent = parent;
5389 param.grand_parent = grand_parent;
5390 param.dlg_data = &dlg_data.dt;
5392
5393 ok(IsWindowEnabled(parent), "wrong parent state (dialog style %#lx)\n", style_in);
5394 if (grand_parent)
5395 ok(IsWindowEnabled(grand_parent), "wrong grand parent state (dialog style %#lx)\n", style_in);
5396
5399}
5400
5401static void test_dialog_styles(void)
5402{
5478
5479 if (pGetLayeredWindowAttributes)
5480 {
5485 }
5486}
5487
5489{
5496};
5497
5499{
5500 if (msg == WM_INITDIALOG) {
5501 struct dlg_parent_param *param = (void*)lparam;
5502 check_parents(hwnd, param->ga_parent, param->gwl_parent, param->get_parent, param->owner,
5503 param->root ? param->root : hwnd, param->ga_root_owner ? param->ga_root_owner : hwnd);
5504
5505 ok(!IsWindowEnabled(param->gwl_parent), "parent is not disabled\n");
5506 EndDialog(hwnd, 2);
5507 ok(IsWindowEnabled(param->gwl_parent), "parent is not enabled\n");
5508 }
5509
5510 return 0;
5511}
5512
5514{
5515 if (msg == WM_INITDIALOG) {
5516 ok(!IsWindowEnabled(GetParent(hwnd)), "parent is not disabled\n");
5518 }
5519
5520 return 0;
5521}
5522
5524{
5525 if (msg == WM_INITDIALOG) {
5526 HWND new_parent = (HWND)lparam;
5528 ok(!IsWindowEnabled(owner), "owner is not disabled\n");
5530 SetParent(hwnd, new_parent);
5531 ok(GetParent(hwnd) == new_parent, "GetParent(hwnd) = %p, expected %p\n", GetParent(hwnd), new_parent);
5532 PostMessageA(hwnd, WM_QUIT, 0, 0);
5533 }
5534
5535 return 0;
5536}
5537
5539{
5540 if (msg == WM_ENTERIDLE) {
5543 /* EndDialog will enable owner */
5545 EndDialog(dialog, 2);
5546 ok(IsWindowEnabled(owner), "owner is not enabled\n");
5547 /* ...but it won't be enabled on dialog exit */
5549 }
5550 return DefWindowProcA( hwnd, msg, wparam, lparam );
5551}
5552
5554{
5555 if (msg == WM_ENTERIDLE) {
5557 PostMessageA(dialog, WM_QUIT, 0, 0);
5558 }
5559 return DefWindowProcA( hwnd, msg, wparam, lparam );
5560}
5561
5563{
5564 if (msg == WM_ENTERIDLE) {
5567 }
5568 return DefWindowProcA( hwnd, msg, wparam, lparam );
5569}
5570
5571static void test_dialog_parent(void)
5572{
5573 HWND dialog, parent, child, child2, other, desktop = GetDesktopWindow();
5574 struct dlg_parent_param param;
5575 INT_PTR ret;
5576 struct
5577 {
5578 DLGTEMPLATE dt;
5579 WORD menu_name;
5580 WORD class_id;
5581 WORD class_atom;
5582 WCHAR caption[1];
5583 } dlg_data;
5584
5585 dlg_data.dt.dwExtendedStyle = 0;
5586 dlg_data.dt.cdit = 0;
5587 dlg_data.dt.x = 0;
5588 dlg_data.dt.y = 0;
5589 dlg_data.dt.cx = 100;
5590 dlg_data.dt.cy = 100;
5591 dlg_data.menu_name = 0;
5592 dlg_data.class_id = 0;
5593 dlg_data.class_atom = 0;
5594 dlg_data.caption[0] = 0;
5595
5596 parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
5597 /* Create a child without WS_CHILD flag. It's a valid owner window. */
5598 child = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
5600 /* Regular child. If passed as an owner, its parent will be true owner window. */
5601 child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, NULL, NULL, NULL);
5602
5603 /* When dialog is created with WS_CHILD style, its parent depends on function used to create it. */
5604 dlg_data.dt.style = WS_CHILD;
5605
5606 /* CreateDialogIndirectParam uses passed parent as dialog parent. */
5608 ok(dialog != 0, "dialog creation failed\n");
5609 check_parents(dialog, child2, child2, child2, NULL, parent, child);
5610
5611 ok(IsWindowEnabled(child2), "child2 is disabled\n");
5612 EnableWindow(child2, FALSE);
5613 EndDialog(dialog, 0);
5614 ok(IsWindowEnabled(child2), "child2 is not enabled\n");
5616
5617 /* DialogBoxIndirectParam uses the first parent of passed owner that's not a child window as dialog
5618 * parent (like in case of dialog with owner). */
5619 param.ga_parent = param.gwl_parent = param.get_parent = child;
5620 param.owner = NULL;
5621 param.root = parent;
5622 param.ga_root_owner = child;
5624 ok(ret == 2, "DialogBoxIndirectParam returned %Id\n", ret);
5625
5626 /* Dialogs without WS_CHILD behave as expected, they use passed owner just like CreateWindow does. */
5627 dlg_data.dt.style = WS_OVERLAPPEDWINDOW;
5628
5630 ok(dialog != 0, "dialog creation failed\n");
5632
5633 ok(IsWindowEnabled(child), "child is disabled\n");
5635 EndDialog(dialog, 0);
5636 ok(IsWindowEnabled(child), "child is not enabled\n");
5638
5639 param.ga_parent = desktop;
5640 param.gwl_parent = child;
5641 param.get_parent = NULL;
5642 param.owner = child;
5643 param.root = param.ga_root_owner = NULL;
5645 ok(ret == 2, "DialogBoxIndirectParam returned %Id\n", ret);
5646
5647 other = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
5649
5650 /* When dialog is created with WS_CHILD|WS_POPUP style, we have an owner. */
5651 dlg_data.dt.style = WS_CHILD|WS_POPUP;
5652
5654 ok(dialog != 0, "dialog creation failed\n");
5656
5657 ok(IsWindowEnabled(child), "child is disabled\n");
5659 EndDialog(dialog, 0);
5660 ok(IsWindowEnabled(child), "child is not enabled\n");
5662
5663 param.ga_parent = desktop;
5664 param.gwl_parent = param.get_parent = child;
5665 param.owner = child;
5666 param.root = NULL;
5667 param.ga_root_owner = child;
5669 ok(ret == 2, "DialogBoxIndirectParam returned %Id\n", ret);
5670
5671 /* If we change parent in WM_INITDIALOG for WS_CHILD dialog WM_ENTERIDLE is still sent to the original
5672 * parent. EndDialog will enable the new parent. */
5675 dlg_data.dt.style = WS_CHILD;
5677 ok(ret == 2, "DialogBoxIndirectParam returned %Id\n", ret);
5678 ok(!IsWindowEnabled(other), "other is not disabled\n");
5679 ok(!IsWindowEnabled(child), "child is not disabled\n");
5680 ok(IsWindowEnabled(child2), "child2 is not enabled\n");
5682
5683 /* If we change parent and style in WM_INITDIALOG for dialog with an owner to make it true child
5684 * (thus GetParent() will return the new parent instead of an owner), WM_ENTERIDLE is still sent
5685 * to the original parent. EndDialog will enable the new parent. */
5687 dlg_data.dt.style = WS_OVERLAPPED;
5689 ok(ret == 1, "DialogBoxIndirectParam returned %Id\n", ret);
5690 ok(!IsWindowEnabled(other), "other is not disabled\n");
5691 ok(!IsWindowEnabled(child), "child is not disabled\n");
5692 ok(IsWindowEnabled(child2), "child2 is not enabled\n");
5695
5696 /* Quit dialog message loop by sending WM_QUIT message. Dialog owner is not enabled. */
5699 ok(ret == 1, "DialogBoxIndirectParam returned %Id\n", ret);
5700 ok(!IsWindowEnabled(other), "other is enabled\n");
5702
5703 /* Quit dialog message loop by destroying the window. Dialog owner is not enabled. */
5706 ok(ret == 1, "DialogBoxIndirectParam returned %Id\n", ret);
5707 ok(!IsWindowEnabled(other), "other is enabled\n");
5709
5712}
5713
5715{
5716 HDC hdc;
5717 RECT rc, rc2, rc3;
5718 COLORREF colr;
5719
5722 flush_events( TRUE );
5723 GetClientRect( hwnd, &rc);
5724 hdc = GetDC( hwnd);
5725 /* test ScrollWindow(Ex) with no clip rectangle */
5726 /* paint the lower half of the window black */
5727 rc2 = rc;
5728 rc2.top = ( rc2.top + rc2.bottom) / 2;
5730 /* paint the upper half of the window white */
5731 rc2.bottom = rc2.top;
5732 rc2.top =0;
5734 /* scroll lower half up */
5735 rc2 = rc;
5736 rc2.top = ( rc2.top + rc2.bottom) / 2;
5737 ScrollWindowEx( hwnd, 0, - rc2.top, &rc2, NULL, NULL, NULL, SW_ERASE);
5739 /* expected: black should have scrolled to the upper half */
5740 colr = GetPixel( hdc, (rc2.left+rc2.right)/ 2, rc2.bottom / 4 );
5741 ok ( colr == 0, "pixel should be black, color is %08lx\n", colr);
5742 /* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
5743 /* paint the lower half of the window black */
5744 rc2 = rc;
5745 rc2.top = ( rc2.top + rc2.bottom) / 2;
5747 /* paint the upper half of the window white */
5748 rc2.bottom = rc2.top;
5749 rc2.top =0;
5751 /* scroll lower half up */
5752 rc2 = rc;
5753 rc2.top = ( rc2.top + rc2.bottom) / 2;
5754 rc3 = rc;
5755 rc3.left = rc3.right / 4;
5756 rc3.right -= rc3.right / 4;
5757 ScrollWindowEx( hwnd, 0, - rc2.top, &rc2, &rc3, NULL, NULL, SW_ERASE);
5759 /* expected: black should have scrolled to the upper half */
5760 colr = GetPixel( hdc, (rc2.left+rc2.right)/ 2, rc2.bottom / 4 );
5761 ok ( colr == 0, "pixel should be black, color is %08lx\n", colr);
5762
5763 /* clean up */
5764 ReleaseDC( hwnd, hdc);
5765}
5766
5768{
5769 HDC hdc;
5770 HRGN hrgn=CreateRectRgn(0,0,0,0);
5771 HRGN exprgn, tmprgn, clipping;
5772 RECT rc, rcu, cliprc;
5773 /* create two overlapping child windows. The visual region
5774 * of hwnd1 is clipped by the overlapping part of
5775 * hwnd2 because of the WS_CLIPSIBLING style */
5776 HWND hwnd1, hwnd2;
5777
5778 clipping = CreateRectRgn(0,0,0,0);
5779 tmprgn = CreateRectRgn(0,0,0,0);
5780 exprgn = CreateRectRgn(0,0,0,0);
5781 hwnd2 = CreateWindowExA(0, "static", NULL,
5783 75, 30, 100, 100, parent, 0, 0, NULL);
5784 hwnd1 = CreateWindowExA(0, "static", NULL,
5786 25, 50, 100, 100, parent, 0, 0, NULL);
5789 GetClientRect( hwnd1, &rc);
5790 cliprc=rc;
5791 SetRectRgn( clipping, 10, 10, 90, 90);
5792 hdc = GetDC( hwnd1);
5793 /* for a visual touch */
5794 TextOutA( hdc, 0,10, "0123456789", 10);
5795 ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu);
5796 /* create a region with what is expected */
5797 SetRectRgn( exprgn, 39,0,49,74);
5798 SetRectRgn( tmprgn, 88,79,98,93);
5799 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5800 SetRectRgn( tmprgn, 0,93,98,98);
5801 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5802 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5803 if (!EqualRgn( exprgn, hrgn))
5804 {
5805 trace("update rect is %s\n", wine_dbgstr_rect(&rcu));
5807 }
5808 /* now with clipping region */
5809 SelectClipRgn( hdc, clipping);
5810 ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu);
5811 /* create a region with what is expected */
5812 SetRectRgn( exprgn, 39,10,49,74);
5813 SetRectRgn( tmprgn, 80,79,90,85);
5814 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5815 SetRectRgn( tmprgn, 10,85,90,90);
5816 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5817 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5818 if (!EqualRgn( exprgn, hrgn))
5819 {
5820 trace("update rect is %s\n", wine_dbgstr_rect(&rcu));
5822 }
5823 ReleaseDC( hwnd1, hdc);
5824
5825 /* test scrolling a rect by more than its size */
5826 DestroyWindow( hwnd2);
5827 ValidateRect( hwnd1, NULL);
5828 SetRect( &rc, 40,40, 50,50);
5829 InvalidateRect( hwnd1, &rc, 1);
5830 ScrollWindowEx( hwnd1, -20, 0, &rc, NULL, hrgn, &rcu,
5832 SetRectRgn( exprgn, 20, 40, 30, 50);
5833 SetRectRgn( tmprgn, 40, 40, 50, 50);
5834 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5835 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5836 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5837 ok( rcu.left == 20 && rcu.top == 40 && rcu.right == 50 && rcu.bottom == 50,
5838 "unexpected update rect: %s\n", wine_dbgstr_rect(&rcu));
5839
5840 /* test scrolling a window with an update region */
5841 ValidateRect( hwnd1, NULL);
5842 SetRect( &rc, 40,40, 50,50);
5843 InvalidateRect( hwnd1, &rc, 1);
5844 GetClientRect( hwnd1, &rc);
5845 cliprc=rc;
5846 ScrollWindowEx( hwnd1, -10, 0, &rc, &cliprc, hrgn, &rcu,
5848 SetRectRgn( exprgn, 88,0,98,98);
5849 SetRectRgn( tmprgn, 30, 40, 50, 50);
5850 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5851 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5852 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5853
5854 /* clear an update region */
5855 UpdateWindow( hwnd1 );
5856
5857 SetRect( &rc, 0,40, 100,60);
5858 SetRect( &cliprc, 0,0, 100,100);
5859 ScrollWindowEx( hwnd1, 0, -25, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
5860 SetRectRgn( exprgn, 0, 40, 98, 60 );
5861 ok( EqualRgn( exprgn, hrgn), "wrong update region in excessive scroll\n");
5862 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5863
5864 /* now test ScrollWindowEx with a combination of
5865 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
5866 /* make hwnd2 the child of hwnd1 */
5867 hwnd2 = CreateWindowExA(0, "static", NULL,
5869 50, 50, 100, 100, hwnd1, 0, 0, NULL);
5871 GetClientRect( hwnd1, &rc);
5872 cliprc=rc;
5873
5874 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
5876 ValidateRect( hwnd1, NULL);
5877 ValidateRect( hwnd2, NULL);
5878 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu,
5880 SetRectRgn( exprgn, 88,0,98,88);
5881 SetRectRgn( tmprgn, 0,88,98,98);
5882 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5883 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5884 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5885
5886 /* SW_SCROLLCHILDREN */
5888 ValidateRect( hwnd1, NULL);
5889 ValidateRect( hwnd2, NULL);
5890 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_SCROLLCHILDREN | SW_INVALIDATE);
5891 /* expected region is the same as in previous test */
5892 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5893 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5894
5895 /* no SW_SCROLLCHILDREN */
5897 ValidateRect( hwnd1, NULL);
5898 ValidateRect( hwnd2, NULL);
5899 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
5900 /* expected region is the same as in previous test */
5901 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5902 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5903
5904 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
5906 ValidateRect( hwnd1, NULL);
5907 ValidateRect( hwnd2, NULL);
5908 ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
5909 SetRectRgn( exprgn, 88,0,98,20);
5910 SetRectRgn( tmprgn, 20,20,98,30);
5911 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5912 SetRectRgn( tmprgn, 20,30,30,88);
5913 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5914 SetRectRgn( tmprgn, 0,88,30,98);
5915 CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
5916 ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
5917 if (!EqualRgn( exprgn, hrgn)) dump_region(hrgn);
5918
5919 /* clean up */
5921 DeleteObject( exprgn);
5922 DeleteObject( tmprgn);
5923 DestroyWindow( hwnd1);
5924 DestroyWindow( hwnd2);
5925}
5926
5927/* couple of tests of return values of scrollbar functions
5928 * called on a scrollbarless window */
5929static void test_scroll(void)
5930{
5931 BOOL ret;
5932 INT min, max;
5933 SCROLLINFO si;
5934 HWND hwnd = CreateWindowExA(0, "Static", "Wine test window",
5936 100, 100, 200, 200, 0, 0, 0, NULL);
5937 /* horizontal */
5939 ok( ret, "GetScrollRange failed\n" );
5940 ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
5941 ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
5942 si.cbSize = sizeof( si);
5943 si.fMask = SIF_PAGE;
5944 si.nPage = 0xdeadbeef;
5946 ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
5947 ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
5948 /* vertical */
5950 ok( ret, "GetScrollRange returns FALSE\n");
5951 ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
5952 ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
5953 si.cbSize = sizeof( si);
5954 si.fMask = SIF_PAGE;
5955 si.nPage = 0xdeadbeef;
5957 ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
5958 ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
5959 /* clean up */
5961}
5962
5964{
5965 HDC hdc;
5966 HRGN exprgn, tmprgn, hrgn;
5967 RECT rc, rc2, rcu, cliprc;
5968 HWND hwnd1;
5969 COLORREF colr;
5970
5971 hrgn = CreateRectRgn(0,0,0,0);
5972 tmprgn = CreateRectRgn(0,0,0,0);
5973 exprgn = CreateRectRgn(0,0,0,0);
5974
5975 hwnd1 = CreateWindowExA(0, "static", NULL,
5977 25, 50, 100, 100, parent, 0, 0, NULL);
5980 flush_events( TRUE );
5981 GetClientRect( hwnd1, &rc);
5982 hdc = GetDC( hwnd1);
5983 /* paint the upper half of the window black */
5984 rc2 = rc;
5985 rc2.bottom = ( rc.top + rc.bottom) /2;
5987 /* clip region is the lower half */
5988 cliprc=rc;
5989 cliprc.top = (rc.top + rc.bottom) /2;
5990 /* test whether scrolled pixels are properly clipped */
5991 colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1);
5992 ok ( colr == 0, "pixel should be black, color is %08lx\n", colr);
5993 /* this scroll should not cause any visible changes */
5994 ScrollDC( hdc, 5, -20, &rc, &cliprc, hrgn, &rcu);
5995 colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1);
5996 ok ( colr == 0, "pixel should be black, color is %08lx\n", colr);
5997 /* test with NULL clip rect */
5998 ScrollDC( hdc, 20, -20, &rc, NULL, hrgn, &rcu);
5999 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
6000 SetRect(&rc2, 0, 0, 100, 100);
6001 ok(EqualRect(&rcu, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rcu),
6003 if (!EqualRect(&rcu, &rc2))
6004 {
6005 trace("update rect: %s\n", wine_dbgstr_rect(&rcu));
6007 }
6008
6009 SetRectRgn( exprgn, 0, 0, 20, 80);
6010 SetRectRgn( tmprgn, 0, 80, 100, 100);
6011 CombineRgn(exprgn, exprgn, tmprgn, RGN_OR);
6012 ok(EqualRgn(exprgn, hrgn), "wrong update region\n");
6013 if (!EqualRgn(exprgn, hrgn)) dump_region(exprgn);
6014 /* test clip rect > scroll rect */
6016 rc2=rc;
6017 InflateRect( &rc2, -(rc.right-rc.left)/4, -(rc.bottom-rc.top)/4);
6019 ScrollDC( hdc, 10, 10, &rc2, &rc, hrgn, &rcu);
6020 SetRectRgn( exprgn, 25, 25, 75, 35);
6021 SetRectRgn( tmprgn, 25, 35, 35, 75);
6022 CombineRgn(exprgn, exprgn, tmprgn, RGN_OR);
6023 ok(EqualRgn(exprgn, hrgn), "wrong update region\n");
6024 if (!EqualRgn(exprgn, hrgn))
6025 {
6026 trace("update rect: %s\n", wine_dbgstr_rect(&rcu));
6028 }
6029 /* clean up */
6030 ReleaseDC(hwnd1, hdc);
6032 DeleteObject(exprgn);
6033 DeleteObject(tmprgn);
6034 DestroyWindow(hwnd1);
6035}
6036
6037static void test_params(void)
6038{
6039 HWND hwnd;
6040 INT rc;
6041
6042 ok(!IsWindow(0), "IsWindow(0)\n");
6043 ok(!IsWindow(HWND_BROADCAST), "IsWindow(HWND_BROADCAST)\n");
6044 ok(!IsWindow(HWND_TOPMOST), "IsWindow(HWND_TOPMOST)\n");
6045
6046 /* Just a param check */
6047 SetLastError(0xdeadbeef);
6048 rc = GetWindowTextA(hwndMain2, NULL, 1024);
6049 ok(!rc, "GetWindowText: rc=%d err=%ld\n",rc,GetLastError());
6050
6051 SetLastError(0xdeadbeef);
6052 hwnd=CreateWindowA("LISTBOX", "TestList",
6054 0, 0, 100, 100,
6055 NULL, (HMENU)1, NULL, 0);
6056
6057 ok(!hwnd || broken(hwnd != NULL), /* w2k3 sp2 */
6058 "CreateWindow with invalid menu handle should fail\n");
6059 if (!hwnd)
6061 "wrong last error value %ld\n", GetLastError());
6062}
6063
6064static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)
6065{
6066 HWND hwnd = 0;
6067
6068 hwnd = CreateWindowExA(exStyle, class, class, style,
6069 110, 100,
6070 225, 200,
6071 0,
6072 menu ? hmenu : 0,
6073 0, 0);
6074 ok(hwnd != NULL, "Failed to create window class=%s, style=0x%08lx, exStyle=0x%08lx\n", class, style, exStyle);
6075
6078
6079 /* retry setting the maximized state to workaround a FVWM bug */
6081 {
6084 }
6085
6087
6088 SetMenu(hwnd, 0);
6090}
6091
6092static BOOL AWR_init(void)
6093{
6094 WNDCLASSA class;
6095
6096 class.style = CS_HREDRAW | CS_VREDRAW;
6097 class.lpfnWndProc = DefWindowProcA;
6098 class.cbClsExtra = 0;
6099 class.cbWndExtra = 0;
6100 class.hInstance = 0;
6101 class.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
6102 class.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
6103 class.hbrBackground = 0;
6104 class.lpszMenuName = 0;
6105 class.lpszClassName = szAWRClass;
6106
6107 if (!RegisterClassA(&class)) {
6108 ok(FALSE, "RegisterClass failed\n");
6109 return FALSE;
6110 }
6111
6112 hmenu = CreateMenu();
6113 if (!hmenu)
6114 return FALSE;
6115 ok(hmenu != 0, "Failed to create menu\n");
6116 ok(AppendMenuA(hmenu, MF_STRING, 1, "Test!"), "Failed to create menu item\n");
6117
6118 return TRUE;
6119}
6120
6121
6123{
6124 static const DWORD styles[] = {
6127 };
6128 static const DWORD exStyles[] = {
6131 };
6132
6133 unsigned int i;
6134
6135 /* A exhaustive check of all the styles takes too long
6136 * so just do a (hopefully representative) sample
6137 */
6138 for (i = 0; i < ARRAY_SIZE(styles); ++i)
6139 test_AWRwindow(szAWRClass, styles[i], 0, menu);
6140 for (i = 0; i < ARRAY_SIZE(exStyles); ++i) {
6141 test_AWRwindow(szAWRClass, WS_POPUP, exStyles[i], menu);
6143 }
6144}
6145
6146static void test_AWR_flags(void)
6147{
6148 static const DWORD styles[] = { WS_POPUP, WS_BORDER, WS_DLGFRAME, WS_THICKFRAME, WS_MINIMIZE };
6149 static const DWORD exStyles[] = { WS_EX_CLIENTEDGE, WS_EX_TOOLWINDOW, WS_EX_WINDOWEDGE,
6151
6152 DWORD i, j, k, style, exstyle;
6153 RECT rect, rect2;
6154
6155 for (i = 0; i < (1 << ARRAY_SIZE(styles)); i++)
6156 {
6157 for (k = style = 0; k < ARRAY_SIZE(styles); k++) if (i & (1 << k)) style |= styles[k];
6158
6159 for (j = 0; j < (1 << ARRAY_SIZE(exStyles)); j++)
6160 {
6161 for (k = exstyle = 0; k < ARRAY_SIZE(exStyles); k++) if (j & (1 << k)) exstyle |= exStyles[k];
6162 SetRect( &rect, 100, 100, 200, 200 );
6163 rect2 = rect;
6164 AdjustWindowRectEx( &rect, style, FALSE, exstyle );
6166 ok( EqualRect( &rect, &rect2 ), "%08lx %08lx rects do not match: win %s wine %s\n",
6167 style, exstyle, wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &rect2 ));
6168 if (pAdjustWindowRectExForDpi)
6169 {
6170 SetRect( &rect, 100, 100, 200, 200 );
6171 rect2 = rect;
6172 pAdjustWindowRectExForDpi( &rect, style, FALSE, exstyle, 192 );
6173 wine_AdjustWindowRectExForDpi( &rect2, style, FALSE, exstyle, 192 );
6174 ok( EqualRect( &rect, &rect2 ), "%08lx %08lx rects do not match: win %s wine %s\n",
6175 style, exstyle, wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &rect2 ));
6176 }
6177 }
6178 }
6179}
6180
6181#define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
6182
6183static void test_AdjustWindowRect(void)
6184{
6185 if (!AWR_init())
6186 return;
6187
6201
6205
6207}
6208#undef SHOWSYSMETRIC
6209
6210
6211/* Global variables to trigger exit from loop */
6213
6215{
6216 switch (msg)
6217 {
6218 case WM_PAINT:
6219 WMPAINT_count++;
6220 if (WMPAINT_count > 10 && redrawComplete == 0) {
6221 PAINTSTRUCT ps;
6222 BeginPaint(hwnd, &ps);
6223 EndPaint(hwnd, &ps);
6224 return 1;
6225 }
6226 return 0;
6227 }
6228 return DefWindowProcA(hwnd, msg, wparam, lparam);
6229}
6230
6231/* Ensure we exit from RedrawNow regardless of invalidated area */
6232static void test_redrawnow(void)
6233{
6234 WNDCLASSA cls;
6235 HWND hwndMain;
6236 BOOL ret;
6237
6238 cls.style = CS_DBLCLKS;
6240 cls.cbClsExtra = 0;
6241 cls.cbWndExtra = 0;
6242 cls.hInstance = GetModuleHandleA(0);
6243 cls.hIcon = 0;
6246 cls.lpszMenuName = NULL;
6247 cls.lpszClassName = "RedrawWindowClass";
6248 ret = RegisterClassA(&cls);
6249 ok(ret, "Failed to register a test class.\n");
6250
6251 hwndMain = CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW,
6252 CW_USEDEFAULT, 0, 100, 100, NULL, NULL, 0, NULL);
6253
6254 ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
6256 ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
6258 ok( WMPAINT_count == 1,
6259 "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
6261 ok( WMPAINT_count < 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count);
6262
6263 /* clean up */
6265}
6266
6271};
6272
6277};
6278
6280{
6281 RECT rc;
6282 PAINTSTRUCT ps;
6283
6285
6286 switch (msg)
6287 {
6288 case WM_PAINT:
6289 GetClientRect(hwnd, &rc);
6290 t->client = rc;
6291 GetWindowRect(hwnd, &rc);
6292 if (winetest_debug > 1)
6293 trace("WM_PAINT: hwnd %p, client rect %s, window rect %s\n", hwnd,
6294 wine_dbgstr_rect(&t->client), wine_dbgstr_rect(&rc));
6295 BeginPaint(hwnd, &ps);
6296 t->paint = ps.rcPaint;
6297 GetClipBox(ps.hdc, &rc);
6298 t->clip = rc;
6299 if (winetest_debug > 1)
6300 trace("clip rect %s, paint rect %s\n", wine_dbgstr_rect(&rc),
6302 EndPaint(hwnd, &ps);
6303 return 0;
6304 }
6305 return DefWindowProcA(hwnd, msg, wparam, lparam);
6306}
6307
6309{
6310 SetRectEmpty(&t->client);
6311 SetRectEmpty(&t->clip);
6312 SetRectEmpty(&t->paint);
6313}
6314
6316{
6317 zero_parentdc_stat(&t->main);
6318 zero_parentdc_stat(&t->child1);
6319 zero_parentdc_stat(&t->child2);
6320}
6321
6322#define parentdc_field_ok(t, w, r, f, got) \
6323 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
6324 ": expected %ld, got %ld\n", \
6325 t.w.r.f, got.w.r.f)
6326
6327#define parentdc_todo_field_ok(t, w, r, f, got) \
6328 todo_wine_if (t.w##_todo.r.f) \
6329 parentdc_field_ok(t, w, r, f, got);
6330
6331#define parentdc_rect_ok(t, w, r, got) \
6332 parentdc_todo_field_ok(t, w, r, left, got); \
6333 parentdc_todo_field_ok(t, w, r, top, got); \
6334 parentdc_todo_field_ok(t, w, r, right, got); \
6335 parentdc_todo_field_ok(t, w, r, bottom, got);
6336
6337#define parentdc_win_ok(t, w, got) \
6338 parentdc_rect_ok(t, w, client, got); \
6339 parentdc_rect_ok(t, w, clip, got); \
6340 parentdc_rect_ok(t, w, paint, got);
6341
6342#define parentdc_ok(t, got) \
6343 parentdc_win_ok(t, main, got); \
6344 parentdc_win_ok(t, child1, got); \
6345 parentdc_win_ok(t, child2, got);
6346
6347static void test_csparentdc(void)
6348{
6349 WNDCLASSA clsMain, cls;
6350 HWND hwndMain, hwnd1, hwnd2;
6351 BOOL ret;
6352 RECT rc;
6353
6354 struct parentdc_test test_answer;
6355
6356#define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
6357 const struct parentdc_test test1 =
6358 {
6359 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo,
6360 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6361 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6362 };
6363#ifdef __REACTOS__
6364 const struct parentdc_test test1_win8 =
6365 {
6366 {{0, 0, 166, 150}, {0, 0, 166, 150}, {0, 0, 166, 150}}, nothing_todo,
6367 {{0, 0, 40, 40}, {-20, -20, 146, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6368 {{0, 0, 40, 40}, {-40, -40, 126, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6369 };
6370#endif
6371
6372 const struct parentdc_test test2 =
6373 {
6374 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo,
6375 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
6376 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
6377 };
6378#ifdef __REACTOS__
6379 const struct parentdc_test test2_win8 =
6380 {
6381 {{0, 0, 166, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo,
6382 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
6383 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
6384 };
6385#endif
6386
6387 const struct parentdc_test test3 =
6388 {
6389 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
6390 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6391 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6392 };
6393#ifdef __REACTOS__
6394 const struct parentdc_test test3_win8 =
6395 {
6396 {{0, 0, 166, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
6397 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6398 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6399 };
6400#endif
6401
6402 const struct parentdc_test test4 =
6403 {
6404 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo,
6405 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo,
6406 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
6407 };
6408#ifdef __REACTOS__
6409 const struct parentdc_test test4_win8 =
6410 {
6411 {{0, 0, 166, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo,
6412 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo,
6413 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
6414 };
6415#endif
6416
6417 const struct parentdc_test test5 =
6418 {
6419 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo,
6420 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6421 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
6422 };
6423#ifdef __REACTOS__
6424 const struct parentdc_test test5_win8 =
6425 {
6426 {{0, 0, 166, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo,
6427 {{0, 0, 40, 40}, {-20, -20, 146, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6428 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
6429 };
6430#endif
6431
6432 const struct parentdc_test test6 =
6433 {
6434 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6435 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
6436 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6437 };
6438
6439 const struct parentdc_test test7 =
6440 {
6441 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6442 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6443 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6444 };
6445#ifdef __REACTOS__
6446 const struct parentdc_test test7_win8 =
6447 {
6448 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6449 {{0, 0, 40, 40}, {-20, -20, 146, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
6450 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
6451 };
6452#endif
6453#undef nothing_todo
6454
6455 clsMain.style = CS_DBLCLKS;
6457 clsMain.cbClsExtra = 0;
6458 clsMain.cbWndExtra = 0;
6459 clsMain.hInstance = GetModuleHandleA(0);
6460 clsMain.hIcon = 0;
6461 clsMain.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
6463 clsMain.lpszMenuName = NULL;
6464 clsMain.lpszClassName = "ParentDcMainWindowClass";
6465 ret = RegisterClassA(&clsMain);
6466 ok(ret, "Failed to register a test class.\n");
6467
6470 cls.cbClsExtra = 0;
6471 cls.cbWndExtra = 0;
6472 cls.hInstance = GetModuleHandleA(0);
6473 cls.hIcon = 0;
6476 cls.lpszMenuName = NULL;
6477 cls.lpszClassName = "ParentDcWindowClass";
6478 ret = RegisterClassA(&cls);
6479 ok(ret, "Failed to register a test class.\n");
6480
6481 SetRect(&rc, 0, 0, 150, 150);
6483 hwndMain = CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW,
6484 CW_USEDEFAULT, 0, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, 0, NULL);
6485 SetWindowLongPtrA(hwndMain, GWLP_USERDATA, (DWORD_PTR)&test_answer.main);
6486 hwnd1 = CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD,
6487 20, 20, 40, 40, hwndMain, NULL, 0, NULL);
6488 SetWindowLongPtrA(hwnd1, GWLP_USERDATA, (DWORD_PTR)&test_answer.child1);
6489 hwnd2 = CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD,
6490 40, 40, 40, 40, hwndMain, NULL, 0, NULL);
6491 SetWindowLongPtrA(hwnd2, GWLP_USERDATA, (DWORD_PTR)&test_answer.child2);
6493 ShowWindow(hwnd1, SW_SHOW);
6494 ShowWindow(hwnd2, SW_SHOW);
6496 flush_events( TRUE );
6497
6498 zero_parentdc_test(&test_answer);
6500 flush_events( TRUE );
6501#ifdef __REACTOS__
6502 /* The parentdc_ok macro breaks if/else staements without braces */
6504 parentdc_ok(test1_win8, test_answer);
6505 }
6506 else {
6507 parentdc_ok(test1, test_answer);
6508 }
6509#else
6510 parentdc_ok(test1, test_answer);
6511#endif
6512
6513 zero_parentdc_test(&test_answer);
6514 SetRect(&rc, 0, 0, 50, 50);
6516 flush_events( TRUE );
6517#ifdef __REACTOS__
6518 /* The parentdc_ok macro breaks if/else staements without braces */
6520 parentdc_ok(test2_win8, test_answer);
6521 }
6522 else {
6523 parentdc_ok(test2, test_answer);
6524 }
6525#else
6526 parentdc_ok(test2, test_answer);
6527#endif
6528
6529 zero_parentdc_test(&test_answer);
6530 SetRect(&rc, 0, 0, 10, 10);
6532 flush_events( TRUE );
6533#ifdef __REACTOS__
6534 /* The parentdc_ok macro breaks if/else staements without braces */
6536 parentdc_ok(test3_win8, test_answer);
6537 }
6538 else {
6539 parentdc_ok(test3, test_answer);
6540 }
6541#else
6542 parentdc_ok(test3, test_answer);
6543#endif
6544
6545 zero_parentdc_test(&test_answer);
6546 SetRect(&rc, 40, 40, 50, 50);
6548 flush_events( TRUE );
6549#ifdef __REACTOS__
6550 /* The parentdc_ok macro breaks if/else staements without braces */
6552 parentdc_ok(test4_win8, test_answer);
6553 }
6554 else {
6555 parentdc_ok(test4, test_answer);
6556 }
6557#else
6558 parentdc_ok(test4, test_answer);
6559#endif
6560
6561 zero_parentdc_test(&test_answer);
6562 SetRect(&rc, 20, 20, 60, 60);
6564 flush_events( TRUE );
6565#ifdef __REACTOS__
6566 /* The parentdc_ok macro breaks if/else staements without braces */
6568 parentdc_ok(test5_win8, test_answer);
6569 }
6570 else {
6571 parentdc_ok(test5, test_answer);
6572 }
6573#else
6574 parentdc_ok(test5, test_answer);
6575#endif
6576
6577 zero_parentdc_test(&test_answer);
6578 SetRect(&rc, 0, 0, 10, 10);
6579 InvalidateRect(hwnd1, &rc, TRUE);
6580 flush_events( TRUE );
6581 parentdc_ok(test6, test_answer);
6582
6583 zero_parentdc_test(&test_answer);
6584 SetRect(&rc, -5, -5, 65, 65);
6585 InvalidateRect(hwnd1, &rc, TRUE);
6586 flush_events( TRUE );
6587#ifdef __REACTOS__
6588 /* The parentdc_ok macro breaks if/else staements without braces */
6590 parentdc_ok(test7_win8, test_answer);
6591 }
6592 else {
6593 parentdc_ok(test7, test_answer);
6594 }
6595#else
6596 parentdc_ok(test7, test_answer);
6597#endif
6598
6600 DestroyWindow(hwnd1);
6601 DestroyWindow(hwnd2);
6602}
6603
6605{
6606 return DefWindowProcA(hwnd, msg, wparam, lparam);
6607}
6608
6610{
6611 return DefWindowProcW(hwnd, msg, wparam, lparam);
6612}
6613
6614static void test_IsWindowUnicode(void)
6615{
6616 static const char ansi_class_nameA[] = "ansi class name";
6617 static const WCHAR ansi_class_nameW[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
6618 static const char unicode_class_nameA[] = "unicode class name";
6619 static const WCHAR unicode_class_nameW[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
6620 WNDCLASSA classA;
6622 HWND hwnd;
6623 ATOM atom;
6624
6625 memset(&classW, 0, sizeof(classW));
6626 classW.hInstance = GetModuleHandleA(0);
6627 classW.lpfnWndProc = def_window_procW;
6628 classW.lpszClassName = unicode_class_nameW;
6630
6631 memset(&classA, 0, sizeof(classA));
6632 classA.hInstance = GetModuleHandleA(0);
6634 classA.lpszClassName = ansi_class_nameA;
6635 atom = RegisterClassA(&classA);
6636 assert(atom);
6637
6638 /* unicode class: window proc */
6639 hwnd = CreateWindowExW(0, unicode_class_nameW, NULL, WS_POPUP,
6640 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6641 assert(hwnd);
6642
6643 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6645 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6647 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6648
6650
6651 hwnd = CreateWindowExA(0, unicode_class_nameA, NULL, WS_POPUP,
6652 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6653 assert(hwnd);
6654
6655 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6657 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6659 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6660
6662
6663 /* ansi class: window proc */
6664 hwnd = CreateWindowExW(0, ansi_class_nameW, NULL, WS_POPUP,
6665 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6666 assert(hwnd);
6667
6668 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6670 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6672 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6673
6675
6676 hwnd = CreateWindowExA(0, ansi_class_nameA, NULL, WS_POPUP,
6677 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6678 assert(hwnd);
6679
6680 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6682 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6684 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6685
6687
6688 /* unicode class: class proc */
6689 hwnd = CreateWindowExW(0, unicode_class_nameW, NULL, WS_POPUP,
6690 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6691 assert(hwnd);
6692
6693 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6695 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6696 /* do not restore class window proc back to unicode */
6697
6699
6700 hwnd = CreateWindowExA(0, unicode_class_nameA, NULL, WS_POPUP,
6701 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6702 assert(hwnd);
6703
6704 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6706 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6707
6709
6710 /* ansi class: class proc */
6711 hwnd = CreateWindowExW(0, ansi_class_nameW, NULL, WS_POPUP,
6712 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6713 assert(hwnd);
6714
6715 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6717 ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
6718 /* do not restore class window proc back to ansi */
6719
6721
6722 hwnd = CreateWindowExA(0, ansi_class_nameA, NULL, WS_POPUP,
6723 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
6724 assert(hwnd);
6725
6726 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6728 ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
6729
6731}
6732
6734{
6735 MINMAXINFO *minmax;
6736
6737 if (msg != WM_GETMINMAXINFO)
6738 return DefWindowProcA(hwnd, msg, wp, lp);
6739
6740 minmax = (MINMAXINFO *)lp;
6741
6743 {
6744 minmax->ptReserved.x = 0;
6745 minmax->ptReserved.y = 0;
6746 minmax->ptMaxSize.x = 400;
6747 minmax->ptMaxSize.y = 400;
6748 minmax->ptMaxPosition.x = 300;
6749 minmax->ptMaxPosition.y = 300;
6750 minmax->ptMaxTrackSize.x = 200;
6751 minmax->ptMaxTrackSize.y = 200;
6752 minmax->ptMinTrackSize.x = 100;
6753 minmax->ptMinTrackSize.y = 100;
6754 }
6755 else
6756 DefWindowProcA(hwnd, msg, wp, lp);
6757 return 1;
6758}
6759
6762
6764{
6765 switch(msg)
6766 {
6767 case WM_GETMINMAXINFO:
6768 {
6769 RECT rect;
6770 GetWindowRect( hwnd, &rect );
6771 ok( !rect.left && !rect.top && !rect.right && !rect.bottom, "wrong rect %s\n",
6773 return DefWindowProcA(hwnd, msg, wp, lp);
6774 }
6775 case WM_NCCREATE:
6776 case WM_CREATE:
6777 {
6779 RECT rect;
6780 GetWindowRect( hwnd, &rect );
6781 ok( cs->cx == expected_cx || broken(cs->cx == (short)expected_cx),
6782 "%p msg %x wrong x size %d/%d\n", hwnd, msg, cs->cx, expected_cx );
6783 ok( cs->cy == expected_cy || broken(cs->cy == (short)expected_cy),
6784 "%p msg %x wrong y size %d/%d\n", hwnd, msg, cs->cy, expected_cy );
6785 ok( (rect.right - rect.left == expected_rect.right - expected_rect.left &&
6786 rect.bottom - rect.top == expected_rect.bottom - expected_rect.top) ||
6787 (rect.right - rect.left == min( 65535, expected_rect.right - expected_rect.left ) &&
6788 rect.bottom - rect.top == min( 65535, expected_rect.bottom - expected_rect.top )) ||
6789 broken( rect.right - rect.left == broken_rect.right - broken_rect.left &&
6790 rect.bottom - rect.top == broken_rect.bottom - broken_rect.top) ||
6791 broken( rect.right - rect.left == (short)broken_rect.right - (short)broken_rect.left &&
6792 rect.bottom - rect.top == (short)broken_rect.bottom - (short)broken_rect.top),
6793 "%p msg %x wrong rect %s / %s\n", hwnd, msg, wine_dbgstr_rect( &rect ),
6795 return DefWindowProcA(hwnd, msg, wp, lp);
6796 }
6797 case WM_NCCALCSIZE:
6798 {
6799 LRESULT ret;
6800 RECT rect, *r = (RECT *)lp;
6801 GetWindowRect( hwnd, &rect );
6802 ok( EqualRect( &rect, r ), "passed rect %s doesn't match window rect %s\n",
6804 ret = DefWindowProcA(hwnd, msg, wp, lp);
6805 ok(!ret, "got %08Ix\n", ret);
6806 return ret;
6807 }
6808 default:
6809 return DefWindowProcA(hwnd, msg, wp, lp);
6810 }
6811}
6812
6813static void test_CreateWindow(void)
6814{
6815 WNDCLASSA cls;
6816 HWND hwnd, parent;
6817 HMENU hmenu;
6818 RECT rc, rc_minmax;
6819 MINMAXINFO minmax;
6820 BOOL res;
6821 HDC hdc;
6822
6823#define expect_menu(window, menu) \
6824 SetLastError(0xdeadbeef); \
6825 res = (GetMenu(window) == (HMENU)menu); \
6826 ok(res, "GetMenu error %ld\n", GetLastError())
6827
6828#define expect_style(window, style)\
6829 ok((ULONG)GetWindowLongA(window, GWL_STYLE) == (style), "expected style %lx != %lx\n", (LONG)(style), GetWindowLongA(window, GWL_STYLE))
6830
6831#define expect_ex_style(window, ex_style)\
6832 ok((ULONG)GetWindowLongA(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %lx != %lx\n", (LONG)(ex_style), GetWindowLongA(window, GWL_EXSTYLE))
6833
6834 hmenu = CreateMenu();
6835 assert(hmenu != 0);
6837 assert(parent != 0);
6838
6839 SetLastError(0xdeadbeef);
6840 res = IsMenu(hmenu);
6841 ok(res, "IsMenu error %ld\n", GetLastError());
6842
6843 /* WS_CHILD */
6844 SetLastError(0xdeadbeef);
6846 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6847 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6848 expect_menu(hwnd, 1);
6852
6853 SetLastError(0xdeadbeef);
6855 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6856 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6857 expect_menu(hwnd, 1);
6861
6862 SetLastError(0xdeadbeef);
6863 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD,
6864 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6865 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6866 expect_menu(hwnd, 1);
6870
6871 SetLastError(0xdeadbeef);
6872 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_CAPTION,
6873 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6874 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6875 expect_menu(hwnd, 1);
6879
6880 /* WS_POPUP */
6881 SetLastError(0xdeadbeef);
6883 0, 0, 100, 100, parent, hmenu, 0, NULL);
6884 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6889 SetLastError(0xdeadbeef);
6890 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6891 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6892
6893 hmenu = CreateMenu();
6894 assert(hmenu != 0);
6895 SetLastError(0xdeadbeef);
6897 0, 0, 100, 100, parent, hmenu, 0, NULL);
6898 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6903 SetLastError(0xdeadbeef);
6904 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6905 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6906
6907 hmenu = CreateMenu();
6908 assert(hmenu != 0);
6909 SetLastError(0xdeadbeef);
6910 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
6911 0, 0, 100, 100, parent, hmenu, 0, NULL);
6912 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6917 SetLastError(0xdeadbeef);
6918 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6919 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6920
6921 hmenu = CreateMenu();
6922 assert(hmenu != 0);
6923 SetLastError(0xdeadbeef);
6924 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_CAPTION,
6925 0, 0, 100, 100, parent, hmenu, 0, NULL);
6926 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6931 SetLastError(0xdeadbeef);
6932 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6933 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6934
6935 /* WS_CHILD | WS_POPUP */
6936 SetLastError(0xdeadbeef);
6938 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6939 ok(!hwnd, "CreateWindowEx should fail\n");
6940 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6941 if (hwnd)
6943
6944 hmenu = CreateMenu();
6945 assert(hmenu != 0);
6946 SetLastError(0xdeadbeef);
6948 0, 0, 100, 100, parent, hmenu, 0, NULL);
6949 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6954 SetLastError(0xdeadbeef);
6955 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6956 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6957
6958 SetLastError(0xdeadbeef);
6960 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6961 ok(!hwnd, "CreateWindowEx should fail\n");
6962 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6963 if (hwnd)
6965
6966 hmenu = CreateMenu();
6967 assert(hmenu != 0);
6968 SetLastError(0xdeadbeef);
6970 0, 0, 100, 100, parent, hmenu, 0, NULL);
6971 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6976 SetLastError(0xdeadbeef);
6977 ok(!IsMenu(hmenu), "IsMenu should fail\n");
6978 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6979
6980 SetLastError(0xdeadbeef);
6981 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP,
6982 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
6983 ok(!hwnd, "CreateWindowEx should fail\n");
6984 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
6985 if (hwnd)
6987
6988 hmenu = CreateMenu();
6989 assert(hmenu != 0);
6990 SetLastError(0xdeadbeef);
6991 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP,
6992 0, 0, 100, 100, parent, hmenu, 0, NULL);
6993 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
6998 SetLastError(0xdeadbeef);
6999 ok(!IsMenu(hmenu), "IsMenu should fail\n");
7000 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
7001
7002 SetLastError(0xdeadbeef);
7004 0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
7005 ok(!hwnd, "CreateWindowEx should fail\n");
7006 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
7007 if (hwnd)
7009
7010 hmenu = CreateMenu();
7011 assert(hmenu != 0);
7012 SetLastError(0xdeadbeef);
7014 0, 0, 100, 100, parent, hmenu, 0, NULL);
7015 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
7020 SetLastError(0xdeadbeef);
7021 ok(!IsMenu(hmenu), "IsMenu should fail\n");
7022 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %ld\n", GetLastError());
7023
7024 /* test child window sizing */
7025 cls.style = 0;
7027 cls.cbClsExtra = 0;
7028 cls.cbWndExtra = 0;
7030 cls.hIcon = 0;
7033 cls.lpszMenuName = NULL;
7034 cls.lpszClassName = "MinMax_WndClass";
7035 RegisterClassA(&cls);
7036
7037 SetLastError(0xdeadbeef);
7038 parent = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
7039 0, 0, 100, 100, 0, 0, 0, NULL);
7040 ok(parent != 0, "CreateWindowEx error %ld\n", GetLastError());
7041 expect_menu(parent, 0);
7044
7045 memset(&minmax, 0, sizeof(minmax));
7047 SetRect(&rc_minmax, 0, 0, minmax.ptMaxSize.x, minmax.ptMaxSize.y);
7048 ok(IsRectEmpty(&rc_minmax), "ptMaxSize is not empty\n");
7049 SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
7050 ok(IsRectEmpty(&rc_minmax), "ptMaxTrackSize is not empty\n");
7051
7052 GetWindowRect(parent, &rc);
7053 ok(!IsRectEmpty(&rc), "parent window rect is empty\n");
7054 GetClientRect(parent, &rc);
7055 ok(!IsRectEmpty(&rc), "parent client rect is empty\n");
7056
7057 InflateRect(&rc, 200, 200);
7058
7059 SetLastError(0xdeadbeef);
7060 hwnd = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
7061 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
7062 parent, (HMENU)1, 0, NULL);
7063 ok(hwnd != 0, "CreateWindowEx error %ld\n", GetLastError());
7064 expect_menu(hwnd, 1);
7067
7068 memset(&minmax, 0, sizeof(minmax));
7070 SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
7071
7072 GetWindowRect(hwnd, &rc);
7073 OffsetRect(&rc, -rc.left, -rc.top);
7074 ok(EqualRect(&rc, &rc_minmax), "rects don't match: %s and %s\n", wine_dbgstr_rect(&rc),
7075 wine_dbgstr_rect(&rc_minmax));
7077
7079 cls.lpszClassName = "Sizes_WndClass";
7080 RegisterClassA(&cls);
7081
7082 expected_cx = expected_cy = 200000;
7083 SetRect( &expected_rect, 0, 0, 200000, 200000 );
7085 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 300000, 300000, 200000, 200000, parent, 0, 0, NULL);
7086 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7087 GetClientRect( hwnd, &rc );
7088 ok( rc.right == 200000 || rc.right == 65535 || broken(rc.right == (short)200000),
7089 "invalid rect right %lu\n", rc.right );
7090 ok( rc.bottom == 200000 || rc.bottom == 65535 || broken(rc.bottom == (short)200000),
7091 "invalid rect bottom %lu\n", rc.bottom );
7093
7094 expected_cx = expected_cy = -10;
7096 SetRect( &broken_rect, 0, 0, -10, -10 );
7097 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, -20, -20, -10, -10, parent, 0, 0, NULL);
7098 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7099 GetClientRect( hwnd, &rc );
7100 ok( rc.right == 0, "invalid rect right %lu\n", rc.right );
7101 ok( rc.bottom == 0, "invalid rect bottom %lu\n", rc.bottom );
7103
7104 expected_cx = expected_cy = -200000;
7106 SetRect( &broken_rect, 0, 0, -200000, -200000 );
7107 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, -300000, -300000, -200000, -200000, parent, 0, 0, NULL);
7108 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7109 GetClientRect( hwnd, &rc );
7110 ok( rc.right == 0, "invalid rect right %lu\n", rc.right );
7111 ok( rc.bottom == 0, "invalid rect bottom %lu\n", rc.bottom );
7113
7114 /* we need a parent at 0,0 so that child coordinates match */
7116 parent = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL);
7117 ok(parent != 0, "CreateWindowEx error %ld\n", GetLastError());
7118
7119 expected_cx = 100;
7120 expected_cy = 0x7fffffff;
7121 SetRect( &expected_rect, 10, 10, 110, 0x7fffffff );
7122 SetRect( &broken_rect, 10, 10, 110, 0x7fffffffU + 10 );
7123 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 10, 10, 100, 0x7fffffff, parent, 0, 0, NULL);
7124 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7125 GetClientRect( hwnd, &rc );
7126 ok( rc.right == 100, "invalid rect right %lu\n", rc.right );
7127 ok( rc.bottom == 0x7fffffff - 10 || rc.bottom ==65535 || broken(rc.bottom == 0),
7128 "invalid rect bottom %lu\n", rc.bottom );
7130
7131 expected_cx = 0x7fffffff;
7132 expected_cy = 0x7fffffff;
7133 SetRect( &expected_rect, 20, 10, 0x7fffffff, 0x7fffffff );
7134 SetRect( &broken_rect, 20, 10, 0x7fffffffU + 20, 0x7fffffffU + 10 );
7135 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 20, 10, 0x7fffffff, 0x7fffffff, parent, 0, 0, NULL);
7136 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7137 GetClientRect( hwnd, &rc );
7138 ok( rc.right == 0x7fffffff - 20 || rc.right == 65535 || broken(rc.right == 0),
7139 "invalid rect right %lu\n", rc.right );
7140 ok( rc.bottom == 0x7fffffff - 10 || rc.right == 65535 || broken(rc.bottom == 0),
7141 "invalid rect bottom %lu\n", rc.bottom );
7143
7144 /* top level window */
7145 expected_cx = expected_cy = 200000;
7147 hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_OVERLAPPEDWINDOW, 300000, 300000, 200000, 200000, 0, 0, 0, NULL);
7148 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7149 GetClientRect( hwnd, &rc );
7150 ok( rc.right <= expected_cx, "invalid rect right %lu\n", rc.right );
7151 ok( rc.bottom <= expected_cy, "invalid rect bottom %lu\n", rc.bottom );
7153
7154 /* invalid class */
7155 SetLastError(0xdeadbeef);
7156 hwnd = CreateWindowExA(0, "INVALID_CLASS", NULL, WS_CHILD, 10, 10, 100, 100, parent, 0, 0, NULL);
7157 ok(hwnd == 0, "CreateWindowEx succeeded\n");
7159 "invalid error %lu\n", GetLastError());
7161
7162 hdc = GetDC( parent );
7164 if (GetLayout( hdc ))
7165 {
7166 ReleaseDC( parent, hdc );
7168 SetLastError( 0xdeadbeef );
7170 0, 0, 100, 100, 0, 0, 0, NULL);
7171 ok( parent != 0, "creation failed err %lu\n", GetLastError());
7173 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL);
7174 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7177 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 20, 20, parent, 0, 0, NULL);
7178 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7179 expect_ex_style( hwnd, 0 );
7182 hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL);
7183 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7184 expect_ex_style( hwnd, 0 );
7186
7187 if (pGetProcessDefaultLayout && pSetProcessDefaultLayout)
7188 {
7189 DWORD layout;
7190
7191 SetLastError( 0xdeadbeef );
7192 ok( !pGetProcessDefaultLayout( NULL ), "GetProcessDefaultLayout succeeded\n" );
7193 ok( GetLastError() == ERROR_NOACCESS, "wrong error %lu\n", GetLastError() );
7194 SetLastError( 0xdeadbeef );
7195 res = pGetProcessDefaultLayout( &layout );
7196 ok( res, "GetProcessDefaultLayout failed err %lu\n", GetLastError ());
7197 ok( layout == 0, "GetProcessDefaultLayout wrong layout %lx\n", layout );
7198 SetLastError( 0xdeadbeef );
7199 res = pSetProcessDefaultLayout( 7 );
7200 ok( res, "SetProcessDefaultLayout failed err %lu\n", GetLastError ());
7201 res = pGetProcessDefaultLayout( &layout );
7202 ok( res, "GetProcessDefaultLayout failed err %lu\n", GetLastError ());
7203 ok( layout == 7, "GetProcessDefaultLayout wrong layout %lx\n", layout );
7204 SetLastError( 0xdeadbeef );
7205 res = pSetProcessDefaultLayout( LAYOUT_RTL );
7206 ok( res, "SetProcessDefaultLayout failed err %lu\n", GetLastError ());
7207 res = pGetProcessDefaultLayout( &layout );
7208 ok( res, "GetProcessDefaultLayout failed err %lu\n", GetLastError ());
7209 ok( layout == LAYOUT_RTL, "GetProcessDefaultLayout wrong layout %lx\n", layout );
7211 0, 0, 100, 100, 0, 0, 0, NULL);
7212 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7216 0, 0, 100, 100, parent, 0, 0, NULL);
7217 ok( hwnd != 0, "creation failed err %lu\n", GetLastError());
7220 pSetProcessDefaultLayout( 0 );
7221 }
7222 else win_skip( "SetProcessDefaultLayout not supported\n" );
7223 }
7224 else win_skip( "SetLayout not supported\n" );
7225
7227
7228 UnregisterClassA("MinMax_WndClass", GetModuleHandleA(NULL));
7229 UnregisterClassA("Sizes_WndClass", GetModuleHandleA(NULL));
7230
7231#undef expect_menu
7232#undef expect_style
7233#undef expect_ex_style
7234}
7235
7236/* function that remembers whether the system the test is running on sets the
7237 * last error for user32 functions to make the tests stricter */
7238static int check_error(DWORD actual, DWORD expected)
7239{
7240 static int sets_last_error = -1;
7241 if (sets_last_error == -1)
7242 sets_last_error = (actual != 0xdeadbeef);
7243 return (!sets_last_error && (actual == 0xdeadbeef)) || (actual == expected);
7244}
7245
7247{
7248#ifdef _WIN64
7249 WNDPROC wnd_proc, wnd_proc_2;
7251 HWND hwnd;
7252 LONG ret;
7253
7254 /* It's not allowed to set or get 64-bit pointer values using 32-bit functions. */
7255 hwnd = CreateWindowExA(0, "MainWindowClass", "Child window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CHILD |
7256 WS_MAXIMIZEBOX | WS_VISIBLE, 100, 100, 200, 200, hwndMain, 0, GetModuleHandleA(NULL), NULL);
7257 ok(hwnd != NULL, "Failed to create test window.\n");
7258
7259 /* GWLP_WNDPROC */
7260 SetLastError(0xdeadbeef);
7262 ok(!wnd_proc && GetLastError() == ERROR_INVALID_INDEX, "Unexpected window proc.\n");
7263
7265 ok(!!wnd_proc, "Unexpected window proc.\n");
7266
7267 SetLastError(0xdeadbeef);
7268 wnd_proc_2 = (WNDPROC)(LONG_PTR)SetWindowLongA(hwnd, GWLP_WNDPROC, 0xdeadbeef);
7269 ok(!wnd_proc_2 && GetLastError() == ERROR_INVALID_INDEX, "Unexpected window proc.\n");
7270
7272 ok(wnd_proc_2 == wnd_proc, "Unexpected window proc.\n");
7273
7274 SetLastError(0xdeadbeef);
7276 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected return value.\n");
7277
7278 /* GWLP_USERDATA */
7279 SetWindowLongPtrA(hwnd, GWLP_USERDATA, ((LONG_PTR)1 << 32) | 123);
7281 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7283 ok(retval > 123, "Unexpected user data.\n");
7285 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7287 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7289 ok(ret == 124, "Unexpected user data %#lx.\n", ret);
7291 ok(retval == 124, "Unexpected user data.\n");
7292
7293 SetWindowLongA(hwnd, GWLP_USERDATA, (1 << 16) | 123);
7295 ok(ret == ((1 << 16) | 123), "Unexpected user data %#lx.\n", ret);
7297 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7298
7300 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7302 ok(ret == ((1 << 16) | 124), "Unexpected user data %#lx.\n", ret);
7304 ok(ret == 124, "Unexpected user data %#lx.\n", ret);
7305
7306 /* GWLP_ID */
7308 ok(!ret, "Unexpected id %#lx.\n", ret);
7309
7311 ok(ret == 1, "Unexpected id %#lx.\n", ret);
7312
7314 ok(ret == 1, "Unexpected id %#lx.\n", ret);
7315
7316 SetWindowLongPtrA(hwnd, GWLP_ID, ((LONG_PTR)1 << 32) | 123);
7318 ok(ret == 123, "Unexpected id %#lx.\n", ret);
7320 ok(ret == 123, "Unexpected id %#lx.\n", ret);
7322 ok(retval > 123, "Unexpected id.\n");
7323 SetLastError(0xdeadbeef);
7325 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected id %#lx.\n", ret);
7326
7327 /* GWLP_HINSTANCE */
7329 ok(retval == (LONG_PTR)GetModuleHandleA(NULL), "Unexpected instance %#Ix.\n", retval);
7330
7331 SetLastError(0xdeadbeef);
7333 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7334
7335 SetLastError(0xdeadbeef);
7337 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7338
7339 SetLastError(0xdeadbeef);
7341 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7342
7343 SetLastError(0xdeadbeef);
7345 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7346
7347 SetLastError(0xdeadbeef);
7349 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7350
7351 /* GWLP_HWNDPARENT */
7352 SetLastError(0xdeadbeef);
7354 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
7355
7356 SetLastError(0xdeadbeef);
7358 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
7359
7360 SetLastError(0xdeadbeef);
7362 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
7363
7364 SetLastError(0xdeadbeef);
7366 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
7367
7369#endif
7370}
7371
7373{
7374 WNDPROC wnd_proc, wnd_proc_2;
7376 HWND hwnd;
7377 LONG ret;
7378
7379 /* It's not allowed to set or get 64-bit pointer values using 32-bit functions. */
7380 hwnd = CreateWindowExA(0, "MainWindowClass", "Child window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CHILD |
7381 WS_MAXIMIZEBOX | WS_VISIBLE, 100, 100, 200, 200, hwndMain, 0, GetModuleHandleA(NULL), NULL);
7382 ok(hwnd != NULL, "Failed to create test window.\n");
7383
7384 /* GWLP_WNDPROC */
7386 ok(!!wnd_proc, "Unexpected window proc.\n");
7387
7388 SetLastError(0xdeadbeef);
7390 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected window proc.\n");
7391
7392 SetLastError(0xdeadbeef);
7393 ret = SetWindowWord(hwnd, GWLP_WNDPROC, 0xbeef);
7394 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected window proc.\n");
7395
7397 ok(wnd_proc_2 == wnd_proc, "Unexpected window proc.\n");
7398
7399 /* GWLP_USERDATA */
7400 ret = SetWindowLongA(hwnd, GWLP_USERDATA, (1 << 16) | 123);
7401 ok(!ret, "Unexpected user data %#lx.\n", ret);
7403 ok(ret > 123, "Unexpected user data %#lx.\n", ret);
7405 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7407 ok(ret == 123, "Unexpected user data %#lx.\n", ret);
7409 ok(ret == 124, "Unexpected user data %#lx.\n", ret);
7411 ok(ret == ((1 << 16) | 124), "Unexpected user data %#lx.\n", ret);
7412
7413 /* GWLP_ID */
7415 ok(!ret, "Unexpected id %#lx.\n", ret);
7417 ok(ret == 1, "Unexpected id %#lx.\n", ret);
7418
7419 SetLastError(0xdeadbeef);
7421 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected id %#lx.\n", ret);
7422 SetLastError(0xdeadbeef);
7424 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected id %#lx.\n", ret);
7425
7426 /* GWLP_HINSTANCE */
7428 ok(retval == (LONG_PTR)GetModuleHandleA(NULL), "Unexpected instance %#Ix.\n", retval);
7429
7430 SetLastError(0xdeadbeef);
7432 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7433
7434 SetLastError(0xdeadbeef);
7436 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected instance %#lx.\n", ret);
7437
7438 /* GWLP_HWNDPARENT */
7440 ok(!!retval, "Unexpected parent window %#lx.\n", ret);
7441
7442 SetLastError(0xdeadbeef);
7444 ok(!ret && GetLastError() == ERROR_INVALID_INDEX, "Unexpected parent window %#lx.\n", ret);
7445
7447}
7448
7449static void test_SetWindowLong(void)
7450{
7452 WNDPROC old_window_procW;
7453
7454 SetLastError(0xdeadbeef);
7456 ok(!retval, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%Ix\n", retval);
7458 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %ld\n", GetLastError());
7459
7460 SetLastError(0xdeadbeef);
7461 retval = SetWindowLongPtrA(hwndMain, 0xdeadbeef, 0);
7462 ok(!retval, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%Ix\n", retval);
7464 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %ld\n", GetLastError());
7465
7466 SetLastError(0xdeadbeef);
7469 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%Ix\n", retval);
7470 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %ld\n", GetLastError());
7473 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%Ix\n", retval);
7474 ok(!IsWindowUnicode(hwndMain), "hwndMain shouldn't be Unicode\n");
7475
7476 old_window_procW = (WNDPROC)GetWindowLongPtrW(hwndMain, GWLP_WNDPROC);
7477 SetLastError(0xdeadbeef);
7480 {
7481 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %ld\n", GetLastError());
7482 ok(retval != 0, "SetWindowLongPtr error %ld\n", GetLastError());
7483 ok((WNDPROC)retval == old_window_procW,
7484 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%Ix\n", retval);
7485 ok(IsWindowUnicode(hwndMain), "hwndMain should now be Unicode\n");
7486
7487 /* Make sure nothing changes if we set the same proc */
7488 retval = SetWindowLongPtrW(hwndMain, GWLP_WNDPROC, (LONG_PTR)old_window_procW);
7489 todo_wine
7490 ok((WNDPROC)retval == main_window_procA, "unexpected proc 0x%Ix\n", retval);
7492 ok((WNDPROC)retval == old_window_procW, "unexpected proc 0x%Ix\n", retval);
7494 ok((WNDPROC)retval == main_window_procA, "unexpected proc 0x%Ix\n", retval);
7495
7496 /* set it back to ANSI */
7498 }
7499
7502}
7503
7505{
7507 const STYLESTRUCT *got = (STYLESTRUCT *)lParam;
7508
7509 if (message == WM_STYLECHANGING && wParam == GWL_STYLE)
7510 {
7511 ok(got->styleOld == expected[0].styleOld, "expected old style %#lx, got %#lx\n",
7512 expected[0].styleOld, got->styleOld);
7513 ok(got->styleNew == expected[0].styleNew, "expected new style %#lx, got %#lx\n",
7514 expected[0].styleNew, got->styleNew);
7515 }
7516 else if (message == WM_STYLECHANGED && wParam == GWL_STYLE)
7517 {
7518 ok(got->styleOld == expected[1].styleOld, "expected old style %#lx, got %#lx\n",
7519 expected[1].styleOld, got->styleOld);
7520 ok(got->styleNew == expected[1].styleNew, "expected new style %#lx, got %#lx\n",
7521 expected[1].styleNew, got->styleNew);
7522 }
7523
7525}
7526
7527static void test_set_window_style(void)
7528{
7529 LONG expected_style, new_style, old_style;
7530 STYLESTRUCT expected_stylestruct[2];
7531 unsigned int i;
7532 WNDCLASSA cls;
7533 HWND hwnd;
7534
7535 static const struct
7536 {
7537 LONG creation_style;
7538 LONG style;
7539 }
7540 tests[] =
7541 {
7558 };
7559
7560 memset(&cls, 0, sizeof(cls));
7562 cls.hInstance = GetModuleHandleA(0);
7563 cls.lpszClassName = "TestSetWindowStylesClass";
7564 ok(RegisterClassA(&cls), "RegisterClass failed\n");
7565
7566 for (i = 0; i < ARRAY_SIZE(tests); i++)
7567 {
7568 expected_style = tests[i].style;
7569 if (tests[i].creation_style & WS_MINIMIZE)
7570 expected_style |= WS_MINIMIZE;
7571
7572 expected_stylestruct[0].styleOld = tests[i].creation_style;
7573 expected_stylestruct[0].styleNew = tests[i].style;
7574 expected_stylestruct[1].styleOld = tests[i].creation_style;
7575 expected_stylestruct[1].styleNew = expected_style;
7576
7577 hwnd = CreateWindowA(cls.lpszClassName, "Test set styles",
7578 tests[i].creation_style, 100, 100, 200, 200, 0, 0, 0, NULL);
7579 ok(hwnd != 0, "CreateWindow failed\n");
7580 SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)&expected_stylestruct);
7581
7582 old_style = SetWindowLongA(hwnd, GWL_STYLE, tests[i].style);
7583 ok(old_style == tests[i].creation_style, "expected old style %#lx, got %#lx\n",
7584 tests[i].creation_style, old_style);
7585 new_style = GetWindowLongA(hwnd, GWL_STYLE);
7586 ok(new_style == expected_style, "expected new style %#lx, got %#lx\n",
7587 expected_style, new_style);
7588
7591 }
7592
7594}
7595
7596static void test_ShowWindow(void)
7597{
7598 HWND hwnd;
7599 DWORD style;
7600 RECT rcMain, rc, rcMinimized, rcClient, rcEmpty, rcMaximized, rcResized, rcNonClient, rcBroken;
7601 LPARAM ret;
7602 MONITORINFO mon_info;
7603 unsigned int i;
7604
7605 DWORD test_style[] =
7606 {
7617 };
7618
7619 SetRect(&rcClient, 0, 0, 90, 90);
7620 rcMain = rcClient;
7621 OffsetRect(&rcMain, 120, 120);
7622 AdjustWindowRect(&rcMain, WS_CAPTION, 0);
7623 SetRect(&rcMinimized, -32000, -32000, -32000 + GetSystemMetrics(SM_CXMINIMIZED),
7625 SetRectEmpty(&rcEmpty);
7626
7627 hwnd = CreateWindowExA(0, "MainWindowClass", NULL,
7630 rcMain.left, rcMain.top,
7631 rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
7632 0, 0, 0, NULL);
7633 assert(hwnd);
7634
7635 mon_info.cbSize = sizeof(mon_info);
7636 GetMonitorInfoW(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &mon_info);
7637 rcMaximized = mon_info.rcWork;
7640
7642 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7643 ok(!(style & WS_VISIBLE), "window should not be visible\n");
7644 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7645 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7646 GetWindowRect(hwnd, &rc);
7647 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7648 wine_dbgstr_rect(&rc));
7649 GetClientRect(hwnd, &rc);
7650 ok(EqualRect(&rcClient, &rc), "expected %s, got %s\n",
7651 wine_dbgstr_rect(&rcClient), wine_dbgstr_rect(&rc));
7652
7654 ok(!ret, "not expected ret: %Iu\n", ret);
7656 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7657 ok(style & WS_VISIBLE, "window should be visible\n");
7658 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7659 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7660 GetWindowRect(hwnd, &rc);
7661 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7662 wine_dbgstr_rect(&rc));
7663 GetClientRect(hwnd, &rc);
7664 ok(EqualRect(&rcClient, &rc), "expected %s, got %s\n",
7665 wine_dbgstr_rect(&rcClient), wine_dbgstr_rect(&rc));
7666
7668 ok(ret, "not expected ret: %Iu\n", ret);
7670 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7671 ok(style & WS_VISIBLE, "window should be visible\n");
7672 ok(style & WS_MINIMIZE, "window should be minimized\n");
7673 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7674 GetWindowRect(hwnd, &rc);
7675 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7676 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7677 GetClientRect(hwnd, &rc);
7678 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7679 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7680 /* shouldn't be able to resize minimized windows */
7681 ret = SetWindowPos(hwnd, 0, 0, 0,
7682 (rcMinimized.right - rcMinimized.left) * 2,
7683 (rcMinimized.bottom - rcMinimized.top) * 2,
7685 ok(ret, "not expected ret: %Iu\n", ret);
7686 GetWindowRect(hwnd, &rc);
7687 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7688 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7689 GetClientRect(hwnd, &rc);
7690 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7691 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7692 /* SetWindowPos shouldn't affect the client rect */
7693 ret = SetWindowPos(hwnd, 0, 0, 0, 0, 0,
7695 ok(ret, "not expected ret: %Iu\n", ret);
7696 GetWindowRect(hwnd, &rc);
7697 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7698 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7699 GetClientRect(hwnd, &rc);
7700 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7701 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7702 /* test NC area */
7703 GetWindowRect(hwnd, &rc);
7704 SetRect(&rcNonClient, rc.left, rc.top, rc.left, rc.top);
7706 ok(!ret, "got %08Ix\n", ret);
7707 ok(EqualRect(&rc, &rcNonClient), "expected %s, got %s\n",
7708 wine_dbgstr_rect(&rcNonClient), wine_dbgstr_rect(&rc));
7709
7711 ok(ret, "not expected ret: %Iu\n", ret);
7713 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7714 ok(style & WS_VISIBLE, "window should be visible\n");
7715 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7716 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7717 GetWindowRect(hwnd, &rc);
7718 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7719 wine_dbgstr_rect(&rc));
7720 GetClientRect(hwnd, &rc);
7721 ok(EqualRect(&rcClient, &rc), "expected %s, got %s\n",
7722 wine_dbgstr_rect(&rcClient), wine_dbgstr_rect(&rc));
7723
7725 ok(ret, "not expected ret: %Iu\n", ret);
7727 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7728 ok(style & WS_VISIBLE, "window should be visible\n");
7729 ok(!(style & WS_MINIMIZE), "window should be minimized\n");
7730 ok(style & WS_MAXIMIZE, "window should not be maximized\n");
7731 GetWindowRect(hwnd, &rc);
7732 ok(EqualRect(&rcMaximized, &rc), "expected %s, got %s\n",
7733 wine_dbgstr_rect(&rcMaximized), wine_dbgstr_rect(&rc));
7734 /* maximized windows can be resized */
7735 ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER);
7736 ok(ret, "not expected ret: %Iu\n", ret);
7737 SetRect(&rcResized, 300, 300, 500, 500);
7738 GetWindowRect(hwnd, &rc);
7739 ok(EqualRect(&rcResized, &rc), "expected %s, got %s\n",
7740 wine_dbgstr_rect(&rcResized), wine_dbgstr_rect(&rc));
7741
7743 ok(ret, "not expected ret: %Iu\n", ret);
7745 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7746 ok(style & WS_VISIBLE, "window should be visible\n");
7747 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7748 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7749 GetWindowRect(hwnd, &rc);
7750 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7751 wine_dbgstr_rect(&rc));
7752
7754 ok(!ret, "not expected ret: %Iu\n", ret);
7756 ok(style & WS_DISABLED, "window should be disabled\n");
7757
7759 ok(!ret, "not expected ret: %Iu\n", ret);
7761 ok(style & WS_DISABLED, "window should be disabled\n");
7762 ok(style & WS_VISIBLE, "window should be visible\n");
7763 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7764 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7765 GetWindowRect(hwnd, &rc);
7766 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7767 wine_dbgstr_rect(&rc));
7768 GetClientRect(hwnd, &rc);
7769 ok(EqualRect(&rcClient, &rc), "expected %s, got %s\n",
7770 wine_dbgstr_rect(&rcClient), wine_dbgstr_rect(&rc));
7771
7773 ok(!ret, "not expected ret: %Iu\n", ret);
7775 ok(style & WS_DISABLED, "window should be disabled\n");
7776 ok(style & WS_VISIBLE, "window should be visible\n");
7777 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7778 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7779 GetWindowRect(hwnd, &rc);
7780 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7781 wine_dbgstr_rect(&rc));
7782 GetClientRect(hwnd, &rc);
7783 ok(EqualRect(&rcClient, &rc), "expected %s, got %s\n",
7784 wine_dbgstr_rect(&rcClient), wine_dbgstr_rect(&rc));
7785
7787 ok(ret, "not expected ret: %Iu\n", ret);
7789 ok(style & WS_DISABLED, "window should be disabled\n");
7790 ok(style & WS_VISIBLE, "window should be visible\n");
7791 ok(style & WS_MINIMIZE, "window should be minimized\n");
7792 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7793 GetWindowRect(hwnd, &rc);
7794 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7795 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7796 GetClientRect(hwnd, &rc);
7797 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7798 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7799
7801 ok(!ret, "not expected ret: %Iu\n", ret);
7803 ok(style & WS_DISABLED, "window should be disabled\n");
7804 ok(style & WS_VISIBLE, "window should be visible\n");
7805 ok(style & WS_MINIMIZE, "window should be minimized\n");
7806 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7807 GetWindowRect(hwnd, &rc);
7808 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7809 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7810 GetClientRect(hwnd, &rc);
7811 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7812 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7813
7815 ok(ret, "not expected ret: %Iu\n", ret);
7817 ok(style & WS_DISABLED, "window should be disabled\n");
7818 ok(style & WS_VISIBLE, "window should be visible\n");
7819 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7820 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7821 GetWindowRect(hwnd, &rc);
7822 ok(EqualRect(&rcMain, &rc), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain),
7823 wine_dbgstr_rect(&rc));
7824 GetClientRect(hwnd, &rc);
7825 ok(EqualRect(&rcClient, &rc), "expected %s, got %s\n",
7826 wine_dbgstr_rect(&rcClient), wine_dbgstr_rect(&rc));
7827
7829 ok(!ret, "not expected ret: %Iu\n", ret);
7830 ok(IsWindow(hwnd), "window should exist\n");
7831
7833 ok(ret, "not expected ret: %Iu\n", ret);
7834
7836 ok(!ret, "not expected ret: %Iu\n", ret);
7837 ok(!IsWindow(hwnd), "window should not exist\n");
7838
7839 hwnd = CreateWindowExA(0, "MainWindowClass", NULL,
7842 rcMain.left, rcMain.top,
7843 rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
7844 0, 0, 0, NULL);
7845 ok(hwnd != NULL, "failed to create window with error %lu\n", GetLastError());
7847 ok(style & WS_MINIMIZE, "window should be minimized\n");
7848 GetWindowRect(hwnd, &rc);
7849 todo_wine
7850 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7851 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7852 GetClientRect(hwnd, &rc);
7853 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7854 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7856
7857 hwnd = CreateWindowExA(0, "MainWindowClass", NULL,
7860 rcMain.left, rcMain.top,
7861 rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
7862 0, 0, 0, NULL);
7863 ok(hwnd != NULL, "failed to create window with error %lu\n", GetLastError());
7865 ok(style & WS_MINIMIZE, "window should be minimized\n");
7866 GetWindowRect(hwnd, &rc);
7867 ok(EqualRect(&rcMinimized, &rc), "expected %s, got %s\n",
7868 wine_dbgstr_rect(&rcMinimized), wine_dbgstr_rect(&rc));
7869 GetClientRect(hwnd, &rc);
7870 ok(EqualRect(&rcEmpty, &rc), "expected %s, got %s\n",
7871 wine_dbgstr_rect(&rcEmpty), wine_dbgstr_rect(&rc));
7873
7875
7876 /* test maximize and restore windows without setting WS_CAPTION */
7877
7878 for (i = 0; i < ARRAY_SIZE(test_style); ++i)
7879 {
7880 SetRect(&rcMain, 0, 0, 90, 90);
7881 OffsetRect(&rcMain, 120, 120);
7882 hwnd = CreateWindowExA(0, "MainWindowClass", NULL, test_style[i],
7883 rcMain.left, rcMain.top,
7884 rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
7885 0, 0, 0, NULL);
7886 ok(hwnd != NULL, "Test %u: failed to create window with error %lu\n", i, GetLastError());
7887
7888 GetWindowRect(hwnd, &rcMain);
7889 ok(rcMain.left > mon_info.rcMonitor.left &&
7890 rcMain.right < mon_info.rcMonitor.right &&
7891 rcMain.top > mon_info.rcMonitor.top &&
7892 rcMain.bottom < mon_info.rcMonitor.bottom,
7893 "Test %u: window should not be fullscreen\n", i);
7894
7895 rcMaximized = (test_style[i] & WS_MAXIMIZEBOX) ? mon_info.rcWork : mon_info.rcMonitor;
7896 AdjustWindowRectEx(&rcMaximized, GetWindowLongA(hwnd, GWL_STYLE) & ~WS_BORDER,
7898
7900 ok(ret, "unexpected ret: %Iu\n", ret);
7902 ok(style & WS_MAXIMIZE, "Test %u: window should be maximized\n", i);
7903 GetWindowRect(hwnd, &rc);
7904
7905 rcBroken = rcMaximized;
7906 if (test_style[i] & WS_THICKFRAME)
7907 {
7908 InflateRect(&rcBroken, -2, -2);
7909 OffsetRect(&rcBroken, -2, -2);
7910 }
7911
7912 ok(EqualRect(&rcMaximized, &rc) || broken(EqualRect(&rcBroken, &rc)),
7913 "Test %u: expected %s, got %s\n", i, wine_dbgstr_rect(&rcMaximized),
7914 wine_dbgstr_rect(&rc));
7915
7917 ok(ret, "unexpected ret: %Iu\n", ret);
7919 ok(!(style & WS_MAXIMIZE), "Test %u: window should not be maximized\n", i);
7920 GetWindowRect(hwnd, &rc);
7921 ok(EqualRect(&rcMain, &rc), "Test %u: expected %s, got %s\n",
7922 i, wine_dbgstr_rect(&rcMain), wine_dbgstr_rect(&rc));
7923
7925
7927 }
7928}
7929
7931{
7932 MONITORINFO mon_info = {sizeof(mon_info)};
7933 RECT rect, orig, expect, nc;
7934 LPARAM ret;
7935 HWND hwnd, hwnd2;
7936 LONG style;
7937
7938 GetMonitorInfoW(MonitorFromWindow(hwndMain, MONITOR_DEFAULTTOPRIMARY), &mon_info);
7939 SetRect(&orig, 20, 20, 210, 110);
7940 hwnd = CreateWindowA("MainWindowClass", "owned", WS_CAPTION | WS_SYSMENU |
7942 orig.left, orig.top, orig.right - orig.left,
7943 orig.bottom - orig.top, hwndMain, 0, 0, NULL);
7944 ok(!!hwnd, "failed to create window, error %lu\n", GetLastError());
7945 hwnd2 = CreateWindowA("MainWindowClass", "owned2", WS_CAPTION | WS_SYSMENU |
7947 orig.left, orig.top, orig.right - orig.left,
7948 orig.bottom - orig.top, hwndMain, 0, 0, NULL);
7949 ok(!!hwnd2, "failed to create window, error %lu\n", GetLastError());
7950
7952 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7953 ok(!(style & WS_VISIBLE), "window should not be visible\n");
7954 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7955 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7957 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
7959
7961 ok(!ret, "wrong ret %Iu\n", ret);
7963 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7964 ok(style & WS_VISIBLE, "window should be visible\n");
7965 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
7966 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7968 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
7970
7972 ok(ret, "wrong ret %Iu\n", ret);
7974 ok(!(style & WS_DISABLED), "window should not be disabled\n");
7975 ok(style & WS_VISIBLE, "window should be visible\n");
7976 ok(style & WS_MINIMIZE, "window should be minimized\n");
7977 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
7981 todo_wine
7982 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
7984 /* shouldn't be able to resize minimized windows */
7985 ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
7986 ok(ret, "wrong ret %Iu\n", ret);
7988 todo_wine
7989 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
7991 /* test NC area */
7993 SetRect(&nc, rect.left, rect.top, rect.left, rect.top);
7995 ok(!ret, "got %08Ix\n", ret);
7996 ok(EqualRect(&rect, &nc), "expected %s, got %s\n",
7998
7999 /* multiple minimized owned windows stack next to each other (and eventually
8000 * on top of each other) */
8002 ret = ShowWindow(hwnd2, SW_MINIMIZE);
8003 ok(ret, "wrong ret %Iu\n", ret);
8004 style = GetWindowLongA(hwnd2, GWL_STYLE);
8005 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8006 ok(style & WS_VISIBLE, "window should be visible\n");
8007 ok(style & WS_MINIMIZE, "window should be minimized\n");
8008 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8009 GetWindowRect(hwnd2, &rect);
8010 todo_wine
8011 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8013
8015 ok(ret, "wrong ret %Iu\n", ret);
8017 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8018 ok(style & WS_VISIBLE, "window should be visible\n");
8019 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8020 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8022 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8024
8026 ok(ret, "wrong ret %Iu\n", ret);
8028 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8029 ok(style & WS_VISIBLE, "window should be visible\n");
8030 ok(!(style & WS_MINIMIZE), "window should be minimized\n");
8031 ok(style & WS_MAXIMIZE, "window should not be maximized\n");
8033 expect = mon_info.rcWork;
8036 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8038 /* maximized windows can be resized */
8039 ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER);
8040 ok(ret, "wrong ret %Iu\n", ret);
8042 SetRect(&expect, 300, 300, 500, 500);
8043 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8045
8047 ok(ret, "wrong ret %Iu\n", ret);
8049 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8050 ok(style & WS_VISIBLE, "window should be visible\n");
8051 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8052 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8054 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8056
8057 DestroyWindow(hwnd2);
8059}
8060
8062{
8063 RECT rect, orig, expect, nc;
8064 LPARAM ret;
8065 HWND hwnd, hwnd2;
8066 LONG style;
8067 POINT pt = {0};
8068
8069 SetRect(&orig, 20, 20, 210, 110);
8070 hwnd = CreateWindowA("MainWindowClass", "child", WS_CAPTION | WS_SYSMENU |
8072 orig.left, orig.top, orig.right - orig.left,
8073 orig.bottom - orig.top, hwndMain, 0, 0, NULL);
8074 ok(!!hwnd, "failed to create window, error %lu\n", GetLastError());
8075 hwnd2 = CreateWindowA("MainWindowClass", "child2", WS_CAPTION | WS_SYSMENU |
8077 orig.left, orig.top, orig.right - orig.left,
8078 orig.bottom - orig.top, hwndMain, 0, 0, NULL);
8079 ok(!!hwnd2, "failed to create window, error %lu\n", GetLastError());
8080
8082 OffsetRect(&orig, pt.x, pt.y);
8083
8085 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8086 ok(!(style & WS_VISIBLE), "window should not be visible\n");
8087 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8088 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8090 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8092
8094 ok(!ret, "wrong ret %Iu\n", ret);
8096 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8097 ok(style & WS_VISIBLE, "window should be visible\n");
8098 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8099 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8101 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8103
8105 ok(ret, "wrong ret %Iu\n", ret);
8107 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8108 ok(style & WS_VISIBLE, "window should be visible\n");
8109 ok(style & WS_MINIMIZE, "window should be minimized\n");
8110 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8115 OffsetRect(&expect, pt.x, pt.y);
8116 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8118 /* shouldn't be able to resize minimized windows */
8119 ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
8120 ok(ret, "wrong ret %Iu\n", ret);
8122 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8124 /* test NC area */
8126 SetRect(&nc, rect.left, rect.top, rect.left, rect.top);
8128 ok(!ret, "got %08Ix\n", ret);
8129 ok(EqualRect(&rect, &nc), "expected %s, got %s\n",
8131
8132 /* multiple minimized children also stack; here the parent is too small to
8133 * fit more than one per row */
8135 ret = ShowWindow(hwnd2, SW_MINIMIZE);
8136 ok(ret, "wrong ret %Iu\n", ret);
8137 style = GetWindowLongA(hwnd2, GWL_STYLE);
8138 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8139 ok(style & WS_VISIBLE, "window should be visible\n");
8140 ok(style & WS_MINIMIZE, "window should be minimized\n");
8141 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8142 GetWindowRect(hwnd2, &rect);
8143 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8145
8147 ok(ret, "wrong ret %Iu\n", ret);
8149 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8150 ok(style & WS_VISIBLE, "window should be visible\n");
8151 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8152 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8154 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8156
8158 ok(ret, "wrong ret %Iu\n", ret);
8160 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8161 ok(style & WS_VISIBLE, "window should be visible\n");
8162 ok(!(style & WS_MINIMIZE), "window should be minimized\n");
8163 ok(style & WS_MAXIMIZE, "window should not be maximized\n");
8168 OffsetRect(&expect, pt.x, pt.y);
8169 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8171 /* maximized windows can be resized */
8172 ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER);
8173 ok(ret, "wrong ret %Iu\n", ret);
8175 SetRect(&expect, 300, 300, 500, 500);
8176 OffsetRect(&expect, pt.x, pt.y);
8177 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8179
8181 ok(ret, "wrong ret %Iu\n", ret);
8183 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8184 ok(style & WS_VISIBLE, "window should be visible\n");
8185 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8186 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8188 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8190
8191 DestroyWindow(hwnd2);
8193}
8194
8196{
8197 RECT rect, orig, expect, nc;
8198 LPARAM ret;
8199 HWND mdiclient, hwnd, hwnd2;
8200 LONG style;
8201 POINT pt = {0};
8202 CLIENTCREATESTRUCT mdi_client_cs = {0,1};
8203
8204 SetRect(&orig, 20, 20, 210, 110);
8206 mdiclient = CreateWindowA("mdiclient", "MDI client", WS_CHILD,
8207 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
8208 hwndMain, 0, 0, &mdi_client_cs);
8209 ok(!!mdiclient, "failed to create window, error %lu\n", GetLastError());
8210 hwnd = CreateWindowExA(WS_EX_MDICHILD, "MainWindowClass", "MDI child",
8212 orig.left, orig.top, orig.right - orig.left,
8213 orig.bottom - orig.top, mdiclient, 0, 0, NULL);
8214 ok(!!hwnd, "failed to create window, error %lu\n", GetLastError());
8215 hwnd2 = CreateWindowExA(WS_EX_MDICHILD, "MainWindowClass", "MDI child 2",
8217 orig.left, orig.top, orig.right - orig.left,
8218 orig.bottom - orig.top, mdiclient, 0, 0, NULL);
8219 ok(!!hwnd2, "failed to create window, error %lu\n", GetLastError());
8220
8222 OffsetRect(&orig, pt.x, pt.y);
8223
8225 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8226 ok(style & WS_VISIBLE, "window should not be visible\n");
8227 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8228 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8230 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8232
8234 ok(ret, "wrong ret %Iu\n", ret);
8236 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8237 ok(style & WS_VISIBLE, "window should be visible\n");
8238 ok(style & WS_MINIMIZE, "window should be minimized\n");
8239 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8244 OffsetRect(&expect, pt.x, pt.y);
8245 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8247 /* shouldn't be able to resize minimized windows */
8248 ret = SetWindowPos(hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
8249 ok(ret, "wrong ret %Iu\n", ret);
8251 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8253 /* test NC area */
8255 SetRect(&nc, rect.left, rect.top, rect.left, rect.top);
8257 ok(!ret, "got %08Ix\n", ret);
8258 ok(EqualRect(&rect, &nc), "expected %s, got %s\n",
8260
8261 /* multiple minimized children also stack; here the parent is too small to
8262 * fit more than one per row */
8264 ret = ShowWindow(hwnd2, SW_MINIMIZE);
8265 ok(ret, "wrong ret %Iu\n", ret);
8266 style = GetWindowLongA(hwnd2, GWL_STYLE);
8267 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8268 ok(style & WS_VISIBLE, "window should be visible\n");
8269 ok(style & WS_MINIMIZE, "window should be minimized\n");
8270 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8271 GetWindowRect(hwnd2, &rect);
8272 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8274
8276 ok(ret, "wrong ret %Iu\n", ret);
8278 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8279 ok(style & WS_VISIBLE, "window should be visible\n");
8280 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8281 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8283 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8285
8287 ok(ret, "wrong ret %Iu\n", ret);
8289 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8290 ok(style & WS_VISIBLE, "window should be visible\n");
8291 ok(!(style & WS_MINIMIZE), "window should be minimized\n");
8292 ok(style & WS_MAXIMIZE, "window should not be maximized\n");
8297 OffsetRect(&expect, pt.x, pt.y);
8298 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8300 /* maximized windows can be resized */
8301 ret = SetWindowPos(hwnd, 0, 300, 300, 200, 200, SWP_NOACTIVATE | SWP_NOZORDER);
8302 ok(ret, "wrong ret %Iu\n", ret);
8304 SetRect(&expect, 300, 300, 500, 500);
8305 OffsetRect(&expect, pt.x, pt.y);
8306 ok(EqualRect(&expect, &rect), "expected %s, got %s\n",
8308
8310 ok(ret, "wrong ret %Iu\n", ret);
8312 ok(!(style & WS_DISABLED), "window should not be disabled\n");
8313 ok(style & WS_VISIBLE, "window should be visible\n");
8314 ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
8315 ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
8317 ok(EqualRect(&orig, &rect), "expected %s, got %s\n",
8319
8320 DestroyWindow(hwnd2);
8322 DestroyWindow(mdiclient);
8323}
8324
8326{
8327 HWND hwnd = arg;
8329 return 0;
8330}
8331
8333{
8334 if (msg == WM_CANCELMODE)
8335 return 0;
8336 return DefWindowProcA(hwnd, msg, wParam, lParam);
8337}
8338
8339static void test_EnableWindow(void)
8340{
8341 WNDCLASSA cls;
8342 HWND hwnd;
8343 HANDLE hthread;
8344 DWORD tid;
8345 MSG msg;
8346
8347 hwnd = CreateWindowExA(0, "MainWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8349 0, 0, 0, NULL);
8350 assert(hwnd);
8351 flush_events( TRUE );
8352 ok(IsWindowEnabled(hwnd), "window should be enabled\n");
8353 SetFocus(hwnd);
8355
8357 check_wnd_state(hwnd, hwnd, 0, 0);
8358 ok(!IsWindowEnabled(hwnd), "window should not be enabled\n");
8359
8360 SetFocus(hwnd);
8363
8365 SetFocus(hwnd);
8367 ok(IsWindowEnabled(hwnd), "window should be enabled\n");
8368
8369 /* test disabling from thread */
8370 hthread = CreateThread(NULL, 0, enablewindow_thread, hwnd, 0, &tid);
8371
8373 {
8374 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE))
8376 }
8377
8378 ok(!IsWindowEnabled(hwnd), "window should not be enabled\n");
8380 ok(0 == GetCapture(), "GetCapture() = %p\n", GetCapture());
8381
8382 CloseHandle(hthread);
8384
8385 /* test preventing release of capture */
8386 memset(&cls, 0, sizeof(cls));
8388 cls.hInstance = GetModuleHandleA(0);
8389 cls.lpszClassName = "EnableWindowClass";
8390 ok(RegisterClassA(&cls), "RegisterClass failed\n");
8391
8392 hwnd = CreateWindowExA(0, "EnableWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8393 0, 0, 100, 100, 0, 0, 0, NULL);
8394 assert(hwnd);
8395 SetFocus(hwnd);
8397
8400
8402}
8403
8405{
8406 HWND hwnd = arg;
8407 char buf[32];
8408 INT buf_len;
8409
8410 /* test GetWindowTextA */
8411 num_gettext_msgs = 0;
8412 memset( buf, 0, sizeof(buf) );
8413 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8414 ok( buf_len != 0, "expected a nonempty window text\n" );
8415 ok( !strcmp(buf, "another_caption"), "got wrong window text '%s'\n", buf );
8416 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8417
8418 return 0;
8419}
8420
8422{
8423 HWND hwnd = arg;
8424 BOOL success;
8425
8426 /* test SetWindowTextA */
8427 num_settext_msgs = 0;
8428 success = SetWindowTextA( hwnd, "thread_caption" );
8429 ok( success, "SetWindowTextA failed\n" );
8430 ok( num_settext_msgs == 1, "got %lu WM_SETTEXT messages\n", num_settext_msgs );
8431
8432 return 0;
8433}
8434
8435static void test_gettext(void)
8436{
8437 static const WCHAR textW[] = {'t','e','x','t'};
8438 DWORD tid, num_msgs;
8439 WCHAR bufW[32];
8440 HANDLE thread;
8441 BOOL success;
8442 char buf[32];
8443 INT buf_len;
8444 HWND hwnd, hwnd2;
8445 LRESULT r;
8446 MSG msg;
8447
8448 hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL );
8449 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
8450
8451 /* test GetWindowTextA */
8452 num_gettext_msgs = 0;
8453 memset( buf, 0, sizeof(buf) );
8454 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8455 ok( buf_len != 0, "expected a nonempty window text\n" );
8456 ok( !strcmp(buf, "caption"), "got wrong window text '%s'\n", buf );
8457 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8458
8459 /* other process window */
8460 strcpy( buf, "a" );
8461 buf_len = GetWindowTextA( GetDesktopWindow(), buf, sizeof(buf) );
8462 ok( buf_len == 0, "expected a nonempty window text\n" );
8463 ok( *buf == 0, "got wrong window text '%s'\n", buf );
8464
8465 strcpy( buf, "blah" );
8466 buf_len = GetWindowTextA( GetDesktopWindow(), buf, 0 );
8467 ok( buf_len == 0, "expected a nonempty window text\n" );
8468 ok( !strcmp(buf, "blah"), "got wrong window text '%s'\n", buf );
8469
8470 bufW[0] = 0xcc;
8471 buf_len = GetWindowTextW( GetDesktopWindow(), bufW, 0 );
8472 ok( buf_len == 0, "expected a nonempty window text\n" );
8473 ok( bufW[0] == 0xcc, "got %x\n", bufW[0] );
8474
8475 g_wm_gettext_override.enabled = TRUE;
8476
8477 num_gettext_msgs = 0;
8478 memset( buf, 0xcc, sizeof(buf) );
8480 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8481 ok( buf_len == 0, "got %d\n", buf_len );
8482 ok( *buf == 0, "got %x\n", *buf );
8483 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8484
8485 num_gettext_msgs = 0;
8486 strcpy( buf, "blah" );
8488 buf_len = GetWindowTextA( hwnd, buf, 0 );
8489 ok( buf_len == 0, "got %d\n", buf_len );
8490 ok( !strcmp(buf, "blah"), "got %s\n", buf );
8491 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8492
8493 bufW[0] = 0xcc;
8494 buf_len = InternalGetWindowText( hwnd, bufW, ARRAYSIZE(bufW) );
8495 ok( buf_len == ARRAYSIZE("caption") - 1, "expected a nonempty window text\n" );
8496 ok( !lstrcmpW( bufW, L"caption" ), "got %s\n", debugstr_w(bufW) );
8497
8498 g_wm_gettext_override.enabled = FALSE;
8499
8500 /* same for W window */
8501 hwnd2 = CreateWindowExW( 0, mainclassW, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL );
8502 ok( hwnd2 != 0, "CreateWindowExA error %ld\n", GetLastError() );
8503
8504 g_wm_gettext_override.enabled = TRUE;
8505
8506 num_gettext_msgs = 0;
8507 memset( bufW, 0xcc, sizeof(bufW) );
8508 g_wm_gettext_override.buffW = bufW;
8509 buf_len = GetWindowTextW( hwnd2, bufW, ARRAY_SIZE(bufW));
8510 ok( buf_len == 0, "got %d\n", buf_len );
8511 ok( *bufW == 0, "got %x\n", *bufW );
8512 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8513
8514 num_gettext_msgs = 0;
8515 memset( bufW, 0xcc, sizeof(bufW) );
8516 g_wm_gettext_override.buffW = bufW;
8517 buf_len = GetWindowTextW( hwnd2, bufW, 0 );
8518 ok( buf_len == 0, "got %d\n", buf_len );
8519 ok( *bufW == 0xcccc, "got %x\n", *bufW );
8520 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8521
8522 g_wm_gettext_override.enabled = FALSE;
8523
8524 DestroyWindow( hwnd2 );
8525
8526 /* test WM_GETTEXT */
8527 num_gettext_msgs = 0;
8528 memset( buf, 0, sizeof(buf) );
8529 r = SendMessageA( hwnd, WM_GETTEXT, sizeof(buf), (LONG_PTR)buf );
8530 ok( r != 0, "expected a nonempty window text\n" );
8531 ok( !strcmp(buf, "caption"), "got wrong window text '%s'\n", buf );
8532 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8533
8534 /* test SetWindowTextA */
8535 num_settext_msgs = 0;
8536 success = SetWindowTextA( hwnd, "new_caption" );
8537 ok( success, "SetWindowTextA failed\n" );
8538 ok( num_settext_msgs == 1, "got %lu WM_SETTEXT messages\n", num_settext_msgs );
8539
8540 num_gettext_msgs = 0;
8541 memset( buf, 0, sizeof(buf) );
8542 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8543 ok( buf_len != 0, "expected a nonempty window text\n" );
8544 ok( !strcmp(buf, "new_caption"), "got wrong window text '%s'\n", buf );
8545 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8546
8547 /* test WM_SETTEXT */
8548 num_settext_msgs = 0;
8549 r = SendMessageA( hwnd, WM_SETTEXT, 0, (ULONG_PTR)"another_caption" );
8550 ok( r != 0, "WM_SETTEXT failed\n" );
8551 ok( num_settext_msgs == 1, "got %lu WM_SETTEXT messages\n", num_settext_msgs );
8552
8553 num_gettext_msgs = 0;
8554 memset( buf, 0, sizeof(buf) );
8555 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8556 ok( buf_len != 0, "expected a nonempty window text\n" );
8557 ok( !strcmp(buf, "another_caption"), "got wrong window text '%s'\n", buf );
8558 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8559
8560 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ))
8562
8563 /* test interthread GetWindowTextA */
8564 num_msgs = 0;
8566 ok(thread != NULL, "CreateThread failed, error %ld\n", GetLastError());
8568 {
8569 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ))
8571 num_msgs++;
8572 }
8574 ok( num_msgs >= 1, "got %lu wakeups from MsgWaitForMultipleObjects\n", num_msgs );
8575
8576 /* test interthread SetWindowText */
8577 num_msgs = 0;
8579 ok(thread != NULL, "CreateThread failed, error %ld\n", GetLastError());
8581 {
8582 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE ))
8584 num_msgs++;
8585 }
8587 ok( num_msgs >= 1, "got %lu wakeups from MsgWaitForMultipleObjects\n", num_msgs );
8588
8589 num_gettext_msgs = 0;
8590 memset( buf, 0, sizeof(buf) );
8591 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8592 ok( buf_len != 0, "expected a nonempty window text\n" );
8593 ok( !strcmp(buf, "thread_caption"), "got wrong window text '%s'\n", buf );
8594 ok( num_gettext_msgs == 1, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
8595
8596 /* WM_GETTEXT does not terminate returned string */
8597 memset( buf, 0x1c, sizeof(buf) );
8598 g_wm_gettext_override.dont_terminate = TRUE;
8599 buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
8600 ok( buf_len == 4, "Unexpected text length, %d\n", buf_len );
8601 ok( !memcmp(buf, "text", 4), "Unexpected window text, '%s'\n", buf );
8602 ok( buf[4] == 0x1c, "Unexpected buffer contents\n" );
8603 g_wm_gettext_override.dont_terminate = FALSE;
8604
8605 memset( bufW, 0x1c, sizeof(bufW) );
8606 g_wm_gettext_override.dont_terminate = TRUE;
8607 buf_len = GetWindowTextW( hwnd, bufW, ARRAY_SIZE(bufW));
8608 ok( buf_len == 4, "Unexpected text length, %d\n", buf_len );
8609 ok( !memcmp(bufW, textW, 4 * sizeof(WCHAR)), "Unexpected window text, %s\n", wine_dbgstr_w(bufW) );
8610 ok( bufW[4] == 0, "Unexpected buffer contents, %#x\n", bufW[4] );
8611 g_wm_gettext_override.dont_terminate = FALSE;
8612
8613 hwnd2 = CreateWindowExW( 0, mainclassW, NULL, WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL );
8614 ok( hwnd2 != 0, "CreateWindowExA error %ld\n", GetLastError() );
8615
8616 memset( buf, 0x1c, sizeof(buf) );
8617 g_wm_gettext_override.dont_terminate = TRUE;
8618 buf_len = GetWindowTextA( hwnd2, buf, sizeof(buf) );
8619 ok( buf_len == 4, "Unexpected text length, %d\n", buf_len );
8620 ok( !memcmp(buf, "text", 4), "Unexpected window text, '%s'\n", buf );
8621 ok( buf[4] == 0, "Unexpected buffer contents, %#x\n", buf[4] );
8622 g_wm_gettext_override.dont_terminate = FALSE;
8623
8624 memset( bufW, 0x1c, sizeof(bufW) );
8625 g_wm_gettext_override.dont_terminate = TRUE;
8626 buf_len = GetWindowTextW( hwnd2, bufW, ARRAY_SIZE(bufW));
8627 ok( buf_len == 4, "Unexpected text length, %d\n", buf_len );
8628 ok( !memcmp(bufW, textW, 4 * sizeof(WCHAR)), "Unexpected window text, %s\n", wine_dbgstr_w(bufW) );
8629 ok( bufW[4] == 0x1c1c, "Unexpected buffer contents, %#x\n", bufW[4] );
8630 g_wm_gettext_override.dont_terminate = FALSE;
8631
8632 DestroyWindow(hwnd2);
8633
8634 /* seems to crash on every modern Windows version */
8635 if (0)
8636 {
8637 r = SendMessageA( hwnd, WM_GETTEXT, 0x10, 0x1000);
8638 ok( r == 0, "WM_GETTEXT should return zero (%Id)\n", r );
8639
8640 r = SendMessageA( hwnd, WM_GETTEXT, 0x10000, 0);
8641 ok( r == 0, "WM_GETTEXT should return zero (%Id)\n", r );
8642
8643 r = SendMessageA( hwnd, WM_GETTEXT, 0xff000000, 0x1000);
8644 ok( r == 0, "WM_GETTEXT should return zero (%Id)\n", r );
8645
8646 r = SendMessageA( hwnd, WM_GETTEXT, 0x1000, 0xff000000);
8647 ok( r == 0, "WM_GETTEXT should return zero (%Id)\n", r );
8648 }
8649
8650 /* GetWindowText doesn't crash */
8651#ifdef __REACTOS__
8652 if (is_reactos()) {
8653 ok(FALSE, "FIXME: These tests crash on ReactOS!\n");
8654 } else {
8655#endif
8656 r = GetWindowTextA( hwnd, (LPSTR)0x10, 0x1000 );
8657 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8658 r = GetWindowTextA( hwnd, (LPSTR)0x10000, 0 );
8659 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8660 r = GetWindowTextA( hwnd, (LPSTR)0xff000000, 0x1000 );
8661 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8662 r = GetWindowTextA( hwnd, (LPSTR)0x1000, 0xff000000 );
8663 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8664
8665 r = GetWindowTextW( hwnd, (LPWSTR)0x10, 0x1000 );
8666 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8667 r = GetWindowTextW( hwnd, (LPWSTR)0x10000, 0 );
8668 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8669 r = GetWindowTextW( hwnd, (LPWSTR)0xff000000, 0x1000 );
8670 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8671 r = GetWindowTextW( hwnd, (LPWSTR)0x1000, 0xff000000);
8672 ok( r == 0, "GetWindowText should return zero (%Id)\n", r );
8673#ifdef __REACTOS__
8674 }
8675#endif
8676
8678}
8679
8680
8681static void test_GetUpdateRect(void)
8682{
8683 MSG msg;
8684 BOOL ret, parent_wm_paint, grandparent_wm_paint;
8685 RECT rc1, rc2;
8686 HWND hgrandparent, hparent, hchild;
8687 WNDCLASSA cls;
8688 static const char classNameA[] = "GetUpdateRectClass";
8689
8690 hgrandparent = CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW,
8691 0, 0, 100, 100, NULL, NULL, 0, NULL);
8692
8693 hparent = CreateWindowA("static", "parent", WS_CHILD|WS_VISIBLE,
8694 0, 0, 100, 100, hgrandparent, NULL, 0, NULL);
8695
8696 hchild = CreateWindowA("static", "child", WS_CHILD|WS_VISIBLE,
8697 10, 10, 30, 30, hparent, NULL, 0, NULL);
8698
8699 ShowWindow(hgrandparent, SW_SHOW);
8700 UpdateWindow(hgrandparent);
8701 flush_events( TRUE );
8702
8703 ShowWindow(hchild, SW_HIDE);
8704 SetRectEmpty(&rc2);
8705 ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
8706 ok(!ret, "GetUpdateRect returned not empty region\n");
8707 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
8709
8710 SetRect(&rc2, 10, 10, 40, 40);
8711 ret = GetUpdateRect(hparent, &rc1, FALSE);
8712 ok(ret, "GetUpdateRect returned empty region\n");
8713 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
8715
8716 parent_wm_paint = FALSE;
8717 grandparent_wm_paint = FALSE;
8718 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
8719 {
8720 if (msg.message == WM_PAINT)
8721 {
8722 if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE;
8723 if (msg.hwnd == hparent) parent_wm_paint = TRUE;
8724 }
8726 }
8727 ok(parent_wm_paint, "WM_PAINT should have been received in parent\n");
8728 ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n");
8729
8730 DestroyWindow(hgrandparent);
8731
8732 cls.style = 0;
8734 cls.cbClsExtra = 0;
8735 cls.cbWndExtra = 0;
8736 cls.hInstance = GetModuleHandleA(0);
8737 cls.hIcon = 0;
8740 cls.lpszMenuName = NULL;
8741 cls.lpszClassName = classNameA;
8742 ret = RegisterClassA(&cls);
8743 ok(ret, "Failed to register a test class.\n");
8744
8745 hgrandparent = CreateWindowA(classNameA, "grandparent", WS_OVERLAPPEDWINDOW,
8746 0, 0, 100, 100, NULL, NULL, 0, NULL);
8747
8748 hparent = CreateWindowA(classNameA, "parent", WS_CHILD|WS_VISIBLE,
8749 0, 0, 100, 100, hgrandparent, NULL, 0, NULL);
8750
8751 hchild = CreateWindowA(classNameA, "child", WS_CHILD|WS_VISIBLE,
8752 10, 10, 30, 30, hparent, NULL, 0, NULL);
8753
8754 ShowWindow(hgrandparent, SW_SHOW);
8755 UpdateWindow(hgrandparent);
8756 flush_events( TRUE );
8757
8758 ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
8759 ok(!ret, "GetUpdateRect returned not empty region\n");
8760
8761 ShowWindow(hchild, SW_HIDE);
8762
8763 SetRectEmpty(&rc2);
8764 ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
8765 ok(!ret, "GetUpdateRect returned not empty region\n");
8766 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
8768
8769 SetRect(&rc2, 10, 10, 40, 40);
8770 ret = GetUpdateRect(hparent, &rc1, FALSE);
8771 ok(ret, "GetUpdateRect returned empty region\n");
8772 ok(EqualRect(&rc1, &rc2), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1),
8774
8775 parent_wm_paint = FALSE;
8776 grandparent_wm_paint = FALSE;
8777 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
8778 {
8779 if (msg.message == WM_PAINT)
8780 {
8781 if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE;
8782 if (msg.hwnd == hparent) parent_wm_paint = TRUE;
8783 }
8785 }
8786 ok(parent_wm_paint, "WM_PAINT should have been received in parent\n");
8787 ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n");
8788
8789 DestroyWindow(hgrandparent);
8790}
8791
8792
8794{
8795 if(msg == WM_PAINT)
8796 {
8797 PAINTSTRUCT ps;
8798 RECT updateRect;
8799 DWORD waitResult;
8800 HWND win;
8801 const int waitTime = 2000;
8802
8803 BeginPaint(hwnd, &ps);
8804
8805 /* create and destroy window to create an exposed region on this window */
8806 win = CreateWindowA("static", "win", WS_VISIBLE,
8807 10,10,50,50, NULL, NULL, 0, NULL);
8809
8810 waitResult = MsgWaitForMultipleObjects( 0, NULL, FALSE, waitTime, QS_PAINT );
8811
8813 EndPaint(hwnd, &ps);
8814
8815 if(waitResult != WAIT_TIMEOUT)
8816 {
8817 GetUpdateRect(hwnd, &updateRect, FALSE);
8818 ok(IsRectEmpty(&updateRect), "Exposed rect should be empty\n");
8819 }
8820
8821 return 1;
8822 }
8823 return DefWindowProcA(hwnd, msg, wParam, lParam);
8824}
8825
8826static void test_Expose(void)
8827{
8828 WNDCLASSA cls;
8829 HWND mw;
8830
8831 memset(&cls, 0, sizeof(WNDCLASSA));
8834 cls.lpszClassName = "TestExposeClass";
8835 RegisterClassA(&cls);
8836
8837 mw = CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE|WS_OVERLAPPEDWINDOW,
8838 0, 0, 200, 100, NULL, NULL, 0, NULL);
8839
8840 UpdateWindow(mw);
8841 DestroyWindow(mw);
8842}
8843
8845{
8846 static UINT ncredrawflags;
8847 PAINTSTRUCT ps;
8848
8849 switch(msg)
8850 {
8851 case WM_CREATE:
8852 ncredrawflags = *(UINT *) (((CREATESTRUCTA *)lParam)->lpCreateParams);
8853 return 0;
8854 case WM_NCPAINT:
8855 RedrawWindow(hwnd, NULL, NULL, ncredrawflags);
8856 break;
8857 case WM_PAINT:
8858 BeginPaint(hwnd, &ps);
8859 EndPaint(hwnd, &ps);
8860 return 0;
8861 }
8862 return DefWindowProcA(hwnd, msg, wParam, lParam);
8863}
8864
8866{
8867 HWND hwnd;
8868 MSG msg;
8869
8870 UINT loopcount = 0;
8871
8872 flush_events( TRUE );
8873 hwnd = CreateWindowA("TestNCRedrawClass", "MainWindow",
8874 WS_OVERLAPPEDWINDOW, 0, 0, 200, 100,
8875 NULL, NULL, 0, &flags);
8879 while (PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE))
8880 {
8881 if (msg.message == WM_PAINT) loopcount++;
8882 if (loopcount >= 100) break;
8886 }
8888 ok(loopcount < 100, "Detected infinite WM_PAINT loop (%x).\n", flags);
8890}
8891
8892static void test_NCRedraw(void)
8893{
8894 WNDCLASSA wndclass;
8895
8896 wndclass.lpszClassName = "TestNCRedrawClass";
8897 wndclass.style = CS_HREDRAW | CS_VREDRAW;
8899 wndclass.cbClsExtra = 0;
8900 wndclass.cbWndExtra = 0;
8901 wndclass.hInstance = 0;
8902 wndclass.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
8903 wndclass.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
8905 wndclass.lpszMenuName = NULL;
8906
8907 RegisterClassA(&wndclass);
8908
8911}
8912
8914{
8915 HWND hwnd;
8917 UINT ret1, ret2;
8918 char buf1[MAX_PATH], buf2[MAX_PATH];
8919
8920 if (!pGetWindowModuleFileNameA)
8921 {
8922 win_skip("GetWindowModuleFileNameA is not available\n");
8923 return;
8924 }
8925
8926 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL);
8927 assert(hwnd);
8928
8930 ok(hinst == 0, "expected 0, got %p\n", hinst);
8931
8932 buf1[0] = 0;
8933 SetLastError(0xdeadbeef);
8934 ret1 = GetModuleFileNameA(hinst, buf1, sizeof(buf1));
8935 ok(ret1, "GetModuleFileName error %lu\n", GetLastError());
8936
8937 buf2[0] = 0;
8938 SetLastError(0xdeadbeef);
8939 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, sizeof(buf2));
8940 ok(ret2, "GetWindowModuleFileNameA error %lu\n", GetLastError());
8941
8942 if (ret2)
8943 {
8944 ok(ret1 == ret2, "%u != %u\n", ret1, ret2);
8945 ok(!strcmp(buf1, buf2), "%s != %s\n", buf1, buf2);
8946 }
8948
8949 SetLastError(0xdeadbeef);
8950 ret2 = GetModuleFileNameA(hinst, buf2, ret1 - 2);
8951 ok(ret2 == ret1 - 2, "expected %u, got %u\n", ret1 - 2, ret2);
8952 ok(GetLastError() == 0xdeadbeef /* XP */ ||
8953 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
8954 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
8955
8956 SetLastError(0xdeadbeef);
8957 ret2 = GetModuleFileNameA(hinst, buf2, 0);
8958 ok(!ret2, "GetModuleFileName should return 0\n");
8959 ok(GetLastError() == 0xdeadbeef /* XP */ ||
8960 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
8961 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
8962
8963 SetLastError(0xdeadbeef);
8964 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, ret1 - 2);
8965 ok(ret2 == ret1 - 2, "expected %u, got %u\n", ret1 - 2, ret2);
8966 ok(GetLastError() == 0xdeadbeef /* XP */ ||
8967 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
8968 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
8969
8970 SetLastError(0xdeadbeef);
8971 ret2 = pGetWindowModuleFileNameA(hwnd, buf2, 0);
8972 ok(!ret2, "expected 0, got %u\n", ret2);
8973 ok(GetLastError() == 0xdeadbeef /* XP */ ||
8974 GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
8975 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %lu\n", GetLastError());
8976
8978
8979 hwnd = (HWND)0xdeadbeef;
8980 SetLastError(0xdeadbeef);
8981 ret1 = pGetWindowModuleFileNameA(hwnd, buf1, sizeof(buf1));
8982 ok(!ret1, "expected 0, got %u\n", ret1);
8984 "expected ERROR_INVALID_WINDOW_HANDLE, got %lu\n", GetLastError());
8985}
8986
8987static void test_hwnd_message(void)
8988{
8989 static const WCHAR mainwindowclassW[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
8990 static const WCHAR message_windowW[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
8991
8992 HWND parent = 0, hwnd, found;
8993 RECT rect;
8994 static const struct
8995 {
8996 int offset;
8998 DWORD error;
8999 }
9000 tests[] =
9001 {
9002 { GWLP_USERDATA, 0, 0 },
9004 { GWL_EXSTYLE, 0, 0 },
9005 { GWLP_ID, 0, 0 },
9006 /* GWLP_HWNDPARENT - returns random values */
9007 /* GWLP_HINSTANCE - not useful and not consistent between Windows versions */
9010 };
9011 HWND root, desktop = GetDesktopWindow();
9013 char buffer[100];
9014 int i;
9015
9016 hwnd = CreateWindowExW(0, mainwindowclassW, message_windowW, WS_CAPTION | WS_VISIBLE,
9017 100, 100, 200, 200, HWND_MESSAGE, 0, 0, NULL);
9018 ok( hwnd != 0, "CreateWindowExW with parent HWND_MESSAGE failed\n" );
9019 ok( !GetParent(hwnd), "GetParent should return 0 for message only windows\n" );
9020
9022 ok(parent != 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
9023 ok(parent != desktop, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
9025 ok(root == hwnd, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
9027 "parent shouldn't have parent %p\n", GetAncestor(parent, GA_PARENT) );
9028 if (!GetClassNameA( parent, buffer, sizeof(buffer) )) buffer[0] = 0;
9029 ok( !lstrcmpiA( buffer, "Message" ), "wrong parent class '%s'\n", buffer );
9031 ok( rect.left == 0 && rect.right == 100 && rect.top == 0 && rect.bottom == 100,
9032 "wrong parent rect %s\n", wine_dbgstr_rect( &rect ));
9033 GetWindowRect( hwnd, &rect );
9034 ok( rect.left == 100 && rect.right == 300 && rect.top == 100 && rect.bottom == 300,
9035 "wrong window rect %s\n", wine_dbgstr_rect( &rect ));
9036
9037 /* test FindWindow behavior */
9038
9039 found = FindWindowExA( 0, 0, 0, "message window" );
9040 ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd );
9041 SetLastError(0xdeadbeef);
9042 found = FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
9043 ok( found == 0, "found message window %p/%p\n", found, hwnd );
9044 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %ld\n", GetLastError() );
9045 if (parent)
9046 {
9047 found = FindWindowExA( parent, 0, 0, "message window" );
9048 ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd );
9049 }
9050
9051 /* test IsChild behavior */
9052
9053 if (parent) ok( !IsChild( parent, hwnd ), "HWND_MESSAGE is child of top window\n" );
9054
9055 /* test IsWindowVisible behavior */
9056
9057 ok( !IsWindowVisible( hwnd ), "HWND_MESSAGE window is visible\n" );
9058 if (parent) ok( !IsWindowVisible( parent ), "HWND_MESSAGE parent is visible\n" );
9059
9060 /* GetWindowLong */
9061 for (i = 0; i < ARRAY_SIZE(tests); i++)
9062 {
9063 SetLastError( 0xdeadbeef );
9065 ok( result == tests[i].expect, "offset %d, got %08Ix expect %08Ix\n",
9067 if (tests[i].error)
9068 ok( GetLastError() == tests[i].error, "offset %d: error %ld expect %ld\n",
9070 else
9071 ok( GetLastError() == 0xdeadbeef, "offset %d: error %ld expect unchanged\n",
9072 tests[i].offset, GetLastError() );
9073 }
9074
9076}
9077
9080
9082{
9083 ok(hwnd != message_window_topmost_hwnd_msg, "Received message %u for message-only window %p\n", msg, hwnd);
9085 return DefWindowProcW(hwnd, msg, wparam, lparam);
9086}
9087
9088
9090{
9091 /* All SWP_* flags except SWP_NOZORDER, which has a different effect. */
9095 /* Same as above, except the flags that cause
9096 * ERROR_INVALID_PARAMETER to be returned by DeferWindowPos(). */
9097 const UINT dwp_flags = SWP_DRAWFRAME | SWP_FRAMECHANGED
9100 HWND hwnd, hwnd_msg;
9101 HDWP hdwp;
9102 RECT rect;
9103 BOOL ret;
9104 MSG msg;
9105
9106 hwnd = CreateWindowW(L"static", L"main window", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9107 210, 211, 212, 213, NULL, NULL, GetModuleHandleW(NULL), NULL);
9108 ok(!!hwnd, "Cannot create main window\n");
9111
9112 hwnd_msg = CreateWindowW(L"static", L"message window", 0,
9113 220, 221, 222, 223, HWND_MESSAGE, NULL, GetModuleHandleW(NULL), NULL);
9114 ok(!!hwnd_msg, "Cannot create message window\n");
9117
9118 ret = GetWindowRect(hwnd_msg, &rect);
9119 ok(ret, "Unexpected failure when calling GetWindowRect()\n");
9120 ok(rect.left == 220 && rect.top == 221 && rect.right == 220 + 222 && rect.bottom == 221 + 223,
9121 "Unexpected rectangle %s\n", wine_dbgstr_rect(&rect));
9122
9123 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
9124 {
9127 }
9128
9130
9131 SetLastError(0xdeadbeef);
9132
9133 ret = SetWindowPos(hwnd_msg, HWND_TOPMOST, 230, 231, 232, 233, 0);
9134 ok(ret, "Unexpected failure when calling SetWindowPos()\n");
9135
9136 ret = SetWindowPos(hwnd_msg, HWND_TOPMOST, 234, 235, 236, 237, swp_flags);
9137 ok(ret, "Unexpected failure when calling SetWindowPos()\n");
9138
9139 ret = SetWindowPos(hwnd_msg, HWND_NOTOPMOST, 240, 241, 242, 243, 0);
9140 ok(ret, "Unexpected failure when calling SetWindowPos()\n");
9141
9142 ret = SetWindowPos(hwnd_msg, HWND_NOTOPMOST, 244, 245, 246, 247, swp_flags);
9143 ok(ret, "Unexpected failure when calling SetWindowPos()\n");
9144
9145 hdwp = BeginDeferWindowPos(4);
9146 ok(!!hdwp, "Unexpected failure when calling BeginDeferWindowPos()\n");
9147
9148 hdwp = DeferWindowPos(hdwp, hwnd_msg, HWND_TOPMOST, 250, 251, 252, 253, 0);
9149 ok(!!hdwp, "Unexpected failure when calling DeferWindowPos()\n");
9150
9151 hdwp = DeferWindowPos(hdwp, hwnd_msg, HWND_TOPMOST, 254, 255, 256, 257, dwp_flags);
9152 ok(!!hdwp, "Unexpected failure when calling DeferWindowPos()\n");
9153
9154 hdwp = DeferWindowPos(hdwp, hwnd_msg, HWND_NOTOPMOST, 260, 261, 262, 263, 0);
9155 ok(!!hdwp, "Unexpected failure when calling DeferWindowPos()\n");
9156
9157 hdwp = DeferWindowPos(hdwp, hwnd_msg, HWND_NOTOPMOST, 264, 265, 266, 267, dwp_flags);
9158 ok(!!hdwp, "Unexpected failure when calling DeferWindowPos()\n");
9159
9160 ret = EndDeferWindowPos(hdwp);
9161 ok(ret, "Unexpected failure when calling EndDeferWindowPos()\n");
9162
9163 ok(GetLastError() == 0xdeadbeef, "Last error unexpectedly set to %#lx\n", GetLastError());
9164
9165 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
9166 {
9169 }
9170
9172
9173 ret = GetWindowRect(hwnd_msg, &rect);
9174 ok(ret, "Unexpected failure when calling GetWindowRect()\n");
9175 ok(rect.left == 220 && rect.top == 221 && rect.right == 220 + 222 && rect.bottom == 221 + 223,
9176 "Unexpected rectangle %s\n", wine_dbgstr_rect(&rect));
9177
9178 ok(!message_window_topmost_received_killfocus, "Received WM_KILLFOCUS\n");
9180
9181 ret = SetWindowPos(hwnd_msg, HWND_TOPMOST, 230, 231, 232, 233, SWP_NOZORDER);
9182 ok(ret, "Unexpected failure when calling SetWindowPos()\n");
9183
9184 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
9185 {
9188 }
9189
9190 ok(message_window_topmost_received_killfocus, "Did not receive WM_KILLFOCUS\n");
9191
9192 ret = GetWindowRect(hwnd_msg, &rect);
9193 ok(ret, "Unexpected failure when calling GetWindowRect()\n");
9194 ok(rect.left == 230 && rect.top == 231 && rect.right == 230 + 232 && rect.bottom == 231 + 233,
9195 "Unexpected rectangle %s\n", wine_dbgstr_rect(&rect));
9196
9197 ok(DestroyWindow(hwnd_msg), "Cannot destroy main window\n");
9198 ok(DestroyWindow(hwnd), "Cannot destroy message window\n");
9199}
9200
9201
9202static void test_layered_window(void)
9203{
9204 HWND hwnd, child;
9205 COLORREF key = 0;
9206 BYTE alpha = 0;
9207 DWORD flags = 0;
9208 POINT pt = { 0, 0 };
9209 SIZE sz = { 200, 200 };
9210 HDC hdc;
9211 HBITMAP hbm;
9212 BOOL ret;
9213 MSG msg;
9214
9215 if (!pGetLayeredWindowAttributes || !pSetLayeredWindowAttributes || !pUpdateLayeredWindow)
9216 {
9217 win_skip( "layered windows not supported\n" );
9218 return;
9219 }
9220
9221 hdc = CreateCompatibleDC( 0 );
9222 hbm = CreateCompatibleBitmap( hdc, 200, 200 );
9223 SelectObject( hdc, hbm );
9224
9225 hwnd = CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION,
9226 100, 100, 200, 200, 0, 0, 0, NULL);
9227 assert( hwnd );
9228 SetLastError( 0xdeadbeef );
9229 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9230 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
9231 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError() );
9232 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9233 ok( !ret, "GetLayeredWindowAttributes should fail on non-layered window\n" );
9234 ret = pSetLayeredWindowAttributes( hwnd, 0, 0, LWA_ALPHA );
9235 ok( !ret, "SetLayeredWindowAttributes should fail on non-layered window\n" );
9237 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9238 ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
9239 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9240 ok( ret, "UpdateLayeredWindow should succeed on layered window\n" );
9241 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9242 ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
9243 ret = pSetLayeredWindowAttributes( hwnd, 0x123456, 44, LWA_ALPHA );
9244 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9245 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9246 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
9247 ok( key == 0x123456 || key == 0, "wrong color key %lx\n", key );
9248 ok( alpha == 44, "wrong alpha %u\n", alpha );
9249 ok( flags == LWA_ALPHA, "wrong flags %lx\n", flags );
9250 SetLastError( 0xdeadbeef );
9251 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9252 ok( !ret, "UpdateLayeredWindow should fail on layered but initialized window\n" );
9253 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError() );
9254
9255 /* clearing WS_EX_LAYERED resets attributes */
9257 SetLastError( 0xdeadbeef );
9258 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9259 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
9260 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9261 ok( !ret, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
9263 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9264 ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
9265 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9266 ok( ret, "UpdateLayeredWindow should succeed on layered window\n" );
9267 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE | ULW_EX_NORESIZE );
9268 ok( !ret, "UpdateLayeredWindow should fail with ex flag\n" );
9269 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
9270 if (pUpdateLayeredWindowIndirect)
9271 {
9272 UPDATELAYEREDWINDOWINFO info;
9273 info.cbSize = sizeof(info);
9274 info.hdcDst = 0;
9275 info.pptDst = NULL;
9276 info.psize = &sz;
9277 info.hdcSrc = hdc;
9278 info.pptSrc = &pt;
9279 info.crKey = 0;
9280 info.pblend = NULL;
9281 info.dwFlags = ULW_OPAQUE | ULW_EX_NORESIZE;
9282 info.prcDirty = NULL;
9283 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
9284 ok( ret, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
9285 sz.cx--;
9286 SetLastError(0);
9287 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
9288 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
9289 /* particular error code differs from version to version, could be ERROR_INCORRECT_SIZE,
9290 ERROR_MR_MID_NOT_FOUND or ERROR_GEN_FAILURE (Win8/Win10) */
9291 ok( GetLastError() != 0, "wrong error %lu\n", GetLastError() );
9292 info.dwFlags = ULW_OPAQUE;
9293 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
9294 ok( ret, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
9295 sz.cx++;
9296 info.dwFlags = ULW_OPAQUE | 0xf00;
9297 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
9298 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
9299 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
9300 info.cbSize--;
9301 info.dwFlags = ULW_OPAQUE;
9302 ret = pUpdateLayeredWindowIndirect( hwnd, &info );
9303 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
9304 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
9305 ret = pUpdateLayeredWindowIndirect( hwnd, NULL );
9306 ok( !ret, "UpdateLayeredWindowIndirect should fail\n" );
9307 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError() );
9308 }
9309
9310 ret = pSetLayeredWindowAttributes( hwnd, 0x654321, 22, LWA_COLORKEY | LWA_ALPHA );
9311 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9312 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9313 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
9314 ok( key == 0x654321, "wrong color key %lx\n", key );
9315 ok( alpha == 22, "wrong alpha %u\n", alpha );
9316 ok( flags == (LWA_COLORKEY | LWA_ALPHA), "wrong flags %lx\n", flags );
9317 SetLastError( 0xdeadbeef );
9318 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9319 ok( !ret, "UpdateLayeredWindow should fail on layered but initialized window\n" );
9320 ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError() );
9321
9322 ret = pSetLayeredWindowAttributes( hwnd, 0x888888, 33, LWA_COLORKEY );
9323 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9324 alpha = 0;
9325 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9326 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
9327 ok( key == 0x888888, "wrong color key %lx\n", key );
9328 /* alpha not changed on vista if LWA_ALPHA is not set */
9329 ok( alpha == 22 || alpha == 33, "wrong alpha %u\n", alpha );
9330 ok( flags == LWA_COLORKEY, "wrong flags %lx\n", flags );
9331
9332 /* color key may or may not be changed without LWA_COLORKEY */
9333 ret = pSetLayeredWindowAttributes( hwnd, 0x999999, 44, 0 );
9334 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9335 alpha = 0;
9336 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9337 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
9338 ok( key == 0x888888 || key == 0x999999, "wrong color key %lx\n", key );
9339 ok( alpha == 22 || alpha == 44, "wrong alpha %u\n", alpha );
9340 ok( flags == 0, "wrong flags %lx\n", flags );
9341
9342 /* default alpha and color key is 0 */
9345 ret = pSetLayeredWindowAttributes( hwnd, 0x222222, 55, 0 );
9346 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9347 ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
9348 ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
9349 ok( key == 0 || key == 0x222222, "wrong color key %lx\n", key );
9350 ok( alpha == 0 || alpha == 55, "wrong alpha %u\n", alpha );
9351 ok( flags == 0, "wrong flags %lx\n", flags );
9352
9353 /* test layered window with WS_CLIPCHILDREN flag */
9357 child = CreateWindowExA( 0, "button", "button", WS_VISIBLE | WS_CHILD,
9358 0, 0, 50, 50, hwnd, 0, 0, NULL );
9359 ok( child != NULL, "CreateWindowEx error %lu\n", GetLastError() );
9361
9362 ret = pSetLayeredWindowAttributes( hwnd, 0, 255, LWA_ALPHA );
9363 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9364 while (GetMessageA(&msg, 0, 0, 0))
9365 {
9367
9368 if (msg.message == WM_PAINT && msg.hwnd == child)
9369 break;
9370 }
9371
9374 ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE );
9375 ok( ret, "UpdateLayeredWindow should succeed on layered window\n" );
9376
9377 ret = pSetLayeredWindowAttributes( hwnd, 0, 255, LWA_ALPHA );
9378 ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
9379#ifdef __REACTOS__
9380 if (is_reactos()) {
9381 ok(FALSE, "FIXME: This hangs on ReactOS!\n");
9382 } else {
9383#endif
9384 while (GetMessageA(&msg, 0, 0, 0))
9385 {
9387
9388 if (msg.message == WM_PAINT && msg.hwnd == child)
9389 break;
9390 }
9391#ifdef __REACTOS__
9392 }
9393#endif
9394
9396 DeleteDC( hdc );
9397 DeleteObject( hbm );
9398}
9399
9401
9403{
9404 switch (msg)
9405 {
9406 case WM_NCCREATE:
9407 {
9409 ok(cs->x == mi.rcMonitor.left && cs->y == mi.rcMonitor.top &&
9410 cs->cx == mi.rcMonitor.right && cs->cy == mi.rcMonitor.bottom,
9411 "expected %s, got (%d,%d)-(%d,%d)\n", wine_dbgstr_rect(&mi.rcMonitor),
9412 cs->x, cs->y, cs->cx, cs->cy);
9413 break;
9414 }
9415 case WM_GETMINMAXINFO:
9416 {
9417 MINMAXINFO *minmax = (MINMAXINFO *)lp;
9418 ok(minmax->ptMaxPosition.x <= mi.rcMonitor.left, "%ld <= %ld\n", minmax->ptMaxPosition.x, mi.rcMonitor.left);
9419 ok(minmax->ptMaxPosition.y <= mi.rcMonitor.top, "%ld <= %ld\n", minmax->ptMaxPosition.y, mi.rcMonitor.top);
9420 ok(minmax->ptMaxSize.x >= mi.rcMonitor.right, "%ld >= %ld\n", minmax->ptMaxSize.x, mi.rcMonitor.right);
9421 ok(minmax->ptMaxSize.y >= mi.rcMonitor.bottom, "%ld >= %ld\n", minmax->ptMaxSize.y, mi.rcMonitor.bottom);
9422 break;
9423 }
9424 case WM_NCCALCSIZE:
9425 {
9427 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wp, lp);
9428 return ret;
9429 }
9430 }
9431 return DefWindowProcA(hwnd, msg, wp, lp);
9432}
9433
9434static void test_fullscreen(void)
9435{
9436 static const DWORD t_style[] = {
9438 };
9439 static const DWORD t_ex_style[] = {
9441 };
9442 RECT rc, virtual_rect, expected_rect;
9443 WNDCLASSA cls;
9444 int timeout;
9445 HWND hwnd;
9446 int i, j;
9447 POINT pt;
9448 HMONITOR hmon;
9449 LRESULT ret;
9450
9451 pt.x = pt.y = 0;
9452 SetLastError(0xdeadbeef);
9453 hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
9454 ok(hmon != 0, "MonitorFromPoint error %lu\n", GetLastError());
9455
9456 mi.cbSize = sizeof(mi);
9457 SetLastError(0xdeadbeef);
9459 ok(ret, "GetMonitorInfo error %lu\n", GetLastError());
9460 trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi.rcMonitor), wine_dbgstr_rect(&mi.rcWork));
9461
9462 cls.style = 0;
9464 cls.cbClsExtra = 0;
9465 cls.cbWndExtra = 0;
9467 cls.hIcon = 0;
9470 cls.lpszMenuName = NULL;
9471 cls.lpszClassName = "fullscreen_class";
9472 RegisterClassA(&cls);
9473
9474 for (i = 0; i < ARRAY_SIZE(t_style); i++)
9475 {
9476 DWORD style, ex_style;
9477
9478 /* avoid a WM interaction */
9479 assert(!(t_style[i] & WS_VISIBLE));
9480
9481 for (j = 0; j < ARRAY_SIZE(t_ex_style); j++)
9482 {
9483 int fixup;
9484
9485 style = t_style[i];
9486 ex_style = t_ex_style[j];
9487
9488 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
9491 ok(hwnd != 0, "%d: CreateWindowExA(%#lx/%#lx) failed\n", i, ex_style, style);
9492 GetWindowRect(hwnd, &rc);
9493 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
9495 "%#lx/%#lx: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
9497
9498 style = t_style[i] | WS_MAXIMIZE;
9499 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
9502 ok(hwnd != 0, "%d: CreateWindowExA(%#lx/%#lx) failed\n", i, ex_style, style);
9503 GetWindowRect(hwnd, &rc);
9504 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
9506 "%#lx/%#lx: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
9508
9509 style = t_style[i] | WS_MAXIMIZE | WS_CAPTION;
9510 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
9513 ok(hwnd != 0, "%d: CreateWindowExA(%#lx/%#lx) failed\n", i, ex_style, style);
9514 GetWindowRect(hwnd, &rc);
9515 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
9517 "%#lx/%#lx: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
9519
9520 style = t_style[i] | WS_CAPTION | WS_MAXIMIZEBOX;
9521 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
9524 ok(hwnd != 0, "%d: CreateWindowExA(%#lx/%#lx) failed\n", i, ex_style, style);
9525 GetWindowRect(hwnd, &rc);
9526 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
9528 "%#lx/%#lx: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
9530
9531 style = t_style[i] | WS_MAXIMIZE | WS_CAPTION | WS_MAXIMIZEBOX;
9532 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
9535 ok(hwnd != 0, "%d: CreateWindowExA(%#lx/%#lx) failed\n", i, ex_style, style);
9536 GetWindowRect(hwnd, &rc);
9537 /* Windows makes a maximized window slightly larger (to hide the borders?) */
9538 fixup = min(abs(rc.left), abs(rc.top));
9539 InflateRect(&rc, -fixup, -fixup);
9540 ok(rc.left >= mi.rcMonitor.left && rc.top >= mi.rcMonitor.top &&
9542 "%#lx/%#lx: window rect %s must be in %s\n", ex_style, style, wine_dbgstr_rect(&rc),
9545
9546 style = t_style[i] | WS_MAXIMIZE | WS_MAXIMIZEBOX;
9547 hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
9550 ok(hwnd != 0, "%d: CreateWindowExA(%#lx/%#lx) failed\n", i, ex_style, style);
9551 GetWindowRect(hwnd, &rc);
9552 /* Windows makes a maximized window slightly larger (to hide the borders?) */
9553 fixup = min(abs(rc.left), abs(rc.top));
9554 InflateRect(&rc, -fixup, -fixup);
9555 if (style & (WS_CHILD | WS_POPUP))
9556 ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
9558 "%#lx/%#lx: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
9559 else
9560 ok(rc.left >= mi.rcMonitor.left && rc.top >= mi.rcMonitor.top &&
9562 "%#lx/%#lx: window rect %s\n", ex_style, style, wine_dbgstr_rect(&rc));
9564 }
9565 }
9566
9567 /* Test restoring a full screen window with WS_THICKFRAME style to normal */
9568 /* Add WS_THICKFRAME style later so that the window can cover the entire monitor */
9569 hwnd = CreateWindowA("fullscreen_class", NULL, WS_POPUP | WS_VISIBLE, 0, 0, mi.rcMonitor.right,
9571 ok(!!hwnd, "CreateWindow failed, error %#lx.\n", GetLastError());
9573
9574 /* Add WS_THICKFRAME and exit full screen */
9578
9579 /* TestBots need about 1000ms to exit full screen */
9580 timeout = 1000;
9581 while (timeout > 0)
9582 {
9583 timeout -= 200;
9585 GetWindowRect(hwnd, &rc);
9586 if (rc.right - rc.left == 100 && rc.bottom - rc.top == 100)
9587 break;
9588 }
9589 ok(rc.right - rc.left == 100, "Expect width %d, got %ld.\n", 100, rc.right - rc.left);
9590 ok(rc.bottom - rc.top == 100, "Expect height %d, got %ld.\n", 100, rc.bottom - rc.top);
9592
9593 UnregisterClassA("fullscreen_class", GetModuleHandleA(NULL));
9594
9595 /* Test fullscreen windows spanning multiple monitors */
9597 {
9598 /* Test windows covering all monitors */
9599 virtual_rect.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
9600 virtual_rect.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
9601 virtual_rect.right = virtual_rect.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
9602 virtual_rect.bottom = virtual_rect.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
9603
9604 hwnd = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, virtual_rect.left,
9605 virtual_rect.top, virtual_rect.right - virtual_rect.left,
9606 virtual_rect.bottom - virtual_rect.top, NULL, NULL, NULL, NULL);
9607 ok(!!hwnd, "CreateWindow failed, error %#lx.\n", GetLastError());
9609
9610 GetWindowRect(hwnd, &rc);
9611 /* FVWM used by TestBots doesn't support _NET_WM_FULLSCREEN_MONITORS */
9612 todo_wine_if(!EqualRect(&rc, &virtual_rect))
9613 ok(EqualRect(&rc, &virtual_rect), "Expected %s, got %s.\n",
9614 wine_dbgstr_rect(&virtual_rect), wine_dbgstr_rect(&rc));
9616
9617 /* Test windows covering one monitor and 1 pixel larger on available sides */
9619 InflateRect(&expected_rect, 1, 1);
9620 IntersectRect(&expected_rect, &expected_rect, &virtual_rect);
9624 ok(!!hwnd, "CreateWindow failed, error %#lx.\n", GetLastError());
9626
9627 GetWindowRect(hwnd, &rc);
9628 todo_wine
9629 ok(EqualRect(&rc, &expected_rect), "Expected %s, got %s.\n",
9632 }
9633 else
9634 {
9635 skip("This test requires at least two monitors.\n");
9636 }
9637}
9638
9640static const char * test_thick_child_name;
9643
9645{
9646 MINMAXINFO* minmax;
9647 int expectedMinTrackX;
9648 int expectedMinTrackY;
9649 int actualMinTrackX;
9650 int actualMinTrackY;
9651 int expectedMaxTrackX;
9652 int expectedMaxTrackY;
9653 int actualMaxTrackX;
9654 int actualMaxTrackY;
9655 int expectedMaxSizeX;
9656 int expectedMaxSizeY;
9657 int actualMaxSizeX;
9658 int actualMaxSizeY;
9659 int expectedPosX;
9660 int expectedPosY;
9661 int actualPosX;
9662 int actualPosY;
9663 LONG adjustedStyle;
9664 RECT rect;
9665 switch (msg)
9666 {
9667 case WM_GETMINMAXINFO:
9668 {
9669 minmax = (MINMAXINFO *)lparam;
9670 if (winetest_debug > 1)
9671 {
9672 trace("hwnd %p, WM_GETMINMAXINFO, %08Ix, %08Ix\n", hwnd, wparam, lparam);
9673 dump_minmax_info( minmax );
9674 }
9676
9677
9678 adjustedStyle = test_thick_child_style;
9679 if ((adjustedStyle & WS_CAPTION) == WS_CAPTION)
9680 adjustedStyle &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
9683
9685 {
9686 expectedMinTrackX = GetSystemMetrics(SM_CXMINTRACK);
9687 expectedMinTrackY = GetSystemMetrics(SM_CYMINTRACK);
9688 }
9689 else
9690 {
9691 expectedMinTrackX = -2 * rect.left;
9692 expectedMinTrackY = -2 * rect.top;
9693 }
9694 actualMinTrackX = minmax->ptMinTrackSize.x;
9695 actualMinTrackY = minmax->ptMinTrackSize.y;
9696
9697 ok(actualMinTrackX == expectedMinTrackX && actualMinTrackY == expectedMinTrackY,
9698 "expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
9699 expectedMinTrackX, expectedMinTrackY, actualMinTrackX, actualMinTrackY,
9701
9702 actualMaxTrackX = minmax->ptMaxTrackSize.x;
9703 actualMaxTrackY = minmax->ptMaxTrackSize.y;
9704 expectedMaxTrackX = GetSystemMetrics(SM_CXMAXTRACK);
9705 expectedMaxTrackY = GetSystemMetrics(SM_CYMAXTRACK);
9706 ok(actualMaxTrackX == expectedMaxTrackX && actualMaxTrackY == expectedMaxTrackY,
9707 "expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
9708 expectedMaxTrackX, expectedMaxTrackY, actualMaxTrackX, actualMaxTrackY,
9710
9711 expectedMaxSizeX = rect.right - rect.left;
9712 expectedMaxSizeY = rect.bottom - rect.top;
9713 actualMaxSizeX = minmax->ptMaxSize.x;
9714 actualMaxSizeY = minmax->ptMaxSize.y;
9715
9716 ok(actualMaxSizeX == expectedMaxSizeX && actualMaxSizeY == expectedMaxSizeY,
9717 "expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
9718 expectedMaxSizeX, expectedMaxSizeY, actualMaxSizeX, actualMaxSizeY,
9720
9721
9722 expectedPosX = rect.left;
9723 expectedPosY = rect.top;
9724 actualPosX = minmax->ptMaxPosition.x;
9725 actualPosY = minmax->ptMaxPosition.y;
9726 ok(actualPosX == expectedPosX && actualPosY == expectedPosY,
9727 "expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
9728 expectedPosX, expectedPosY, actualPosX, actualPosY, test_thick_child_name);
9729
9730 break;
9731 }
9732
9733 case WM_NCCALCSIZE:
9734 {
9736 ok(!ret, "got %08Ix (%08Ix %08Ix)\n", ret, wparam, lparam);
9737 return ret;
9738 }
9739 }
9740
9741 return DefWindowProcA(hwnd, msg, wparam, lparam);
9742}
9743
9744#define NUMBER_OF_THICK_CHILD_TESTS 16
9745static void test_thick_child_size(HWND parentWindow)
9746{
9747 BOOL success;
9748 RECT childRect;
9749 RECT adjustedParentRect;
9750 HWND childWindow;
9751 LONG childWidth;
9752 LONG childHeight;
9753 LONG expectedWidth;
9754 LONG expectedHeight;
9755 WNDCLASSA cls;
9756 static const char className[] = "THICK_CHILD_CLASS";
9757 int i;
9758 LONG adjustedStyle;
9759 static const LONG styles[NUMBER_OF_THICK_CHILD_TESTS] = {
9776 };
9777
9778 static const LONG exStyles[NUMBER_OF_THICK_CHILD_TESTS] = {
9779 0,
9780 0,
9781 0,
9782 0,
9795 };
9796 static const char *styleName[NUMBER_OF_THICK_CHILD_TESTS] = {
9797 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
9798 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
9799 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
9800 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
9801 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
9802 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
9803 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
9804 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
9805 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
9806 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
9807 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
9808 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
9809 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
9810 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
9811 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
9812 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
9813 };
9814
9815 cls.style = 0;
9817 cls.cbClsExtra = 0;
9818 cls.cbWndExtra = 0;
9819 cls.hInstance = GetModuleHandleA(0);
9820 cls.hIcon = 0;
9823 cls.lpszMenuName = NULL;
9824 cls.lpszClassName = className;
9825 SetLastError(0xdeadbeef);
9826 success = RegisterClassA(&cls);
9827 ok(success,"RegisterClassA failed, error: %lu\n", GetLastError());
9828
9829 for(i = 0; i < NUMBER_OF_THICK_CHILD_TESTS; i++)
9830 {
9831 test_thick_child_name = styleName[i];
9832 test_thick_child_style = styles[i];
9833 test_thick_child_exStyle = exStyles[i];
9835
9836 SetLastError(0xdeadbeef);
9837 childWindow = CreateWindowExA( exStyles[i], className, "", styles[i], 0, 0, 0, 0, parentWindow, 0, GetModuleHandleA(0), NULL );
9838 ok(childWindow != NULL, "Failed to create child window, error: %lu\n", GetLastError());
9839
9840 ok(test_thick_child_got_minmax, "Got no WM_GETMINMAXINFO\n");
9841
9842 SetLastError(0xdeadbeef);
9843 success = GetWindowRect(childWindow, &childRect);
9844 ok(success,"GetWindowRect call failed, error: %lu\n", GetLastError());
9845 childWidth = childRect.right - childRect.left;
9846 childHeight = childRect.bottom - childRect.top;
9847
9848 adjustedStyle = styles[i];
9849 if ((adjustedStyle & WS_CAPTION) == WS_CAPTION)
9850 adjustedStyle &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
9851 GetClientRect(GetParent(childWindow), &adjustedParentRect);
9852 AdjustWindowRectEx(&adjustedParentRect, adjustedStyle, FALSE, test_thick_child_exStyle);
9853
9854
9856 {
9857 expectedWidth = GetSystemMetrics(SM_CXMINTRACK);
9858 expectedHeight = GetSystemMetrics(SM_CYMINTRACK);
9859 }
9860 else
9861 {
9862 expectedWidth = -2 * adjustedParentRect.left;
9863 expectedHeight = -2 * adjustedParentRect.top;
9864 }
9865
9866 ok((childWidth == expectedWidth) && (childHeight == expectedHeight),
9867 "size of window (%s) is wrong: expected size %ldx%ld != actual size %ldx%ld\n",
9868 test_thick_child_name, expectedWidth, expectedHeight, childWidth, childHeight);
9869
9870 SetLastError(0xdeadbeef);
9871 success = DestroyWindow(childWindow);
9872 ok(success,"DestroyWindow call failed, error: %lu\n", GetLastError());
9873 }
9874 ok(UnregisterClassA(className, GetModuleHandleA(NULL)),"UnregisterClass call failed\n");
9875}
9876
9877static void test_handles( HWND full_hwnd )
9878{
9879 HWND hwnd = full_hwnd;
9880 BOOL ret;
9881 RECT rect;
9882
9883 SetLastError( 0xdeadbeef );
9884 ret = GetWindowRect( hwnd, &rect );
9885 ok( ret, "GetWindowRect failed for %p err %lu\n", hwnd, GetLastError() );
9886
9887#ifdef _WIN64
9888 if ((ULONG_PTR)full_hwnd >> 32)
9889 hwnd = (HWND)((ULONG_PTR)full_hwnd & ~0u);
9890 else
9891 hwnd = (HWND)((ULONG_PTR)full_hwnd | ((ULONG_PTR)~0u << 32));
9892 SetLastError( 0xdeadbeef );
9893 ret = GetWindowRect( hwnd, &rect );
9894 ok( ret, "GetWindowRect failed for %p err %lu\n", hwnd, GetLastError() );
9895
9896 hwnd = (HWND)(((ULONG_PTR)full_hwnd & ~0u) | ((ULONG_PTR)0x1234 << 32));
9897 SetLastError( 0xdeadbeef );
9898 ret = GetWindowRect( hwnd, &rect );
9899 ok( ret, "GetWindowRect failed for %p err %lu\n", hwnd, GetLastError() );
9900
9901 hwnd = (HWND)(((ULONG_PTR)full_hwnd & 0xffff) | ((ULONG_PTR)0x9876 << 16));
9902 SetLastError( 0xdeadbeef );
9903 ret = GetWindowRect( hwnd, &rect );
9904 ok( !ret, "GetWindowRect succeeded for %p\n", hwnd );
9905 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %lu\n", GetLastError() );
9906
9907 hwnd = (HWND)(((ULONG_PTR)full_hwnd & 0xffff) | ((ULONG_PTR)0x12345678 << 16));
9908 SetLastError( 0xdeadbeef );
9909 ret = GetWindowRect( hwnd, &rect );
9910 ok( !ret, "GetWindowRect succeeded for %p\n", hwnd );
9911 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %lu\n", GetLastError() );
9912#endif
9913}
9914
9915static void test_winregion(void)
9916{
9917 HWND hwnd;
9918 RECT r;
9919 int ret, width;
9920 HRGN hrgn;
9921
9922 if (!pGetWindowRgnBox)
9923 {
9924 win_skip("GetWindowRgnBox not supported\n");
9925 return;
9926 }
9927
9928 hwnd = CreateWindowExA(0, "static", NULL, WS_VISIBLE, 10, 10, 10, 10, NULL, 0, 0, NULL);
9929 /* NULL prect */
9930 SetLastError(0xdeadbeef);
9931 ret = pGetWindowRgnBox(hwnd, NULL);
9932 ok( ret == ERROR, "Expected ERROR, got %d\n", ret);
9933 ok( GetLastError() == 0xdeadbeef, "Expected , got %ld\n", GetLastError());
9934
9935 hrgn = CreateRectRgn(2, 3, 10, 15);
9936 ok( hrgn != NULL, "Region creation failed\n");
9937 if (hrgn)
9938 {
9940
9941 SetLastError(0xdeadbeef);
9942 ret = pGetWindowRgnBox(hwnd, NULL);
9943 ok( ret == ERROR, "Expected ERROR, got %d\n", ret);
9944 ok( GetLastError() == 0xdeadbeef, "Expected , got %ld\n", GetLastError());
9945
9946 SetRectEmpty(&r);
9947 ret = pGetWindowRgnBox(hwnd, &r);
9948 ok( ret == SIMPLEREGION, "Expected SIMPLEREGION, got %d\n", ret);
9949 ok( r.left == 2 && r.top == 3 && r.right == 10 && r.bottom == 15,
9950 "Expected (2,3)-(10,15), got %s\n", wine_dbgstr_rect( &r ));
9951 if (pMirrorRgn)
9952 {
9953 hrgn = CreateRectRgn(2, 3, 10, 15);
9954 ret = pMirrorRgn( hwnd, hrgn );
9955 ok( ret == TRUE, "MirrorRgn failed %u\n", ret );
9956 SetRectEmpty(&r);
9957 GetWindowRect( hwnd, &r );
9958 width = r.right - r.left;
9959 SetRectEmpty(&r);
9960 ret = GetRgnBox( hrgn, &r );
9961 ok( ret == SIMPLEREGION, "GetRgnBox failed %u\n", ret );
9962 ok( r.left == width - 10 && r.top == 3 && r.right == width - 2 && r.bottom == 15,
9963 "Wrong rectangle %s for width %d\n", wine_dbgstr_rect( &r ), width );
9964 }
9965 else win_skip( "MirrorRgn not supported\n" );
9966 }
9968}
9969
9970static void test_rtl_layout(void)
9971{
9972 HWND parent, child;
9973 RECT r;
9974 POINT pt;
9975
9976 if (!pSetProcessDefaultLayout)
9977 {
9978 win_skip( "SetProcessDefaultLayout not supported\n" );
9979 return;
9980 }
9981
9982 parent = CreateWindowExA(WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, 100, 100, 300, 300, NULL, 0, 0, NULL);
9983 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 10, 10, 20, 20, parent, 0, 0, NULL);
9984
9985 GetWindowRect( parent, &r );
9986 ok( r.left == 100 && r.right == 400, "wrong rect %s\n", wine_dbgstr_rect( &r ));
9987 GetClientRect( parent, &r );
9988 ok( r.left == 0 && r.right == 300, "wrong rect %s\n", wine_dbgstr_rect( &r ));
9989 GetClientRect( child, &r );
9990 ok( r.left == 0 && r.right == 20, "wrong rect %s\n", wine_dbgstr_rect( &r ));
9991 MapWindowPoints( child, parent, (POINT *)&r, 2 );
9992 ok( r.left == 10 && r.right == 30, "wrong rect %s\n", wine_dbgstr_rect( &r ));
9993 GetWindowRect( child, &r );
9994 ok( r.left == 370 && r.right == 390, "wrong rect %s\n", wine_dbgstr_rect( &r ));
9995 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
9996 ok( r.left == 10 && r.right == 30, "wrong rect %s\n", wine_dbgstr_rect( &r ));
9997 GetWindowRect( child, &r );
9998 MapWindowPoints( NULL, parent, (POINT *)&r, 1 );
9999 MapWindowPoints( NULL, parent, (POINT *)&r + 1, 1 );
10000 ok( r.left == 30 && r.right == 10, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10001 pt.x = pt.y = 12;
10002 MapWindowPoints( child, parent, &pt, 1 );
10003 ok( pt.x == 22 && pt.y == 22, "wrong point %ld,%ld\n", pt.x, pt.y );
10004 SetWindowPos( parent, 0, 0, 0, 250, 250, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
10005 GetWindowRect( parent, &r );
10006 ok( r.left == 100 && r.right == 350, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10007 GetWindowRect( child, &r );
10008 ok( r.left == 320 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10010 GetWindowRect( child, &r );
10011 ok( r.left == 320 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10012 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
10013 ok( r.left == 220 && r.right == 240, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10015 GetWindowRect( child, &r );
10016 ok( r.left == 320 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10017 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
10018 ok( r.left == 10 && r.right == 30, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10019 SetWindowPos( child, 0, 0, 0, 30, 30, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
10020 GetWindowRect( child, &r );
10021 ok( r.left == 310 && r.right == 340, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10022 MapWindowPoints( NULL, parent, (POINT *)&r, 2 );
10023 ok( r.left == 10 && r.right == 40, "wrong rect %s\n", wine_dbgstr_rect( &r ));
10026}
10027
10028static void test_FlashWindow(void)
10029{
10030 HWND hwnd;
10031 BOOL ret;
10032 if (!pFlashWindow)
10033 {
10034 win_skip( "FlashWindow not supported\n" );
10035 return;
10036 }
10037
10038 hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP,
10039 0, 0, 0, 0, 0, 0, 0, NULL );
10040 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10041
10042 SetLastError( 0xdeadbeef );
10043 ret = pFlashWindow( NULL, TRUE );
10046 "FlashWindow returned with %ld\n", GetLastError() );
10047
10049
10050 SetLastError( 0xdeadbeef );
10051 ret = pFlashWindow( hwnd, TRUE );
10054 "FlashWindow returned with %ld\n", GetLastError() );
10055}
10056
10057static void test_FlashWindowEx(void)
10058{
10059 HWND hwnd;
10060 FLASHWINFO finfo;
10061 BOOL prev, ret;
10062
10063 if (!pFlashWindowEx)
10064 {
10065 win_skip( "FlashWindowEx not supported\n" );
10066 return;
10067 }
10068
10069 hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP,
10070 0, 0, 0, 0, 0, 0, 0, NULL );
10071 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10072
10073 finfo.cbSize = sizeof(FLASHWINFO);
10074 finfo.dwFlags = FLASHW_TIMER;
10075 finfo.uCount = 3;
10076 finfo.dwTimeout = 200;
10077 finfo.hwnd = NULL;
10078 SetLastError(0xdeadbeef);
10079 ret = pFlashWindowEx(&finfo);
10082 "FlashWindowEx returned with %ld\n", GetLastError());
10083
10084 finfo.hwnd = hwnd;
10085 SetLastError(0xdeadbeef);
10086 ret = pFlashWindowEx(NULL);
10088 "FlashWindowEx returned with %ld\n", GetLastError());
10089
10090 SetLastError(0xdeadbeef);
10091 ret = pFlashWindowEx(&finfo);
10092 todo_wine ok(!ret, "previous window state should not be active\n");
10093
10094 finfo.cbSize = sizeof(FLASHWINFO) - 1;
10095 SetLastError(0xdeadbeef);
10096 ret = pFlashWindowEx(&finfo);
10098 "FlashWindowEx succeeded\n");
10099
10100 finfo.cbSize = sizeof(FLASHWINFO) + 1;
10101 SetLastError(0xdeadbeef);
10102 ret = pFlashWindowEx(&finfo);
10104 "FlashWindowEx succeeded\n");
10105 finfo.cbSize = sizeof(FLASHWINFO);
10106
10108
10109 SetLastError(0xdeadbeef);
10110 ret = pFlashWindowEx(&finfo);
10113 "FlashWindowEx returned with %ld\n", GetLastError());
10114
10115 ok(finfo.cbSize == sizeof(FLASHWINFO), "FlashWindowEx modified cdSize to %x\n", finfo.cbSize);
10116 ok(finfo.hwnd == hwnd, "FlashWindowEx modified hwnd to %p\n", finfo.hwnd);
10117 ok(finfo.dwFlags == FLASHW_TIMER, "FlashWindowEx modified dwFlags to %lx\n", finfo.dwFlags);
10118 ok(finfo.uCount == 3, "FlashWindowEx modified uCount to %x\n", finfo.uCount);
10119 ok(finfo.dwTimeout == 200, "FlashWindowEx modified dwTimeout to %lx\n", finfo.dwTimeout);
10120
10121 hwnd = CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE | WS_POPUPWINDOW,
10122 0, 0, 0, 0, 0, 0, 0, NULL );
10123 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10124 finfo.hwnd = hwnd;
10125
10126 SetLastError(0xdeadbeef);
10127 ret = pFlashWindowEx(NULL);
10129 "FlashWindowEx returned with %ld\n", GetLastError());
10130
10131 SetLastError(0xdeadbeef);
10132 prev = pFlashWindowEx(&finfo);
10133
10134 ok(finfo.cbSize == sizeof(FLASHWINFO), "FlashWindowEx modified cdSize to %x\n", finfo.cbSize);
10135 ok(finfo.hwnd == hwnd, "FlashWindowEx modified hwnd to %p\n", finfo.hwnd);
10136 ok(finfo.dwFlags == FLASHW_TIMER, "FlashWindowEx modified dwFlags to %lx\n", finfo.dwFlags);
10137 ok(finfo.uCount == 3, "FlashWindowEx modified uCount to %x\n", finfo.uCount);
10138 ok(finfo.dwTimeout == 200, "FlashWindowEx modified dwTimeout to %lx\n", finfo.dwTimeout);
10139
10140 finfo.dwFlags = FLASHW_STOP;
10141 SetLastError(0xdeadbeef);
10142 ret = pFlashWindowEx(&finfo);
10143 ok(prev != ret, "previous window state should be different\n");
10144
10146}
10147
10148static void test_FindWindowEx(void)
10149{
10150 HWND hwnd, found;
10151
10152 hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
10153 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10154
10155 num_gettext_msgs = 0;
10156 found = FindWindowExA( 0, 0, "ClassThatDoesntExist", "" );
10157 ok( found == NULL, "expected a NULL hwnd\n" );
10158 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10159
10160 num_gettext_msgs = 0;
10161 found = FindWindowExA( 0, 0, "ClassThatDoesntExist", NULL );
10162 ok( found == NULL, "expected a NULL hwnd\n" );
10163 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10164
10165 num_gettext_msgs = 0;
10166 found = FindWindowExA( 0, 0, "MainWindowClass", "" );
10167 ok( found == NULL, "expected a NULL hwnd\n" );
10168 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10169
10170 num_gettext_msgs = 0;
10171 found = FindWindowExA( 0, 0, "MainWindowClass", NULL );
10172 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10173 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10174
10175 num_gettext_msgs = 0;
10176 found = FindWindowExA( 0, 0, "MainWindowClass", "caption" );
10177 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10178 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10179
10181
10182 hwnd = CreateWindowExA( 0, "MainWindowClass", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
10183 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10184
10185 num_gettext_msgs = 0;
10186 found = FindWindowExA( 0, 0, "MainWindowClass", "" );
10187 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10188 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10189
10190 num_gettext_msgs = 0;
10191 found = FindWindowExA( 0, 0, "MainWindowClass", NULL );
10192 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10193 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10194
10196
10197 /* test behaviour with a window title that is an empty character */
10198 found = FindWindowExA( 0, 0, "Shell_TrayWnd", "" );
10199 ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
10200 found = FindWindowExA( 0, 0, "Shell_TrayWnd", NULL );
10201 ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
10202}
10203
10204static void test_FindWindow(void)
10205{
10206 HWND hwnd, found;
10207
10208 hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
10209 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10210
10211 num_gettext_msgs = 0;
10212 found = FindWindowA( "ClassThatDoesntExist", "" );
10213 ok( found == NULL, "expected a NULL hwnd\n" );
10214 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10215
10216 num_gettext_msgs = 0;
10217 found = FindWindowA( "ClassThatDoesntExist", NULL );
10218 ok( found == NULL, "expected a NULL hwnd\n" );
10219 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10220
10221 num_gettext_msgs = 0;
10222 found = FindWindowA( "MainWindowClass", "" );
10223 ok( found == NULL, "expected a NULL hwnd\n" );
10224 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10225
10226 num_gettext_msgs = 0;
10227 found = FindWindowA( "MainWindowClass", NULL );
10228 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10229 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10230
10231 num_gettext_msgs = 0;
10232 found = FindWindowA( "MainWindowClass", "caption" );
10233 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10234 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10235
10237
10238 hwnd = CreateWindowExA( 0, "MainWindowClass", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL );
10239 ok( hwnd != 0, "CreateWindowExA error %ld\n", GetLastError() );
10240
10241 num_gettext_msgs = 0;
10242 found = FindWindowA( "MainWindowClass", "" );
10243 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10244 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10245
10246 num_gettext_msgs = 0;
10247 found = FindWindowA( "MainWindowClass", NULL );
10248 ok( found == hwnd, "found is %p, expected a valid hwnd\n", found );
10249 ok( num_gettext_msgs == 0, "got %lu WM_GETTEXT messages\n", num_gettext_msgs );
10250
10252
10253 /* test behaviour with a window title that is an empty character */
10254 found = FindWindowA( "Shell_TrayWnd", "" );
10255 ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
10256 found = FindWindowA( "Shell_TrayWnd", NULL );
10257 ok( found != NULL, "found is NULL, expected a valid hwnd\n" );
10258}
10259
10261{
10262 HWND hwndOwner, hwndPopup1, hwndPopup2;
10263
10264 hwndOwner = CreateWindowExA(0, "MainWindowClass", NULL,
10266 100, 100, 200, 200,
10268 hwndPopup1 = CreateWindowExA(0, "MainWindowClass", NULL,
10270 100, 100, 200, 200,
10271 hwndOwner, 0, GetModuleHandleA(NULL), NULL);
10272 hwndPopup2 = CreateWindowExA(0, "MainWindowClass", NULL,
10274 100, 100, 200, 200,
10275 hwndPopup1, 0, GetModuleHandleA(NULL), NULL);
10276 ok( GetLastActivePopup(hwndOwner) == hwndPopup2, "wrong last active popup\n" );
10277 DestroyWindow( hwndPopup2 );
10278 DestroyWindow( hwndPopup1 );
10279 DestroyWindow( hwndOwner );
10280}
10281
10283{
10284 if (msg == WM_NCHITTEST) return HTTRANSPARENT;
10285 return DefWindowProcA(hwnd, msg, wp, lp);
10286}
10287
10289{
10290 return DefWindowProcA(hwnd, msg, wp, lp);
10291}
10292
10294{
10295 static const DWORD style[] = { 0, WS_VISIBLE, WS_DISABLED, WS_VISIBLE | WS_DISABLED };
10296 int i, pos;
10297
10298 memset(window, 0, size * sizeof(window[0]));
10299
10300 pos = 0;
10301 for (i = 0; i < ARRAY_SIZE(style); i++)
10302 {
10303 assert(pos < size);
10304 window[pos] = CreateWindowExA(0, "my_window", NULL, style[i] | WS_CHILD,
10305 0, 0, 100, 100, parent, 0, 0, NULL);
10306 ok(window[pos] != 0, "CreateWindowEx failed\n");
10307 pos++;
10308 assert(pos < size);
10310 0, 0, 100, 100, parent, 0, 0, NULL);
10311 ok(window[pos] != 0, "CreateWindowEx failed\n");
10312 pos++;
10313
10314 assert(pos < size);
10315 window[pos] = CreateWindowExA(0, "my_httrasparent", NULL, style[i] | WS_CHILD,
10316 0, 0, 100, 100, parent, 0, 0, NULL);
10317 ok(window[pos] != 0, "CreateWindowEx failed\n");
10318 pos++;
10319 assert(pos < size);
10320 window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "my_httrasparent", NULL, style[i] | WS_CHILD,
10321 0, 0, 100, 100, parent, 0, 0, NULL);
10322 ok(window[pos] != 0, "CreateWindowEx failed\n");
10323 pos++;
10324
10325 assert(pos < size);
10326 window[pos] = CreateWindowExA(0, "my_button", NULL, style[i] | WS_CHILD | BS_GROUPBOX,
10327 0, 0, 100, 100, parent, 0, 0, NULL);
10328 ok(window[pos] != 0, "CreateWindowEx failed\n");
10329 pos++;
10330 assert(pos < size);
10332 0, 0, 100, 100, parent, 0, 0, NULL);
10333 ok(window[pos] != 0, "CreateWindowEx failed\n");
10334 pos++;
10335 assert(pos < size);
10336 window[pos] = CreateWindowExA(0, "my_button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON,
10337 0, 0, 100, 100, parent, 0, 0, NULL);
10338 ok(window[pos] != 0, "CreateWindowEx failed\n");
10339 pos++;
10340 assert(pos < size);
10342 0, 0, 100, 100, parent, 0, 0, NULL);
10343 ok(window[pos] != 0, "CreateWindowEx failed\n");
10344 pos++;
10345
10346 assert(pos < size);
10347 window[pos] = CreateWindowExA(0, "Button", NULL, style[i] | WS_CHILD | BS_GROUPBOX,
10348 0, 0, 100, 100, parent, 0, 0, NULL);
10349 ok(window[pos] != 0, "CreateWindowEx failed\n");
10350 pos++;
10351 assert(pos < size);
10353 0, 0, 100, 100, parent, 0, 0, NULL);
10354 ok(window[pos] != 0, "CreateWindowEx failed\n");
10355 pos++;
10356 assert(pos < size);
10358 0, 0, 100, 100, parent, 0, 0, NULL);
10359 ok(window[pos] != 0, "CreateWindowEx failed\n");
10360 pos++;
10361 assert(pos < size);
10363 0, 0, 100, 100, parent, 0, 0, NULL);
10364 ok(window[pos] != 0, "CreateWindowEx failed\n");
10365 pos++;
10366
10367 assert(pos < size);
10368 window[pos] = CreateWindowExA(0, "Static", NULL, style[i] | WS_CHILD,
10369 0, 0, 100, 100, parent, 0, 0, NULL);
10370 ok(window[pos] != 0, "CreateWindowEx failed\n");
10371 pos++;
10372 assert(pos < size);
10374 0, 0, 100, 100, parent, 0, 0, NULL);
10375 ok(window[pos] != 0, "CreateWindowEx failed\n");
10376 pos++;
10377 }
10378}
10379
10381{
10382 char class_name[128];
10384};
10385
10387{
10388 DWORD style, ex_style, hittest;
10389
10391 ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE);
10392 attrs->class_name[0] = 0;
10393 GetClassNameA(hwnd, attrs->class_name, sizeof(attrs->class_name));
10394 hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, 0);
10395
10396 attrs->is_visible = (style & WS_VISIBLE) != 0;
10397 attrs->is_enabled = (style & WS_DISABLED) == 0;
10398 attrs->is_groupbox = !lstrcmpiA(attrs->class_name, "Button") && (style & BS_TYPEMASK) == BS_GROUPBOX;
10399 attrs->is_httransparent = hittest == HTTRANSPARENT;
10400 attrs->is_extransparent = (ex_style & WS_EX_TRANSPARENT) != 0;
10401}
10402
10404{
10405 int i;
10406
10407 for (i = 0; i < size; i++)
10408 {
10409 if (!window[i]) break;
10410 if (window[i] == hwnd) return i;
10411 }
10412 return -1;
10413}
10414
10416{
10417 static const int real_child_pos[] = { 14,15,16,17,18,19,20,21,24,25,26,27,42,43,
10418 44,45,46,47,48,49,52,53,54,55,51,50,23,22,-1 };
10419 WNDCLASSA cls;
10420 HWND hwnd, parent, window[100];
10421 POINT pt;
10422 int found_invisible, found_disabled, found_groupbox, found_httransparent, found_extransparent;
10423 int ret, i;
10424
10425 ret = GetClassInfoA(0, "Button", &cls);
10426 ok(ret, "GetClassInfo(Button) failed\n");
10427 cls.lpszClassName = "my_button";
10428 ret = RegisterClassA(&cls);
10429 ok(ret, "RegisterClass(my_button) failed\n");
10430
10431 cls.lpszClassName = "my_httrasparent";
10433 ret = RegisterClassA(&cls);
10434 ok(ret, "RegisterClass(my_httrasparent) failed\n");
10435
10436 cls.lpszClassName = "my_window";
10438 ret = RegisterClassA(&cls);
10439 ok(ret, "RegisterClass(my_window) failed\n");
10440
10441 parent = CreateWindowExA(0, "MainWindowClass", NULL,
10443 100, 100, 200, 200,
10444 0, 0, GetModuleHandleA(NULL), NULL);
10445 ok(parent != 0, "CreateWindowEx failed\n");
10446 trace("parent %p\n", parent);
10447
10449
10450 found_invisible = 0;
10451 found_disabled = 0;
10452 found_groupbox = 0;
10453 found_httransparent = 0;
10454 found_extransparent = 0;
10455
10456 /* FIXME: also test WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx */
10457 for (i = 0; i < ARRAY_SIZE(real_child_pos); i++)
10458 {
10459 struct window_attributes attrs;
10460
10461 pt.x = pt.y = 50;
10463 ok(hwnd != 0, "RealChildWindowFromPoint failed\n");
10465 /* FIXME: remove once Wine is fixed */
10466 todo_wine_if (ret != real_child_pos[i])
10467 ok(ret == real_child_pos[i], "expected %d, got %d\n", real_child_pos[i], ret);
10468
10469 get_window_attributes(hwnd, &attrs);
10470 if (!attrs.is_visible) found_invisible++;
10471 if (!attrs.is_enabled) found_disabled++;
10472 if (attrs.is_groupbox) found_groupbox++;
10473 if (attrs.is_httransparent) found_httransparent++;
10474 if (attrs.is_extransparent) found_extransparent++;
10475
10476 if (ret != real_child_pos[i] && ret != -1)
10477 {
10478 trace("found hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
10479 hwnd, attrs.class_name, attrs.is_visible, attrs.is_enabled, attrs.is_groupbox, attrs.is_httransparent, attrs.is_extransparent);
10480 get_window_attributes(window[real_child_pos[i]], &attrs);
10481 trace("expected hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
10482 window[real_child_pos[i]], attrs.class_name, attrs.is_visible, attrs.is_enabled, attrs.is_groupbox, attrs.is_httransparent, attrs.is_extransparent);
10483 }
10484 if (ret == -1)
10485 {
10486 ok(hwnd == parent, "expected %p, got %p\n", parent, hwnd);
10487 break;
10488 }
10490 }
10491
10493
10494 ok(!found_invisible, "found %d invisible windows\n", found_invisible);
10495 ok(found_disabled, "found %d disabled windows\n", found_disabled);
10496 todo_wine
10497 ok(found_groupbox == 4, "found %d groupbox windows\n", found_groupbox);
10498 ok(found_httransparent, "found %d httransparent windows\n", found_httransparent);
10499 todo_wine
10500 ok(found_extransparent, "found %d extransparent windows\n", found_extransparent);
10501
10502 ret = UnregisterClassA("my_button", cls.hInstance);
10503 ok(ret, "UnregisterClass(my_button) failed\n");
10504 ret = UnregisterClassA("my_httrasparent", cls.hInstance);
10505 ok(ret, "UnregisterClass(my_httrasparent) failed\n");
10506 ret = UnregisterClassA("my_window", cls.hInstance);
10507 ok(ret, "UnregisterClass(my_window) failed\n");
10508}
10509
10510static void simulate_click(int x, int y)
10511{
10512 INPUT input[2];
10513 UINT events_no;
10514 POINT pt;
10515
10516 GetCursorPos(&pt);
10517 SetCursorPos(x, y);
10518 memset(input, 0, sizeof(input));
10519 input[0].type = INPUT_MOUSE;
10520 input[0].mi.dx = x;
10521 input[0].mi.dy = y;
10522 input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
10523 input[1].type = INPUT_MOUSE;
10524 input[1].mi.dx = x;
10525 input[1].mi.dy = y;
10526 input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
10527 events_no = SendInput(2, input, sizeof(input[0]));
10528 ok(events_no == 2, "SendInput returned %d\n", events_no);
10529 SetCursorPos(pt.x, pt.y);
10530}
10531
10535{
10536 if(msg == WM_NCHITTEST)
10537 got_hittest = TRUE;
10538 if(msg == WM_LBUTTONDOWN)
10539 ok(0, "unexpected call\n");
10540
10541 return def_static_proc(hwnd, msg, wp, lp);
10542}
10543
10545{
10546 HANDLE start_event, end_event;
10547 HANDLE win, child_static, child_button;
10548 BOOL got_click;
10549 DWORD ret;
10550 POINT pt;
10551 MSG msg;
10552
10553 start_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_wfp_start");
10554 ok(start_event != 0, "OpenEvent failed\n");
10555 end_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_wfp_end");
10556 ok(end_event != 0, "OpenEvent failed\n");
10557
10558 child_static = CreateWindowExA(0, "static", "static", WS_CHILD | WS_VISIBLE,
10559 0, 0, 100, 100, parent, 0, NULL, NULL);
10560 ok(child_static != 0, "CreateWindowEx failed\n");
10561 pt.x = pt.y = 50;
10562 ClientToScreen( child_static, &pt );
10564 ok(win == parent, "WindowFromPoint returned %p, expected %p\n", win, parent);
10565
10566 child_button = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
10567 100, 0, 100, 100, parent, 0, NULL, NULL);
10568 ok(child_button != 0, "CreateWindowEx failed\n");
10569 pt.x = pt.y = 50;
10570 ClientToScreen( child_button, &pt );
10572 ok(win == child_button, "WindowFromPoint returned %p, expected %p\n", win, child_button);
10573
10574 /* without this window simulate click test keeps sending WM_NCHITTEST
10575 * message to child_static in an infinite loop */
10576 win = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
10577 0, 0, 100, 100, parent, 0, NULL, NULL);
10578 ok(win != 0, "CreateWindowEx failed\n");
10579 def_static_proc = (void*)SetWindowLongPtrA(child_static,
10583
10585 got_click = FALSE;
10586 while(!got_click && wait_for_message(&msg)) {
10587 if(msg.message == WM_LBUTTONUP) {
10588 ok(msg.hwnd == win, "msg.hwnd = %p, expected %p\n", msg.hwnd, win);
10589 got_click = TRUE;
10590 }
10592 }
10593 ok(got_hittest, "transparent window didn't get WM_NCHITTEST message\n");
10594 ok(got_click, "button under static window didn't get WM_LBUTTONUP\n");
10595
10596 ret = WaitForSingleObject(end_event, 5000);
10597 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject returned %lx\n", ret);
10598
10600 CloseHandle(end_event);
10601}
10602
10603static void test_window_from_point(HWND main_window, const char *argv0)
10604{
10605 HWND hwnd, child, win;
10606 POINT pt;
10609 char cmd[MAX_PATH];
10610 HANDLE start_event, end_event;
10611
10612 hwnd = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP | WS_VISIBLE,
10613 100, 100, 200, 100, main_window, 0, NULL, NULL);
10614 ok(hwnd != 0, "CreateWindowEx failed\n");
10615
10616 pt.x = pt.y = 50;
10617 ClientToScreen( hwnd, &pt );
10619 pt.x = 150;
10620 pt.y = 50;
10621 ClientToScreen( hwnd, &pt );
10622 if(win == hwnd)
10624 if(win != hwnd) {
10625 skip("there's another window covering test window\n");
10627 return;
10628 }
10629
10630 child = CreateWindowExA(0, "static", "static", WS_CHILD | WS_VISIBLE,
10631 0, 0, 100, 100, hwnd, 0, NULL, NULL);
10632 ok(child != 0, "CreateWindowEx failed\n");
10633 pt.x = pt.y = 50;
10634 ClientToScreen( hwnd, &pt );
10636 ok(win == hwnd, "WindowFromPoint returned %p, expected %p\n", win, hwnd);
10638
10639 child = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
10640 0, 0, 100, 100, hwnd, 0, NULL, NULL);
10641 ok(child != 0, "CreateWindowEx failed\n");
10643 ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
10645
10646 start_event = CreateEventA(NULL, FALSE, FALSE, "test_wfp_start");
10647 ok(start_event != 0, "CreateEvent failed\n");
10648 end_event = CreateEventA(NULL, FALSE, FALSE, "test_wfp_end");
10649 ok(start_event != 0, "CreateEvent failed\n");
10650
10651 sprintf(cmd, "%s win create_children %p\n", argv0, hwnd);
10652 memset(&startup, 0, sizeof(startup));
10653 startup.cb = sizeof(startup);
10655 &startup, &info), "CreateProcess failed.\n");
10656 ok(wait_for_events(1, &start_event, 1000) == 0, "didn't get start_event\n");
10657
10660 ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
10661
10662 simulate_click(pt.x, pt.y);
10664
10666 pt.x = 150;
10667 pt.y = 50;
10668 ClientToScreen( hwnd, &pt );
10670 ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
10671
10672 SetEvent(end_event);
10673 wait_child_process(info.hProcess);
10675 CloseHandle(end_event);
10676 CloseHandle(info.hProcess);
10677 CloseHandle(info.hThread);
10678
10680}
10681
10682static void test_map_points(void)
10683{
10684 BOOL ret;
10685 POINT p;
10686 HWND wnd, wnd0, dwnd;
10687 INT n;
10688 DWORD err;
10689 POINT pos = { 100, 200 };
10690 int width = 150;
10691 int height = 150;
10692 RECT window_rect;
10693 RECT client_rect;
10694
10695 /* Create test windows */
10696 wnd = CreateWindowA("static", "test1", WS_POPUP, pos.x, pos.y, width, height, NULL, NULL, NULL, NULL);
10697 ok(wnd != NULL, "Failed %p\n", wnd);
10698 wnd0 = CreateWindowA("static", "test2", WS_POPUP, 0, 0, width, height, NULL, NULL, NULL, NULL);
10699 ok(wnd0 != NULL, "Failed %p\n", wnd);
10700 dwnd = CreateWindowA("static", "test3", 0, 200, 300, 150, 150, NULL, NULL, NULL, NULL);
10701 DestroyWindow(dwnd);
10702 ok(dwnd != NULL, "Failed %p\n", dwnd);
10703
10704 /* Verify window rect and client rect (they should have the same width and height) */
10705 GetWindowRect(wnd, &window_rect);
10706 ok(window_rect.left == pos.x, "left is %ld instead of %ld\n", window_rect.left, pos.x);
10707 ok(window_rect.top == pos.y, "top is %ld instead of %ld\n", window_rect.top, pos.y);
10708 ok(window_rect.right == pos.x + width, "right is %ld instead of %ld\n", window_rect.right, pos.x + width);
10709 ok(window_rect.bottom == pos.y + height, "bottom is %ld instead of %ld\n", window_rect.bottom, pos.y + height);
10710 GetClientRect(wnd, &client_rect);
10711 ok(client_rect.left == 0, "left is %ld instead of 0\n", client_rect.left);
10712 ok(client_rect.top == 0, "top is %ld instead of 0\n", client_rect.top);
10713 ok(client_rect.right == width, "right is %ld instead of %d\n", client_rect.right, width);
10714 ok(client_rect.bottom == height, "bottom is %ld instead of %d\n", client_rect.bottom, height);
10715
10716 /* Test MapWindowPoints */
10717
10718 /* MapWindowPoints(NULL or wnd, NULL or wnd, NULL, 1); crashes on Windows */
10719
10720 SetLastError(0xdeadbeef);
10721 n = MapWindowPoints(NULL, NULL, NULL, 0);
10722 err = GetLastError();
10723 ok(n == 0, "Got %d, expected %d\n", n, 0);
10724 ok(err == 0xdeadbeef, "Got %lx, expected %x\n", err, 0xdeadbeef);
10725
10726 SetLastError(0xdeadbeef);
10727 n = MapWindowPoints(wnd, wnd, NULL, 0);
10728 err = GetLastError();
10729 ok(n == 0, "Got %d, expected %d\n", n, 0);
10730 ok(err == 0xdeadbeef, "Got %lx, expected %x\n", err, 0xdeadbeef);
10731
10732 n = MapWindowPoints(wnd, NULL, NULL, 0);
10733 ok(n == MAKELONG(window_rect.left, window_rect.top), "Got %x, expected %lx\n",
10734 n, MAKELONG(window_rect.left, window_rect.top));
10735
10736 n = MapWindowPoints(NULL, wnd, NULL, 0);
10737 ok(n == MAKELONG(-window_rect.left, -window_rect.top), "Got %x, expected %lx\n",
10738 n, MAKELONG(-window_rect.left, -window_rect.top));
10739
10740 SetLastError(0xdeadbeef);
10741 p.x = p.y = 100;
10742 n = MapWindowPoints(dwnd, NULL, &p, 1);
10743 err = GetLastError();
10744 ok(n == 0, "Got %d, expected %d\n", n, 0);
10745 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10746 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10747
10748 SetLastError(0xdeadbeef);
10749 p.x = p.y = 100;
10750 n = MapWindowPoints(dwnd, wnd, &p, 1);
10751 err = GetLastError();
10752 ok(n == 0, "Got %d, expected %d\n", n, 0);
10753 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10754 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10755
10756 SetLastError(0xdeadbeef);
10757 p.x = p.y = 100;
10758 n = MapWindowPoints(NULL, dwnd, &p, 1);
10759 err = GetLastError();
10760 ok(n == 0, "Got %d, expected %d\n", n, 0);
10761 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10762 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10763
10764 SetLastError(0xdeadbeef);
10765 p.x = p.y = 100;
10766 n = MapWindowPoints(wnd, dwnd, &p, 1);
10767 err = GetLastError();
10768 ok(n == 0, "Got %d, expected %d\n", n, 0);
10769 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10770 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10771
10772 SetLastError(0xdeadbeef);
10773 p.x = p.y = 100;
10774 n = MapWindowPoints(dwnd, dwnd, &p, 1);
10775 err = GetLastError();
10776 ok(n == 0, "Got %d, expected %d\n", n, 0);
10777 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10778 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10779
10780 SetLastError(0xdeadbeef);
10781 p.x = p.y = 100;
10782 n = MapWindowPoints(NULL, NULL, &p, 1);
10783 err = GetLastError();
10784 ok(n == 0, "Got %d, expected %d\n", n, 0);
10785 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10786 ok(err == 0xdeadbeef, "Got %lx, expected %x\n", err, 0xdeadbeef);
10787
10788 SetLastError(0xdeadbeef);
10789 p.x = p.y = 100;
10790 n = MapWindowPoints(wnd, wnd, &p, 1);
10791 err = GetLastError();
10792 ok(n == 0, "Got %d, expected %d\n", n, 0);
10793 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10794 ok(err == 0xdeadbeef, "Got %lx, expected %x\n", err, 0xdeadbeef);
10795
10796 p.x = p.y = 100;
10797 n = MapWindowPoints(wnd, NULL, &p, 1);
10798 ok(n == MAKELONG(window_rect.left, window_rect.top), "Got %x, expected %lx\n",
10799 n, MAKELONG(window_rect.left, window_rect.top));
10800 ok((p.x == (window_rect.left + 100)) && (p.y == (window_rect.top + 100)), "Failed got (%ld, %ld), expected (%ld, %ld)\n",
10801 p.x, p.y, window_rect.left + 100, window_rect.top + 100);
10802
10803 p.x = p.y = 100;
10804 n = MapWindowPoints(NULL, wnd, &p, 1);
10805 ok(n == MAKELONG(-window_rect.left, -window_rect.top), "Got %x, expected %lx\n",
10806 n, MAKELONG(-window_rect.left, -window_rect.top));
10807 ok((p.x == (-window_rect.left + 100)) && (p.y == (-window_rect.top + 100)), "Failed got (%ld, %ld), expected (%ld, %ld)\n",
10808 p.x, p.y, -window_rect.left + 100, -window_rect.top + 100);
10809
10810 SetLastError(0xdeadbeef);
10811 p.x = p.y = 0;
10812 n = MapWindowPoints(wnd0, NULL, &p, 1);
10813 err = GetLastError();
10814 ok(n == 0, "Got %x, expected 0\n", n);
10815 ok((p.x == 0) && (p.y == 0), "Failed got (%ld, %ld), expected (0, 0)\n", p.x, p.y);
10816 ok(err == 0xdeadbeef, "Got %lx, expected %x\n", err, 0xdeadbeef);
10817
10818 SetLastError(0xdeadbeef);
10819 p.x = p.y = 0;
10820 n = MapWindowPoints(NULL, wnd0, &p, 1);
10821 err = GetLastError();
10822 ok(n == 0, "Got %x, expected 0\n", n);
10823 ok((p.x == 0) && (p.y == 0), "Failed got (%ld, %ld), expected (0, 0)\n", p.x, p.y);
10824 ok(err == 0xdeadbeef, "Got %lx, expected %x\n", err, 0xdeadbeef);
10825
10826 /* Test ClientToScreen */
10827
10828 /* ClientToScreen(wnd, NULL); crashes on Windows */
10829
10830 SetLastError(0xdeadbeef);
10832 err = GetLastError();
10833 ok(!ret, "Should fail\n");
10834 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10835
10836 SetLastError(0xdeadbeef);
10837 p.x = p.y = 100;
10838 ret = ClientToScreen(NULL, &p);
10839 err = GetLastError();
10840 ok(!ret, "Should fail\n");
10841 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10842 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10843
10844 SetLastError(0xdeadbeef);
10845 p.x = p.y = 100;
10846 ret = ClientToScreen(dwnd, &p);
10847 err = GetLastError();
10848 ok(!ret, "Should fail\n");
10849 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10850 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10851
10852 p.x = p.y = 100;
10853 ret = ClientToScreen(wnd, &p);
10854 ok(ret, "Failed with error %lu\n", GetLastError());
10855 ok((p.x == (window_rect.left + 100)) && (p.y == (window_rect.top + 100)), "Failed got (%ld, %ld), expected (%ld, %ld)\n",
10856 p.x, p.y, window_rect.left + 100, window_rect.top + 100);
10857
10858 p.x = p.y = 0;
10859 ret = ClientToScreen(wnd0, &p);
10860 ok(ret, "Failed with error %lu\n", GetLastError());
10861 ok((p.x == 0) && (p.y == 0), "Failed got (%ld, %ld), expected (0, 0)\n", p.x, p.y);
10862
10863 /* Test ScreenToClient */
10864
10865 /* ScreenToClient(wnd, NULL); crashes on Windows */
10866
10867 SetLastError(0xdeadbeef);
10869 err = GetLastError();
10870 ok(!ret, "Should fail\n");
10871 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10872
10873 SetLastError(0xdeadbeef);
10874 p.x = p.y = 100;
10875 ret = ScreenToClient(NULL, &p);
10876 err = GetLastError();
10877 ok(!ret, "Should fail\n");
10878 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10879 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10880
10881 SetLastError(0xdeadbeef);
10882 p.x = p.y = 100;
10883 ret = ScreenToClient(dwnd, &p);
10884 err = GetLastError();
10885 ok(!ret, "Should fail\n");
10886 ok(p.x == 100 && p.y == 100, "Failed got(%ld, %ld), expected (%d, %d)\n", p.x, p.y, 100, 100);
10887 ok(err == ERROR_INVALID_WINDOW_HANDLE, "Got %lx, expected %x\n", err, ERROR_INVALID_WINDOW_HANDLE);
10888
10889 p.x = p.y = 100;
10890 ret = ScreenToClient(wnd, &p);
10891 ok(ret, "Failed with error %lu\n", GetLastError());
10892 ok((p.x == (-window_rect.left + 100)) && (p.y == (-window_rect.top + 100)), "Failed got(%ld, %ld), expected (%ld, %ld)\n",
10893 p.x, p.y, -window_rect.left + 100, -window_rect.top + 100);
10894
10895 p.x = p.y = 0;
10896 ret = ScreenToClient(wnd0, &p);
10897 ok(ret, "Failed with error %lu\n", GetLastError());
10898 ok((p.x == 0) && (p.y == 0), "Failed got (%ld, %ld), expected (0, 0)\n", p.x, p.y);
10899
10900 DestroyWindow(wnd);
10901 DestroyWindow(wnd0);
10902}
10903
10904static void test_update_region(void)
10905{
10907 HRGN rgn1, rgn2;
10908 const RECT rc = {15, 15, 40, 40};
10909 const POINT wnd_orig = {30, 20};
10910 const POINT child_orig = {10, 5};
10911
10912 parent = CreateWindowExA(0, "MainWindowClass", NULL,
10914 0, 0, 300, 150, NULL, NULL, GetModuleHandleA(0), 0);
10915 hwnd = CreateWindowExA(0, "MainWindowClass", NULL,
10917 0, 0, 200, 100, parent, NULL, GetModuleHandleA(0), 0);
10918 child = CreateWindowExA(0, "MainWindowClass", NULL,
10920 child_orig.x, child_orig.y, 100, 50,
10921 hwnd, NULL, GetModuleHandleA(0), 0);
10922 assert(parent && hwnd && child);
10923
10926 InvalidateRect(hwnd, &rc, FALSE);
10928
10929 rgn1 = CreateRectRgn(0, 0, 0, 0);
10931 "has invalid area after ValidateRgn(NULL)\n");
10932 GetUpdateRgn(hwnd, rgn1, FALSE);
10933 rgn2 = CreateRectRgnIndirect(&rc);
10934 ok(EqualRgn(rgn1, rgn2), "assigned and retrieved update regions are different\n");
10936 "has invalid area after ValidateRgn(NULL)\n");
10937
10938 SetWindowPos(hwnd, 0, wnd_orig.x, wnd_orig.y, 0, 0,
10940
10941 /* parent now has non-simple update region, it consist of
10942 * two rects, that was exposed after hwnd moving ... */
10943 SetRectRgn(rgn1, 0, 0, 200, wnd_orig.y);
10944 SetRectRgn(rgn2, 0, 0, wnd_orig.x, 100);
10945 CombineRgn(rgn1, rgn1, rgn2, RGN_OR);
10946 /* ... and mapped hwnd's invalid area, that hwnd has before moving */
10947 SetRectRgn(rgn2, rc.left + wnd_orig.x, rc.top + wnd_orig.y,
10948 rc.right + wnd_orig.x, rc.bottom + wnd_orig.y);
10949 CombineRgn(rgn1, rgn1, rgn2, RGN_OR);
10950 GetUpdateRgn(parent, rgn2, FALSE);
10951 todo_wine
10952 ok(EqualRgn(rgn1, rgn2), "wrong update region\n");
10953
10954 /* hwnd has the same invalid region as before moving */
10955 SetRectRgn(rgn1, rc.left, rc.top, rc.right, rc.bottom);
10956 GetUpdateRgn(hwnd, rgn2, FALSE);
10957 ok(EqualRgn(rgn1, rgn2), "wrong update region\n");
10958
10959 /* hwnd's invalid area maps to child during moving */
10960 SetRectRgn(rgn1, rc.left - child_orig.x , rc.top - child_orig.y,
10961 rc.right - child_orig.x, rc.bottom - child_orig.y);
10962 GetUpdateRgn(child, rgn2, FALSE);
10963 todo_wine
10964 ok(EqualRgn(rgn1, rgn2), "wrong update region\n");
10965
10966 DeleteObject(rgn1);
10967 DeleteObject(rgn2);
10969}
10970
10972{
10973 HWND hwnd;
10974
10976 0, 0, 50, 50, hwndMain, NULL, 0, NULL);
10977 ok(hwnd != NULL, "CreateWindow failed\n");
10978
10980 "can't remove WS_CHILD style\n");
10981
10987
10989}
10990
10991
10993{
11000};
11001
11002
11004{
11005 switch (msg)
11006 {
11007 case WM_APP:
11008 {
11010
11011 ok(hwnd == data->thread_hwnd, "unexpected hwnd %p\n", hwnd);
11012
11013 SendNotifyMessageA(data->main_hwnd, WM_APP+1, 0, lparam);
11014
11015 /* Don't return until the main thread is processing our sent message. */
11016 ok(WaitForSingleObject(data->main_in_wm_app_1, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
11017
11018 /* Break the PeekMessage loop so we can notify the main thread after we return. */
11019 SetEvent(data->thread_got_wm_app);
11020
11021 return 0x240408ea;
11022 }
11023 case WM_APP+1:
11024 {
11026 LRESULT res;
11027
11028 ok(hwnd == data->main_hwnd, "unexpected hwnd %p\n", hwnd);
11029
11030 /* Ask the thread to reply to our WM_APP message. */
11031 SetEvent(data->main_in_wm_app_1);
11032
11033 /* Wait until the thread has sent a reply. */
11034 ok(WaitForSingleObject(data->thread_replied, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
11035
11036 /* Send another message while we have a reply queued for the current one. */
11037 res = SendMessageA(data->thread_hwnd, WM_APP+2, 0, lparam);
11038 ok(res == 0x449b0190, "unexpected result %Ix\n", res);
11039
11040 return 0;
11041 }
11042 case WM_APP+2:
11043 {
11045
11046 ok(hwnd == data->thread_hwnd, "unexpected hwnd %p\n", hwnd);
11047
11048 /* Don't return until we know the main thread is processing sent messages. */
11049 SendMessageA(data->main_hwnd, WM_NULL, 0, 0);
11050
11051 return 0x449b0190;
11052 }
11053 case WM_CLOSE:
11054 PostQuitMessage(0);
11055 break;
11056 }
11057 return DefWindowProcA(hwnd, msg, wparam, lparam);
11058}
11059
11061{
11062 MSG msg;
11064
11065 data->thread_hwnd = CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW,
11066 100, 100, 200, 200, 0, 0, 0, NULL);
11067 ok(data->thread_hwnd != 0, "Failed to create overlapped window\n");
11068
11069 SetEvent(data->thread_started);
11070
11071 /* Loop until we've processed WM_APP. */
11072 while (WaitForSingleObject(data->thread_got_wm_app, 0) != WAIT_OBJECT_0)
11073 {
11074 if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
11075 {
11078 }
11079 else
11080 {
11081 MsgWaitForMultipleObjects(1, &data->thread_got_wm_app, FALSE, INFINITE, QS_SENDMESSAGE);
11082 }
11083 }
11084
11085 /* Notify the main thread that we replied to its WM_APP message. */
11086 SetEvent(data->thread_replied);
11087
11088 while (GetMessageA(&msg, 0, 0, 0))
11089 {
11092 }
11093
11094 return 0;
11095}
11096
11097static void test_smresult(void)
11098{
11099 WNDCLASSA cls;
11101 DWORD tid;
11103 BOOL ret;
11104 LRESULT res;
11105
11106 cls.style = CS_DBLCLKS;
11108 cls.cbClsExtra = 0;
11109 cls.cbWndExtra = 0;
11110 cls.hInstance = GetModuleHandleA(0);
11111 cls.hIcon = 0;
11114 cls.lpszMenuName = NULL;
11115 cls.lpszClassName = "SmresultClass";
11116
11117 ret = RegisterClassA(&cls);
11118 ok(ret, "RegisterClassA failed\n");
11119
11120 data.thread_started = CreateEventA(NULL, TRUE, FALSE, NULL);
11121 ok(data.thread_started != NULL, "CreateEventA failed\n");
11122
11123 data.thread_got_wm_app = CreateEventA(NULL, TRUE, FALSE, NULL);
11124 ok(data.thread_got_wm_app != NULL, "CreateEventA failed\n");
11125
11126 data.main_in_wm_app_1 = CreateEventA(NULL, TRUE, FALSE, NULL);
11127 ok(data.main_in_wm_app_1 != NULL, "CreateEventA failed\n");
11128
11129 data.thread_replied = CreateEventA(NULL, TRUE, FALSE, NULL);
11130 ok(data.thread_replied != NULL, "CreateEventA failed\n");
11131
11132 data.main_hwnd = CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW,
11133 100, 100, 200, 200, 0, 0, 0, NULL);
11134
11136 ok(hThread != NULL, "CreateThread failed, error %ld\n", GetLastError());
11137
11138 ok(WaitForSingleObject(data.thread_started, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
11139
11140 res = SendMessageA(data.thread_hwnd, WM_APP, 0, (LPARAM)&data);
11141 ok(res == 0x240408ea, "unexpected result %Ix\n", res);
11142
11143 SendMessageA(data.thread_hwnd, WM_CLOSE, 0, 0);
11144
11145 DestroyWindow(data.main_hwnd);
11146
11147 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
11148
11149 CloseHandle(data.thread_started);
11150 CloseHandle(data.thread_got_wm_app);
11151 CloseHandle(data.main_in_wm_app_1);
11152 CloseHandle(data.thread_replied);
11154}
11155
11156static void test_GetMessagePos(void)
11157{
11158 HWND button;
11159 DWORD pos;
11160 MSG msg;
11161
11162 button = CreateWindowExA(0, "button", "button", WS_VISIBLE,
11163 100, 100, 100, 100, 0, 0, 0, NULL);
11164 ok(button != 0, "CreateWindowExA failed\n");
11165
11166 SetCursorPos(120, 140);
11168 pos = GetMessagePos();
11169 ok(pos == MAKELONG(120, 140), "pos = %08lx\n", pos);
11170
11171 SetCursorPos(340, 320);
11172 pos = GetMessagePos();
11173 ok(pos == MAKELONG(120, 140), "pos = %08lx\n", pos);
11174
11175 SendMessageW(button, WM_APP, 0, 0);
11176 pos = GetMessagePos();
11177 ok(pos == MAKELONG(120, 140), "pos = %08lx\n", pos);
11178
11179 PostMessageA(button, WM_APP, 0, 0);
11180 GetMessageA(&msg, button, 0, 0);
11181 ok(msg.message == WM_APP, "msg.message = %x\n", msg.message);
11182 pos = GetMessagePos();
11183 ok(pos == MAKELONG(340, 320), "pos = %08lx\n", pos);
11184
11185 PostMessageA(button, WM_APP, 0, 0);
11186 SetCursorPos(350, 330);
11187 GetMessageA(&msg, button, 0, 0);
11188 ok(msg.message == WM_APP, "msg.message = %x\n", msg.message);
11189 pos = GetMessagePos();
11190 ok(pos == MAKELONG(340, 320), "pos = %08lx\n", pos);
11191
11192 PostMessageA(button, WM_APP, 0, 0);
11193 SetCursorPos(320, 340);
11194 PostMessageA(button, WM_APP+1, 0, 0);
11195 pos = GetMessagePos();
11196 ok(pos == MAKELONG(340, 320), "pos = %08lx\n", pos);
11197 GetMessageA(&msg, button, 0, 0);
11198 ok(msg.message == WM_APP, "msg.message = %x\n", msg.message);
11199 pos = GetMessagePos();
11200 ok(pos == MAKELONG(350, 330), "pos = %08lx\n", pos);
11201 GetMessageA(&msg, button, 0, 0);
11202 ok(msg.message == WM_APP+1, "msg.message = %x\n", msg.message);
11203 pos = GetMessagePos();
11204 ok(pos == MAKELONG(320, 340), "pos = %08lx\n", pos);
11205
11206 SetTimer(button, 1, 250, NULL);
11207 SetCursorPos(330, 350);
11208 GetMessageA(&msg, button, 0, 0);
11209 while (msg.message == WM_PAINT)
11210 {
11212 GetMessageA(&msg, button, 0, 0);
11213 }
11214 ok(msg.message == WM_TIMER, "msg.message = %x\n", msg.message);
11215 pos = GetMessagePos();
11216 ok(pos == MAKELONG(330, 350), "pos = %08lx\n", pos);
11217 KillTimer(button, 1);
11218
11220}
11221
11222#define SET_FOREGROUND_STEAL_1 0x01
11223#define SET_FOREGROUND_SET_1 0x02
11224#define SET_FOREGROUND_STEAL_2 0x04
11225#define SET_FOREGROUND_SET_2 0x08
11226#define SET_FOREGROUND_INJECT 0x10
11227
11229{
11233};
11234
11236{
11238 MSG msg;
11239
11240 p->thread_window = CreateWindowExA(0, "static", "thread window", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11241 0, 0, 10, 10, 0, 0, 0, NULL);
11242 SetEvent(p->command_executed);
11243
11244 while(GetMessageA(&msg, 0, 0, 0))
11245 {
11246 if (msg.message == p->msg_quit)
11247 break;
11248
11249 if (msg.message == p->msg_command)
11250 {
11251 if (msg.wParam & SET_FOREGROUND_STEAL_1)
11252 {
11253 SetForegroundWindow(p->thread_window);
11254 check_wnd_state(p->thread_window, p->thread_window, p->thread_window, 0);
11255 }
11256 if (msg.wParam & SET_FOREGROUND_INJECT)
11257 {
11258 SendNotifyMessageA(p->window1, WM_ACTIVATEAPP, 0, 0);
11259 }
11260 if (msg.wParam & SET_FOREGROUND_SET_1)
11261 {
11262 SetForegroundWindow(p->window1);
11263 check_wnd_state(0, p->window1, 0, 0);
11264 }
11265 if (msg.wParam & SET_FOREGROUND_STEAL_2)
11266 {
11267 SetForegroundWindow(p->thread_window);
11268 check_wnd_state(p->thread_window, p->thread_window, p->thread_window, 0);
11269 }
11270 if (msg.wParam & SET_FOREGROUND_SET_2)
11271 {
11272 SetForegroundWindow(p->window2);
11273 check_wnd_state(0, p->window2, 0, 0);
11274 }
11275
11276 SetEvent(p->command_executed);
11277 continue;
11278 }
11279
11282 }
11283
11284 DestroyWindow(p->thread_window);
11285 return 0;
11286}
11287
11289{
11291 HANDLE thread;
11292 struct set_foreground_thread_params thread_params;
11293 DWORD tid;
11294 MSG msg;
11295
11296 window2 = CreateWindowExA(0, "static", "window 2", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11297 300, 0, 10, 10, 0, 0, 0, NULL);
11298 thread_params.msg_quit = WM_USER;
11299 thread_params.msg_command = WM_USER + 1;
11300 thread_params.window1 = window1;
11301 thread_params.window2 = window2;
11302 thread_params.command_executed = CreateEventW(NULL, FALSE, FALSE, NULL);
11303
11304 thread = CreateThread(NULL, 0, set_foreground_thread, &thread_params, 0, &tid);
11306
11309 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11310
11311 /* Steal foreground: WM_ACTIVATEAPP(0) is delivered. */
11316 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
11317 thread_params.thread_window, test_window);
11318 /* Active and Focus window are sometimes 0 on KDE. Ignore them.
11319 * check_wnd_state(window1, thread_params.thread_window, window1, 0); */
11320 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11321 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11322 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11323 check_wnd_state(0, thread_params.thread_window, 0, 0);
11325 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
11326 thread_params.thread_window, test_window);
11327 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11328 /* This message is reliable on Windows and inside a virtual desktop.
11329 * It is unreliable on KDE (50/50) and never arrives on FVWM.
11330 * ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n"); */
11331
11332 /* Set foreground: WM_ACTIVATEAPP (1) is delivered. */
11336 check_wnd_state(0, 0, 0, 0);
11338 ok(!test_window, "Expected foreground window 0, got %p\n", test_window);
11339 ok(!app_activated, "Received WM_ACTIVATEAPP(!= 0), did not expect it.\n");
11340 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11341 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11344 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11346 ok(app_activated, "Expected WM_ACTIVATEAPP(1), did not receive it.\n");
11347 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11348
11349 /* Steal foreground then set it back: No messages are delivered. */
11354 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11357 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11358 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11359 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11361 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11364 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11365 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11366
11367 /* This is not implemented with a plain WM_ACTIVATEAPP filter. */
11373 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11376 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11377 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11378 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11380 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11383 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11384 ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n");
11385
11386 SetForegroundWindow(thread_params.thread_window);
11387
11388 /* Set foreground then remove: Both messages are delivered. */
11393 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
11394 thread_params.thread_window, test_window);
11395 check_wnd_state(0, thread_params.thread_window, 0, 0);
11396 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11397 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11398 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11400 ok(test_window == thread_params.thread_window, "Expected foreground window %p, got %p\n",
11401 thread_params.thread_window, test_window);
11402 /* Active and focus are window1 on wine because the internal WM_WINE_SETACTIVEWINDOW(0)
11403 * message is never generated. GetCapture() returns 0 though, so we'd get a test success
11404 * in todo_wine in the line below.
11405 * todo_wine check_wnd_state(0, thread_params.thread_window, 0, 0); */
11406 ok(app_activated, "Expected WM_ACTIVATEAPP(1), did not receive it.\n");
11407 todo_wine ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n");
11408
11411 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11414
11415 /* Switch to a different window from the same thread? No messages. */
11420 ok(test_window == window1, "Expected foreground window %p, got %p\n",
11423 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11424 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11425 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
11427 ok(test_window == window2, "Expected foreground window %p, got %p\n",
11430 ok(!app_activated, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
11431 ok(!app_deactivated, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
11432
11433 PostThreadMessageA(tid, thread_params.msg_quit, 0, 0);
11435
11436 CloseHandle(thread_params.command_executed);
11438}
11439
11441{
11442 if(!hwnd) {
11443 int *count = (int*)lparam;
11444 (*count)++;
11445 }
11446 return 0;
11447}
11448
11450{
11451 if(msg == WM_SETTEXT)
11452 {
11453 const char *text = (const char*)lparam;
11454
11455 ok(!wparam, "wparam = %08Ix\n", wparam);
11456 ok(!strcmp(text, "text"), "WM_SETTEXT lparam = %s\n", text);
11457 return 1;
11458 }
11459 return 0;
11460}
11461
11462static const WCHAR textW[] = {'t','e','x','t',0};
11464{
11465 if(msg == WM_SETTEXT)
11466 {
11467 const WCHAR *text = (const WCHAR*)lparam;
11468
11469 ok(!wparam, "wparam = %08Ix\n", wparam);
11470 ok(!lstrcmpW(text, textW), "WM_SETTEXT lparam = %s\n", wine_dbgstr_w(text));
11471 return 1;
11472 }
11473 return 0;
11474}
11475
11476static void test_winproc_handles(const char *argv0)
11477{
11478 static const WCHAR winproc_testW[] = {'w','i','n','p','r','o','c','_','t','e','s','t',0};
11479
11481 WNDCLASSA wnd_classA;
11482 WNDCLASSW wnd_classW;
11483 int count, ret;
11486 char cmd[MAX_PATH];
11487
11488 memset(&wnd_classA, 0, sizeof(wnd_classA));
11489 wnd_classA.lpszClassName = "winproc_test";
11490 wnd_classA.lpfnWndProc = winproc;
11491 ret = RegisterClassA(&wnd_classA);
11492 ok(ret, "RegisterClass failed with error %ld\n", GetLastError());
11493
11494 ret = GetClassInfoW(hinst, winproc_testW, &wnd_classW);
11495 ok(ret, "GetClassInfoW failed with error %ld\n", GetLastError());
11496 ok(wnd_classA.lpfnWndProc != wnd_classW.lpfnWndProc,
11497 "winproc pointers should not be identical\n");
11498
11499 count = 0;
11500 CallWindowProcA(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
11501 ok(count == 1, "winproc should be called once (%d)\n", count);
11502 count = 0;
11503 CallWindowProcW(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
11504 ok(count == 1, "winproc should be called once (%d)\n", count);
11505
11506 ret = UnregisterClassW(winproc_testW, hinst);
11507 ok(ret, "UnregisterClass failed with error %ld\n", GetLastError());
11508
11509 /* crashes on 64-bit windows because lpfnWndProc handle is already freed */
11510 if (sizeof(void*) == 4)
11511 {
11512 count = 0;
11513 CallWindowProcA(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
11514 todo_wine ok(!count, "winproc should not be called (%d)\n", count);
11515 CallWindowProcW(wnd_classW.lpfnWndProc, 0, 0, 0, (LPARAM)&count);
11516 todo_wine ok(!count, "winproc should not be called (%d)\n", count);
11517 }
11518
11519 sprintf(cmd, "%s win winproc_limit", argv0);
11520 memset(&startup, 0, sizeof(startup));
11521 startup.cb = sizeof(startup);
11523 &startup, &info), "CreateProcess failed.\n");
11524 wait_child_process(info.hProcess);
11525 CloseHandle(info.hProcess);
11526 CloseHandle(info.hThread);
11527}
11528
11529static void test_winproc_limit(void)
11530{
11531 WNDPROC winproc_handle;
11532 LONG_PTR ret;
11533 HWND hwnd;
11534 int i;
11535
11536 hwnd = CreateWindowExA(0, "static", "test", WS_POPUP, 0, 0, 0, 0, 0, 0, 0, 0);
11537 ok(hwnd != 0, "CreateWindowEx failed\n");
11538
11540 "SetWindowLongPtr failed\n");
11541 winproc_handle = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
11542 ok(winproc_handle != winproc, "winproc pointers should not be identical\n");
11543
11544 /* run out of winproc slots */
11545 for(i = 2; i<0xffff; i++)
11546 {
11547 ok(SetWindowLongPtrA(hwnd, GWLP_WNDPROC, i), "SetWindowLongPtr failed (%d)\n", i);
11549 break;
11550 }
11551 ok(i != 0xffff, "unable to run out of winproc slots\n");
11552
11554 ok(ret, "SetWindowLongPtr failed with error %ld\n", GetLastError());
11555 ok(SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"text"), "WM_SETTEXT failed\n");
11556 ok(SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)textW), "WM_SETTEXT with conversion failed\n");
11557
11559 ok(ret, "SetWindowLongPtr failed with error %ld\n", GetLastError());
11560 ok(SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"text"), "WM_SETTEXT failed\n");
11561 ok(SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)textW), "WM_SETTEXT with conversion failed\n");
11562
11563 /* Show that there's no message conversion when CallWindowProc is used */
11565 "winproc_convW returned error\n");
11567 "winproc_convW returned error\n");
11568
11569 i = 0;
11570 CallWindowProcA(winproc_handle, 0, 0, 0, (LPARAM)&i);
11571 ok(i == 1, "winproc should be called once (%d)\n", i);
11572 i = 0;
11573 CallWindowProcW(winproc_handle, 0, 0, 0, (LPARAM)&i);
11574 ok(i == 1, "winproc should be called once (%d)\n", i);
11575
11577
11578 i = 0;
11579 CallWindowProcA(winproc_handle, 0, 0, 0, (LPARAM)&i);
11580 ok(i == 1, "winproc should be called once (%d)\n", i);
11581 i = 0;
11582 CallWindowProcW(winproc_handle, 0, 0, 0, (LPARAM)&i);
11583 ok(i == 1, "winproc should be called once (%d)\n", i);
11584}
11585
11586static void test_deferwindowpos(void)
11587{
11588 HDWP hdwp, hdwp2;
11589 HWND hwnd;
11590 BOOL ret;
11591
11592 hdwp = BeginDeferWindowPos(0);
11593 ok(hdwp != NULL, "got %p\n", hdwp);
11594
11596 ok(!ret, "got %d\n", ret);
11597
11598 hdwp2 = DeferWindowPos(NULL, NULL, NULL, 0, 0, 10, 10, 0);
11599 todo_wine
11600 ok(hdwp2 == NULL && ((GetLastError() == ERROR_INVALID_DWP_HANDLE) ||
11601 broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE) /* before win8 */), "got %p, error %ld\n", hdwp2, GetLastError());
11602
11603 hdwp2 = DeferWindowPos((HDWP)0xdead, GetDesktopWindow(), NULL, 0, 0, 10, 10, 0);
11604 todo_wine
11605 ok(hdwp2 == NULL && ((GetLastError() == ERROR_INVALID_DWP_HANDLE) ||
11606 broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE) /* before win8 */), "got %p, error %ld\n", hdwp2, GetLastError());
11607
11608 hdwp2 = DeferWindowPos(hdwp, NULL, NULL, 0, 0, 10, 10, 0);
11609 ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %ld\n", hdwp2, GetLastError());
11610
11611 hdwp2 = DeferWindowPos(hdwp, GetDesktopWindow(), NULL, 0, 0, 10, 10, 0);
11612 ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %ld\n", hdwp2, GetLastError());
11613
11614 hdwp2 = DeferWindowPos(hdwp, (HWND)0xdead, NULL, 0, 0, 10, 10, 0);
11615 ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %ld\n", hdwp2, GetLastError());
11616
11617 ret = EndDeferWindowPos(hdwp);
11618 ok(ret, "got %d\n", ret);
11619 hdwp = BeginDeferWindowPos(0);
11620 ok(hdwp != NULL, "got %p\n", hdwp);
11621
11623 hdwp2 = DeferWindowPos(hdwp, hwnd, NULL, 0, 0, 10, 10, 0);
11624 ok(hdwp2 != NULL, "got %p, error %ld\n", hdwp2, GetLastError());
11626
11627 ret = EndDeferWindowPos(hdwp);
11628 ok(ret, "got %d\n", ret);
11629}
11630
11632{
11633 typedef struct
11634 {
11635 HWND hwnd_lock, hwnd_draw;
11636 BOOL allow_drawing;
11637 BOOL expect_valid;
11638 } TEST;
11639
11640 int i;
11641 HWND child = CreateWindowA("static", 0, WS_CHILD | WS_VISIBLE, 0, 0, 20, 20, parent, 0, 0, 0);
11642
11643 TEST tests[] = {
11644 {child, child, 0, 0},
11645 {child, child, 1, 1},
11646 {child, parent, 0, 1},
11647 {child, parent, 1, 1},
11648 {parent, child, 0, 0},
11649 {parent, child, 1, 1},
11650 {parent, parent, 0, 0},
11651 {parent, parent, 1, 1}
11652 };
11653
11654 if (!child)
11655 {
11656 skip("CreateWindow failed, skipping LockWindowUpdate tests\n");
11657 return;
11658 }
11659
11663
11664 for (i = 0; i < ARRAY_SIZE(tests); ++i)
11665 {
11666 HDC hdc;
11667 POINT p = {10, 10};
11668 BOOL ret;
11669 const DWORD dc_flags = DCX_USESTYLE | (tests[i].allow_drawing ? DCX_LOCKWINDOWUPDATE : 0);
11670 const COLORREF c1 = 0x111100, c2 = 0x222200;
11671
11672 hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
11673
11674#define TEST_PIXEL(c_valid, c_invalid) \
11675 do { \
11676 COLORREF c = GetPixel(hdc, p.x, p.y); \
11677 COLORREF e = tests[i].expect_valid ? (c_valid) : (c_invalid); \
11678 todo_wine_if(!tests[i].expect_valid) \
11679 ok(c == e, "%u: GetPixel: got %08lx, expected %08lx\n", i, c, e); \
11680 } while (0)
11681
11682 SetPixel(hdc, p.x, p.y, c1);
11683 ret = LockWindowUpdate(tests[i].hwnd_lock);
11684 ok(ret, "%u: LockWindowUpdate failed\n", i);
11686 SetPixel(hdc, p.x, p.y, c2);
11689 TEST_PIXEL(c2, c1);
11690 ReleaseDC(tests[i].hwnd_draw, hdc);
11691#undef TEST_PIXEL
11692 }
11694}
11695
11696static void test_hide_window(void)
11697{
11698 HWND hwnd, hwnd2, hwnd3;
11699
11700 hwnd = CreateWindowExA(0, "MainWindowClass", "Main window", WS_POPUP | WS_VISIBLE,
11701 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11702 hwnd2 = CreateWindowExA(0, "MainWindowClass", "Main window 2", WS_POPUP | WS_VISIBLE,
11703 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11704 if (winetest_debug > 1) trace("hwnd = %p, hwnd2 = %p\n", hwnd, hwnd2);
11705 check_active_state(hwnd2, hwnd2, hwnd2);
11706 ok(GetWindow(hwnd2, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd2, GW_HWNDNEXT));
11707
11708 /* test hiding two normal windows */
11709 ShowWindow(hwnd2, SW_HIDE);
11711 todo_wine
11712 ok(GetWindow(hwnd, GW_HWNDNEXT) == hwnd2, "expected %p, got %p\n", hwnd2, GetWindow(hwnd, GW_HWNDNEXT));
11713
11716 ok(GetWindow(hwnd, GW_HWNDNEXT) == hwnd2, "expected %p, got %p\n", hwnd2, GetWindow(hwnd, GW_HWNDNEXT));
11717
11720
11721 ShowWindow(hwnd2, SW_SHOW);
11722 check_active_state(hwnd2, hwnd2, hwnd2);
11723 ok(GetWindow(hwnd2, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd2, GW_HWNDNEXT));
11724
11725 /* hide a non-active window */
11727 check_active_state(hwnd2, hwnd2, hwnd2);
11728 todo_wine
11729 ok(GetWindow(hwnd2, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd2, GW_HWNDNEXT));
11730
11731 /* hide a window in the middle */
11733 ShowWindow(hwnd2, SW_SHOW);
11734 hwnd3 = CreateWindowExA(0, "MainWindowClass", "Main window 3", WS_POPUP | WS_VISIBLE,
11735 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11736 SetActiveWindow(hwnd2);
11737 ShowWindow(hwnd2, SW_HIDE);
11738 check_active_state(hwnd3, hwnd3, hwnd3);
11739 todo_wine {
11740 ok(GetWindow(hwnd3, GW_HWNDNEXT) == hwnd2, "expected %p, got %p\n", hwnd2, GetWindow(hwnd3, GW_HWNDNEXT));
11741 ok(GetWindow(hwnd2, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd2, GW_HWNDNEXT));
11742 }
11743
11744 DestroyWindow(hwnd3);
11745
11746 /* hide a normal window when there is a topmost window */
11747 hwnd3 = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", "Topmost window 3", WS_POPUP|WS_VISIBLE,
11748 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11750 ShowWindow(hwnd2, SW_SHOW);
11751 check_active_state(hwnd2, hwnd2, hwnd2);
11752 ShowWindow(hwnd2, SW_HIDE);
11753 todo_wine
11754 check_active_state(hwnd3, hwnd3, hwnd3);
11755 ok(GetWindow(hwnd2, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd2, GW_HWNDNEXT));
11756
11757 /* hide a topmost window */
11758 ShowWindow(hwnd2, SW_SHOW);
11759 ShowWindow(hwnd3, SW_SHOW);
11760 ShowWindow(hwnd3, SW_HIDE);
11761 check_active_state(hwnd2, hwnd2, hwnd2);
11762 ok(GetWindow(hwnd2, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd2, GW_HWNDNEXT));
11763
11764 DestroyWindow(hwnd3);
11765
11766 /* hiding an owned window activates its owner */
11768 ShowWindow(hwnd2, SW_SHOW);
11769 hwnd3 = CreateWindowExA(0, "MainWindowClass", "Owned window 3", WS_POPUP|WS_VISIBLE,
11770 100, 100, 200, 200, hwnd, 0, GetModuleHandleA(NULL), NULL);
11771 ShowWindow(hwnd3, SW_HIDE);
11773 todo_wine {
11774 ok(GetWindow(hwnd3, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd3, GW_HWNDNEXT));
11775 ok(GetWindow(hwnd, GW_HWNDNEXT) == hwnd2, "expected %p, got %p\n", hwnd2, GetWindow(hwnd, GW_HWNDNEXT));
11776 }
11777
11778 /* hide an owner window */
11780 ShowWindow(hwnd2, SW_SHOW);
11781 ShowWindow(hwnd3, SW_SHOW);
11783 check_active_state(hwnd3, hwnd3, hwnd3);
11784 ok(GetWindow(hwnd3, GW_HWNDNEXT) == hwnd, "expected %p, got %p\n", hwnd, GetWindow(hwnd3, GW_HWNDNEXT));
11785 ok(GetWindow(hwnd, GW_HWNDNEXT) == hwnd2, "expected %p, got %p\n", hwnd2, GetWindow(hwnd, GW_HWNDNEXT));
11786
11787 DestroyWindow(hwnd3);
11788 DestroyWindow(hwnd2);
11790}
11791
11793{
11794 HWND hwnd, hwnd2, hwnd3;
11795
11796 hwnd = CreateWindowExA(0, "MainWindowClass", "Main window", WS_POPUP | WS_VISIBLE,
11797 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11798 hwnd2 = CreateWindowExA(0, "MainWindowClass", "Main window 2", WS_POPUP | WS_VISIBLE,
11799 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11800 if (winetest_debug > 1) trace("hwnd = %p, hwnd2 = %p\n", hwnd, hwnd2);
11801 check_active_state(hwnd2, hwnd2, hwnd2);
11802
11803 /* test hiding two normal windows */
11804 ShowWindow(hwnd2, SW_MINIMIZE);
11805 todo_wine
11807
11809 todo_wine
11810 if (GetActiveWindow() == 0)
11811 check_active_state(0, 0, 0);
11812
11815
11816 ShowWindow(hwnd2, SW_RESTORE);
11817 check_active_state(hwnd2, hwnd2, hwnd2);
11818
11819 /* try SW_SHOWMINIMIZED */
11821 check_active_state(hwnd2, hwnd2, 0);
11822
11823 ShowWindow(hwnd2, SW_RESTORE);
11824 check_active_state(hwnd2, hwnd2, hwnd2);
11825
11826 /* hide a non-active window */
11828 check_active_state(hwnd2, hwnd2, hwnd2);
11829
11830 /* hide a window in the middle */
11832 ShowWindow(hwnd2, SW_RESTORE);
11833 hwnd3 = CreateWindowExA(0, "MainWindowClass", "Main window 3", WS_POPUP | WS_VISIBLE,
11834 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11835 SetActiveWindow(hwnd2);
11836 ShowWindow(hwnd2, SW_MINIMIZE);
11837 todo_wine
11838 check_active_state(hwnd3, hwnd3, hwnd3);
11839
11840 DestroyWindow(hwnd3);
11841
11842 /* hide a normal window when there is a topmost window */
11843 hwnd3 = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", "Topmost window 3", WS_POPUP|WS_VISIBLE,
11844 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
11846 ShowWindow(hwnd2, SW_RESTORE);
11847 check_active_state(hwnd2, hwnd2, hwnd2);
11848 ShowWindow(hwnd2, SW_MINIMIZE);
11849 todo_wine
11850 check_active_state(hwnd3, hwnd3, hwnd3);
11851
11852 /* hide a topmost window */
11853 ShowWindow(hwnd2, SW_RESTORE);
11854 ShowWindow(hwnd3, SW_RESTORE);
11855 ShowWindow(hwnd3, SW_MINIMIZE);
11856 check_active_state(hwnd2, hwnd2, hwnd2);
11857
11858 DestroyWindow(hwnd3);
11859
11860 /* hide an owned window */
11862 ShowWindow(hwnd2, SW_RESTORE);
11863 hwnd3 = CreateWindowExA(0, "MainWindowClass", "Owned window 3", WS_POPUP|WS_VISIBLE,
11864 100, 100, 200, 200, hwnd, 0, GetModuleHandleA(NULL), NULL);
11865 ShowWindow(hwnd3, SW_MINIMIZE);
11866 todo_wine
11867 check_active_state(hwnd2, hwnd2, hwnd2);
11868
11869 /* with SW_SHOWMINIMIZED */
11870 ShowWindow(hwnd3, SW_RESTORE);
11872 check_active_state(hwnd3, hwnd3, 0);
11873
11874 /* hide an owner window */
11876 ShowWindow(hwnd2, SW_RESTORE);
11877 ShowWindow(hwnd3, SW_RESTORE);
11879 todo_wine
11880 check_active_state(hwnd2, hwnd2, hwnd2);
11881
11882 DestroyWindow(hwnd3);
11883
11884 /* test a child window - focus should be yielded back to the parent */
11886 hwnd3 = CreateWindowExA(0, "MainWindowClass", "Child window 3", WS_CHILD|WS_VISIBLE,
11887 100, 100, 200, 200, hwnd, 0, GetModuleHandleA(NULL), NULL);
11888 SetFocus(hwnd3);
11889 check_active_state(hwnd, hwnd, hwnd3);
11890 ShowWindow(hwnd3, SW_MINIMIZE);
11892
11893 /* with SW_SHOWMINIMIZED */
11894 ShowWindow(hwnd3, SW_RESTORE);
11895 SetFocus(hwnd3);
11896 check_active_state(hwnd, hwnd, hwnd3);
11899
11900 DestroyWindow(hwnd3);
11901 DestroyWindow(hwnd2);
11903}
11904
11905static void test_desktop( void )
11906{
11907 HWND desktop = GetDesktopWindow();
11908 /* GetWindowLong Desktop window tests */
11909 static const struct
11910 {
11911 int offset;
11913 DWORD error;
11914 }
11915 tests[] =
11916 {
11917 { GWLP_USERDATA, 0, 0 },
11919 { GWL_EXSTYLE, 0, 0 },
11920 { GWLP_ID, 0, 0 },
11921 { GWLP_HWNDPARENT, 0, 0 },
11922 /* GWLP_HINSTANCE - not useful and not consistent between Windows versions */
11925 };
11927 int i;
11928
11929 for (i = 0; i < ARRAY_SIZE(tests); i++)
11930 {
11931 SetLastError( 0xdeadbeef );
11932 result = GetWindowLongPtrW( desktop, tests[i].offset );
11933 ok( result == tests[i].expect, "offset %d, got %08Ix expect %08Ix\n",
11935 if (tests[i].error)
11936 ok( GetLastError() == tests[i].error, "offset %d: error %ld expect %ld\n",
11938 else
11939 ok( GetLastError() == 0xdeadbeef, "offset %d: error %ld expect unchanged\n",
11940 tests[i].offset, GetLastError() );
11941 }
11942}
11943
11945{
11946 return (GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
11947}
11948
11950{
11951 BOOL ret;
11952
11954 ok(ret, "SetWindowPos failed\n");
11955 flush_events( TRUE );
11956}
11957
11958static void reset_window_state(HWND *state, int n)
11959{
11960 int i;
11961
11962 for (i = 0; i < n; i++)
11963 {
11964 if (state[i])
11965 {
11967 todo_wine_if(i == 5) /* FIXME: remove once Wine is fixed */
11968 ok(!is_topmost(state[i]), "%d: hwnd %p is still topmost\n", i, state[i]);
11970 }
11971 }
11972}
11973
11974static void test_topmost(void)
11975{
11976 HWND owner, hwnd, hwnd2, hwnd_child, hwnd_child2, hwnd_grandchild, state[6] = { 0 };
11977 BOOL is_wine = !strcmp(winetest_platform, "wine");
11978
11981 ok(owner != 0, "Failed to create owner window (%ld)\n", GetLastError());
11982
11983 /* Give current thread foreground state otherwise the tests may fail. */
11984 if (!SetForegroundWindow(owner))
11985 {
11986 DestroyWindow(owner);
11987 skip("SetForegroundWindow not working\n");
11988 return;
11989 }
11990
11993 ok(hwnd != 0, "Failed to create popup window (%ld)\n", GetLastError());
11996 ok(hwnd2 != 0, "Failed to create popup window (%ld)\n", GetLastError());
11997
11998 flush_events( TRUE );
11999
12000 if (winetest_debug > 1) trace("owner %p, hwnd %p, hwnd2 %p\n", owner, hwnd, hwnd2);
12001 state[0] = owner;
12002 state[1] = hwnd;
12003 state[2] = hwnd2;
12004
12005 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12006 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12007 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12008 check_z_order(hwnd, 0, hwnd2, owner, FALSE);
12009
12011 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12012 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12013 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12014 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12016 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12017 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12018 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12019 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12021 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12022 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12023 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12024 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12026
12028 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12029 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12030 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12031 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12032 swp_after(hwnd2, hwnd);
12033 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12034 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12035 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12036 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12037 swp_after(hwnd, hwnd2);
12038 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12039 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12040 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12041 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12042 swp_after(hwnd2, HWND_TOP);
12043 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12044 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12045 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12046 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12047 swp_after(owner, HWND_TOPMOST);
12048 todo_wine
12049 ok(is_topmost(owner), "owner should be topmost\n");
12050 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12051 todo_wine
12052 ok(is_topmost(hwnd2), "hwnd2 should be topmost\n");
12054 ok(!is_topmost(owner) || broken(is_topmost(owner)) /*win7 64-bit*/, "owner should NOT be topmost\n");
12055 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12056 ok(!is_topmost(hwnd2) || broken(is_topmost(hwnd2)) /*win7 64-bit*/, "hwnd2 should NOT be topmost\n");
12057 if (0) /*win7 64-bit is broken*/
12058 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12059 swp_after(hwnd2, HWND_NOTOPMOST);
12060 ok(!is_topmost(owner) || broken(is_topmost(owner)) /*win7 64-bit*/, "owner should NOT be topmost\n");
12061 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12062 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12063 if (!is_wine) /* FIXME: remove once Wine is fixed */
12064 check_z_order(hwnd, 0, hwnd2, owner, FALSE);
12066
12068 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12069 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12070 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12071 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12073 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12074 todo_wine
12075 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12076 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12077 if (!is_wine) /* FIXME: remove once Wine is fixed */
12078 check_z_order(hwnd, 0, hwnd2, owner, FALSE);
12080
12082 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12083 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12084 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12085 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12086 swp_after(hwnd, hwnd2);
12087 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12088 todo_wine
12089 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12090 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12091 if (!is_wine) /* FIXME: remove once Wine is fixed */
12092 check_z_order(hwnd, 0, hwnd2, owner, FALSE);
12093 /* FIXME: compensate todo_wine above */
12095 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12096 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12097 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12098 if (!is_wine) /* FIXME: remove once Wine is fixed */
12099 check_z_order(hwnd, 0, hwnd2, owner, FALSE);
12101
12103 ok(hwnd_child2 != 0, "Failed to create popup window (%ld)\n", GetLastError());
12105 ok(hwnd_child != 0, "Failed to create popup window (%ld)\n", GetLastError());
12106 hwnd_grandchild = create_tool_window(WS_VISIBLE|WS_POPUP, hwnd_child);
12107 ok(hwnd_grandchild != 0, "Failed to create popup window (%ld)\n", GetLastError());
12108
12109 flush_events( TRUE );
12110
12111 if (winetest_debug > 1)
12112 trace("hwnd_child %p, hwnd_child2 %p, hwnd_grandchild %p\n", hwnd_child, hwnd_child2, hwnd_grandchild);
12113 state[3] = hwnd_child2;
12114 state[4] = hwnd_child;
12115 state[5] = hwnd_grandchild;
12116
12117 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12118 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12119 ok(!is_topmost(hwnd2), "hwnd2 should NOT be topmost\n");
12120 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12121 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12122 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12123 if (!is_wine) /* FIXME: remove once Wine is fixed */
12124 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12125 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12126
12128 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12129 todo_wine
12130 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12131 todo_wine
12132 ok(is_topmost(hwnd_child), "child should be topmost\n");
12133 todo_wine
12134 ok(is_topmost(hwnd_child2), "child2 should be topmost\n");
12135 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12136 if (!is_wine) /* FIXME: remove once Wine is fixed */
12137 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12138 if (!is_wine) /* FIXME: remove once Wine is fixed */
12139 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12141 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12142 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12143 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12144 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12145 todo_wine
12146 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12147 if (!is_wine) /* FIXME: remove once Wine is fixed */
12148 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12149 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12151
12153 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12154 todo_wine
12155 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12156 todo_wine
12157 ok(is_topmost(hwnd_child), "child should be topmost\n");
12158 todo_wine
12159 ok(is_topmost(hwnd_child2), "child2 should be topmost\n");
12160 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12161 if (!is_wine) /* FIXME: remove once Wine is fixed */
12162 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12163 if (!is_wine) /* FIXME: remove once Wine is fixed */
12164 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12165 swp_after(hwnd_child, HWND_NOTOPMOST);
12166 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12167 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12168 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12169 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12170 todo_wine
12171 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12172 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12173 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12175
12177 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12178 todo_wine
12179 ok(is_topmost(hwnd), "hwnd should be topmost\n");
12180 todo_wine
12181 ok(is_topmost(hwnd_child), "child should be topmost\n");
12182 todo_wine
12183 ok(is_topmost(hwnd_child2), "child2 should be topmost\n");
12184 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12185 if (!is_wine) /* FIXME: remove once Wine is fixed */
12186 check_z_order(hwnd, hwnd2, 0, owner, TRUE);
12187 if (!is_wine) /* FIXME: remove once Wine is fixed */
12188 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12189 swp_after(hwnd_grandchild, HWND_NOTOPMOST);
12190 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12191 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12192 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12193 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12194 todo_wine
12195 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12196 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12197 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12199
12200 swp_after(hwnd_child, HWND_TOPMOST);
12201 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12202 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12203 todo_wine
12204 ok(is_topmost(hwnd_child), "child should be topmost\n");
12205 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12206 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12207 if (!is_wine) /* FIXME: remove once Wine is fixed */
12208 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12209 if (!is_wine) /* FIXME: remove once Wine is fixed */
12210 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12211 swp_after(hwnd_child, HWND_TOP);
12212 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12213 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12214 todo_wine
12215 ok(is_topmost(hwnd_child), "child should be topmost\n");
12216 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12217 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12218 if (!is_wine) /* FIXME: remove once Wine is fixed */
12219 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12220 if (!is_wine) /* FIXME: remove once Wine is fixed */
12221 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12223 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12224 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12225 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12226 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12227 todo_wine
12228 ok(!is_topmost(hwnd_grandchild) || broken(is_topmost(hwnd_grandchild))/*win2008 64-bit*/, "grandchild should NOT be topmost\n");
12229 if (!is_wine) /* FIXME: remove once Wine is fixed */
12230 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12231 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12233
12234 swp_after(hwnd_child, HWND_TOPMOST);
12235 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12236 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12237 todo_wine
12238 ok(is_topmost(hwnd_child), "child should be topmost\n");
12239 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12240 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12241 if (!is_wine) /* FIXME: remove once Wine is fixed */
12242 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12243 if (!is_wine) /* FIXME: remove once Wine is fixed */
12244 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12246 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12247 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12248 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12249 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12250 todo_wine
12251 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12252 if (!is_wine) /* FIXME: remove once Wine is fixed */
12253 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12254 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12256
12257 swp_after(hwnd_grandchild, HWND_TOPMOST);
12258 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12259 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12260 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12261 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12262 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12263 if (!is_wine) /* FIXME: remove once Wine is fixed */
12264 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12265 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, FALSE);
12266 swp_after(hwnd_child2, HWND_NOTOPMOST);
12267 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12268 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12269 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12270 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12271 ok(is_topmost(hwnd_grandchild) || broken(!is_topmost(hwnd_grandchild)) /* win8+ */, "grandchild should be topmost\n");
12272 if (!is_wine) /* FIXME: remove once Wine is fixed */
12273 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12274 if (!is_wine) /* FIXME: remove once Wine is fixed */
12275 check_z_order(hwnd_child, 0, hwnd_child2, hwnd, FALSE);
12277
12278 swp_after(hwnd_child, HWND_TOPMOST);
12279 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12280 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12281 todo_wine
12282 ok(is_topmost(hwnd_child), "child should be topmost\n");
12283 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12284 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12285 if (!is_wine) /* FIXME: remove once Wine is fixed */
12286 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12287 if (!is_wine) /* FIXME: remove once Wine is fixed */
12288 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12289 swp_after(hwnd_child, HWND_BOTTOM);
12290 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12291 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12292 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12293 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12294 todo_wine
12295 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12296 if (!is_wine) /* FIXME: remove once Wine is fixed */
12297 check_z_order(hwnd, 0, hwnd2, owner, FALSE);
12298 if (!is_wine) /* FIXME: remove once Wine is fixed */
12299 check_z_order(hwnd_child, 0, hwnd_child2, hwnd, FALSE);
12301
12302 swp_after(hwnd_child, HWND_TOPMOST);
12303 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12304 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12305 todo_wine
12306 ok(is_topmost(hwnd_child), "child should be topmost\n");
12307 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12308 ok(is_topmost(hwnd_grandchild), "grandchild should be topmost\n");
12309 if (!is_wine) /* FIXME: remove once Wine is fixed */
12310 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12311 if (!is_wine) /* FIXME: remove once Wine is fixed */
12312 check_z_order(hwnd_child, hwnd_child2, 0, hwnd, TRUE);
12313 swp_after(hwnd_child, hwnd_child2);
12314 ok(!is_topmost(owner), "owner should NOT be topmost\n");
12315 ok(!is_topmost(hwnd), "hwnd should NOT be topmost\n");
12316 ok(!is_topmost(hwnd_child), "child should NOT be topmost\n");
12317 ok(!is_topmost(hwnd_child2), "child2 should NOT be topmost\n");
12318 todo_wine
12319 ok(!is_topmost(hwnd_grandchild), "grandchild should NOT be topmost\n");
12320 if (!is_wine) /* FIXME: remove once Wine is fixed */
12321 check_z_order(hwnd, hwnd2, 0, owner, FALSE);
12322 if (!is_wine) /* FIXME: remove once Wine is fixed */
12323 check_z_order(hwnd_child, 0, hwnd_child2, hwnd, FALSE);
12325
12326 DestroyWindow(hwnd_grandchild);
12327 DestroyWindow(hwnd_child);
12328 DestroyWindow(hwnd_child2);
12330 DestroyWindow(hwnd2);
12331 DestroyWindow(owner);
12332}
12333
12335{
12337 BOOL ret, dwm;
12338 LONG styleex;
12339
12340 if (!pGetWindowDisplayAffinity || !pSetWindowDisplayAffinity)
12341 {
12342 win_skip("GetWindowDisplayAffinity or SetWindowDisplayAffinity missing\n");
12343 return;
12344 }
12345
12346 ret = pGetWindowDisplayAffinity(NULL, NULL);
12347 ok(!ret, "GetWindowDisplayAffinity succeeded\n");
12348 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "Expected ERROR_INVALID_WINDOW_HANDLE, got %lu\n", GetLastError());
12349
12350 ret = pGetWindowDisplayAffinity(NULL, &affinity);
12351 ok(!ret, "GetWindowDisplayAffinity succeeded\n");
12352 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "Expected ERROR_INVALID_WINDOW_HANDLE, got %lu\n", GetLastError());
12353
12354 ret = pGetWindowDisplayAffinity(win, NULL);
12355 ok(!ret, "GetWindowDisplayAffinity succeeded\n");
12356 ok(GetLastError() == ERROR_NOACCESS, "Expected ERROR_NOACCESS, got %lu\n", GetLastError());
12357
12358 styleex = GetWindowLongW(win, GWL_EXSTYLE);
12360
12361 affinity = 0xdeadbeef;
12362 ret = pGetWindowDisplayAffinity(win, &affinity);
12363 ok(ret, "GetWindowDisplayAffinity failed with %lu\n", GetLastError());
12364 ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%lx\n", affinity);
12365
12366 /* Windows 7 fails with ERROR_NOT_ENOUGH_MEMORY when dwm compositing is disabled */
12367 ret = pSetWindowDisplayAffinity(win, WDA_MONITOR);
12369 "SetWindowDisplayAffinity failed with %lu\n", GetLastError());
12370 dwm = ret;
12371
12372 affinity = 0xdeadbeef;
12373 ret = pGetWindowDisplayAffinity(win, &affinity);
12374 ok(ret, "GetWindowDisplayAffinity failed with %lu\n", GetLastError());
12375 if (dwm) ok(affinity == WDA_MONITOR, "Expected WDA_MONITOR, got 0x%lx\n", affinity);
12376 else ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%lx\n", affinity);
12377
12378 ret = pSetWindowDisplayAffinity(win, WDA_NONE);
12380 "SetWindowDisplayAffinity failed with %lu\n", GetLastError());
12381
12382 affinity = 0xdeadbeef;
12383 ret = pGetWindowDisplayAffinity(win, &affinity);
12384 ok(ret, "GetWindowDisplayAffinity failed with %lu\n", GetLastError());
12385 ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%lx\n", affinity);
12386
12388
12389 affinity = 0xdeadbeef;
12390 ret = pGetWindowDisplayAffinity(win, &affinity);
12391 ok(ret, "GetWindowDisplayAffinity failed with %lu\n", GetLastError());
12392 ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%lx\n", affinity);
12393
12394 ret = pSetWindowDisplayAffinity(win, WDA_MONITOR);
12396 "SetWindowDisplayAffinity failed with %lu\n", GetLastError());
12397
12398 affinity = 0xdeadbeef;
12399 ret = pGetWindowDisplayAffinity(win, &affinity);
12400 ok(ret, "GetWindowDisplayAffinity failed with %lu\n", GetLastError());
12401 if (dwm) ok(affinity == WDA_MONITOR, "Expected WDA_MONITOR, got 0x%lx\n", affinity);
12402 else ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%lx\n", affinity);
12403
12404 ret = pSetWindowDisplayAffinity(win, WDA_NONE);
12406 "SetWindowDisplayAffinity failed with %lu\n", GetLastError());
12407
12408 affinity = 0xdeadbeef;
12409 ret = pGetWindowDisplayAffinity(win, &affinity);
12410 ok(ret, "GetWindowDisplayAffinity failed with %lu\n", GetLastError());
12411 ok(affinity == WDA_NONE, "Expected WDA_NONE, got 0x%lx\n", affinity);
12412
12413 SetWindowLongW(win, GWL_EXSTYLE, styleex);
12414}
12415
12416static struct destroy_data
12417{
12426
12428{
12429 switch (msg)
12430 {
12431 case WM_DESTROY:
12432 ok( destroy_data.destroy_count > 0, "parent didn't get WM_DESTROY\n" );
12433 PostQuitMessage(0);
12434 break;
12435 case WM_NCDESTROY:
12436 ok( destroy_data.ncdestroy_count > 0, "parent didn't get WM_NCDESTROY\n" );
12437 break;
12438 }
12439 return DefWindowProcA(hwnd, msg, wparam, lparam);
12440}
12441
12443{
12444 switch (msg)
12445 {
12446 case WM_DESTROY:
12447 ok( destroy_data.destroy_count > 0, "parent didn't get WM_DESTROY\n" );
12448 break;
12449 case WM_NCDESTROY:
12450 ok( destroy_data.ncdestroy_count > 0, "parent didn't get WM_NCDESTROY\n" );
12451 ok( WaitForSingleObject(destroy_data.evt, 10000) != WAIT_TIMEOUT, "timeout\n" );
12452 PostQuitMessage(0);
12453 break;
12454 }
12455 return DefWindowProcA(hwnd, msg, wparam, lparam);
12456}
12457
12459{
12460 switch (msg)
12461 {
12462 case WM_DESTROY:
12464 break;
12465 case WM_NCDESTROY:
12467 break;
12468 }
12469 return DefWindowProcA(hwnd, msg, wparam, lparam);
12470}
12471
12473{
12474 MSG msg;
12475
12476 destroy_data.thread1_wnd = CreateWindowExA(0, "destroy_test_thread1",
12477 "destroy test thread", WS_CHILD, 100, 100, 100, 100,
12479 ok(destroy_data.thread1_wnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError());
12481
12482 while (GetMessageA(&msg, 0, 0, 0))
12483 {
12486 }
12488 ok( WaitForSingleObject(destroy_data.evt, 10000) != WAIT_TIMEOUT, "timeout\n" );
12489 ok( IsWindow( destroy_data.thread1_wnd ), "window destroyed\n" );
12490 return 0;
12491}
12492
12494{
12495 MSG msg;
12496
12497 destroy_data.thread2_wnd = CreateWindowExA(0, "destroy_test_thread2",
12498 "destroy test thread", WS_CHILD, 100, 100, 100, 100,
12500 ok(destroy_data.thread2_wnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError());
12501
12503 Sleep( 100 );
12504
12505 while (GetMessageA(&msg, 0, 0, 0))
12506 {
12509 }
12510 ok( !IsWindow( destroy_data.thread2_wnd ), "window not destroyed\n" );
12511 return 0;
12512}
12513
12514static void test_destroy_quit(void)
12515{
12516 MSG msg;
12517 WNDCLASSA wnd_classA;
12518 ATOM ret;
12520
12525
12526 memset(&wnd_classA, 0, sizeof(wnd_classA));
12527 wnd_classA.lpszClassName = "destroy_test_main";
12528 wnd_classA.lpfnWndProc = destroy_main_wndproc;
12529 ret = RegisterClassA(&wnd_classA);
12530 ok(ret, "RegisterClass failed with error %ld\n", GetLastError());
12531
12532 wnd_classA.lpszClassName = "destroy_test_thread1";
12534 ret = RegisterClassA(&wnd_classA);
12535 ok(ret, "RegisterClass failed with error %ld\n", GetLastError());
12536
12537 wnd_classA.lpszClassName = "destroy_test_thread2";
12539 ret = RegisterClassA(&wnd_classA);
12540 ok(ret, "RegisterClass failed with error %ld\n", GetLastError());
12541
12542 destroy_data.main_wnd = CreateWindowExA(0, "destroy_test_main",
12543 "destroy test main", WS_OVERLAPPED | WS_CAPTION, 100, 100, 100, 100,
12544 0, 0, GetModuleHandleA(NULL), NULL);
12545 ok(destroy_data.main_wnd != NULL, "CreateWindowEx failed with error %ld\n", GetLastError());
12547 {
12549 return;
12550 }
12551
12553
12554 while (GetMessageA(&msg, 0, 0, 0))
12555 {
12556 BOOL done = 0;
12557 switch (msg.message)
12558 {
12559 case WM_USER:
12562 break;
12563 case WM_USER + 1:
12565 break;
12566 case WM_USER + 2:
12568 done = 1;
12569 break;
12570 default:
12572 break;
12573 }
12574 if (done) break;
12575 }
12576
12577 ok( WaitForSingleObject( thread1, 10000 ) != WAIT_TIMEOUT, "timeout\n" );
12578 ok( !IsWindow( destroy_data.thread1_wnd ), "window not destroyed\n" );
12580}
12581
12582static void test_IsWindowEnabled(void)
12583{
12584 BOOL ret;
12585 HWND hwnd;
12586
12588 ok(!ret, "Expect IsWindowEnabled() return FALSE\n");
12589
12592 ok(ret, "Expect IsWindowEnabled() return TRUE\n");
12593
12596 ok(ret, "Expect IsWindowEnabled() return TRUE\n");
12599 ok(!ret, "Expect IsWindowEnabled() return FALSE\n");
12601}
12602
12603static void test_window_placement(void)
12604{
12605 RECT orig = {100, 200, 300, 400}, orig2 = {200, 300, 400, 500}, rect, work_rect;
12606 WINDOWPLACEMENT wp = {sizeof(wp)};
12607 MONITORINFO mon_info;
12608 HWND hwnd;
12609 BOOL ret;
12610
12611 hwnd = CreateWindowA("MainWindowClass", "wp", WS_OVERLAPPEDWINDOW,
12612 orig.left, orig.top, orig.right - orig.left, orig.bottom - orig.top, 0, 0, 0, 0);
12613 ok(!!hwnd, "failed to create window, error %lu\n", GetLastError());
12614
12615 mon_info.cbSize = sizeof(mon_info);
12616 GetMonitorInfoW(MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY), &mon_info);
12617 work_rect = mon_info.rcWork;
12618
12619 ret = GetWindowPlacement(hwnd, &wp);
12620 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12621 ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd);
12622 ok(wp.ptMinPosition.x == -1 && wp.ptMinPosition.y == -1,
12623 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12624 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12625 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12626 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12628
12630
12631 ret = GetWindowPlacement(hwnd, &wp);
12632 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12633 ok(!wp.flags, "got flags %#x\n", wp.flags);
12634 ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
12635 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12636 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12637 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12638 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12639 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12641
12643
12644 ret = GetWindowPlacement(hwnd, &wp);
12645 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12646 ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd);
12647 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12648 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12649 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12650 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12651 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12653
12655
12656 ret = GetWindowPlacement(hwnd, &wp);
12657 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12658 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12659 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12660 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12661 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12662 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12663 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12665
12666 SetWindowPos(hwnd, 0, 100, 100, 100, 100, SWP_NOZORDER | SWP_NOACTIVATE);
12667
12668 ret = GetWindowPlacement(hwnd, &wp);
12669 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12670 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12671 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12672 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12673 ok(wp.ptMaxPosition.x == 100 && wp.ptMaxPosition.y == 100,
12674 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12675 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12677
12678 SetWindowPos(hwnd, 0, work_rect.left, work_rect.top, work_rect.right - work_rect.left,
12679 work_rect.bottom - work_rect.top, SWP_NOZORDER | SWP_NOACTIVATE);
12680 ret = GetWindowPlacement(hwnd, &wp);
12681 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12682 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12683 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12684 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12685 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12686 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12687 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12689
12690 SetWindowPos(hwnd, 0, work_rect.left, work_rect.top, work_rect.right - work_rect.left - 1,
12691 work_rect.bottom - work_rect.top, SWP_NOZORDER | SWP_NOACTIVATE);
12692 ret = GetWindowPlacement(hwnd, &wp);
12693 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12694 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12695 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12696 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12697 ok(wp.ptMaxPosition.x == work_rect.left && wp.ptMaxPosition.y == work_rect.top,
12698 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12699 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12701
12702 SetWindowPos(hwnd, 0, work_rect.left, work_rect.top, work_rect.right - work_rect.left,
12703 work_rect.bottom - work_rect.top - 1, SWP_NOZORDER | SWP_NOACTIVATE);
12704 ret = GetWindowPlacement(hwnd, &wp);
12705 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12706 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12707 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12708 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12709 ok(wp.ptMaxPosition.x == work_rect.left && wp.ptMaxPosition.y == work_rect.top,
12710 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12711 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12713
12715
12716 ret = GetWindowPlacement(hwnd, &wp);
12717 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12718 ok(wp.flags == WPF_RESTORETOMAXIMIZED, "got flags %#x\n", wp.flags);
12719 ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
12720 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12721 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12722 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12723 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12724 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12726
12728
12729 ret = GetWindowPlacement(hwnd, &wp);
12730 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12731 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12732 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12733 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12734 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12735 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12736 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12738
12740
12741 ret = GetWindowPlacement(hwnd, &wp);
12742 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12743 ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd);
12744 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12745 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12746 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12747 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12748 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12750
12752 wp.ptMinPosition.x = wp.ptMinPosition.y = 100;
12753 wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100;
12754 wp.rcNormalPosition = orig2;
12755 ret = SetWindowPlacement(hwnd, &wp);
12756 ok(ret, "failed to set window placement, error %lu\n", GetLastError());
12757
12758 ret = GetWindowPlacement(hwnd, &wp);
12759 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12760 ok(wp.showCmd == SW_SHOWNORMAL, "got show cmd %u\n", wp.showCmd);
12761 ok(wp.ptMinPosition.x == 100 && wp.ptMinPosition.y == 100,
12762 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12763 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12764 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12765 ok(EqualRect(&wp.rcNormalPosition, &orig2), "got normal pos %s\n",
12768 ok(EqualRect(&rect, &orig2), "got window rect %s\n", wine_dbgstr_rect(&rect));
12769
12771
12772 ret = GetWindowPlacement(hwnd, &wp);
12773 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12774 ok(!wp.flags, "got flags %#x\n", wp.flags);
12775 ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
12776 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12777 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12778 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12779 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12780 ok(EqualRect(&wp.rcNormalPosition, &orig2), "got normal pos %s\n",
12782
12784
12786 wp.showCmd = SW_MINIMIZE;
12787 wp.ptMinPosition.x = wp.ptMinPosition.y = 100;
12788 wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100;
12789 wp.rcNormalPosition = orig;
12790 ret = SetWindowPlacement(hwnd, &wp);
12791 ok(ret, "failed to set window placement, error %lu\n", GetLastError());
12792
12793 ret = GetWindowPlacement(hwnd, &wp);
12794 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12795 ok(!wp.flags, "got flags %#x\n", wp.flags);
12796 ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
12797 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12798 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12799 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12800 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12801 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12803
12805
12807 wp.showCmd = SW_MAXIMIZE;
12808 wp.ptMinPosition.x = wp.ptMinPosition.y = 100;
12809 wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100;
12810 wp.rcNormalPosition = orig;
12811 ret = SetWindowPlacement(hwnd, &wp);
12812 ok(ret, "failed to set window placement, error %lu\n", GetLastError());
12813
12814 ret = GetWindowPlacement(hwnd, &wp);
12815 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12816 ok(wp.showCmd == SW_SHOWMAXIMIZED, "got show cmd %u\n", wp.showCmd);
12817 ok(wp.ptMinPosition.x == 100 && wp.ptMinPosition.y == 100,
12818 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12819 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12820 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12821 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12823
12825 wp.showCmd = SW_NORMAL;
12826 wp.ptMinPosition.x = wp.ptMinPosition.y = 100;
12827 wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100;
12828 wp.rcNormalPosition = orig;
12829 ret = SetWindowPlacement(hwnd, &wp);
12830 ok(ret, "failed to set window placement, error %lu\n", GetLastError());
12831
12833
12834 ret = GetWindowPlacement(hwnd, &wp);
12835 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12836 ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
12837 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12838 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12839 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12840 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12841 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12843
12844 ret = SetWindowPos(hwnd, NULL, 100, 100, 151, 151, SWP_NOACTIVATE | SWP_NOZORDER);
12845 ok(ret, "failed to set window pos, error %lu\n", GetLastError());
12846
12847 ret = GetWindowPlacement(hwnd, &wp);
12848 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12849 ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
12850 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12851 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12852 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12853 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12854 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12857 ok(rect.left == -32000 && rect.top == -32000, "got window rect %s\n", wine_dbgstr_rect(&rect));
12858
12860
12861 ret = GetWindowPlacement(hwnd, &wp);
12862 ok(ret, "failed to get window placement, error %lu\n", GetLastError());
12863 ok(wp.showCmd == SW_NORMAL, "got show cmd %u\n", wp.showCmd);
12864 ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
12865 "got minimized pos (%ld,%ld)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
12866 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
12867 "got maximized pos (%ld,%ld)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
12868 ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
12871 ok(EqualRect(&rect, &orig), "got window rect %s\n", wine_dbgstr_rect(&rect));
12872
12873 ret = SetWindowPlacement(hwnd, &wp);
12874 ok(ret, "failed to set window placement, error %lu\n", GetLastError());
12875
12876 wp.length = 0;
12877 SetLastError(0xdeadbeef);
12878 ret = SetWindowPlacement(hwnd, &wp);
12879 ok(!ret, "SetWindowPlacement should have failed\n");
12880 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %lu\n", GetLastError());
12881
12883}
12884
12886{
12887 MINIMIZEDMETRICS mm = {sizeof(mm)}, oldmm = {sizeof(oldmm)};
12888 RECT orig = {100, 200, 300, 400}, rect, expect, parent_rect;
12889 POINT pt = {0};
12890 HWND parent, hwnds[10];
12891 UINT ret;
12892 int i, row, col;
12893
12894 parent = CreateWindowA("MainWindowClass", "parent", WS_OVERLAPPEDWINDOW,
12895 100, 200, 500, 300, NULL, 0, 0, NULL);
12896 ok(!!parent, "failed to create window, error %lu\n", GetLastError());
12897
12898 GetClientRect(parent, &parent_rect);
12900 SystemParametersInfoA(SPI_GETMINIMIZEDMETRICS, sizeof(oldmm), &oldmm, 0);
12901
12902 mm.iWidth = 100;
12903 mm.iHorzGap = 40;
12904 mm.iVertGap = 3;
12906 ret = SystemParametersInfoA(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0);
12907 ok(ret, "failed to set minimized metrics, error %lu\n", GetLastError());
12908
12909 SetLastError(0xdeadbeef);
12911 ok(!ret, "wrong ret %u\n", ret);
12912 ok(GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError());
12913
12914 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
12915 {
12916 hwnds[i] = CreateWindowA("MainWindowClass", "child", WS_CHILD |
12917 WS_OVERLAPPEDWINDOW, orig.left, orig.top, orig.right - orig.left,
12918 orig.bottom - orig.top, parent, 0, 0, NULL);
12919 ok(!!hwnds[i], "failed to create window %u, error %lu\n", i, GetLastError());
12920 }
12921
12922 SetLastError(0xdeadbeef);
12924 ok(!ret, "wrong ret %u\n", ret);
12925 ok(GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError());
12926
12927 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
12928 {
12929 GetWindowRect(hwnds[i], &rect);
12930 expect = orig;
12931 OffsetRect(&expect, pt.x, pt.y);
12932 ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i,
12934 }
12935
12936 ShowWindow(hwnds[0], SW_MINIMIZE);
12937
12938 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
12939 {
12940 ret = SetWindowPos(hwnds[i], 0, orig.left, orig.top, 0, 0,
12942 ok(ret, "hwnd %u: failed to move window, error %lu\n", i, GetLastError());
12943 }
12944
12946 ok(ret == 1, "wrong ret %u\n", ret);
12947
12948 GetWindowRect(hwnds[0], &rect);
12951 OffsetRect(&expect, pt.x, pt.y);
12952 ok(EqualRect(&rect, &expect), "expected rect %s, got %s\n",
12954
12955 for (i = 1; i < ARRAY_SIZE(hwnds); ++i)
12956 {
12957 GetWindowRect(hwnds[i], &rect);
12958 expect = orig;
12959 OffsetRect(&expect, pt.x, pt.y);
12960 ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i,
12962 }
12963
12964 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
12965 {
12966 ShowWindow(hwnds[i], SW_MINIMIZE);
12967 ret = SetWindowPos(hwnds[i], 0, orig.left, orig.top, 0, 0,
12969 ok(ret, "hwnd %u: failed to move window, error %lu\n", i, GetLastError());
12970 }
12971
12973 ok(ret == 10, "wrong ret %u\n", ret);
12974
12975 col = mm.iHorzGap;
12976 row = mm.iVertGap;
12977 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
12978 {
12979 if (col + GetSystemMetrics(SM_CXMINIMIZED) > parent_rect.right - parent_rect.left)
12980 {
12981 col = mm.iHorzGap;
12983 }
12984
12985 GetWindowRect(hwnds[i], &rect);
12988 OffsetRect(&expect, pt.x, pt.y);
12989 ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i,
12991
12993 }
12994
12996 mm.iVertGap = 10;
12997 ret = SystemParametersInfoA(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0);
12998 ok(ret, "failed to set minimized metrics, error %lu\n", GetLastError());
12999
13000 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
13001 {
13002 ret = SetWindowPos(hwnds[i], 0, orig.left, orig.top, 0, 0,
13004 ok(ret, "hwnd %u: failed to move window, error %lu\n", i, GetLastError());
13005 }
13006
13008 ok(ret == 10, "wrong ret %u\n", ret);
13009
13010 col = parent_rect.right - mm.iHorzGap;
13011 row = parent_rect.bottom - mm.iVertGap;
13012 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
13013 {
13014 if (row - GetSystemMetrics(SM_CYMINIMIZED) < parent_rect.top)
13015 {
13016 row = parent_rect.bottom - mm.iVertGap;
13018 }
13019
13020 GetWindowRect(hwnds[i], &rect);
13023 OffsetRect(&expect, pt.x, pt.y);
13024 ok(EqualRect(&rect, &expect), "hwnd %u: expected rect %s, got %s\n", i,
13026
13028 }
13029
13030 for (i = 0; i < ARRAY_SIZE(hwnds); ++i)
13031 DestroyWindow(hwnds[i]);
13033
13034 ret = SystemParametersInfoA(SPI_SETMINIMIZEDMETRICS, sizeof(oldmm), &oldmm, 0);
13035 ok(ret, "failed to restore minimized metrics, error %lu\n", GetLastError());
13036}
13037
13039{
13040 HANDLE window_ready_event, test_done_event;
13041 WINDOWPLACEMENT wp = {0};
13042 DWORD ret;
13043
13044 window_ready_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_opw_window");
13045 ok(!!window_ready_event, "OpenEvent failed.\n");
13046 test_done_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_opw_test");
13047 ok(!!test_done_event, "OpenEvent failed.\n");
13048
13049 /* SW_SHOW */
13050 ret = WaitForSingleObject(window_ready_event, 5000);
13051 ok(ret == WAIT_OBJECT_0, "Unexpected ret %lx.\n", ret);
13052 ret = GetWindowPlacement(hwnd, &wp);
13053 ok(ret, "Unexpected ret %#lx.\n", ret);
13054 ok(wp.showCmd == SW_SHOWNORMAL, "Unexpected showCmd %#x.\n", wp.showCmd);
13055 ok(!wp.flags, "Unexpected flags %#x.\n", wp.flags);
13056 SetEvent(test_done_event);
13057
13058 /* SW_SHOWMAXIMIZED */
13059 ret = WaitForSingleObject(window_ready_event, 5000);
13060 ok(ret == WAIT_OBJECT_0, "Unexpected ret %lx.\n", ret);
13061 ret = GetWindowPlacement(hwnd, &wp);
13062 ok(ret, "Unexpected ret %#lx.\n", ret);
13063 ok(wp.showCmd == SW_SHOWMAXIMIZED, "Unexpected showCmd %#x.\n", wp.showCmd);
13064 todo_wine ok(wp.flags == WPF_RESTORETOMAXIMIZED, "Unexpected flags %#x.\n", wp.flags);
13065 SetEvent(test_done_event);
13066
13067 /* SW_SHOWMINIMIZED */
13068 ret = WaitForSingleObject(window_ready_event, 5000);
13069 ok(ret == WAIT_OBJECT_0, "Unexpected ret %lx.\n", ret);
13070 ret = GetWindowPlacement(hwnd, &wp);
13071 ok(ret, "Unexpected ret %#lx.\n", ret);
13072 ok(wp.showCmd == SW_SHOWMINIMIZED, "Unexpected showCmd %#x.\n", wp.showCmd);
13073 todo_wine ok(wp.flags == WPF_RESTORETOMAXIMIZED, "Unexpected flags %#x.\n", wp.flags);
13074 SetEvent(test_done_event);
13075
13076 /* SW_RESTORE */
13077 ret = WaitForSingleObject(window_ready_event, 5000);
13078 ok(ret == WAIT_OBJECT_0, "Unexpected ret %lx.\n", ret);
13079 ret = GetWindowPlacement(hwnd, &wp);
13080 ok(ret, "Unexpected ret %#lx.\n", ret);
13081 ok(wp.showCmd == SW_SHOWMAXIMIZED, "Unexpected showCmd %#x.\n", wp.showCmd);
13082 todo_wine ok(wp.flags == WPF_RESTORETOMAXIMIZED, "Unexpected flags %#x.\n", wp.flags);
13083 SetEvent(test_done_event);
13084
13085 CloseHandle(window_ready_event);
13086 CloseHandle(test_done_event);
13087}
13088
13089static void test_SC_SIZE(void)
13090{
13091 HWND hwnd;
13092 RECT rect;
13093 MSG msg;
13094
13095 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_VISIBLE,
13096 100, 100, 100, 100, 0, 0, NULL, NULL);
13097 ok(!!hwnd, "CreateWindowEx failed.\n");
13098
13100 ok(rect.left == 100, "rect.left = %ld\n", rect.left);
13101 ok(rect.top == 100, "rect.top = %ld\n", rect.top);
13102 ok(rect.right == 200, "rect.right = %ld\n", rect.right);
13103 ok(rect.bottom == 200, "rect.bottom = %ld\n", rect.bottom);
13104
13105 SetCursorPos(100, 100);
13107 SetCursorPos(110, 100);
13108 PostMessageA(hwnd, WM_MOUSEMOVE, 0, MAKELONG(110, 100));
13110
13111 while (GetMessageA(&msg, 0, 0, 0))
13112 {
13115
13116 if (msg.message == WM_SYSCOMMAND) break;
13117 }
13118
13120 ok(rect.left == 110, "rect.left = %ld\n", rect.left);
13121 ok(rect.top == 100, "rect.top = %ld\n", rect.top);
13122 ok(rect.right == 210, "rect.right = %ld\n", rect.right);
13123 ok(rect.bottom == 200, "rect.bottom = %ld\n", rect.bottom);
13124
13126}
13127
13128static void test_other_process_window(const char *argv0)
13129{
13130 HANDLE window_ready_event, test_done_event;
13133 char cmd[MAX_PATH];
13134 HWND hwnd;
13135 BOOL ret;
13136
13137 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
13138 100, 100, 100, 100, 0, 0, NULL, NULL);
13139 ok(!!hwnd, "CreateWindowEx failed.\n");
13140
13141 window_ready_event = CreateEventA(NULL, FALSE, FALSE, "test_opw_window");
13142 ok(!!window_ready_event, "CreateEvent failed.\n");
13143 test_done_event = CreateEventA(NULL, FALSE, FALSE, "test_opw_test");
13144 ok(!!test_done_event, "CreateEvent failed.\n");
13145
13146 sprintf(cmd, "%s win test_other_process_window %p", argv0, hwnd);
13147 memset(&startup, 0, sizeof(startup));
13148 startup.cb = sizeof(startup);
13149
13151 &startup, &info), "CreateProcess failed.\n");
13152
13154 ok(!ret, "Unexpected ret %#x.\n", ret);
13155 SetEvent(window_ready_event);
13156 ret = WaitForSingleObject(test_done_event, 5000);
13157 ok(ret == WAIT_OBJECT_0, "Unexpected ret %x.\n", ret);
13158
13160 ok(ret, "Unexpected ret %#x.\n", ret);
13161 SetEvent(window_ready_event);
13162 ret = WaitForSingleObject(test_done_event, 5000);
13163 ok(ret == WAIT_OBJECT_0, "Unexpected ret %x.\n", ret);
13164
13166 ok(ret, "Unexpected ret %#x.\n", ret);
13167 SetEvent(window_ready_event);
13168 ret = WaitForSingleObject(test_done_event, 5000);
13169 ok(ret == WAIT_OBJECT_0, "Unexpected ret %x.\n", ret);
13170
13172 ok(ret, "Unexpected ret %#x.\n", ret);
13173 SetEvent(window_ready_event);
13174 ret = WaitForSingleObject(test_done_event, 5000);
13175 ok(ret == WAIT_OBJECT_0, "Unexpected ret %x.\n", ret);
13176
13177 wait_child_process(info.hProcess);
13178 CloseHandle(window_ready_event);
13179 CloseHandle(test_done_event);
13180 CloseHandle(info.hProcess);
13181 CloseHandle(info.hThread);
13183}
13184
13185static void test_cancel_mode(void)
13186{
13187 HWND hwnd1, hwnd2, child;
13188 LRESULT ret;
13189
13190 hwnd1 = CreateWindowA("MainWindowClass", "window 1", WS_OVERLAPPEDWINDOW,
13191 100, 200, 500, 300, NULL, NULL, NULL, NULL);
13192 hwnd2 = CreateWindowA("MainWindowClass", "window 2", WS_OVERLAPPEDWINDOW,
13193 100, 200, 500, 300, NULL, NULL, NULL, NULL);
13195 SetCapture(hwnd1);
13196 ok(GetCapture() == hwnd1, "got capture %p\n", GetCapture());
13197
13198 ret = SendMessageA(hwnd2, WM_CANCELMODE, 0, 0);
13199 ok(!ret, "got %Id\n", ret);
13200 ok(GetCapture() == hwnd1, "got capture %p\n", GetCapture());
13201
13202 ret = SendMessageA(hwnd1, WM_CANCELMODE, 0, 0);
13203 ok(!ret, "got %Id\n", ret);
13204 ok(!GetCapture(), "got capture %p\n", GetCapture());
13205
13206 child = CreateWindowA("MainWindowClass", "child", WS_CHILD,
13207 0, 0, 100, 100, hwnd1, NULL, NULL, NULL);
13208
13210 ok(GetCapture() == child, "got capture %p\n", GetCapture());
13211
13212 ret = SendMessageA(hwnd2, WM_CANCELMODE, 0, 0);
13213 ok(!ret, "got %Id\n", ret);
13214 ok(GetCapture() == child, "got capture %p\n", GetCapture());
13215
13216 ret = SendMessageA(hwnd1, WM_CANCELMODE, 0, 0);
13217 ok(!ret, "got %Id\n", ret);
13218 ok(GetCapture() == child, "got capture %p\n", GetCapture());
13219
13221 ok(!ret, "got %Id\n", ret);
13222 ok(!GetCapture(), "got capture %p\n", GetCapture());
13223
13225 DestroyWindow(hwnd1);
13226 DestroyWindow(hwnd2);
13227}
13228
13229static void test_DragDetect(void)
13230{
13231 int cx_drag = GetSystemMetrics( SM_CXDRAG ), cy_drag = GetSystemMetrics( SM_CYDRAG );
13232 HWND hwnd;
13233 POINT pt;
13234 BOOL ret;
13235
13236 ok(!GetCapture(), "got capture window %p\n", GetCapture());
13237 ok(!(GetKeyState( VK_LBUTTON ) & 0x8000), "got VK_LBUTTON\n");
13238
13239 GetCursorPos(&pt);
13241 ok(!ret, "got %d\n", ret);
13242
13243 ok(!GetCapture(), "got capture window %p\n", GetCapture());
13244 ok(!(GetKeyState( VK_LBUTTON ) & 0x8000), "got VK_LBUTTON\n");
13245
13246 /* Test mouse moving out of the drag rectangle in client coordinates */
13247 hwnd = CreateWindowA( "static", "test", WS_POPUP | WS_VISIBLE, 100, 100, 50, 50, 0, 0, 0, 0 );
13249
13250 PostMessageA( hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(cx_drag, cy_drag) );
13251
13252 pt.x = 0;
13253 pt.y = 0;
13254 ret = DragDetect( hwnd, pt );
13255 ok(ret, "Got unexpected %d.\n", ret);
13256 flush_events( TRUE );
13257
13258 /* Test mouse not moving out of the drag rectangle in client coordinates */
13259 PostMessageA( hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(cx_drag - 1, cy_drag - 1) );
13260 PostMessageA( hwnd, WM_LBUTTONUP, 0, 0 );
13261
13262 pt.x = 0;
13263 pt.y = 0;
13264 ret = DragDetect( hwnd, pt );
13265 ok(!ret || broken(ret) /* Win 7 */, "Got unexpected %d\n", ret);
13266 flush_events( TRUE );
13267
13268 /* Test mouse moving out of the drag rectangle in screen coordinates */
13269 PostMessageA( hwnd, WM_MOUSEMOVE, MK_LBUTTON, MAKELPARAM(cx_drag, cy_drag) );
13270
13271 pt.x = 0;
13272 pt.y = 0;
13273 ClientToScreen( hwnd, &pt );
13274 ret = DragDetect( hwnd, pt );
13275 ok(ret || broken(!ret) /* Win 7 */, "Got unexpected %d\n", ret);
13276 flush_events( TRUE );
13277
13278 /* Test mouse not moving out of the drag rectangle in screen coordinates */
13280
13281 pt.x = 0;
13282 pt.y = 0;
13283 ClientToScreen( hwnd, &pt );
13284 ret = DragDetect( hwnd, pt );
13285 /* NOTE that if DragDetect() do use screen coordinates for the second parameter for the initial
13286 * mouse position, then FALSE should be returned in this case. But TRUE is returned here. So
13287 * this means that DragDetect() don't use screen coordinates even though MSDN says that it does */
13288 ok(ret, "Got unexpected %d\n", ret);
13289
13292}
13293
13295{
13296 unsigned int ret;
13297 HWND parent, child;
13298 RECT rect, exp;
13299
13300 switch (msg)
13301 {
13302 case WM_NCDESTROY:
13303 SetLastError( 0xdeadbeef );
13304 ret = SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOSIZE|SWP_NOMOVE );
13305 todo_wine
13306 ok( !ret, "SetWindowPos succeeded\n" );
13307 todo_wine
13308 ok( GetLastError() == ERROR_INVALID_PARAMETER, "SetWindowPos returned error %lu\n", GetLastError() );
13309
13310 SetLastError( 0xdeadbeef );
13312 ok( parent == 0, "SetParent returned %p\n", parent );
13313#ifdef __REACTOS__
13314 ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* WS03 */, "got error %lu\n", GetLastError() );
13315#else
13316 ok( GetLastError() == ERROR_INVALID_PARAMETER, "got error %lu\n", GetLastError() );
13317#endif
13318
13319 ret = GetWindowRect( hwnd, &rect );
13320 ok( ret, "GetWindowRect failed: %lu\n", GetLastError() );
13321 SetRect( &exp, 10, 20, 110, 220 );
13322 ok( EqualRect( &rect, &exp ), "unexpected rect %s, expected %s\n", wine_dbgstr_rect( &rect ),
13323 wine_dbgstr_rect( &exp ));
13324
13325 ret = MoveWindow( hwnd, 11, 12, 20, 30, FALSE );
13326 ok( ret, "MoveWindow failed: %lu\n", GetLastError() );
13327 ret = GetWindowRect( hwnd, &rect );
13328 ok( ret, "GetWindowRect failed: %lu\n", GetLastError() );
13329 SetRect( &exp, 11, 12, 31, 42 );
13330 ok( EqualRect( &rect, &exp ), "unexpected rect %s, expected %s\n", wine_dbgstr_rect( &rect ),
13331 wine_dbgstr_rect( &exp ));
13332
13333 child = CreateWindowExA( 0, "ToolWindowClass", "Tool window 1", WS_CHILD,
13334 0, 0, 100, 100, hwnd, 0, 0, NULL );
13335#ifdef __REACTOS__
13336 ok( GetLastError() == ERROR_INVALID_PARAMETER /* MSVC test builds return child, GCC test builds don't on Windows */
13337 || broken(child && GetLastError() == ERROR_SUCCESS) /* WS03 */,
13338 "CreateWindowExA returned %p %lu\n", child, GetLastError() );
13339#else
13341 "CreateWindowExA returned %p %lu\n", child, GetLastError() );
13342#endif
13343 break;
13344 }
13345
13346 return DefWindowProcW( hwnd, msg, wp, lp );
13347}
13348
13349static void test_ncdestroy(void)
13350{
13351 HWND hwnd;
13354 MoveWindow( hwnd, 10, 20, 100, 200, FALSE );
13356}
13357
13358static void test_WM_NCCALCSIZE(void)
13359{
13360 WNDCLASSA cls;
13361 HWND hwnd;
13363 WINDOWPOS winpos;
13364 RECT client_rect, window_rect;
13365 LRESULT ret;
13366
13369 cls.cbClsExtra = 0;
13370 cls.cbWndExtra = 0;
13371 cls.hInstance = GetModuleHandleA(0);
13372 cls.hIcon = 0;
13375 cls.lpszMenuName = NULL;
13376 cls.lpszClassName = "dummy_window_class";
13377 ret = RegisterClassA(&cls);
13378 ok(ret, "RegisterClass error %lu\n", GetLastError());
13379
13380 hwnd = CreateWindowExA(0, "dummy_window_class", NULL,
13382 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL), NULL);
13383 ok(hwnd != 0, "CreateWindowEx error %lu\n", GetLastError());
13384
13385 GetWindowRect(hwnd, &window_rect);
13386 params.rgrc[0] = window_rect;
13387 params.rgrc[1] = window_rect;
13388 GetClientRect(hwnd, &client_rect);
13389 MapWindowPoints(hwnd, 0, (POINT *)&client_rect, 2);
13390 params.rgrc[2] = client_rect;
13391
13392 winpos.hwnd = hwnd;
13393 winpos.hwndInsertAfter = HWND_TOP;
13394 winpos.x = window_rect.left;
13395 winpos.y = window_rect.top;
13396 winpos.cx = window_rect.right - window_rect.left;
13397 winpos.cy = window_rect.bottom - window_rect.top;
13398 winpos.flags = SWP_NOMOVE;
13399 params.lppos = &winpos;
13400
13402 ok(!ret, "got %08Ix\n", ret);
13403 ok(EqualRect(&params.rgrc[0], &client_rect), "got %s\n", wine_dbgstr_rect(&params.rgrc[0]));
13404
13405 params.rgrc[0] = window_rect;
13407 ok(!ret, "got %08Ix\n", ret);
13408 ok(EqualRect(&params.rgrc[0], &client_rect), "got %s\n", wine_dbgstr_rect(&params.rgrc[0]));
13409
13410 GetWindowRect(hwnd, &window_rect);
13411 ret = SendMessageW(hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&window_rect);
13412 ok(!ret, "got %08Ix\n", ret);
13413 ok(EqualRect(&window_rect, &client_rect), "got %s\n", wine_dbgstr_rect(&window_rect));
13414
13415 GetWindowRect(hwnd, &window_rect);
13416 ret = DefWindowProcA(hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&window_rect);
13417 ok(!ret, "got %08Ix\n", ret);
13418 ok(EqualRect(&window_rect, &client_rect), "got %s\n", wine_dbgstr_rect(&window_rect));
13419
13421}
13422
13423#define TRAY_MINIMIZE_ALL 419
13424#define TRAY_MINIMIZE_ALL_UNDO 416
13425
13426static void test_shell_tray(void)
13427{
13428 HWND hwnd, traywnd;
13429
13430 if (!(traywnd = FindWindowA( "Shell_TrayWnd", NULL )))
13431 {
13432 skip( "Shell_TrayWnd not found, skipping tests.\n" );
13433 return;
13434 }
13435
13436 hwnd = CreateWindowW( L"static", L"parent", WS_OVERLAPPEDWINDOW|WS_VISIBLE,
13437 100, 100, 200, 200, 0, 0, 0, NULL );
13438 ok( !!hwnd, "failed, error %lu.\n", GetLastError() );
13439 flush_events( TRUE );
13440
13441 ok( !IsIconic( hwnd ), "window is minimized.\n" );
13442
13443 SendMessageA( traywnd, WM_COMMAND, TRAY_MINIMIZE_ALL, 0xdeadbeef );
13444 flush_events( TRUE );
13445 todo_wine ok( IsIconic( hwnd ), "window is not minimized.\n" );
13446
13447 SendMessageA( traywnd, WM_COMMAND, TRAY_MINIMIZE_ALL_UNDO, 0xdeadbeef );
13448 flush_events( TRUE );
13449 ok( !IsIconic( hwnd ), "window is minimized.\n" );
13450
13452}
13453
13456
13458{
13459 if (msg == WM_MOUSEMOVE)
13460 {
13462 if (wm_mousemove_count >= 100)
13463 return 1;
13464
13467 return 0;
13468 }
13469 return DefWindowProcA(hwnd, msg, wp, lp);
13470}
13471
13472static void test_ReleaseCapture(void)
13473{
13474 WNDCLASSA cls = {0};
13475 ATOM atom;
13476 HWND hwnd;
13477 POINT pt;
13478 BOOL ret;
13479
13481 cls.hInstance = GetModuleHandleA(0);
13484 cls.lpszClassName = "test_ReleaseCapture_class";
13485 atom = RegisterClassA(&cls);
13486 ok(!!atom, "RegisterClassA failed, error %#lx.\n", GetLastError());
13487
13489 100, 100, NULL, NULL, 0, NULL);
13490 ok(!!hwnd, "CreateWindowA failed, error %#lx.\n", GetLastError());
13492 ok(ret, "SetForegroundWindow failed, error %#lx.\n", GetLastError());
13493 GetCursorPos(&pt);
13494 ret = SetCursorPos(150, 150);
13495 ok(ret, "SetCursorPos failed, error %#lx.\n", GetLastError());
13497
13498 /* Test a Wine bug that WM_MOUSEMOVE is post too many times when calling ReleaseCapture() during
13499 * handling WM_MOUSEMOVE and the cursor is on the window */
13501 ret = ReleaseCapture();
13502 ok(ret, "ReleaseCapture failed, error %#lx.\n", GetLastError());
13505 ok(wm_mousemove_count < 10, "Got too many WM_MOUSEMOVE.\n");
13506
13507 /* Test that ReleaseCapture() should send a WM_MOUSEMOVE if a window is captured */
13510 ret = ReleaseCapture();
13511 ok(ret, "ReleaseCapture failed, error %#lx.\n", GetLastError());
13513 ok(wm_mousemove_count == 1, "Got no WM_MOUSEMOVE.\n");
13514
13515 /* Test that ReleaseCapture() shouldn't send WM_MOUSEMOVE if no window is captured */
13517 ret = ReleaseCapture();
13518 ok(ret, "ReleaseCapture failed, error %#lx.\n", GetLastError());
13520 ok(wm_mousemove_count == 0, "Got WM_MOUSEMOVE.\n");
13521
13522 ret = SetCursorPos(pt.x, pt.y);
13523 ok(ret, "SetCursorPos failed, error %#lx.\n", GetLastError());
13526}
13527
13529{
13530 char **argv;
13532 HMODULE user32 = GetModuleHandleA( "user32.dll" );
13533 HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
13534 pGetWindowInfo = (void *)GetProcAddress( user32, "GetWindowInfo" );
13535 pGetWindowModuleFileNameA = (void *)GetProcAddress( user32, "GetWindowModuleFileNameA" );
13536 pGetLayeredWindowAttributes = (void *)GetProcAddress( user32, "GetLayeredWindowAttributes" );
13537 pSetLayeredWindowAttributes = (void *)GetProcAddress( user32, "SetLayeredWindowAttributes" );
13538 pUpdateLayeredWindow = (void *)GetProcAddress( user32, "UpdateLayeredWindow" );
13539 pUpdateLayeredWindowIndirect = (void *)GetProcAddress( user32, "UpdateLayeredWindowIndirect" );
13540 pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
13541 pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
13542 pGetProcessDefaultLayout = (void *)GetProcAddress( user32, "GetProcessDefaultLayout" );
13543 pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" );
13544 pFlashWindow = (void *)GetProcAddress( user32, "FlashWindow" );
13545 pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" );
13546 pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" );
13547 pGetWindowDisplayAffinity = (void *)GetProcAddress( user32, "GetWindowDisplayAffinity" );
13548 pSetWindowDisplayAffinity = (void *)GetProcAddress( user32, "SetWindowDisplayAffinity" );
13549 pAdjustWindowRectExForDpi = (void *)GetProcAddress( user32, "AdjustWindowRectExForDpi" );
13550 pSystemParametersInfoForDpi = (void *)GetProcAddress( user32, "SystemParametersInfoForDpi" );
13551 pInternalGetWindowIcon = (void *)GetProcAddress( user32, "InternalGetWindowIcon" );
13552
13553 if (argc == 4)
13554 {
13555 HWND hwnd;
13556
13557 sscanf(argv[3], "%p", &hwnd);
13558 if (!strcmp(argv[2], "create_children"))
13559 {
13561 return;
13562 }
13563 else if (!strcmp(argv[2], "test_other_process_window"))
13564 {
13566 return;
13567 }
13568 }
13569
13570 if (argc == 3 && !strcmp(argv[2], "winproc_limit"))
13571 {
13573 return;
13574 }
13575
13576 if (argc == 4 && !strcmp( argv[2], "SetActiveWindow_0" ))
13577 {
13579 return;
13580 }
13581
13582 if (!RegisterWindowClasses()) assert(0);
13583
13584 hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
13587 100, 100, 200, 200,
13588 0, 0, GetModuleHandleA(NULL), NULL);
13589 assert( hwndMain );
13590
13592 /* workaround for foreground lock timeout */
13593 simulate_click(101, 101);
13594 ok(SetForegroundWindow(hwndMain), "SetForegroundWindow failed\n");
13595 }
13596
13597 SetLastError(0xdeafbeef);
13599
13601 if (!hhook) win_skip( "Cannot set CBT hook, skipping some tests\n" );
13602
13603 /* make sure that these tests are executed first */
13607
13608 hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
13611 100, 100, 200, 200,
13612 0, 0, GetModuleHandleA(NULL), NULL);
13613 assert( hwndMain2 );
13614
13616
13617 /* This test is sensitive to other windows created with
13618 * CW_USEDEFAULT position, execute it early too */
13619 test_mdi();
13620
13621 /* Add the tests below this line */
13629 test_params();
13638
13644
13645 test_icons();
13651 test_NCRedraw();
13652
13664 test_scroll();
13667
13681 test_gettext();
13683 test_Expose();
13685
13692 test_smresult();
13698 test_desktop();
13707 test_SC_SIZE();
13712
13713 /* add the tests above this line */
13715
13718
13719 /* Make sure that following tests are executed last, under Windows they
13720 * tend to break the tests which are sensitive to z-order and activation
13721 * state of hwndMain and hwndMain2 windows.
13722 */
13723 test_topmost();
13724
13727}
#define DCX_USESTYLE
Definition: GetDCEx.c:10
#define SYSRGN
Definition: GetRandomRgn.c:13
@ 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 expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
static void startup(void)
Arabic default style
Definition: afstyles.h:94
#define GetNTVersion()
Definition: apitest.h:17
static int state
Definition: maze.c:121
VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#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
HWND hWnd
Definition: settings.c:17
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:20
static HANDLE thread
Definition: service.c:33
#define UlongToHandle(ul)
Definition: basetsd.h:91
#define HandleToULong(h)
Definition: basetsd.h:89
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
struct _root root
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static HWND hwndParent
Definition: cryptui.c:300
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c: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
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
key_state
Definition: listview.c:430
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
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HANDLE HWND
Definition: compat.h:19
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
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
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(const char *app_name, char *cmd_line, SECURITY_ATTRIBUTES *process_attr, SECURITY_ATTRIBUTES *thread_attr, BOOL inherit, DWORD flags, void *env, const char *cur_dir, STARTUPINFOA *startup_info, PROCESS_INFORMATION *info)
Definition: process.c:686
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
MonoAssembly int argc
Definition: metahost.c:107
const WCHAR * text
Definition: package.c:1794
unsigned short vk
Definition: console.c:118
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
#define UINT_MAX
Definition: limits.h:27
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static void test_window(IHTMLDocument2 *doc)
Definition: dom.c:6306
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
r parent
Definition: btrfs.c:3010
int main()
Definition: test.c:6
#define INFINITE
Definition: serial.h:102
POINTL point
Definition: edittest.c:50
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 short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
size_t total
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
DWORD WINAPI SetLayout(_In_ HDC hdc, _In_ DWORD dwLayout)
Definition: coord.c:780
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
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
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLuint color
Definition: glext.h:6243
const GLubyte * c
Definition: glext.h:8905
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
GLuint64EXT * result
Definition: glext.h:11304
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 cs
Definition: i386-dis.c:442
WNDPROC old_wnd_proc
Definition: imm32.c:367
static TfClientId tid
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
static real win[4][36]
static HANDLE hmon
Definition: localmon.c:41
const char * winetest_platform
int winetest_debug
#define win_skip
Definition: minitest.h:67
#define todo_wine_if(is_todo)
Definition: minitest.h:81
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
#define todo_wine
Definition: minitest.h:80
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
int * LPINT
Definition: minwindef.h:151
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static struct test_info tests[]
#define sprintf
Definition: sprintf.c:45
#define TEST(x)
Definition: precomp.h:20
HDC hdc
Definition: main.c:9
HANDLE events[2]
Definition: event.c:4
DWORD WINAPI thread1(LPVOID crap)
Definition: mutex.c:26
DWORD WINAPI thread2(LPVOID crap)
Definition: mutex.c:57
static HBITMAP
Definition: button.c:44
DWORD button
Definition: button.c:166
static HINSTANCE hinst
Definition: edit.c:551
static const BYTE bitmap_bits[48 *48/8]
Definition: imagelist.c:131
static HICON
Definition: imagelist.c:80
BOOL expected
Definition: store.c:2000
static DWORD layout
Definition: bitmap.c:46
static HANDLE start_event
Definition: thread.c:136
static SYSTEM_INFO si
Definition: virtual.c:39
static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: activex.c:2663
static IHTMLWindow2 * window
Definition: events.c:77
#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:60
static WNDPROC old_proc
Definition: clipboard.c:236
static HWND child
Definition: cursoricon.c:298
#define menu
Definition: input.c:3273
static void test_handles(void)
Definition: monitor.c:2629
static void test_SetFocus(void)
Definition: msg.c:19625
DWORD exp
Definition: msg.c:18625
static void test_SetForegroundWindow(void)
Definition: msg.c:16527
static HWND mdi_client
Definition: msg.c:4038
static void test_SetActiveWindow(void)
Definition: msg.c:16456
static void reset_window_state(HWND *state, int n)
Definition: win.c:11958
static void test_set_window_long_size(void)
Definition: win.c:7246
static void test_activateapp(HWND window1)
Definition: win.c:11288
static INT_PTR WINAPI reparent_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5513
static LRESULT WINAPI message_window_topmost_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:9081
static void test_GetUpdateRect(void)
Definition: win.c:8681
static BOOL test_thick_child_got_minmax
Definition: win.c:9639
static void test_MDI_child_stack(HWND mdi_client)
Definition: win.c:2191
static DWORD CALLBACK destroy_thread2(void *user)
Definition: win.c:12493
static void test_cancel_mode(void)
Definition: win.c:13185
static void test_destroy_quit(void)
Definition: win.c:12514
static void test_dialog_parent(void)
Definition: win.c:5571
static LRESULT WINAPI check_style_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win.c:7504
static void nccalchelper(HWND hwnd, INT x, INT y, RECT *prc)
Definition: win.c:4783
static LRESULT WINAPI destroy_dialog_owner_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5562
#define SET_FOREGROUND_SET_1
Definition: win.c:11223
static ATOM atomStyleCheckClass
Definition: win.c:5075
static void FixedAdjustWindowRectEx(RECT *rc, LONG style, BOOL menu, LONG exstyle)
Definition: win.c:1373
static int window_to_index(HWND hwnd, HWND *window, int size)
Definition: win.c:10403
static void window_from_point_proc(HWND parent)
Definition: win.c:10544
static void test_smresult(void)
Definition: win.c:11097
static void test_FindWindowEx(void)
Definition: win.c:10148
static HWND message_window_topmost_hwnd_msg
Definition: win.c:9078
static void create_window_tree(HWND parent, HWND *window, int size)
Definition: win.c:10293
static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner, BOOL topmost, const char *file, int line)
Definition: win.c:3531
static DWORD CALLBACK gettext_msg_thread(LPVOID arg)
Definition: win.c:8404
static void test_ncdestroy(void)
Definition: win.c:13349
static DWORD WINAPI smresult_thread_proc(void *param)
Definition: win.c:11060
static void test_capture_1(void)
Definition: win.c:4192
static DWORD CALLBACK settext_msg_thread(LPVOID arg)
Definition: win.c:8421
static BOOL got_hittest
Definition: win.c:10533
static void test_AdjustWindowRect(void)
Definition: win.c:6183
static void test_window_from_point(HWND main_window, const char *argv0)
Definition: win.c:10603
static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_out, DWORD ex_style_out)
Definition: win.c:5307
static void test_SC_SIZE(void)
Definition: win.c:13089
static void test_nonclient_area(HWND hwnd)
Definition: win.c:1493
#define check_icon_size(a, b, c)
Definition: win.c:2860
static void test_window_without_child_style(void)
Definition: win.c:10971
static DWORD our_pid
Definition: win.c:79
static LRESULT CALLBACK minmax_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:6733
static void test_window_info(const char *hook, HWND hwnd)
Definition: win.c:1318
static void other_process_proc(HWND hwnd)
Definition: win.c:13038
static void test_gettext(void)
Definition: win.c:8435
static BOOL mdi_RegisterWindowClasses(void)
Definition: win.c:2574
static const WCHAR mainclassW[]
Definition: win.c:1221
static void test_LockWindowUpdate(HWND parent)
Definition: win.c:11631
static void test_layered_window(void)
Definition: win.c:9202
static LRESULT CALLBACK fullscreen_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:9402
static INT_PTR WINAPI empty_dlg_proc2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5253
static void get_window_attributes(HWND hwnd, struct window_attributes *attrs)
Definition: win.c:10386
static LRESULT WINAPI main_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:1152
static void test_validatergn(HWND hwnd)
Definition: win.c:4745
static char mdi_lParam_test_message[]
Definition: win.c:1873
static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:10534
static const char * szAWRClass
Definition: win.c:77
static void check_wnd_state_(const char *file, int line, HWND active, HWND foreground, HWND focus, HWND capture)
Definition: win.c:154
static void wine_AdjustWindowRectEx(RECT *rect, LONG style, BOOL menu, LONG exStyle)
Definition: win.c:1389
static int WMPAINT_count
Definition: win.c:6212
static void run_NCRedrawLoop(UINT flags)
Definition: win.c:8865
static RECT broken_rect
Definition: win.c:6761
static void test_winregion(void)
Definition: win.c:9915
static const char * test_thick_child_name
Definition: win.c:9640
static void zero_parentdc_stat(struct parentdc_stat *t)
Definition: win.c:6308
static COLORREF BYTE DWORD *static BYTE
Definition: win.c:53
static void test_message_window_topmost(void)
Definition: win.c:9089
static void swp_after(HWND hwnd, HWND after)
Definition: win.c:11949
static BOOL
Definition: win.c:65
static void test_winproc_handles(const char *argv0)
Definition: win.c:11476
static MONITORINFO mi
Definition: win.c:9400
static LRESULT WINAPI winproc_convA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:11449
static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut)
Definition: win.c:5097
#define ULONG_PTR
Definition: win.c:42
static void test_SetParent(void)
Definition: win.c:4835
static void test_scrolldc(HWND parent)
Definition: win.c:5963
static LRESULT WINAPI smresult_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:11003
static void test_SetWindowLong(void)
Definition: win.c:7449
static void wine_AdjustWindowRectExForDpi(RECT *rect, LONG style, BOOL menu, LONG exStyle, UINT dpi)
Definition: win.c:1430
static DWORD WINAPI internal_get_icon_thread(void *arg)
Definition: win.c:2888
static void test_children_zorder(HWND parent)
Definition: win.c:3494
static void test_set_window_word_size(void)
Definition: win.c:7372
static DWORD WINAPI set_foreground_thread(void *params)
Definition: win.c:11235
static DWORD WINAPI create_window_thread(void *param)
Definition: win.c:4002
static void test_hide_window(void)
Definition: win.c:11696
static BOOL app_activated
Definition: win.c:75
static LRESULT WINAPI parentdc_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:6279
static BOOL CALLBACK enum_proc(HWND hwnd, LPARAM lParam)
Definition: win.c:690
static WINDOWINFO *static LPSTR
Definition: win.c:51
static void test_keyboard_input(HWND hwnd)
Definition: win.c:4421
static void simulate_click(int x, int y)
Definition: win.c:10510
static HHOOK hhook
Definition: win.c:74
static LRESULT WINAPI ncdestroy_test_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:13294
static BOOL AWR_init(void)
Definition: win.c:6092
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:134
static void test_thread_exit_destroy(void)
Definition: win.c:794
static BOOL app_deactivated
Definition: win.c:75
static WNDPROC old_button_proc
Definition: win.c:4136
static void test_redrawnow(void)
Definition: win.c:6232
static LRESULT WINAPI test_ReleaseCapture_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:13457
void dump_region(HRGN hrgn)
Definition: msg.c:8291
static void test_Expose(void)
Definition: win.c:8826
static INT_PTR WINAPI parent_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5498
static LRESULT WINAPI winproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:11440
static DWORD num_gettext_msgs
Definition: win.c:70
#define check_active_state(a, b, c)
Definition: win.c:168
static LRESULT WINAPI def_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:6609
static void test_scrollwindow(HWND hwnd)
Definition: win.c:5714
static INT_PTR WINAPI empty_dlg_proc3(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5239
static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5045
static void test_mdi(void)
Definition: win.c:2601
static BOOL wait_for_message(MSG *msg)
Definition: win.c:4497
static DWORD wait_for_events(DWORD count, HANDLE *events, DWORD timeout)
Definition: win.c:200
static LRESULT CALLBACK enable_window_procA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:8332
static BOOL peek_message(MSG *msg)
Definition: win.c:4411
static void register_style_check_class(void)
Definition: win.c:5077
static void test_dialog_styles(void)
Definition: win.c:5401
#define WM_SYSTIMER
Definition: win.c:38
static void test_FlashWindowEx(void)
Definition: win.c:10057
static LRESULT WINAPI mdi_child_wnd_proc_2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:2398
static void test_GetWindowModuleFileName(void)
Definition: win.c:8913
static void test_SetActiveWindow_0(char **argv)
Definition: win.c:3875
static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *info)
Definition: win.c:1270
static HWND hwndMain2
Definition: win.c:73
static BOOL is_topmost(HWND hwnd)
Definition: win.c:11944
static LRESULT WINAPI button_hook_proc(HWND button, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:4138
#define check_wnd_state(a, b, c, d)
Definition: win.c:153
static HWND hwndMain
Definition: win.c:73
static int redrawComplete
Definition: win.c:6212
#define expect_style(window, style)
static void test_nccalcscroll(HWND parent)
Definition: win.c:4796
static HRGN hrgn
Definition: win.c:62
static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
Definition: win.c:1875
static void test_ReleaseCapture(void)
Definition: win.c:13472
#define check_z_order(hwnd, next, prev, owner, topmost)
Definition: win.c:3527
static int expected_cy
Definition: win.c:6760
static void test_rtl_layout(void)
Definition: win.c:9970
static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style)
Definition: win.c:3567
static void check_icon_size_(int line, HICON icon, LONG width, LONG height)
Definition: win.c:2861
static UINT type
Definition: win.c:67
static WNDPROC def_static_proc
Definition: win.c:10532
static HWND create_tool_window(LONG style, HWND parent)
Definition: win.c:236
static void test_AWR_window_size(BOOL menu)
Definition: win.c:6122
static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: win.c:1653
static LRESULT WINAPI def_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:6604
static DWORD CALLBACK enum_thread(void *arg)
Definition: win.c:696
static COLORREF BYTE DWORD *static DWORD
Definition: win.c:53
static void test_SetWindowPos(HWND hwnd, HWND hwnd2)
Definition: win.c:3145
static void test_enum_thread_windows(void)
Definition: win.c:750
static void test_deferwindowpos(void)
Definition: win.c:11586
static void test_display_affinity(HWND win)
Definition: win.c:12334
#define parentdc_ok(t, got)
Definition: win.c:6342
static LONG test_thick_child_exStyle
Definition: win.c:9642
static LRESULT WINAPI reparent_dialog_owner_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5538
static LRESULT WINAPI test_thick_child_size_winproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:9644
static LRESULT WINAPI nccalcsize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:3132
static void test_IsWindowEnabled(void)
Definition: win.c:12582
static void test_capture_2(void)
Definition: win.c:4216
static LRESULT WINAPI my_window_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:10288
static void test_icons(void)
Definition: win.c:2901
static LONG test_thick_child_style
Definition: win.c:9641
static WINDOWINFO *static UINT
Definition: win.c:51
#define nothing_todo
static void test_CreateWindow(void)
Definition: win.c:6813
static BOOL CALLBACK EnumChildProc1(HWND hwndChild, LPARAM lParam)
Definition: win.c:230
static BOOL ignore_message(UINT message, HWND hwnd)
Definition: win.c:181
static void test_desktop(void)
Definition: win.c:11905
static void test_IsWindowUnicode(void)
Definition: win.c:6614
#define TEST_PIXEL(c_valid, c_invalid)
static BOOL test_lbuttondown_flag
Definition: win.c:69
static void test_WM_NCCALCSIZE(void)
Definition: win.c:13358
static void test_GetLastActivePopup(void)
Definition: win.c:10260
static INT_PTR WINAPI reparent_owned_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5523
static RECT expected_rect
Definition: win.c:6761
static void test_capture_3(HWND hwnd1, HWND hwnd2)
Definition: win.c:4272
#define SET_FOREGROUND_STEAL_2
Definition: win.c:11224
static void test_parent_owner(void)
Definition: win.c:245
static HMENU hmenu
Definition: win.c:78
static void test_scrollvalidate(HWND parent)
Definition: win.c:5767
#define TRAY_MINIMIZE_ALL
Definition: win.c:13423
static DWORD CALLBACK enablewindow_thread(LPVOID arg)
Definition: win.c:8325
static const WCHAR textW[]
Definition: win.c:11462
static void test_ShowWindow_child(HWND hwndMain)
Definition: win.c:8061
static void test_child_window_from_point(void)
Definition: win.c:10415
static void test_ShowWindow_mdichild(HWND hwndMain)
Definition: win.c:8195
static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:6214
static void test_window_placement(void)
Definition: win.c:12603
#define SET_FOREGROUND_SET_2
Definition: win.c:11225
static void test_mouse_input(HWND hwnd)
Definition: win.c:4515
static void test_shell_tray(void)
Definition: win.c:13426
static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:1189
static LRESULT WINAPI winproc_convW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:11463
static LRESULT WINAPI my_httrasparent_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:10282
static void test_topmost(void)
Definition: win.c:11974
static LRESULT CALLBACK test_capture_4_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:4297
static void test_ShowWindow(void)
Definition: win.c:7596
static void test_AWR_flags(void)
Definition: win.c:6146
static void test_EnableWindow(void)
Definition: win.c:8339
static const UPDATELAYEREDWINDOWINFO *static LPRECT
Definition: win.c:56
static LRESULT CALLBACK TestNCRedraw_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:8844
static void test_SetMenu(HWND parent)
Definition: win.c:3362
#define TRAY_MINIMIZE_ALL_UNDO
Definition: win.c:13424
static void test_minimize_window(HWND hwndMain)
Definition: win.c:11792
static void test_params(void)
Definition: win.c:6037
static BOOL do_release_capture
Definition: win.c:13455
static LRESULT WINAPI destroy_thread2_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:12442
static void hold_key(int vk)
Definition: win.c:81
#define SHOWSYSMETRIC(SM)
Definition: win.c:6181
static void test_map_points(void)
Definition: win.c:10682
static LRESULT CALLBACK TestExposedRegion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: win.c:8793
static LRESULT WINAPI post_quit_dialog_owner_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5553
static COLORREF BYTE DWORD *static COLORREF
Definition: win.c:53
static void test_NCRedraw(void)
Definition: win.c:8892
static void test_arrange_iconic_windows(void)
Definition: win.c:12885
static DWORD WINAPI test_shell_window_thread(LPVOID param)
Definition: win.c:1751
static void zero_parentdc_test(struct parentdc_test *t)
Definition: win.c:6315
#define SET_FOREGROUND_INJECT
Definition: win.c:11226
static int wm_mousemove_count
Definition: win.c:13454
static BOOL message_window_topmost_received_killfocus
Definition: win.c:9079
#define check_internal_icon_size(a, b, c, d)
Definition: win.c:2875
static LRESULT WINAPI destroy_thread1_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:12427
static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:3685
static LRESULT WINAPI cbt_proc(int ncode, WPARAM wparam, LPARAM lparam)
Definition: win.c:5019
static void test_winproc_limit(void)
Definition: win.c:11529
#define SET_FOREGROUND_STEAL_1
Definition: win.c:11222
static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total)
Definition: win.c:3452
static DWORD * affinity
Definition: win.c:63
static void test_GetMessagePos(void)
Definition: win.c:11156
static DWORD num_settext_msgs
Definition: win.c:71
static DWORD CALLBACK test_thread_exit_parent_thread(void *args)
Definition: win.c:765
static void test_shell_window(void)
Definition: win.c:1846
#define NUMBER_OF_THICK_CHILD_TESTS
Definition: win.c:9744
static BOOL RegisterWindowClasses(void)
Definition: win.c:1223
static DWORD CALLBACK destroy_thread1(void *user)
Definition: win.c:12472
static void test_ShowWindow_owned(HWND hwndMain)
Definition: win.c:7930
static void test_other_process_window(const char *argv0)
Definition: win.c:13128
static void MDI_ChildGetMinMaxInfo(HWND client, HWND hwnd, MINMAXINFO *lpMinMax)
Definition: win.c:2266
static void test_thick_child_size(HWND parentWindow)
Definition: win.c:9745
static HWND hwndMessage
Definition: win.c:72
static void test_capture_4(void)
Definition: win.c:4362
static void release_key(int vk)
Definition: win.c:93
static LRESULT CALLBACK test_standard_scrollbar_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:1465
static void check_active_state_(const char *file, int line, HWND active, HWND foreground, HWND focus)
Definition: win.c:169
static void test_SetActiveWindow_0_proc(char **argv)
Definition: win.c:3805
static void test_vis_rgn(HWND hwnd)
Definition: win.c:3666
#define expect_menu(window, menu)
static void test_window_styles(void)
Definition: win.c:5172
static void test_csparentdc(void)
Definition: win.c:6347
static void test_FlashWindow(void)
Definition: win.c:10028
static struct wm_gettext_override_data g_wm_gettext_override
static void test_hwnd_message(void)
Definition: win.c:8987
static LRESULT CALLBACK winsizes_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:6763
static void test_set_window_style(void)
Definition: win.c:7527
static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:2508
static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
Definition: win.c:222
static void dump_minmax_info(const MINMAXINFO *minmax)
Definition: win.c:105
static int offset
Definition: win.c:1463
#define expect_ex_style(window, ex_style)
static void test_FindWindow(void)
Definition: win.c:10204
static HDC
Definition: win.c:54
static void test_update_region(void)
Definition: win.c:10904
static LRESULT WINAPI destroy_main_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:12458
static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)
Definition: win.c:6064
static INT_PTR WINAPI empty_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:5234
static int expected_cx
Definition: win.c:6760
static void test_fullscreen(void)
Definition: win.c:9434
static void test_DragDetect(void)
Definition: win.c:13229
static void check_internal_icon_size_(int line, HANDLE window, UINT type, LONG width, LONG height)
Definition: win.c:2876
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:1035
static BOOL bInvert
Definition: win.c:60
static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
Definition: win.c:2283
static LRESULT CALLBACK test_thread_exit_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: win.c:787
static void test_scroll(void)
Definition: win.c:5929
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
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
unsigned int UINT
Definition: ndis.h:50
HANDLE hThread
Definition: wizard.c:28
HANDLE stop_event
Definition: nfs41_daemon.c:55
#define GENERIC_ALL
Definition: nt_native.h:92
_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
struct _STARTUPINFOA STARTUPINFOA
static unsigned __int64 next
Definition: rand_nt.c:6
#define err(...)
#define test
Definition: rosglue.h:37
#define offsetof(TYPE, MEMBER)
strcpy
Definition: string.h:131
#define flaky_wine
Definition: test.h:165
int winetest_get_mainargs(char ***pargv)
#define flaky
Definition: test.h:164
#define wait_child_process
Definition: test.h:159
#define memset(x, y, z)
Definition: compat.h:39
#define args
Definition: format.c:66
static FILE * client
Definition: client.c:37
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define _WIN32_WINNT_WIN8
Definition: sdkddkver.h:29
static char argv0[MAX_PATH]
Definition: shlexec.c:49
& rect
Definition: startmenu.cpp:1413
TCHAR * cmdline
Definition: stretchblt.cpp:32
WORD cdit
Definition: winuser.h:3169
short y
Definition: winuser.h:3171
short cy
Definition: winuser.h:3173
DWORD style
Definition: winuser.h:3167
DWORD dwExtendedStyle
Definition: winuser.h:3168
short x
Definition: winuser.h:3170
short cx
Definition: winuser.h:3172
Definition: comm.c:65
LONG y
Definition: windef.h:130
LONG x
Definition: windef.h:129
LONG cx
Definition: kdterminal.h:27
POINT ptMaxPosition
Definition: winuser.h:3402
RECT rcNormalPosition
Definition: winuser.h:3403
POINT ptMinPosition
Definition: winuser.h:3401
HWND hwnd
Definition: winuser.h:3696
UINT flags
Definition: winuser.h:3702
HWND hwndInsertAfter
Definition: winuser.h:3697
HBRUSH hbrBackground
Definition: winuser.h:3278
HICON hIcon
Definition: winuser.h:3276
HINSTANCE hInstance
Definition: winuser.h:3275
HCURSOR hCursor
Definition: winuser.h:3277
int cbWndExtra
Definition: winuser.h:3274
UINT style
Definition: winuser.h:3271
LPCSTR lpszMenuName
Definition: winuser.h:3279
LPCSTR lpszClassName
Definition: winuser.h:3280
WNDPROC lpfnWndProc
Definition: winuser.h:3272
int cbClsExtra
Definition: winuser.h:3273
HICON hIconSm
Definition: winuser.h:3320
WNDPROC lpfnWndProc
Definition: winuser.h:3311
LPCSTR lpszClassName
Definition: winuser.h:3319
HICON hIcon
Definition: winuser.h:3315
LPCWSTR lpszClassName
Definition: winuser.h:3293
LPCWSTR lpszMenuName
Definition: winuser.h:3292
HBRUSH hbrBackground
Definition: winuser.h:3291
HICON hIcon
Definition: winuser.h:3289
HINSTANCE hInstance
Definition: winuser.h:3288
int cbClsExtra
Definition: winuser.h:3286
UINT style
Definition: winuser.h:3284
WNDPROC lpfnWndProc
Definition: winuser.h:3285
int cbWndExtra
Definition: winuser.h:3287
HCURSOR hCursor
Definition: winuser.h:3290
Definition: match.c:390
Definition: uimain.c:89
Definition: ftp_var.h:139
HWND main_wnd
Definition: win.c:12418
DWORD main_tid
Definition: win.c:12422
DWORD destroy_count
Definition: win.c:12423
DWORD ncdestroy_count
Definition: win.c:12424
HANDLE evt
Definition: win.c:12421
HWND thread2_wnd
Definition: win.c:12420
HWND thread1_wnd
Definition: win.c:12419
HWND parent
Definition: win.c:5249
DLGTEMPLATE * dlg_data
Definition: win.c:5250
HWND grand_parent
Definition: win.c:5249
HWND ga_parent
Definition: win.c:5490
HWND owner
Definition: win.c:5493
HWND gwl_parent
Definition: win.c:5491
HWND get_parent
Definition: win.c:5492
HWND ga_root_owner
Definition: win.c:5495
Definition: fci.c:127
Definition: copy.c:22
Definition: parser.c:49
Definition: tftpd.h:60
RECT paint
Definition: win.c:6270
RECT client
Definition: win.c:6268
RECT clip
Definition: win.c:6269
struct parentdc_stat child2 child2_todo
Definition: win.c:6276
struct parentdc_stat child1 child1_todo
Definition: win.c:6275
struct parentdc_stat main main_todo
Definition: win.c:6274
HANDLE thread_got_wm_app
Definition: win.c:10997
HANDLE thread_started
Definition: win.c:10996
HANDLE thread_replied
Definition: win.c:10999
HANDLE main_in_wm_app_1
Definition: win.c:10998
Definition: format.c:80
Definition: ps.c:97
LPCREATESTRUCTA lpcs
Definition: winuser.h:3078
HWND hwndInsertAfter
Definition: winuser.h:3079
DWORD cbSize
Definition: winable.h:70
POINT ptMaxPosition
Definition: winuser.h:3737
POINT ptMaxSize
Definition: winuser.h:3736
POINT ptMinTrackSize
Definition: winuser.h:3738
POINT ptReserved
Definition: winuser.h:3735
POINT ptMaxTrackSize
Definition: winuser.h:3739
RECT rcMonitor
Definition: winuser.h:3893
DWORD cbSize
Definition: winuser.h:3892
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
DWORD styleNew
Definition: winuser.h:3801
DWORD styleOld
Definition: winuser.h:3800
DWORD cbSize
Definition: winuser.h:3874
DWORD cs_exstyle
Definition: win.c:5014
DWORD style
Definition: win.c:5015
DWORD cs_style
Definition: win.c:5013
DWORD exstyle
Definition: win.c:5016
Definition: dhcpd.h:248
BOOL is_groupbox
Definition: win.c:10383
BOOL is_visible
Definition: win.c:10383
char class_name[128]
Definition: win.c:10382
BOOL is_httransparent
Definition: win.c:10383
BOOL is_extransparent
Definition: win.c:10383
BOOL is_enabled
Definition: win.c:10383
#define max(a, b)
Definition: svc.c:63
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:726
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:573
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
Definition: synch.c:605
__inline int after(__u32 seq1, __u32 seq2)
Definition: tcpcore.h:2395
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
static IsThemeActiveT pIsThemeActive
Definition: treelist.c:367
#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 retval
Definition: wcstombs.cpp:91
#define dpi
Definition: sysparams.c:23
HDESK WINAPI CreateDesktopA(LPCSTR lpszDesktop, LPCSTR lpszDevice, LPDEVMODEA pDevmode, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa)
Definition: desktop.c:431
int WINAPI GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount)
Definition: window.c:1300
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
HWND WINAPI GetShellWindow(void)
Definition: input.c:974
#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:1220
#define WAIT_OBJECT_0
Definition: winbase.h:383
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
void * arg
Definition: msvc.h:10
#define WINAPI
Definition: msvc.h:6
#define ERROR_TLW_WITH_WSCHILD
Definition: winerror.h:1232
#define ERROR_INVALID_INDEX
Definition: winerror.h:1239
#define ERROR_INVALID_DWP_HANDLE
Definition: winerror.h:1231
#define ERROR_INVALID_MENU_HANDLE
Definition: winerror.h:1227
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226
#define ERROR_CLASS_DOES_NOT_EXIST
Definition: winerror.h:1237
#define ERROR_CANNOT_FIND_WND_CLASS
Definition: winerror.h:1233
#define ERROR_NOACCESS
Definition: winerror.h:902
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define LTGRAY_BRUSH
Definition: wingdi.h:900
#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:1546
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 CLR_INVALID
Definition: wingdi.h:883
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define WHITE_BRUSH
Definition: wingdi.h:902
#define GRAY_BRUSH
Definition: wingdi.h:898
#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:781
#define WM_PAINT
Definition: winuser.h:1648
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
HWND WINAPI GetFocus(void)
Definition: window.c:1863
#define HWND_MESSAGE
Definition: winuser.h:1221
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define GW_OWNER
Definition: winuser.h:777
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CS_VREDRAW
Definition: winuser.h:666
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 SW_SHOWMAXIMIZED
Definition: winuser.h:784
#define WM_MDISETMENU
Definition: winuser.h:1850
#define GW_HWNDFIRST
Definition: winuser.h:775
#define SetWindowLongPtrA
Definition: winuser.h:5511
#define WS_EX_STATICEDGE
Definition: winuser.h:403
BOOL WINAPI IsWindow(_In_opt_ HWND)
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
#define SM_CXMINIMIZED
Definition: winuser.h:1031
#define SetClassLongPtrW
Definition: winuser.h:5431
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define SW_HIDE
Definition: winuser.h:779
#define WM_CLOSE
Definition: winuser.h:1649
LRESULT WINAPI DefMDIChildProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SWP_NOACTIVATE
Definition: winuser.h:1253
BOOL WINAPI SetMenu(_In_ HWND, _In_opt_ HMENU)
#define SWP_NOREDRAW
Definition: winuser.h:1257
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1050
#define WM_SYSCOMMAND
Definition: winuser.h:1769
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:891
#define GW_HWNDLAST
Definition: winuser.h:776
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define SM_CYEDGE
Definition: winuser.h:1020
#define SM_CXDRAG
Definition: winuser.h:1039
#define GA_ROOT
Definition: winuser.h:2893
#define SetClassLongPtrA
Definition: winuser.h:5430
#define SWP_FRAMECHANGED
Definition: winuser.h:1251
#define WM_QUIT
Definition: winuser.h:1651
BOOL WINAPI SetKeyboardState(_In_reads_(256) LPBYTE)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
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 COLOR_WINDOW
Definition: winuser.h:929
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 SM_CYSCREEN
Definition: winuser.h:971
#define HTCAPTION
Definition: winuser.h:2512
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define WM_MDICREATE
Definition: winuser.h:1840
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1196
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
#define HWND_TOPMOST
Definition: winuser.h:1219
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
UINT WINAPI ArrangeIconicWindows(_In_ HWND)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SM_CXEDGE
Definition: winuser.h:1019
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetThreadDesktop(_In_ HDESK)
HICON WINAPI CreateIcon(_In_opt_ HINSTANCE, _In_ int, _In_ int, _In_ BYTE, _In_ BYTE, _In_ const BYTE *, _In_ const BYTE *)
Definition: cursoricon.c:2764
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2414
#define WM_CAPTURECHANGED
Definition: winuser.h:1836
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1689
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define SW_SCROLLCHILDREN
Definition: winuser.h:2614
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetLastActivePopup(_In_ HWND)
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
#define WDA_NONE
Definition: winuser.h:3515
#define WM_CREATE
Definition: winuser.h:1636
#define WS_EX_APPWINDOW
Definition: winuser.h:383
#define SM_CXMINTRACK
Definition: winuser.h:1008
#define SW_MINIMIZE
Definition: winuser.h:787
HHOOK WINAPI SetWindowsHookExW(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
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:972
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SWP_DRAWFRAME
Definition: winuser.h:1250
#define VK_SPACE
Definition: winuser.h:2255
#define HCBT_ACTIVATE
Definition: winuser.h:60
#define SM_CYMINIMIZED
Definition: winuser.h:1032
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
#define WM_SIZE
Definition: winuser.h:1639
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:1215
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_CANCELMODE
Definition: winuser.h:1663
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define SM_CXFRAME
Definition: winuser.h:1005
#define BS_TYPEMASK
Definition: winuser.h:270
#define SWP_NOMOVE
Definition: winuser.h:1255
BOOL WINAPI ValidateRect(_In_opt_ HWND, _In_opt_ LPCRECT)
#define WM_COMMAND
Definition: winuser.h:1768
#define SW_INVALIDATE
Definition: winuser.h:2615
#define CS_HREDRAW
Definition: winuser.h:661
#define MF_STRING
Definition: winuser.h:138
#define ARW_UP
Definition: winuser.h:1093
struct tagCREATESTRUCTA * LPCREATESTRUCTA
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define GA_ROOTOWNER
Definition: winuser.h:2894
#define MA_ACTIVATE
Definition: winuser.h:2537
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define IDC_ARROW
Definition: winuser.h:695
#define SM_CYMENU
Definition: winuser.h:987
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3064
#define GCLP_WNDPROC
Definition: winuser.h:686
#define WM_NCHITTEST
Definition: winuser.h:1714
#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:1024
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SW_SHOWNOACTIVATE
Definition: winuser.h:785
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define GA_PARENT
Definition: winuser.h:2892
#define DS_3DLOOK
Definition: winuser.h:367
#define QS_ALLINPUT
Definition: winuser.h:914
#define SIF_PAGE
Definition: winuser.h:1244
#define SWP_NOSIZE
Definition: winuser.h:1256
#define WM_MOUSEMOVE
Definition: winuser.h:1803
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:1646
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define RDW_UPDATENOW
Definition: winuser.h:1231
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define WM_MDINEXT
Definition: winuser.h:1844
#define RDW_ERASE
Definition: winuser.h:1222
BOOL WINAPI IsMenu(_In_ HMENU)
#define GetWindowLongPtrA
Definition: winuser.h:4982
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
#define CS_DBLCLKS
Definition: winuser.h:659
#define WM_INITDIALOG
Definition: winuser.h:1767
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
HWND WINAPI FindWindowExA(_In_opt_ HWND, _In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR)
#define WM_DEVICECHANGE
Definition: winuser.h:1839
#define WH_CBT
Definition: winuser.h:35
WORD WINAPI SetWindowWord(_In_ HWND, _In_ int, _In_ WORD)
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
#define SWP_ASYNCWINDOWPOS
Definition: winuser.h:1264
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:3056
#define WM_MDIACTIVATE
Definition: winuser.h:1842
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define ULW_OPAQUE
Definition: winuser.h:2890
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:867
#define SWP_DEFERERASE
Definition: winuser.h:1263
#define HCBT_CREATEWND
Definition: winuser.h:58
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WDA_MONITOR
Definition: winuser.h:3516
#define SM_CYFRAME
Definition: winuser.h:1007
#define SM_CYHSCROLL
Definition: winuser.h:973
BOOL WINAPI IsIconic(_In_ HWND)
#define MDIS_ALLCHILDSTYLES
Definition: winuser.h:253
#define GW_HWNDNEXT
Definition: winuser.h:772
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:1711
#define IDI_APPLICATION
Definition: winuser.h:712
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
#define SC_SIZE
Definition: winuser.h:2620
#define WM_ACTIVATE
Definition: winuser.h:1640
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
#define WM_TIMECHANGE
Definition: winuser.h:1662
#define ARW_RIGHT
Definition: winuser.h:1092
#define SC_MINIMIZE
Definition: winuser.h:2622
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1049
#define WM_SETTEXT
Definition: winuser.h:1645
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1194
BOOL WINAPI IsWindowUnicode(_In_ HWND)
#define SW_SHOWMINIMIZED
Definition: winuser.h:782
#define WM_NCMOUSEMOVE
Definition: winuser.h:1719
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1195
#define SM_CYBORDER
Definition: winuser.h:976
#define SM_CXSMICON
Definition: winuser.h:1023
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
#define VK_RETURN
Definition: winuser.h:2237
#define SM_CYICON
Definition: winuser.h:984
#define HWND_TOP
Definition: winuser.h:1218
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define ARW_TOPLEFT
Definition: winuser.h:1088
#define SM_CXMAXTRACK
Definition: winuser.h:1033
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
BOOL WINAPI SendNotifyMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_GETMINMAXINFO
Definition: winuser.h:1668
BOOL WINAPI LockWindowUpdate(_In_opt_ HWND)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SIZE_MAXIMIZED
Definition: winuser.h:2543
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
BOOL WINAPI IsChild(_In_ HWND, _In_ HWND)
HWND WINAPI SetActiveWindow(_In_ HWND)
#define SWP_NOCOPYBITS
Definition: winuser.h:1254
#define WM_MDIDESTROY
Definition: winuser.h:1841
#define HCBT_SETFOCUS
Definition: winuser.h:64
#define ULW_EX_NORESIZE
Definition: winuser.h:2891
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GWLP_HWNDPARENT
Definition: winuser.h:869
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
#define WM_TIMER
Definition: winuser.h:1770
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:2429
#define LBS_STANDARD
Definition: winuser.h:321
#define SM_CXBORDER
Definition: winuser.h:975
#define PM_REMOVE
Definition: winuser.h:1207
BOOL WINAPI ScrollDC(_In_ HDC, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define RDW_ERASENOW
Definition: winuser.h:1230
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
#define RDW_FRAME
Definition: winuser.h:1223
#define SM_CYMAXTRACK
Definition: winuser.h:1034
int WINAPI GetUpdateRgn(_In_ HWND, _In_ HRGN, _In_ BOOL)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SIF_ALL
Definition: winuser.h:1243
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define WM_NULL
Definition: winuser.h:1635
BOOL WINAPI GetMonitorInfoA(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#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
BOOL WINAPI DragDetect(_In_ HWND, _In_ POINT)
HDC WINAPI GetDC(_In_opt_ HWND)
#define SC_CLOSE
Definition: winuser.h:2628
#define WM_MOUSEACTIVATE
Definition: winuser.h:1665
#define WS_EX_LAYERED
Definition: winuser.h:389
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4470
#define SM_CXDLGFRAME
Definition: winuser.h:977
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:1805
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WA_ACTIVE
Definition: winuser.h:2665
HWND WINAPI GetParent(_In_ HWND)
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
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:1252
#define WM_NCDESTROY
Definition: winuser.h:1712
#define DCX_LOCKWINDOWUPDATE
Definition: winuser.h:2156
#define SIZE_RESTORED
Definition: winuser.h:2541
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_NCLBUTTONUP
Definition: winuser.h:1721
#define HTTRANSPARENT
Definition: winuser.h:2509
#define WPF_RESTORETOMAXIMIZED
Definition: winuser.h:2568
HWND WINAPI WindowFromPoint(_In_ POINT)
#define DWLP_MSGRESULT
Definition: winuser.h:881
#define GWLP_ID
Definition: winuser.h:871
#define SWP_NOOWNERZORDER
Definition: winuser.h:1260
BOOL WINAPI SystemParametersInfoA(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define SW_RESTORE
Definition: winuser.h:790
WORD WINAPI GetWindowWord(_In_ HWND, _In_ int)
#define SW_ERASE
Definition: winuser.h:2616
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define WM_USER
Definition: winuser.h:1923
#define MK_LBUTTON
Definition: winuser.h:2403
#define SM_CYSMCAPTION
Definition: winuser.h:1025
#define QS_PAINT
Definition: winuser.h:890
#define WM_ACTIVATEAPP
Definition: winuser.h:1660
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GW_HWNDPREV
Definition: winuser.h:773
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:979
DWORD WINAPI GetClassLongA(_In_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:786
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define WM_DESTROY
Definition: winuser.h:1637
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 SM_CXSCREEN
Definition: winuser.h:970
#define WM_KEYDOWN
Definition: winuser.h:1743
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
#define WM_MDIGETACTIVE
Definition: winuser.h:1849
#define GW_CHILD
Definition: winuser.h:774
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1047
BOOL WINAPI CloseDesktop(_In_ HDESK)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
BOOL WINAPI PostThreadMessageA(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TPM_RETURNCMD
Definition: winuser.h:2423
#define WM_NCMOUSELEAVE
Definition: winuser.h:1870
#define SWP_NOZORDER
Definition: winuser.h:1258
#define SW_MAXIMIZE
Definition: winuser.h:783
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:2513
BOOL WINAPI GetClassInfoW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSW)
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
#define SetWindowLongPtrW
Definition: winuser.h:5512
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SM_CYDRAG
Definition: winuser.h:1040
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_ACTIVECAPTION
Definition: winuser.h:2704
#define WM_NCCALCSIZE
Definition: winuser.h:1713
#define GWL_STYLE
Definition: winuser.h:863
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:664
BOOL WINAPI GetUpdateRect(_In_ HWND, _Out_opt_ LPRECT, _In_ BOOL)
#define SM_CXICON
Definition: winuser.h:983
BOOL WINAPI SetWindowPlacement(_In_ HWND hWnd, _In_ const WINDOWPLACEMENT *)
HWND WINAPI FindWindowA(_In_opt_ LPCSTR, _In_opt_ LPCSTR)
#define SM_CMONITORS
Definition: winuser.h:1051
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1690
#define SWP_NOSENDCHANGING
Definition: winuser.h:1262
#define SC_RESTORE
Definition: winuser.h:2634
#define WM_ENTERIDLE
Definition: winuser.h:1777
#define HWND_NOTOPMOST
Definition: winuser.h:1217
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 WPF_SETMINPOSITION
Definition: winuser.h:2569
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define SM_CYCAPTION
Definition: winuser.h:974
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define PM_NOREMOVE
Definition: winuser.h:1206
int WINAPI GetSystemMetrics(_In_ int)
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
Definition: window.c:929
#define SW_NORMAL
Definition: winuser.h:780
#define WM_SYSKEYDOWN
Definition: winuser.h:1747
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1720
#define GCW_ATOM
Definition: winuser.h:669
#define SM_CYMINTRACK
Definition: winuser.h:1009
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:1225
#define WS_EX_NOINHERITLAYOUT
Definition: winuser.h:396
#define HWND_BOTTOM
Definition: winuser.h:1216
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)
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1048
HMENU WINAPI GetMenu(_In_ HWND)
#define SC_MAXIMIZE
Definition: winuser.h:2624
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2459
#define SB_HORZ
Definition: winuser.h:552
SHORT WINAPI GetKeyState(_In_ int)
#define ARW_BOTTOMRIGHT
Definition: winuser.h:1086
#define COLOR_BTNFACE
Definition: winuser.h:939
#define WM_NCPAINT
Definition: winuser.h:1715
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:862
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422
#define VK_LBUTTON
Definition: winuser.h:2226
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char * LPSTR
Definition: xmlstorage.h:182
unsigned char BYTE
Definition: xxhash.c:193