1 /*
2  * PROJECT:         ReactOS API tests
3  * LICENSE:         LGPLv2.1+ - See COPYING.LIB in the top level directory
4  * PURPOSE:         Test for CreateWindowEx
5  * PROGRAMMERS:     Thomas Faber <thomas.faber@reactos.org>
6  *                  Mark Jansen
7  */
8 
9 #include "precomp.h"
10 
11 static void Test_Params(void)
12 {
13     HWND hWnd;
14     DWORD dwError;
15 
16     SetLastError(0x1234);
17     hWnd = CreateWindowExW(0, L"BUTTON", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
18     dwError = GetLastError();
19     ok(hWnd != NULL, "hWnd = %p\n", hWnd);
20     ok(dwError == 0, "error = %lu\n", dwError);
21     DestroyWindow(hWnd);
22 
23     SetLastError(0x1234);
24     hWnd = CreateWindowExW(0, L"BUTTON", NULL, 0, 0, 0, 0, 0, (HWND)(LONG_PTR)-1, NULL, NULL, NULL);
25     dwError = GetLastError();
26     ok(hWnd == NULL, "hWnd = %p\n", hWnd);
27     ok(dwError == ERROR_INVALID_WINDOW_HANDLE, "error = %lu\n", dwError);
28 
29     SetLastError(0x1234);
30     hWnd = CreateWindowExW(0, L"BUTTON", NULL, WS_CHILD, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
31     dwError = GetLastError();
32     ok(hWnd == NULL, "hWnd = %p\n", hWnd);
33     ok(dwError == ERROR_TLW_WITH_WSCHILD, "error = %lu\n", dwError);
34 
35     SetLastError(0x1234);
36     hWnd = CreateWindowExW(0, L"BUTTON", NULL, WS_CHILD, 0, 0, 0, 0, (HWND)(LONG_PTR)-1, NULL, NULL, NULL);
37     dwError = GetLastError();
38     ok(hWnd == NULL, "hWnd = %p\n", hWnd);
39     ok(dwError == ERROR_INVALID_WINDOW_HANDLE, "error = %lu\n", dwError);
40 
41     SetLastError(0x1234);
42     hWnd = CreateWindowExW(0, L"BUTTON", NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
43     dwError = GetLastError();
44     ok(hWnd != NULL, "hWnd = %p\n", hWnd);
45     ok(dwError == 0, "error = %lu\n", dwError);
46     DestroyWindow(hWnd);
47 
48     SetLastError(0x1234);
49     hWnd = CreateWindowExW(0, L"BUTTON", NULL, WS_POPUP, 0, 0, 0, 0, (HWND)(LONG_PTR)-1, NULL, NULL, NULL);
50     dwError = GetLastError();
51     ok(hWnd == NULL, "hWnd = %p\n", hWnd);
52     ok(dwError == ERROR_INVALID_WINDOW_HANDLE, "error = %lu\n", dwError);
53 
54     SetLastError(0x1234);
55     hWnd = CreateWindowExW(0, L"BUTTON", NULL, WS_CHILD|WS_POPUP, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
56     dwError = GetLastError();
57     ok(hWnd != NULL, "hWnd = %p\n", hWnd);
58     ok(dwError == 0, "error = %lu\n", dwError);
59     DestroyWindow(hWnd);
60 
61     SetLastError(0x1234);
62     hWnd = CreateWindowExW(0, L"BUTTON", NULL, WS_CHILD|WS_POPUP, 0, 0, 0, 0, (HWND)(LONG_PTR)-1, NULL, NULL, NULL);
63     dwError = GetLastError();
64     ok(hWnd == NULL, "hWnd = %p\n", hWnd);
65     ok(dwError == ERROR_INVALID_WINDOW_HANDLE, "error = %lu\n", dwError);
66 }
67 
68 HWND g_TestWindow = NULL;
69 HWND g_ChildWindow = NULL;
70 HWND g_hwndMDIClient = NULL;
71 
72 static int get_iwnd(HWND hWnd)
73 {
74     if (!g_TestWindow)
75         g_TestWindow = hWnd;
76     if (!g_ChildWindow && hWnd != g_TestWindow)
77         g_ChildWindow = hWnd;
78 
79     if (hWnd == g_TestWindow)
80         return 1;
81     else if (hWnd == g_ChildWindow)
82         return 2;
83     return 0;
84 }
85 
86 DWORD g_FaultLine = 0;
87 DWORD g_NcExpectStyle = 0;
88 DWORD g_NcExpectExStyle = 0;
89 DWORD g_ExpectStyle = 0;
90 DWORD g_ExpectExStyle = 0;
91 
92 DWORD g_ChildNcExpectStyle = 0;
93 DWORD g_ChildNcExpectExStyle = 0;
94 DWORD g_ChildExpectStyle = 0;
95 DWORD g_ChildExpectExStyle = 0;
96 
97 #define ok_hex_(expression, result) \
98     do { \
99         int _value = (expression); \
100         ok_(__FILE__, g_FaultLine)(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
101            #expression, (int)(result), _value); \
102     } while (0)
103 
104 
105 
106 static int g_ChangeStyle = 0;
107 static LRESULT CALLBACK MSGTestProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
108 {
109     LRESULT lRet;
110     int iwnd = get_iwnd(hWnd);
111 
112     if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
113         return DefWindowProc(hWnd, message, wParam, lParam);
114 
115     switch(message)
116     {
117     case WM_IME_SETCONTEXT:
118     case WM_IME_NOTIFY:
119     case WM_GETICON:
120     case WM_GETTEXT:
121         return DefWindowProc(hWnd, message, wParam, lParam);
122         break;
123     case WM_NCCREATE:
124     {
125         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
126         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
127         ok_hex_(create->style, g_NcExpectStyle);
128         ok_hex_(create->dwExStyle, g_NcExpectExStyle);
129         if (g_ChangeStyle)
130         {
131             DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
132             dwStyle &= ~(WS_EX_CLIENTEDGE);
133             SetWindowLong(hWnd, GWL_EXSTYLE, dwStyle);
134             RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
135             SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
136                          SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME);
137 
138             RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
139             ok_hex_(create->style, g_NcExpectStyle);
140             ok_hex_(create->dwExStyle, g_NcExpectExStyle);
141         }
142     }
143         break;
144     case WM_CREATE:
145     {
146         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
147         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
148         ok_hex_(create->style, g_ExpectStyle);
149         ok_hex_(create->dwExStyle, g_ExpectExStyle);
150     }
151         break;
152     case WM_NCCALCSIZE:
153     case WM_STYLECHANGING:
154     case WM_STYLECHANGED:
155     case WM_SIZE:
156         RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
157         break;
158     case WM_WINDOWPOSCHANGING:
159     case WM_WINDOWPOSCHANGED:
160         ok(wParam == 0,"expected wParam=0\n");
161         RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
162         break;
163     default:
164         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
165         break;
166     }
167     lRet = DefWindowProc(hWnd, message, wParam, lParam);
168     RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
169     return lRet;
170 }
171 
172 MSG_ENTRY create_chain[] =
173 {
174     { 1, WM_GETMINMAXINFO, SENT },
175     { 1, WM_GETMINMAXINFO, SENT_RET },
176     { 1, WM_NCCREATE, SENT },
177     { 1, WM_NCCREATE, SENT_RET },
178     { 1, WM_NCCALCSIZE, SENT },
179     { 1, WM_NCCALCSIZE, SENT_RET },
180     { 1, WM_CREATE, SENT },
181     { 1, WM_CREATE, SENT_RET },
182     { 0, 0 }
183 };
184 
185 MSG_ENTRY create_chain_modify[] =
186 {
187     { 1, WM_GETMINMAXINFO, SENT },
188     { 1, WM_GETMINMAXINFO, SENT_RET },
189     { 1, WM_NCCREATE, SENT },
190         { 1, WM_STYLECHANGING, SENT, GWL_EXSTYLE },
191         { 1, WM_STYLECHANGING, SENT_RET },
192         { 1, WM_STYLECHANGED, SENT, GWL_EXSTYLE },
193         { 1, WM_STYLECHANGED, SENT_RET },
194     { 1, WM_NCCREATE, MARKER },
195         { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED },
196         { 1, WM_WINDOWPOSCHANGING, SENT_RET },
197         { 1, WM_NCCALCSIZE, SENT, TRUE },
198         { 1, WM_NCCALCSIZE, SENT_RET },
199         { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED },
200             { 1, WM_MOVE, SENT },
201             { 1, WM_MOVE, SENT_RET },
202             { 1, WM_SIZE, SENT },
203             { 1, WM_SIZE, SENT_RET },
204         { 1, WM_WINDOWPOSCHANGED, SENT_RET },
205     { 1, WM_NCCREATE, MARKER },
206     { 1, WM_NCCREATE, SENT_RET },
207     { 1, WM_NCCALCSIZE, SENT },
208     { 1, WM_NCCALCSIZE, SENT_RET },
209     { 1, WM_CREATE, SENT },
210     { 1, WM_CREATE, SENT_RET },
211     { 0, 0 }
212 };
213 
214 MSG_ENTRY create_chain_modify_below8_nonsrv[] =
215 {
216     { 1, WM_GETMINMAXINFO, SENT },
217     { 1, WM_GETMINMAXINFO, SENT_RET },
218     { 1, WM_NCCREATE, SENT },
219         { 1, WM_STYLECHANGING, SENT, GWL_EXSTYLE },
220         { 1, WM_STYLECHANGING, SENT_RET },
221         { 1, WM_STYLECHANGED, SENT, GWL_EXSTYLE },
222         { 1, WM_STYLECHANGED, SENT_RET },
223     { 1, WM_NCCREATE, MARKER },
224         { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED },
225         { 1, WM_WINDOWPOSCHANGING, SENT_RET },
226         { 1, WM_NCCALCSIZE, SENT, TRUE },
227         { 1, WM_NCCALCSIZE, SENT_RET },
228         { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED },
229             { 1, WM_MOVE, SENT },
230             { 1, WM_MOVE, SENT_RET },
231             { 1, WM_SIZE, SENT },
232             { 1, WM_SIZE, SENT_RET },
233         { 1, WM_WINDOWPOSCHANGED, SENT_RET },
234         { 1, WM_NCCALCSIZE, SENT, TRUE },
235         { 1, WM_NCCALCSIZE, SENT_RET },
236     { 1, WM_NCCREATE, MARKER },
237     { 1, WM_NCCREATE, SENT_RET },
238     { 1, WM_NCCALCSIZE, SENT },
239     { 1, WM_NCCALCSIZE, SENT_RET },
240     { 1, WM_CREATE, SENT },
241     { 1, WM_CREATE, SENT_RET },
242     { 0, 0 }
243 };
244 
245 
246 static BOOL
247 IsWindowsServer()
248 {
249     OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, VER_NT_WORKSTATION };
250     DWORDLONG        const dwlConditionMask = VerSetConditionMask( 0, VER_PRODUCT_TYPE, VER_EQUAL );
251 
252     return !VerifyVersionInfoW(&osvi, VER_PRODUCT_TYPE, dwlConditionMask);
253 }
254 
255 
256 static BOOL
257 IsWindows8OrGreater()
258 {
259     OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0 };
260     DWORDLONG const dwlConditionMask = VerSetConditionMask(VerSetConditionMask(
261         VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL),
262             VER_MINORVERSION, VER_GREATER_EQUAL),
263             VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
264 
265     osvi.dwMajorVersion = HIBYTE(_WIN32_WINNT_WIN8);
266     osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_WIN8);
267 
268     return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE;
269 }
270 
271 static void Test_Messages(void)
272 {
273     HWND hWnd;
274     BOOL Below8NonServer = !IsWindows8OrGreater() && !IsWindowsServer();
275 
276     RegisterSimpleClass(MSGTestProc, L"Test_Message_Window_XX");
277 
278     g_ChangeStyle = 0;
279 
280     g_ExpectStyle = g_NcExpectStyle = 0;
281     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
282     g_FaultLine = __LINE__ + 1;
283     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_XX", L"", 0, 10, 20,
284                            200, 210, NULL, NULL, 0, NULL);
285 
286     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
287     COMPARE_CACHE(create_chain);
288     DestroyWindow(hWnd);
289     g_TestWindow = g_ChildWindow = NULL;
290     EMPTY_CACHE();
291 
292     g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
293     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
294     g_FaultLine = __LINE__ + 1;
295     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_XX", L"", WS_OVERLAPPEDWINDOW, 10, 20,
296                            200, 210, NULL, NULL, 0, NULL);
297 
298     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
299     COMPARE_CACHE(create_chain);
300     DestroyWindow(hWnd);
301     g_TestWindow = g_ChildWindow = NULL;
302     EMPTY_CACHE();
303 
304     g_ChangeStyle = 1;
305 
306     g_ExpectStyle = g_NcExpectStyle = 0;
307     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
308     g_FaultLine = __LINE__ + 1;
309     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_XX", L"", 0, 10, 20,
310                            200, 210, NULL, NULL, 0, NULL);
311 
312     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
313     COMPARE_CACHE(Below8NonServer ? create_chain_modify_below8_nonsrv : create_chain_modify);
314     DestroyWindow(hWnd);
315     g_TestWindow = g_ChildWindow = NULL;
316     EMPTY_CACHE();
317 
318     g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
319     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
320     g_FaultLine = __LINE__ + 1;
321     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_XX", L"", WS_OVERLAPPEDWINDOW, 10, 20,
322                            200, 210, NULL, NULL, 0, NULL);
323 
324     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
325     COMPARE_CACHE(Below8NonServer ? create_chain_modify_below8_nonsrv : create_chain_modify);
326     DestroyWindow(hWnd);
327     g_TestWindow = g_ChildWindow = NULL;
328     EMPTY_CACHE();
329 
330     UnregisterClassW(L"Test_Message_Window_XX", NULL);
331 }
332 
333 
334 static LRESULT CALLBACK MSGChildProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
335 {
336     LRESULT lRet;
337     int iwnd = get_iwnd(hWnd);
338 
339     if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
340         return DefWindowProc(hWnd, message, wParam, lParam);
341 
342     switch(message)
343     {
344     case WM_IME_SETCONTEXT:
345     case WM_IME_NOTIFY:
346     case WM_GETICON:
347     case WM_GETTEXT:
348         return DefWindowProc(hWnd, message, wParam, lParam);
349         break;
350     case WM_NCCREATE:
351     {
352         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
353         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
354         ok_hex_(create->style, g_ChildNcExpectStyle);
355         ok_hex_(create->dwExStyle, g_ChildNcExpectExStyle);
356 
357         if (g_ChangeStyle)
358         {
359             DWORD dwStyle = GetWindowLong(g_TestWindow, GWL_EXSTYLE);
360             dwStyle &= ~(WS_EX_CLIENTEDGE);
361             SetWindowLong(g_TestWindow, GWL_EXSTYLE, dwStyle);
362             RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
363             SetWindowPos(g_TestWindow, NULL, 0, 0, 0, 0,
364                          SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME);
365 
366             RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
367             ok_hex_(create->style, g_ChildNcExpectStyle);
368             ok_hex_(create->dwExStyle, g_ChildNcExpectExStyle);
369         }
370     }
371     break;
372     case WM_CREATE:
373     {
374         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
375         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
376         ok_hex_(create->style, g_ChildExpectStyle);
377         ok_hex_(create->dwExStyle, g_ChildExpectExStyle);
378     }
379     break;
380     case WM_NCCALCSIZE:
381     case WM_STYLECHANGING:
382     case WM_STYLECHANGED:
383     case WM_SIZE:
384         RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
385         break;
386     case WM_WINDOWPOSCHANGING:
387     case WM_WINDOWPOSCHANGED:
388         ok(wParam == 0,"expected wParam=0\n");
389         RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
390         break;
391     default:
392         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
393         break;
394     }
395     lRet = DefWindowProc(hWnd, message, wParam, lParam);
396     RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
397     return lRet;
398 }
399 
400 
401 static LRESULT CALLBACK MSGTestProc2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
402 {
403     LRESULT lRet;
404     int iwnd = get_iwnd(hWnd);
405 
406     if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
407         return DefWindowProc(hWnd, message, wParam, lParam);
408 
409     switch(message)
410     {
411     case WM_IME_SETCONTEXT:
412     case WM_IME_NOTIFY:
413     case WM_GETICON:
414     case WM_GETTEXT:
415         return DefWindowProc(hWnd, message, wParam, lParam);
416         break;
417     case WM_NCCREATE:
418     {
419         HWND child;
420         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
421         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
422         ok_hex_(create->style, g_NcExpectStyle);
423         ok_hex_(create->dwExStyle, g_NcExpectExStyle);
424 
425         child = CreateWindowExW(0, L"Test_Message_Window_Child2", L"", WS_CHILD, 0, 0, 10, 10, hWnd, NULL, 0, NULL);
426         RECORD_MESSAGE(iwnd, message, MARKER, 0, 0);
427         ok_(__FILE__, g_FaultLine)(g_ChildWindow == child, "Testing against the wrong child!\n");
428     }
429     break;
430     case WM_NCDESTROY:
431         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
432         DestroyWindow(g_ChildWindow);
433         break;
434     case WM_CREATE:
435     {
436         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
437         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
438         ok_hex_(create->style, g_ExpectStyle);
439         ok_hex_(create->dwExStyle, g_ExpectExStyle);
440     }
441     break;
442     case WM_NCCALCSIZE:
443     case WM_STYLECHANGING:
444     case WM_STYLECHANGED:
445     case WM_SIZE:
446         RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
447         break;
448     case WM_WINDOWPOSCHANGING:
449     case WM_WINDOWPOSCHANGED:
450         ok(wParam == 0,"expected wParam=0\n");
451         RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
452         break;
453     default:
454         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
455         break;
456     }
457     lRet = DefWindowProc(hWnd, message, wParam, lParam);
458     RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
459     return lRet;
460 }
461 
462 
463 MSG_ENTRY child_create_chain[] =
464 {
465     { 1, WM_GETMINMAXINFO, SENT },
466     { 1, WM_GETMINMAXINFO, SENT_RET },
467     { 1, WM_NCCREATE, SENT },
468         { 2, WM_NCCREATE, SENT },
469         { 2, WM_NCCREATE, SENT_RET },
470         { 2, WM_NCCALCSIZE, SENT },
471         { 2, WM_NCCALCSIZE, SENT_RET },
472         { 2, WM_CREATE, SENT },
473         { 2, WM_CREATE, SENT_RET },
474         { 2, WM_SIZE, SENT },
475         { 2, WM_SIZE, SENT_RET },
476         { 2, WM_MOVE, SENT },
477         { 2, WM_MOVE, SENT_RET },
478         { 1, WM_PARENTNOTIFY, SENT },
479         { 1, WM_PARENTNOTIFY, SENT_RET },
480     { 1, WM_NCCREATE, MARKER },
481     { 1, WM_NCCREATE, SENT_RET },
482     { 1, WM_NCCALCSIZE, SENT },
483     { 1, WM_NCCALCSIZE, SENT_RET },
484     { 1, WM_CREATE, SENT },
485     { 1, WM_CREATE, SENT_RET },
486     { 0, 0 }
487 };
488 
489 MSG_ENTRY child_create_chain_modify[] =
490 {
491     { 1, WM_GETMINMAXINFO, SENT },
492     { 1, WM_GETMINMAXINFO, SENT_RET },
493     { 1, WM_NCCREATE, SENT },
494         { 2, WM_NCCREATE, SENT },
495             { 1, WM_STYLECHANGING, SENT, GWL_EXSTYLE },
496             { 1, WM_STYLECHANGING, SENT_RET },
497             { 1, WM_STYLECHANGED, SENT, GWL_EXSTYLE },
498             { 1, WM_STYLECHANGED, SENT_RET },
499         { 2, WM_NCCREATE, MARKER },
500             { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED },
501             { 1, WM_WINDOWPOSCHANGING, SENT_RET },
502             { 1, WM_NCCALCSIZE, SENT, TRUE },
503             { 1, WM_NCCALCSIZE, SENT_RET },
504             { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED },
505                 { 1, WM_MOVE, SENT },
506                 { 1, WM_MOVE, SENT_RET },
507                 { 1, WM_SIZE, SENT },
508                 { 1, WM_SIZE, SENT_RET },
509             { 1, WM_WINDOWPOSCHANGED, SENT_RET },
510         { 2, WM_NCCREATE, MARKER },
511         { 2, WM_NCCREATE, SENT_RET },
512         { 2, WM_NCCALCSIZE, SENT },
513         { 2, WM_NCCALCSIZE, SENT_RET },
514         { 2, WM_CREATE, SENT },
515         { 2, WM_CREATE, SENT_RET },
516         { 2, WM_SIZE, SENT },
517         { 2, WM_SIZE, SENT_RET },
518         { 2, WM_MOVE, SENT },
519         { 2, WM_MOVE, SENT_RET },
520         { 1, WM_PARENTNOTIFY, SENT },
521         { 1, WM_PARENTNOTIFY, SENT_RET },
522     { 1, WM_NCCREATE, MARKER },
523     { 1, WM_NCCREATE, SENT_RET },
524     { 1, WM_NCCALCSIZE, SENT },
525     { 1, WM_NCCALCSIZE, SENT_RET },
526     { 1, WM_CREATE, SENT },
527     { 1, WM_CREATE, SENT_RET },
528     { 0, 0 }
529 };
530 
531 MSG_ENTRY child_create_chain_modify_below8_nonsrv[] =
532 {
533     { 1, WM_GETMINMAXINFO, SENT },
534     { 1, WM_GETMINMAXINFO, SENT_RET },
535     { 1, WM_NCCREATE, SENT },
536         { 2, WM_NCCREATE, SENT },
537             { 1, WM_STYLECHANGING, SENT, GWL_EXSTYLE },
538             { 1, WM_STYLECHANGING, SENT_RET },
539             { 1, WM_STYLECHANGED, SENT, GWL_EXSTYLE },
540             { 1, WM_STYLECHANGED, SENT_RET },
541         { 2, WM_NCCREATE, MARKER },
542             { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED },
543             { 1, WM_WINDOWPOSCHANGING, SENT_RET },
544             { 1, WM_NCCALCSIZE, SENT, TRUE },
545             { 1, WM_NCCALCSIZE, SENT_RET },
546             { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED },
547                 { 1, WM_MOVE, SENT },
548                 { 1, WM_MOVE, SENT_RET },
549                 { 1, WM_SIZE, SENT },
550                 { 1, WM_SIZE, SENT_RET },
551             { 1, WM_WINDOWPOSCHANGED, SENT_RET },
552             { 1, WM_NCCALCSIZE, SENT, TRUE },
553             { 1, WM_NCCALCSIZE, SENT_RET },
554         { 2, WM_NCCREATE, MARKER },
555         { 2, WM_NCCREATE, SENT_RET },
556         { 2, WM_NCCALCSIZE, SENT },
557         { 2, WM_NCCALCSIZE, SENT_RET },
558         { 2, WM_CREATE, SENT },
559         { 2, WM_CREATE, SENT_RET },
560         { 2, WM_SIZE, SENT },
561         { 2, WM_SIZE, SENT_RET },
562         { 2, WM_MOVE, SENT },
563         { 2, WM_MOVE, SENT_RET },
564         { 1, WM_PARENTNOTIFY, SENT },
565         { 1, WM_PARENTNOTIFY, SENT_RET },
566     { 1, WM_NCCREATE, MARKER },
567     { 1, WM_NCCREATE, SENT_RET },
568     { 1, WM_NCCALCSIZE, SENT },
569     { 1, WM_NCCALCSIZE, SENT_RET },
570     { 1, WM_CREATE, SENT },
571     { 1, WM_CREATE, SENT_RET },
572     { 0, 0 }
573 };
574 
575 
576 
577 static void Test_Messages_Child(void)
578 {
579     HWND hWnd;
580     BOOL Below8NonServer = !IsWindows8OrGreater() && !IsWindowsServer();
581 
582     RegisterSimpleClass(MSGTestProc2, L"Test_Message_Window_X2");
583     RegisterSimpleClass(MSGChildProc2, L"Test_Message_Window_Child2");
584 
585     g_ChangeStyle = 0;
586 
587     g_ExpectStyle = g_NcExpectStyle = 0;
588     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
589     g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
590     g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
591     g_FaultLine = __LINE__ + 1;
592     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2", L"", 0, 10, 20,
593                            200, 210, NULL, NULL, 0, NULL);
594 
595     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
596     COMPARE_CACHE(child_create_chain);
597     DestroyWindow(hWnd);
598     g_TestWindow = g_ChildWindow = NULL;
599     EMPTY_CACHE();
600 
601     g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
602     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
603     g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
604     g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
605     g_FaultLine = __LINE__ + 1;
606     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2", L"", WS_OVERLAPPEDWINDOW, 10, 20,
607                            200, 210, NULL, NULL, 0, NULL);
608 
609     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
610     COMPARE_CACHE(child_create_chain);
611     DestroyWindow(hWnd);
612     g_TestWindow = g_ChildWindow = NULL;
613     EMPTY_CACHE();
614 
615     g_ChangeStyle = 1;
616 
617     g_ExpectStyle = g_NcExpectStyle = 0;
618     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
619     g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
620     g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
621     g_FaultLine = __LINE__ + 1;
622     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2", L"", 0, 10, 20,
623                            200, 210, NULL, NULL, 0, NULL);
624 
625     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
626     COMPARE_CACHE(Below8NonServer ? child_create_chain_modify_below8_nonsrv : child_create_chain_modify);
627     DestroyWindow(hWnd);
628     g_TestWindow = g_ChildWindow = NULL;
629     EMPTY_CACHE();
630 
631     g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
632     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
633     g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD;
634     g_ChildExpectExStyle = g_ChildNcExpectExStyle = 0;
635     g_FaultLine = __LINE__ + 1;
636     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_X2", L"", WS_OVERLAPPEDWINDOW, 10, 20,
637                            200, 210, NULL, NULL, 0, NULL);
638 
639     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
640     COMPARE_CACHE(Below8NonServer ? child_create_chain_modify_below8_nonsrv : child_create_chain_modify);
641     DestroyWindow(hWnd);
642     g_TestWindow = g_ChildWindow = NULL;
643     EMPTY_CACHE();
644 
645     UnregisterClassW(L"Test_Message_Window_X2", NULL);
646     UnregisterClassW(L"Test_Message_Window_Child2", NULL);
647 }
648 
649 
650 
651 static LRESULT CALLBACK MSGTestProcMDI(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
652 {
653     LRESULT lRet;
654     int iwnd = get_iwnd(hWnd);
655 
656     if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
657         return DefWindowProc(hWnd, message, wParam, lParam);
658 
659     switch(message)
660     {
661     case WM_IME_SETCONTEXT:
662     case WM_IME_NOTIFY:
663     case WM_GETICON:
664     case WM_GETTEXT:
665         return DefWindowProc(hWnd, message, wParam, lParam);
666         break;
667     case WM_NCCREATE:
668     {
669         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
670         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
671         ok_hex_(create->style, g_NcExpectStyle);
672         ok_hex_(create->dwExStyle, g_NcExpectExStyle);
673     }
674     break;
675     case WM_CREATE:
676     {
677         CLIENTCREATESTRUCT ccs = { 0 };
678         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
679         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
680         ok_hex_(create->style, g_ExpectStyle);
681         ok_hex_(create->dwExStyle, g_ExpectExStyle);
682 
683         g_hwndMDIClient = CreateWindow("MDICLIENT", (LPCTSTR) NULL,
684                                      WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
685                                      0, 0, 0, 0, hWnd, (HMENU) 0xCAC, NULL, (LPSTR) &ccs);
686 
687         ShowWindow(g_hwndMDIClient, SW_SHOW);
688 
689     }
690     break;
691     case WM_NCCALCSIZE:
692     case WM_STYLECHANGING:
693     case WM_STYLECHANGED:
694     case WM_SIZE:
695         RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
696         break;
697     case WM_WINDOWPOSCHANGING:
698     case WM_WINDOWPOSCHANGED:
699         ok(wParam == 0,"expected wParam=0\n");
700         RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
701         break;
702     default:
703         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
704         break;
705     }
706     lRet = DefWindowProc(hWnd, message, wParam, lParam);
707     RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
708     return lRet;
709 }
710 
711 MSG_ENTRY create_chain_MDI[] =
712 {
713     { 1, WM_GETMINMAXINFO, SENT },
714     { 1, WM_GETMINMAXINFO, SENT_RET },
715     { 1, WM_NCCREATE, SENT },
716     { 1, WM_NCCREATE, SENT_RET },
717     { 1, WM_NCCALCSIZE, SENT },
718     { 1, WM_NCCALCSIZE, SENT_RET },
719     { 1, WM_CREATE, SENT },
720     { 1, WM_PARENTNOTIFY, SENT },
721     { 1, WM_PARENTNOTIFY, SENT_RET },
722     { 1, WM_CREATE, SENT_RET },
723     { 0, 0 }
724 };
725 
726 static void Test_Messages_MDI(void)
727 {
728     HWND hWnd;
729 
730     RegisterSimpleClass(MSGTestProcMDI, L"Test_Message_Window_MDI_XX");
731 
732     g_ExpectStyle = g_NcExpectStyle = 0;
733     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
734     g_FaultLine = __LINE__ + 1;
735     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_MDI_XX", L"", 0, 10, 20,
736                            200, 210, NULL, NULL, 0, NULL);
737 
738     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
739     COMPARE_CACHE(create_chain_MDI);
740     DestroyWindow(hWnd);
741     g_TestWindow = g_hwndMDIClient = g_ChildWindow = NULL;
742     EMPTY_CACHE();
743 
744     g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
745     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
746     g_FaultLine = __LINE__ + 1;
747     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_Window_MDI_XX", L"", WS_OVERLAPPEDWINDOW, 10, 20,
748                            200, 210, NULL, NULL, 0, NULL);
749 
750     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
751     COMPARE_CACHE(create_chain_MDI);
752     DestroyWindow(hWnd);
753     g_TestWindow = g_hwndMDIClient = g_ChildWindow = NULL;
754     EMPTY_CACHE();
755 
756     UnregisterClassW(L"Test_Message_Window_MDI_XX", NULL);
757 }
758 
759 
760 static LRESULT CALLBACK MSGTestProcMDI2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
761 {
762     LRESULT lRet;
763     int iwnd = get_iwnd(hWnd);
764 
765     if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
766         return DefWindowProc(hWnd, message, wParam, lParam);
767 
768     switch(message)
769     {
770     case WM_IME_SETCONTEXT:
771     case WM_IME_NOTIFY:
772     case WM_GETICON:
773     case WM_GETTEXT:
774         return DefWindowProc(hWnd, message, wParam, lParam);
775         break;
776     case WM_NCCREATE:
777     {
778         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
779         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
780         ok_hex_(create->style, g_NcExpectStyle);
781         ok_hex_(create->dwExStyle, g_NcExpectExStyle);
782     }
783     break;
784     case WM_CREATE:
785     {
786         MDICREATESTRUCT mcs = {0};
787         CLIENTCREATESTRUCT ccs = { 0 };
788         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
789         HWND hchild;
790         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
791         ok_hex_(create->style, g_ExpectStyle);
792         ok_hex_(create->dwExStyle, g_ExpectExStyle);
793 
794 
795         g_hwndMDIClient = CreateWindow("MDICLIENT", (LPCTSTR) NULL,
796                                        WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
797                                        0, 0, 0, 0, hWnd, (HMENU) 0xCAC, NULL, (LPSTR) &ccs);
798 
799         ShowWindow(g_hwndMDIClient, SW_SHOW);
800 
801 
802         mcs.szClass = "Test_Message_MDI_Window_Child2";
803         mcs.x = mcs.cx = CW_USEDEFAULT;
804         mcs.y = mcs.cy = CW_USEDEFAULT;
805         mcs.style = WS_MAXIMIZE;
806 
807         hchild = (HWND) SendMessage (g_hwndMDIClient, WM_MDICREATE, 0,
808             (LONG)(LPMDICREATESTRUCT) &mcs);
809         ok(hchild == g_ChildWindow, "We are testing with %p instead of %p\n", g_ChildWindow, hchild);
810 
811     }
812     break;
813     case WM_NCCALCSIZE:
814     case WM_STYLECHANGING:
815     case WM_STYLECHANGED:
816     case WM_SIZE:
817         RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
818         break;
819     case WM_WINDOWPOSCHANGING:
820     case WM_WINDOWPOSCHANGED:
821         ok(wParam == 0,"expected wParam=0\n");
822         RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
823         break;
824     default:
825         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
826         break;
827     }
828     lRet = DefWindowProc(hWnd, message, wParam, lParam);
829     RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
830     return lRet;
831 }
832 
833 static LRESULT CALLBACK MSGChildProcMDI2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
834 {
835     LRESULT lRet;
836     int iwnd = get_iwnd(hWnd);
837 
838     if(message > WM_USER || !iwnd || IsDWmMsg(message) || IseKeyMsg(message))
839         return DefMDIChildProc(hWnd, message, wParam, lParam);
840 
841     switch(message)
842     {
843     case WM_IME_SETCONTEXT:
844     case WM_IME_NOTIFY:
845     case WM_GETICON:
846     case WM_GETTEXT:
847         return DefMDIChildProc(hWnd, message, wParam, lParam);
848         break;
849     case WM_NCCREATE:
850     {
851         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
852         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
853         ok_hex_(create->style, g_ChildNcExpectStyle);
854         ok_hex_(create->dwExStyle, g_ChildNcExpectExStyle);
855     }
856     break;
857     case WM_CREATE:
858     {
859         LPCREATESTRUCT create = (LPCREATESTRUCT)lParam;
860         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
861         ok_hex_(create->style, g_ChildExpectStyle);
862         ok_hex_(create->dwExStyle, g_ChildExpectExStyle);
863     }
864     break;
865     case WM_NCCALCSIZE:
866     case WM_STYLECHANGING:
867     case WM_STYLECHANGED:
868     case WM_SIZE:
869         RECORD_MESSAGE(iwnd, message, SENT, wParam, 0);
870         break;
871     case WM_WINDOWPOSCHANGING:
872     case WM_WINDOWPOSCHANGED:
873         ok(wParam == 0,"expected wParam=0\n");
874         RECORD_MESSAGE(iwnd, message, SENT, ((WINDOWPOS*)lParam)->flags, 0);
875         break;
876     default:
877         RECORD_MESSAGE(iwnd, message, SENT, 0, 0);
878         break;
879     }
880     lRet = DefMDIChildProc(hWnd, message, wParam, lParam);
881     RECORD_MESSAGE(iwnd, message, SENT_RET, 0, 0);
882     return lRet;
883 }
884 
885 
886 MSG_ENTRY child_create_chain_MDI[] =
887 {
888     { 1, WM_GETMINMAXINFO, SENT },
889     { 1, WM_GETMINMAXINFO, SENT_RET },
890     { 1, WM_NCCREATE, SENT },
891     { 1, WM_NCCREATE, SENT_RET },
892     { 1, WM_NCCALCSIZE, SENT },
893     { 1, WM_NCCALCSIZE, SENT_RET },
894     { 1, WM_CREATE, SENT },
895         { 1, WM_PARENTNOTIFY, SENT },
896         { 1, WM_PARENTNOTIFY, SENT_RET },
897         { 2, WM_GETMINMAXINFO, SENT },
898         { 2, WM_GETMINMAXINFO, SENT_RET },
899         { 2, WM_NCCREATE, SENT },
900         { 2, WM_NCCREATE, SENT_RET },
901         { 2, WM_NCCALCSIZE, SENT },
902         { 2, WM_NCCALCSIZE, SENT_RET },
903         { 2, WM_CREATE, SENT },
904         { 2, WM_CREATE, SENT_RET },
905         { 2, WM_SIZE, SENT },
906         { 2, WM_SIZE, SENT_RET },
907         { 2, WM_MOVE, SENT },
908         { 2, WM_MOVE, SENT_RET },
909         { 2, WM_GETMINMAXINFO, SENT },
910         { 2, WM_GETMINMAXINFO, SENT_RET },
911         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x8000 },
912         { 2, WM_GETMINMAXINFO, SENT },
913         { 2, WM_GETMINMAXINFO, SENT_RET },
914         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
915         { 2, WM_NCCALCSIZE, SENT, 1 },
916         { 2, WM_NCCALCSIZE, SENT_RET },
917         { 2, WM_WINDOWPOSCHANGED, SENT, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW | 0x8800 },
918             { 2, WM_MOVE, SENT },
919             { 2, WM_MOVE, SENT_RET },
920             { 2, WM_SIZE, SENT, SIZE_MAXIMIZED },
921                 { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE },
922                 { 1, WM_WINDOWPOSCHANGING, SENT_RET },
923                 { 1, WM_NCCALCSIZE, SENT, TRUE },
924                 { 1, WM_NCCALCSIZE, SENT_RET },
925                 { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x1800 },
926                 { 1, WM_WINDOWPOSCHANGED, SENT_RET },
927             { 2, WM_SIZE, SENT_RET },
928         { 2, WM_WINDOWPOSCHANGED, SENT_RET },
929         { 2, WM_NCCALCSIZE, SENT, TRUE },
930         { 2, WM_NCCALCSIZE, SENT_RET },
931         { 2, WM_SHOWWINDOW, SENT },
932         { 2, WM_SHOWWINDOW, SENT_RET },
933         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE },
934         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
935         { 2, WM_CHILDACTIVATE, SENT },
936         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE },
937         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
938         { 2, WM_MDIACTIVATE, SENT },
939         { 2, WM_MDIACTIVATE, SENT_RET },
940         { 2, WM_CHILDACTIVATE, SENT_RET },
941         { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED },
942         { 1, WM_WINDOWPOSCHANGING, SENT_RET },
943         { 1, WM_NCCALCSIZE, SENT, TRUE },
944         { 1, WM_NCCALCSIZE, SENT_RET },
945         { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x1800 },
946         { 1, WM_WINDOWPOSCHANGED, SENT_RET },
947     { 1, WM_CREATE, SENT_RET },
948     { 0, 0 },
949 };
950 
951 MSG_ENTRY child_create_chain_MDI_below8[] =
952 {
953     { 1, WM_GETMINMAXINFO, SENT },
954     { 1, WM_GETMINMAXINFO, SENT_RET },
955     { 1, WM_NCCREATE, SENT },
956     { 1, WM_NCCREATE, SENT_RET },
957     { 1, WM_NCCALCSIZE, SENT },
958     { 1, WM_NCCALCSIZE, SENT_RET },
959     { 1, WM_CREATE, SENT },
960         { 1, WM_PARENTNOTIFY, SENT },
961         { 1, WM_PARENTNOTIFY, SENT_RET },
962         { 2, WM_GETMINMAXINFO, SENT },
963         { 2, WM_GETMINMAXINFO, SENT_RET },
964         { 2, WM_NCCREATE, SENT },
965         { 2, WM_NCCREATE, SENT_RET },
966         { 2, WM_NCCALCSIZE, SENT },
967         { 2, WM_NCCALCSIZE, SENT_RET },
968         { 2, WM_CREATE, SENT },
969         { 2, WM_CREATE, SENT_RET },
970         { 2, WM_SIZE, SENT },
971         { 2, WM_SIZE, SENT_RET },
972         { 2, WM_MOVE, SENT },
973         { 2, WM_MOVE, SENT_RET },
974         { 2, WM_GETMINMAXINFO, SENT },
975         { 2, WM_GETMINMAXINFO, SENT_RET },
976         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x8000 },
977         { 2, WM_GETMINMAXINFO, SENT },
978         { 2, WM_GETMINMAXINFO, SENT_RET },
979         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
980         { 2, WM_NCCALCSIZE, SENT, 1 },
981         { 2, WM_NCCALCSIZE, SENT_RET },
982         { 2, WM_WINDOWPOSCHANGED, SENT, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW | 0x8800 },
983             { 2, WM_MOVE, SENT },
984             { 2, WM_MOVE, SENT_RET },
985             { 2, WM_SIZE, SENT, SIZE_MAXIMIZED },
986                 { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE },
987                 { 1, WM_WINDOWPOSCHANGING, SENT_RET },
988                 { 1, WM_NCCALCSIZE, SENT, TRUE },
989                 { 1, WM_NCCALCSIZE, SENT_RET },
990                 { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x1800 },
991                 { 1, WM_WINDOWPOSCHANGED, SENT_RET },
992             { 2, WM_SIZE, SENT_RET },
993         { 2, WM_WINDOWPOSCHANGED, SENT_RET },
994         //{ 2, WM_NCCALCSIZE, SENT, TRUE },
995         //{ 2, WM_NCCALCSIZE, SENT_RET },
996         { 2, WM_SHOWWINDOW, SENT },
997         { 2, WM_SHOWWINDOW, SENT_RET },
998         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE },
999         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
1000         { 2, WM_CHILDACTIVATE, SENT },
1001         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE },
1002         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
1003         { 2, WM_MDIACTIVATE, SENT },
1004         { 2, WM_MDIACTIVATE, SENT_RET },
1005         { 2, WM_CHILDACTIVATE, SENT_RET },
1006         { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED },
1007         { 1, WM_WINDOWPOSCHANGING, SENT_RET },
1008         { 1, WM_NCCALCSIZE, SENT, TRUE },
1009         { 1, WM_NCCALCSIZE, SENT_RET },
1010         { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x1800 },
1011         { 1, WM_WINDOWPOSCHANGED, SENT_RET },
1012     { 1, WM_CREATE, SENT_RET },
1013     { 0, 0 },
1014 };
1015 
1016 MSG_ENTRY child_create_chain_MDI_below8_nonsrv[] =
1017 {
1018     { 1, WM_GETMINMAXINFO, SENT },
1019     { 1, WM_GETMINMAXINFO, SENT_RET },
1020     { 1, WM_NCCREATE, SENT },
1021     { 1, WM_NCCREATE, SENT_RET },
1022     { 1, WM_NCCALCSIZE, SENT },
1023     { 1, WM_NCCALCSIZE, SENT_RET },
1024     { 1, WM_CREATE, SENT },
1025         { 1, WM_PARENTNOTIFY, SENT },
1026         { 1, WM_PARENTNOTIFY, SENT_RET },
1027         { 2, WM_GETMINMAXINFO, SENT },
1028         { 2, WM_GETMINMAXINFO, SENT_RET },
1029         { 2, WM_NCCREATE, SENT },
1030         { 2, WM_NCCREATE, SENT_RET },
1031         { 2, WM_NCCALCSIZE, SENT },
1032         { 2, WM_NCCALCSIZE, SENT_RET },
1033         { 2, WM_CREATE, SENT },
1034         { 2, WM_CREATE, SENT_RET },
1035         { 2, WM_SIZE, SENT },
1036         { 2, WM_SIZE, SENT_RET },
1037         { 2, WM_MOVE, SENT },
1038         { 2, WM_MOVE, SENT_RET },
1039         { 2, WM_GETMINMAXINFO, SENT },
1040         { 2, WM_GETMINMAXINFO, SENT_RET },
1041         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x8000 },
1042         { 2, WM_GETMINMAXINFO, SENT },
1043         { 2, WM_GETMINMAXINFO, SENT_RET },
1044         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
1045         { 2, WM_NCCALCSIZE, SENT, 1 },
1046         { 2, WM_NCCALCSIZE, SENT_RET },
1047         { 2, WM_WINDOWPOSCHANGED, SENT, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW | 0x8800 },
1048             { 2, WM_MOVE, SENT },
1049             { 2, WM_MOVE, SENT_RET },
1050             { 2, WM_SIZE, SENT, SIZE_MAXIMIZED },
1051                 { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE },
1052                 { 1, WM_WINDOWPOSCHANGING, SENT_RET },
1053                 { 1, WM_NCCALCSIZE, SENT, TRUE },
1054                 { 1, WM_NCCALCSIZE, SENT_RET },
1055                 { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x1800 },
1056                 { 1, WM_WINDOWPOSCHANGED, SENT_RET },
1057                 // +
1058                 { 1, WM_NCCALCSIZE, SENT, TRUE },
1059                 { 1, WM_NCCALCSIZE, SENT_RET },
1060                 // -
1061             { 2, WM_SIZE, SENT_RET },
1062         { 2, WM_WINDOWPOSCHANGED, SENT_RET },
1063         { 2, WM_NCCALCSIZE, SENT, TRUE },
1064         { 2, WM_NCCALCSIZE, SENT_RET },
1065         { 2, WM_SHOWWINDOW, SENT },
1066         { 2, WM_SHOWWINDOW, SENT_RET },
1067         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE },
1068         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
1069         { 2, WM_CHILDACTIVATE, SENT },
1070         { 2, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE },
1071         { 2, WM_WINDOWPOSCHANGING, SENT_RET },
1072         { 2, WM_MDIACTIVATE, SENT },
1073         { 2, WM_MDIACTIVATE, SENT_RET },
1074         { 2, WM_CHILDACTIVATE, SENT_RET },
1075         { 1, WM_WINDOWPOSCHANGING, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE | SWP_FRAMECHANGED },
1076         { 1, WM_WINDOWPOSCHANGING, SENT_RET },
1077         { 1, WM_NCCALCSIZE, SENT, TRUE },
1078         { 1, WM_NCCALCSIZE, SENT_RET },
1079         { 1, WM_WINDOWPOSCHANGED, SENT, SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_FRAMECHANGED | SWP_NOACTIVATE | 0x1800 },
1080         { 1, WM_WINDOWPOSCHANGED, SENT_RET },
1081     { 1, WM_CREATE, SENT_RET },
1082     { 0, 0 },
1083 };
1084 
1085 static void Test_Messages_MDI_Child(void)
1086 {
1087     HWND hWnd;
1088 
1089     BOOL Below8 = !IsWindows8OrGreater();
1090     BOOL Below8NonServer = !IsWindows8OrGreater() && !IsWindowsServer();
1091 
1092     RegisterSimpleClass(MSGTestProcMDI2, L"Test_Message_MDI_Window_X2");
1093     RegisterSimpleClass(MSGChildProcMDI2, L"Test_Message_MDI_Window_Child2");
1094 
1095     g_ExpectStyle = g_NcExpectStyle = 0;
1096     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_CLIENTEDGE;
1097     g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_MAXIMIZE | WS_OVERLAPPEDWINDOW;
1098     g_ChildExpectExStyle = g_ChildNcExpectExStyle = WS_EX_WINDOWEDGE | WS_EX_MDICHILD;
1099     g_FaultLine = __LINE__ + 1;
1100     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_MDI_Window_X2", L"", 0, 10, 20,
1101                            200, 210, NULL, NULL, 0, NULL);
1102 
1103     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
1104     COMPARE_CACHE(Below8NonServer ? (child_create_chain_MDI_below8_nonsrv) : (Below8 ? child_create_chain_MDI_below8 : child_create_chain_MDI));
1105     DestroyWindow(hWnd);
1106     g_TestWindow = g_ChildWindow = NULL;
1107     EMPTY_CACHE();
1108 
1109     g_ExpectStyle = g_NcExpectStyle = WS_OVERLAPPEDWINDOW;
1110     g_ExpectExStyle = g_NcExpectExStyle = WS_EX_OVERLAPPEDWINDOW;
1111     g_ChildExpectStyle = g_ChildNcExpectStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_MAXIMIZE | WS_OVERLAPPEDWINDOW;
1112     g_ChildExpectExStyle = g_ChildNcExpectExStyle = WS_EX_WINDOWEDGE | WS_EX_MDICHILD;
1113     g_FaultLine = __LINE__ + 1;
1114     hWnd = CreateWindowExW(WS_EX_CLIENTEDGE, L"Test_Message_MDI_Window_X2", L"", WS_OVERLAPPEDWINDOW, 10, 20,
1115                            200, 210, NULL, NULL, 0, NULL);
1116 
1117     ok(hWnd == g_TestWindow, "We are testing with %p instead of %p\n", g_TestWindow, hWnd);
1118     COMPARE_CACHE(Below8NonServer ? (child_create_chain_MDI_below8_nonsrv) : (Below8 ? child_create_chain_MDI_below8 : child_create_chain_MDI));
1119     DestroyWindow(hWnd);
1120     g_TestWindow = g_ChildWindow = NULL;
1121     EMPTY_CACHE();
1122 
1123     UnregisterClassW(L"Test_Message_Window_X2", NULL);
1124     UnregisterClassW(L"Test_Message_MDI_Window_Child2", NULL);
1125 }
1126 
1127 
1128 START_TEST(CreateWindowEx)
1129 {
1130     Test_Params();
1131     Test_Messages();
1132     Test_Messages_Child();
1133     Test_Messages_MDI();
1134     Test_Messages_MDI_Child();
1135 }
1136