2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
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.
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.
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
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
43 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
46 #define WM_SYSTIMER 0x0118
49 #define WND_PARENT_ID 1
50 #define WND_POPUP_ID 2
51 #define WND_CHILD_ID 3
53 static BOOL test_DestroyWindow_flag;
54 static HWINEVENTHOOK hEvent_hook;
56 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
58 static void dump_winpos_flags(UINT flags);
61 FIXME: add tests for these
62 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
63 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
64 WS_THICKFRAME: thick border
65 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
66 WS_BORDER (default for overlapped windows): single black border
67 none (default for child (and popup?) windows): no border
84 UINT message; /* the WM_* code */
85 msg_flags_t flags; /* message props */
86 WPARAM wParam; /* expected value of wParam */
87 LPARAM lParam; /* expected value of lParam */
90 /* Empty message sequence */
91 static const struct message WmEmptySeq[] =
95 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
96 static const struct message WmCreateOverlappedSeq[] = {
97 { HCBT_CREATEWND, hook },
98 { WM_GETMINMAXINFO, sent },
99 { WM_NCCREATE, sent },
100 { WM_NCCALCSIZE, sent|wparam, 0 },
101 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
103 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
106 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
107 * for a not visible overlapped window.
109 static const struct message WmSWP_ShowOverlappedSeq[] = {
110 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
111 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
112 { WM_NCPAINT, sent|wparam|optional, 1 },
113 { WM_GETTEXT, sent|defwinproc|optional },
114 { WM_ERASEBKGND, sent|optional },
115 { HCBT_ACTIVATE, hook },
116 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
117 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
118 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
119 { WM_ACTIVATEAPP, sent|wparam, 1 },
120 { WM_NCACTIVATE, sent|wparam, 1 },
121 { WM_GETTEXT, sent|defwinproc|optional },
122 { WM_ACTIVATE, sent|wparam, 1 },
123 { HCBT_SETFOCUS, hook },
124 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
125 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
126 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
127 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
128 { WM_NCPAINT, sent|wparam|optional, 1 },
129 { WM_GETTEXT, sent|defwinproc|optional },
130 { WM_ERASEBKGND, sent|optional },
131 /* Win9x adds SWP_NOZORDER below */
132 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
133 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
134 { WM_NCPAINT, sent|wparam|optional, 1 },
135 { WM_ERASEBKGND, sent|optional },
136 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
139 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
140 * for a visible overlapped window.
142 static const struct message WmSWP_HideOverlappedSeq[] = {
143 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
144 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
145 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
149 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
150 * for a visible overlapped window.
152 static const struct message WmSWP_ResizeSeq[] = {
153 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
154 { WM_GETMINMAXINFO, sent|defwinproc },
155 { WM_NCCALCSIZE, sent|wparam, TRUE },
156 { WM_NCPAINT, sent|optional },
157 { WM_GETTEXT, sent|defwinproc|optional },
158 { WM_ERASEBKGND, sent|optional },
159 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
160 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
161 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
162 { WM_NCPAINT, sent|optional },
163 { WM_GETTEXT, sent|defwinproc|optional },
164 { WM_ERASEBKGND, sent|optional },
165 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
166 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
170 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
171 * for a visible popup window.
173 static const struct message WmSWP_ResizePopupSeq[] = {
174 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
175 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
176 { WM_NCCALCSIZE, sent|wparam, TRUE },
177 { WM_NCPAINT, sent|optional },
178 { WM_GETTEXT, sent|defwinproc|optional },
179 { WM_ERASEBKGND, sent|optional },
180 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
181 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
182 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
183 { WM_NCPAINT, sent|optional },
184 { WM_GETTEXT, sent|defwinproc|optional },
185 { WM_ERASEBKGND, sent|optional },
186 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
190 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
191 * for a visible overlapped window.
193 static const struct message WmSWP_MoveSeq[] = {
194 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
195 { WM_NCPAINT, sent|optional },
196 { WM_GETTEXT, sent|defwinproc|optional },
197 { WM_ERASEBKGND, sent|optional },
198 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
199 { WM_MOVE, sent|defwinproc|wparam, 0 },
200 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
204 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
205 SWP_NOZORDER|SWP_FRAMECHANGED)
206 * for a visible overlapped window with WS_CLIPCHILDREN style set.
208 static const struct message WmSWP_FrameChanged_clip[] = {
209 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
210 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
211 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
212 { WM_GETTEXT, sent|parent|defwinproc|optional },
213 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
214 { WM_NCPAINT, sent }, /* wparam != 1 */
215 { WM_ERASEBKGND, sent },
216 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
217 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
221 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
222 SWP_NOZORDER|SWP_FRAMECHANGED)
223 * for a visible overlapped window.
225 static const struct message WmSWP_FrameChangedDeferErase[] = {
226 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
227 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
228 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
229 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
230 { WM_PAINT, sent|parent },
231 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
232 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
234 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
235 { WM_ERASEBKGND, sent|beginpaint },
239 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
240 SWP_NOZORDER|SWP_FRAMECHANGED)
241 * for a visible overlapped window without WS_CLIPCHILDREN style set.
243 static const struct message WmSWP_FrameChanged_noclip[] = {
244 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
245 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
246 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
247 { WM_GETTEXT, sent|parent|defwinproc|optional },
248 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
249 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
250 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
252 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
253 { WM_ERASEBKGND, sent|beginpaint },
257 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
258 static const struct message WmShowOverlappedSeq[] = {
259 { WM_SHOWWINDOW, sent|wparam, 1 },
260 { WM_NCPAINT, sent|wparam|optional, 1 },
261 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
262 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
263 { WM_NCPAINT, sent|wparam|optional, 1 },
264 { WM_GETTEXT, sent|defwinproc|optional },
265 { WM_ERASEBKGND, sent|optional },
266 { HCBT_ACTIVATE, hook },
267 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
268 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
269 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
270 { WM_NCPAINT, sent|wparam|optional, 1 },
271 { WM_ACTIVATEAPP, sent|wparam, 1 },
272 { WM_NCACTIVATE, sent|wparam, 1 },
273 { WM_GETTEXT, sent|defwinproc|optional },
274 { WM_ACTIVATE, sent|wparam, 1 },
275 { HCBT_SETFOCUS, hook },
276 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
277 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
278 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
279 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
280 { WM_NCPAINT, sent|wparam|optional, 1 },
281 { WM_GETTEXT, sent|defwinproc|optional },
282 { WM_ERASEBKGND, sent|optional },
283 /* Win9x adds SWP_NOZORDER below */
284 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
285 { WM_NCCALCSIZE, sent|optional },
286 { WM_NCPAINT, sent|optional },
287 { WM_ERASEBKGND, sent|optional },
288 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
289 * messages. Does that mean that CreateWindow doesn't set initial
290 * window dimensions for overlapped windows?
297 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
298 static const struct message WmShowMaxOverlappedSeq[] = {
299 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
300 { WM_GETMINMAXINFO, sent },
301 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
302 { WM_GETMINMAXINFO, sent|defwinproc },
303 { WM_NCCALCSIZE, sent|wparam, TRUE },
304 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
305 { HCBT_ACTIVATE, hook },
306 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
307 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
308 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
309 { WM_ACTIVATEAPP, sent|wparam, 1 },
310 { WM_NCACTIVATE, sent|wparam, 1 },
311 { WM_GETTEXT, sent|defwinproc|optional },
312 { WM_ACTIVATE, sent|wparam, 1 },
313 { HCBT_SETFOCUS, hook },
314 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
315 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
316 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
317 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
318 { WM_NCPAINT, sent|wparam|optional, 1 },
319 { WM_GETTEXT, sent|defwinproc|optional },
320 { WM_ERASEBKGND, sent|optional },
321 /* Win9x adds SWP_NOZORDER below */
322 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
323 { WM_MOVE, sent|defwinproc },
324 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
325 { WM_NCCALCSIZE, sent|optional },
326 { WM_NCPAINT, sent|optional },
327 { WM_ERASEBKGND, sent|optional },
328 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
329 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
332 /* ShowWindow(SW_HIDE) for a visible overlapped window */
333 static const struct message WmHideOverlappedSeq[] = {
334 { WM_SHOWWINDOW, sent|wparam, 0 },
335 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
336 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
337 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
338 { WM_SIZE, sent|optional }, /* XP doesn't send it */
339 { WM_MOVE, sent|optional }, /* XP doesn't send it */
340 { WM_NCACTIVATE, sent|wparam, 0 },
341 { WM_ACTIVATE, sent|wparam, 0 },
342 { WM_ACTIVATEAPP, sent|wparam, 0 },
343 { WM_KILLFOCUS, sent|wparam, 0 },
344 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
345 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
348 /* DestroyWindow for a visible overlapped window */
349 static const struct message WmDestroyOverlappedSeq[] = {
350 { HCBT_DESTROYWND, hook },
351 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
352 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
353 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
354 { WM_NCACTIVATE, sent|wparam, 0 },
355 { WM_ACTIVATE, sent|wparam, 0 },
356 { WM_ACTIVATEAPP, sent|wparam, 0 },
357 { WM_KILLFOCUS, sent|wparam, 0 },
358 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
359 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
360 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
361 { WM_DESTROY, sent },
362 { WM_NCDESTROY, sent },
365 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
366 static const struct message WmCreateMaxPopupSeq[] = {
367 { HCBT_CREATEWND, hook },
368 { WM_NCCREATE, sent },
369 { WM_NCCALCSIZE, sent|wparam, 0 },
371 { WM_SIZE, sent|wparam, SIZE_RESTORED },
373 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
374 { WM_GETMINMAXINFO, sent },
375 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
376 { WM_NCCALCSIZE, sent|wparam, TRUE },
377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
378 { WM_MOVE, sent|defwinproc },
379 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
380 { WM_SHOWWINDOW, sent|wparam, 1 },
381 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
382 { HCBT_ACTIVATE, hook },
383 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
384 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
385 { WM_ACTIVATEAPP, sent|wparam, 1 },
386 { WM_NCACTIVATE, sent|wparam, 1 },
387 { WM_ACTIVATE, sent|wparam, 1 },
388 { HCBT_SETFOCUS, hook },
389 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
390 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
391 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
392 { WM_SYNCPAINT, sent|wparam|optional, 4 },
393 { WM_NCPAINT, sent|wparam|optional, 1 },
394 { WM_ERASEBKGND, sent|optional },
395 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
398 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
399 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
400 { HCBT_CREATEWND, hook },
401 { WM_NCCREATE, sent },
402 { WM_NCCALCSIZE, sent|wparam, 0 },
404 { WM_SIZE, sent|wparam, SIZE_RESTORED },
406 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
407 { WM_GETMINMAXINFO, sent },
408 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
409 { WM_NCCALCSIZE, sent|wparam, TRUE },
410 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
411 { WM_MOVE, sent|defwinproc },
412 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
415 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
416 static const struct message WmShowMaxPopupResizedSeq[] = {
417 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
418 { WM_GETMINMAXINFO, sent },
419 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
420 { WM_NCCALCSIZE, sent|wparam, TRUE },
421 { HCBT_ACTIVATE, hook },
422 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
423 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
424 { WM_ACTIVATEAPP, sent|wparam, 1 },
425 { WM_NCACTIVATE, sent|wparam, 1 },
426 { WM_ACTIVATE, sent|wparam, 1 },
427 { HCBT_SETFOCUS, hook },
428 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
429 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
430 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
431 { WM_NCPAINT, sent|wparam|optional, 1 },
432 { WM_ERASEBKGND, sent|optional },
433 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE },
434 /* WinNT4.0 sends WM_MOVE */
435 { WM_MOVE, sent|defwinproc|optional },
436 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
439 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
440 static const struct message WmShowMaxPopupSeq[] = {
441 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
442 { WM_GETMINMAXINFO, sent },
443 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
444 { WM_NCCALCSIZE, sent|wparam, TRUE },
445 { HCBT_ACTIVATE, hook },
446 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
447 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
448 { WM_ACTIVATEAPP, sent|wparam, 1 },
449 { WM_NCACTIVATE, sent|wparam, 1 },
450 { WM_ACTIVATE, sent|wparam, 1 },
451 { HCBT_SETFOCUS, hook },
452 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
453 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
454 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
455 { WM_SYNCPAINT, sent|wparam|optional, 4 },
456 { WM_NCPAINT, sent|wparam|optional, 1 },
457 { WM_ERASEBKGND, sent|optional },
458 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
461 /* CreateWindow(WS_VISIBLE) for popup window */
462 static const struct message WmCreatePopupSeq[] = {
463 { HCBT_CREATEWND, hook },
464 { WM_NCCREATE, sent },
465 { WM_NCCALCSIZE, sent|wparam, 0 },
467 { WM_SIZE, sent|wparam, SIZE_RESTORED },
469 { WM_SHOWWINDOW, sent|wparam, 1 },
470 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
471 { HCBT_ACTIVATE, hook },
472 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
473 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
474 { WM_NCPAINT, sent|wparam|optional, 1 },
475 { WM_ERASEBKGND, sent|optional },
476 { WM_ACTIVATEAPP, sent|wparam, 1 },
477 { WM_NCACTIVATE, sent|wparam, 1 },
478 { WM_ACTIVATE, sent|wparam, 1 },
479 { HCBT_SETFOCUS, hook },
480 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
481 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
482 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
483 { WM_SYNCPAINT, sent|wparam|optional, 4 },
484 { WM_NCPAINT, sent|wparam|optional, 1 },
485 { WM_ERASEBKGND, sent|optional },
486 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
489 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
490 static const struct message WmShowVisMaxPopupSeq[] = {
491 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
492 { WM_GETMINMAXINFO, sent },
493 { WM_GETTEXT, sent|optional },
494 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
495 { WM_NCCALCSIZE, sent|wparam, TRUE },
496 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
497 { WM_NCPAINT, sent|wparam|optional, 1 },
498 { WM_ERASEBKGND, sent|optional },
499 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
500 { WM_MOVE, sent|defwinproc },
501 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
504 /* CreateWindow (for a child popup window, not initially visible) */
505 static const struct message WmCreateChildPopupSeq[] = {
506 { HCBT_CREATEWND, hook },
507 { WM_NCCREATE, sent },
508 { WM_NCCALCSIZE, sent|wparam, 0 },
510 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
511 { WM_SIZE, sent|wparam, SIZE_RESTORED },
515 /* CreateWindow (for a popup window, not initially visible,
516 * which sets WS_VISIBLE in WM_CREATE handler)
518 static const struct message WmCreateInvisiblePopupSeq[] = {
519 { HCBT_CREATEWND, hook },
520 { WM_NCCREATE, sent },
521 { WM_NCCALCSIZE, sent|wparam, 0 },
523 { WM_STYLECHANGING, sent },
524 { WM_STYLECHANGED, sent },
525 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
526 { WM_SIZE, sent|wparam, SIZE_RESTORED },
530 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
531 * for a popup window with WS_VISIBLE style set
533 static const struct message WmShowVisiblePopupSeq_2[] = {
534 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
537 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
538 * for a popup window with WS_VISIBLE style set
540 static const struct message WmShowVisiblePopupSeq_3[] = {
541 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
542 { HCBT_ACTIVATE, hook },
543 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
544 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
545 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
546 { WM_NCACTIVATE, sent|wparam, 1 },
547 { WM_ACTIVATE, sent|wparam, 1 },
548 { HCBT_SETFOCUS, hook },
549 { WM_KILLFOCUS, sent|parent },
550 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
551 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
552 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
553 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
554 { WM_SETFOCUS, sent|defwinproc },
557 /* CreateWindow (for child window, not initially visible) */
558 static const struct message WmCreateChildSeq[] = {
559 { HCBT_CREATEWND, hook },
560 { WM_NCCREATE, sent },
561 /* child is inserted into parent's child list after WM_NCCREATE returns */
562 { WM_NCCALCSIZE, sent|wparam, 0 },
564 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
565 { WM_SIZE, sent|wparam, SIZE_RESTORED },
567 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
570 /* CreateWindow (for maximized child window, not initially visible) */
571 static const struct message WmCreateMaximizedChildSeq[] = {
572 { HCBT_CREATEWND, hook },
573 { WM_NCCREATE, sent },
574 { WM_NCCALCSIZE, sent|wparam, 0 },
576 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
577 { WM_SIZE, sent|wparam, SIZE_RESTORED },
579 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
580 { WM_GETMINMAXINFO, sent },
581 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
582 { WM_NCCALCSIZE, sent|wparam, 1 },
583 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
584 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
585 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
586 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
589 /* CreateWindow (for a child window, initially visible) */
590 static const struct message WmCreateVisibleChildSeq[] = {
591 { HCBT_CREATEWND, hook },
592 { WM_NCCREATE, sent },
593 /* child is inserted into parent's child list after WM_NCCREATE returns */
594 { WM_NCCALCSIZE, sent|wparam, 0 },
595 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
597 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
598 { WM_SIZE, sent|wparam, SIZE_RESTORED },
600 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
601 { WM_SHOWWINDOW, sent|wparam, 1 },
602 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
603 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
604 { WM_ERASEBKGND, sent|parent|optional },
605 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
606 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
607 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
610 /* ShowWindow(SW_SHOW) for a not visible child window */
611 static const struct message WmShowChildSeq[] = {
612 { WM_SHOWWINDOW, sent|wparam, 1 },
613 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
614 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
615 { WM_ERASEBKGND, sent|parent|optional },
616 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
619 /* ShowWindow(SW_HIDE) for a visible child window */
620 static const struct message WmHideChildSeq[] = {
621 { WM_SHOWWINDOW, sent|wparam, 0 },
622 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
623 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
624 { WM_ERASEBKGND, sent|parent|optional },
625 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
628 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
629 * for a not visible child window
631 static const struct message WmShowChildSeq_2[] = {
632 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
633 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
634 { WM_CHILDACTIVATE, sent },
635 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
638 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
639 * for a not visible child window
641 static const struct message WmShowChildSeq_3[] = {
642 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
643 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
644 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
647 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
648 * for a visible child window with a caption
650 static const struct message WmShowChildSeq_4[] = {
651 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
652 { WM_CHILDACTIVATE, sent },
655 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
656 static const struct message WmShowChildInvisibleParentSeq_1[] = {
657 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
658 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
659 { WM_NCCALCSIZE, sent|wparam, 1 },
660 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
661 { WM_MOVE, sent|defwinproc },
662 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
663 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
664 /* FIXME: Wine creates an icon/title window while Windows doesn't */
665 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
666 { WM_GETTEXT, sent|optional },
669 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
670 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
671 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
674 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
675 static const struct message WmShowChildInvisibleParentSeq_2[] = {
676 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
677 { WM_GETMINMAXINFO, sent },
678 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
679 { WM_NCCALCSIZE, sent|wparam, 1 },
680 { WM_CHILDACTIVATE, sent },
681 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
682 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
683 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
686 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
687 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
688 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
691 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
692 static const struct message WmShowChildInvisibleParentSeq_3[] = {
693 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
694 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
695 { WM_NCCALCSIZE, sent|wparam, 1 },
696 { WM_CHILDACTIVATE, sent },
697 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
698 { WM_MOVE, sent|defwinproc },
699 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
700 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
701 /* FIXME: Wine creates an icon/title window while Windows doesn't */
702 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
703 { WM_GETTEXT, sent|optional },
706 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
707 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
708 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
711 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
712 static const struct message WmShowChildInvisibleParentSeq_4[] = {
713 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
714 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
715 { WM_NCCALCSIZE, sent|wparam, 1 },
716 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
717 { WM_MOVE, sent|defwinproc },
718 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
719 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
720 /* FIXME: Wine creates an icon/title window while Windows doesn't */
721 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
722 { WM_GETTEXT, sent|optional },
725 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
726 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
727 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
730 /* ShowWindow(SW_SHOW) for child with invisible parent */
731 static const struct message WmShowChildInvisibleParentSeq_5[] = {
732 { WM_SHOWWINDOW, sent|wparam, 1 },
735 /* ShowWindow(SW_HIDE) for child with invisible parent */
736 static const struct message WmHideChildInvisibleParentSeq[] = {
737 { WM_SHOWWINDOW, sent|wparam, 0 },
740 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
741 static const struct message WmShowChildInvisibleParentSeq_6[] = {
742 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
743 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
744 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
747 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
748 static const struct message WmHideChildInvisibleParentSeq_2[] = {
749 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
750 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
751 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
754 /* DestroyWindow for a visible child window */
755 static const struct message WmDestroyChildSeq[] = {
756 { HCBT_DESTROYWND, hook },
757 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
758 { WM_SHOWWINDOW, sent|wparam, 0 },
759 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
760 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
761 { WM_ERASEBKGND, sent|parent|optional },
762 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
763 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
764 { WM_KILLFOCUS, sent },
765 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
766 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
767 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
768 { WM_SETFOCUS, sent|parent },
769 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
770 { WM_DESTROY, sent },
771 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
772 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
773 { WM_NCDESTROY, sent },
776 /* DestroyWindow for a visible child window with invisible parent */
777 static const struct message WmDestroyInvisibleChildSeq[] = {
778 { HCBT_DESTROYWND, hook },
779 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
780 { WM_SHOWWINDOW, sent|wparam, 0 },
781 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
782 { WM_DESTROY, sent },
783 { WM_NCDESTROY, sent },
786 /* Moving the mouse in nonclient area */
787 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
788 { WM_NCHITTEST, sent },
789 { WM_SETCURSOR, sent },
790 { WM_NCMOUSEMOVE, posted },
793 /* Moving the mouse in client area */
794 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
795 { WM_NCHITTEST, sent },
796 { WM_SETCURSOR, sent },
797 { WM_MOUSEMOVE, posted },
800 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
801 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
802 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
803 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
804 { WM_GETMINMAXINFO, sent|defwinproc },
805 { WM_ENTERSIZEMOVE, sent|defwinproc },
806 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
807 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
808 { WM_MOVE, sent|defwinproc },
809 { WM_EXITSIZEMOVE, sent|defwinproc },
812 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
813 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
814 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
815 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
816 { WM_GETMINMAXINFO, sent|defwinproc },
817 { WM_ENTERSIZEMOVE, sent|defwinproc },
818 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
819 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
820 { WM_GETMINMAXINFO, sent|defwinproc },
821 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
822 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
823 { WM_GETTEXT, sent|defwinproc },
824 { WM_ERASEBKGND, sent|defwinproc },
825 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
826 { WM_MOVE, sent|defwinproc },
827 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
828 { WM_EXITSIZEMOVE, sent|defwinproc },
831 /* Resizing child window with MoveWindow (32) */
832 static const struct message WmResizingChildWithMoveWindowSeq[] = {
833 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
834 { WM_NCCALCSIZE, sent|wparam, 1 },
835 { WM_ERASEBKGND, sent|optional },
836 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
837 { WM_MOVE, sent|defwinproc },
838 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
839 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
842 /* Clicking on inactive button */
843 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
844 { WM_NCHITTEST, sent },
845 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
846 { WM_MOUSEACTIVATE, sent },
847 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
848 { WM_SETCURSOR, sent },
849 { WM_SETCURSOR, sent|parent|defwinproc },
850 { WM_LBUTTONDOWN, posted },
851 { WM_KILLFOCUS, posted|parent },
852 { WM_SETFOCUS, posted },
853 { WM_CTLCOLORBTN, posted|parent },
854 { BM_SETSTATE, posted },
855 { WM_CTLCOLORBTN, posted|parent },
856 { WM_LBUTTONUP, posted },
857 { BM_SETSTATE, posted },
858 { WM_CTLCOLORBTN, posted|parent },
859 { WM_COMMAND, posted|parent },
862 /* Reparenting a button (16/32) */
863 /* The last child (button) reparented gets topmost for its new parent. */
864 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
865 { WM_SHOWWINDOW, sent|wparam, 0 },
866 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
867 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
868 { WM_ERASEBKGND, sent|parent },
869 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
870 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
871 { WM_CHILDACTIVATE, sent },
872 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
873 { WM_MOVE, sent|defwinproc },
874 { WM_SHOWWINDOW, sent|wparam, 1 },
877 /* Creation of a custom dialog (32) */
878 static const struct message WmCreateCustomDialogSeq[] = {
879 { HCBT_CREATEWND, hook },
880 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
881 { WM_GETMINMAXINFO, sent },
882 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
883 { WM_NCCREATE, sent },
884 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
885 { WM_NCCALCSIZE, sent|wparam, 0 },
886 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
887 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
889 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
890 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
891 { WM_SHOWWINDOW, sent|wparam, 1 },
892 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
893 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
894 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
895 { HCBT_ACTIVATE, hook },
896 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
898 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
900 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
901 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
903 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
905 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
906 { WM_NCACTIVATE, sent|wparam, 1 },
907 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
908 { WM_GETTEXT, sent|optional|defwinproc },
909 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
910 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
911 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
912 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
913 { WM_GETTEXT, sent|optional|defwinproc },
914 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
915 { WM_ACTIVATE, sent|wparam, 1 },
916 { WM_KILLFOCUS, sent|parent },
917 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
918 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
919 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
920 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
921 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
922 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
923 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
924 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
925 { WM_SETFOCUS, sent },
926 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
927 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
928 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
929 { WM_NCPAINT, sent|wparam, 1 },
930 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
931 { WM_GETTEXT, sent|optional|defwinproc },
932 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
933 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
934 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
935 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
936 { WM_GETTEXT, sent|optional|defwinproc },
937 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
938 { WM_ERASEBKGND, sent },
939 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
940 { WM_CTLCOLORDLG, sent|defwinproc },
941 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
942 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
943 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
944 { WM_GETTEXT, sent|optional },
945 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
946 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
947 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
948 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
949 { WM_GETTEXT, sent|optional },
950 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
951 { WM_NCCALCSIZE, sent|optional },
952 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
953 { WM_NCPAINT, sent|optional },
954 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
955 { WM_GETTEXT, sent|optional|defwinproc },
956 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
957 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
958 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
959 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
960 { WM_GETTEXT, sent|optional|defwinproc },
961 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
962 { WM_ERASEBKGND, sent|optional },
963 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
964 { WM_CTLCOLORDLG, sent|optional|defwinproc },
965 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
966 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
967 { WM_SIZE, sent|wparam, SIZE_RESTORED },
968 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
972 /* Calling EndDialog for a custom dialog (32) */
973 static const struct message WmEndCustomDialogSeq[] = {
974 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
975 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
976 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
977 { WM_GETTEXT, sent|optional },
978 { HCBT_ACTIVATE, hook },
979 { WM_NCACTIVATE, sent|wparam, 0 },
980 { WM_GETTEXT, sent|optional|defwinproc },
981 { WM_GETTEXT, sent|optional|defwinproc },
982 { WM_ACTIVATE, sent|wparam, 0 },
983 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
984 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
985 { HCBT_SETFOCUS, hook },
986 { WM_KILLFOCUS, sent },
987 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
988 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
989 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
990 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
991 { WM_SETFOCUS, sent|parent|defwinproc },
994 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
995 static const struct message WmShowCustomDialogSeq[] = {
996 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
997 { WM_SHOWWINDOW, sent|wparam, 1 },
998 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
999 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1000 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1001 { HCBT_ACTIVATE, hook },
1002 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1004 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1005 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1007 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1008 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1009 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1010 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1011 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1012 { WM_NCACTIVATE, sent|wparam, 1 },
1013 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1014 { WM_ACTIVATE, sent|wparam, 1 },
1016 { WM_KILLFOCUS, sent|parent },
1017 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1018 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1019 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1020 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1021 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1022 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1023 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1024 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1025 { WM_SETFOCUS, sent },
1026 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1027 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1028 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1029 { WM_NCPAINT, sent|wparam, 1 },
1030 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1031 { WM_ERASEBKGND, sent },
1032 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1033 { WM_CTLCOLORDLG, sent|defwinproc },
1035 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1036 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1039 /* Creation and destruction of a modal dialog (32) */
1040 static const struct message WmModalDialogSeq[] = {
1041 { WM_CANCELMODE, sent|parent },
1042 { HCBT_SETFOCUS, hook },
1043 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1044 { WM_KILLFOCUS, sent|parent },
1045 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1046 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1047 { WM_ENABLE, sent|parent|wparam, 0 },
1048 { HCBT_CREATEWND, hook },
1049 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1050 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1051 { WM_SETFONT, sent },
1052 { WM_INITDIALOG, sent },
1053 { WM_CHANGEUISTATE, sent|optional },
1054 { WM_SHOWWINDOW, sent },
1055 { HCBT_ACTIVATE, hook },
1056 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1057 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1058 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1059 { WM_NCACTIVATE, sent|wparam, 1 },
1060 { WM_GETTEXT, sent|optional },
1061 { WM_ACTIVATE, sent|wparam, 1 },
1062 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1063 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1064 { WM_NCPAINT, sent },
1065 { WM_GETTEXT, sent|optional },
1066 { WM_ERASEBKGND, sent },
1067 { WM_CTLCOLORDLG, sent },
1068 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1069 { WM_GETTEXT, sent|optional },
1070 { WM_NCCALCSIZE, sent|optional },
1071 { WM_NCPAINT, sent|optional },
1072 { WM_GETTEXT, sent|optional },
1073 { WM_ERASEBKGND, sent|optional },
1074 { WM_CTLCOLORDLG, sent|optional },
1075 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1076 { WM_PAINT, sent|optional },
1077 { WM_CTLCOLORBTN, sent },
1078 { WM_ENTERIDLE, sent|parent|optional },
1079 { WM_ENTERIDLE, sent|parent|optional },
1080 { WM_ENTERIDLE, sent|parent|optional },
1081 { WM_ENTERIDLE, sent|parent|optional },
1082 { WM_ENTERIDLE, sent|parent|optional },
1083 { WM_ENTERIDLE, sent|parent|optional },
1084 { WM_ENTERIDLE, sent|parent|optional },
1085 { WM_ENTERIDLE, sent|parent|optional },
1086 { WM_ENTERIDLE, sent|parent|optional },
1087 { WM_ENTERIDLE, sent|parent|optional },
1088 { WM_ENTERIDLE, sent|parent|optional },
1089 { WM_ENTERIDLE, sent|parent|optional },
1090 { WM_ENTERIDLE, sent|parent|optional },
1091 { WM_ENTERIDLE, sent|parent|optional },
1092 { WM_ENTERIDLE, sent|parent|optional },
1093 { WM_ENTERIDLE, sent|parent|optional },
1094 { WM_ENTERIDLE, sent|parent|optional },
1095 { WM_ENTERIDLE, sent|parent|optional },
1096 { WM_ENTERIDLE, sent|parent|optional },
1097 { WM_ENTERIDLE, sent|parent|optional },
1099 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1100 { WM_ENABLE, sent|parent|wparam, 1 },
1101 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1102 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1103 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1104 { WM_GETTEXT, sent|optional },
1105 { HCBT_ACTIVATE, hook },
1106 { WM_NCACTIVATE, sent|wparam, 0 },
1107 { WM_GETTEXT, sent|optional },
1108 { WM_ACTIVATE, sent|wparam, 0 },
1109 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1110 { WM_WINDOWPOSCHANGING, sent|optional },
1111 { HCBT_SETFOCUS, hook },
1112 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1113 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1114 { WM_SETFOCUS, sent|parent|defwinproc },
1115 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1116 { HCBT_DESTROYWND, hook },
1117 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1118 { WM_DESTROY, sent },
1119 { WM_NCDESTROY, sent },
1122 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1123 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1124 /* (inside dialog proc, handling WM_INITDIALOG) */
1125 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1126 { WM_NCCALCSIZE, sent },
1127 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1128 { WM_GETTEXT, sent|defwinproc },
1129 { WM_ACTIVATE, sent|parent|wparam, 0 },
1130 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1131 { WM_WINDOWPOSCHANGING, sent|parent },
1132 { WM_NCACTIVATE, sent|wparam, 1 },
1133 { WM_ACTIVATE, sent|wparam, 1 },
1134 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1135 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1136 /* (setting focus) */
1137 { WM_SHOWWINDOW, sent|wparam, 1 },
1138 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1139 { WM_NCPAINT, sent },
1140 { WM_GETTEXT, sent|defwinproc },
1141 { WM_ERASEBKGND, sent },
1142 { WM_CTLCOLORDLG, sent|defwinproc },
1143 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1145 /* (bunch of WM_CTLCOLOR* for each control) */
1146 { WM_PAINT, sent|parent },
1147 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1148 { WM_SETCURSOR, sent|parent },
1151 /* SetMenu for NonVisible windows with size change*/
1152 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1153 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1154 { WM_NCCALCSIZE, sent|wparam, 1 },
1155 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1156 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1157 { WM_MOVE, sent|defwinproc },
1158 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1159 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1160 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1161 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1162 { WM_GETTEXT, sent|optional },
1163 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1166 /* SetMenu for NonVisible windows with no size change */
1167 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1168 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1169 { WM_NCCALCSIZE, sent|wparam, 1 },
1170 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1171 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1174 /* SetMenu for Visible windows with size change */
1175 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1176 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1177 { WM_NCCALCSIZE, sent|wparam, 1 },
1178 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1179 { WM_NCPAINT, sent }, /* wparam != 1 */
1180 { WM_GETTEXT, sent|defwinproc|optional },
1181 { WM_ERASEBKGND, sent|optional },
1182 { WM_ACTIVATE, sent|optional },
1183 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1184 { WM_MOVE, sent|defwinproc },
1185 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1186 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1187 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1188 { WM_ERASEBKGND, sent|optional },
1189 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1190 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1193 /* SetMenu for Visible windows with no size change */
1194 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1195 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1196 { WM_NCCALCSIZE, sent|wparam, 1 },
1197 { WM_NCPAINT, sent }, /* wparam != 1 */
1198 { WM_GETTEXT, sent|defwinproc|optional },
1199 { WM_ERASEBKGND, sent|optional },
1200 { WM_ACTIVATE, sent|optional },
1201 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1202 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1205 /* DrawMenuBar for a visible window */
1206 static const struct message WmDrawMenuBarSeq[] =
1208 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1209 { WM_NCCALCSIZE, sent|wparam, 1 },
1210 { WM_NCPAINT, sent }, /* wparam != 1 */
1211 { WM_GETTEXT, sent|defwinproc|optional },
1212 { WM_ERASEBKGND, sent|optional },
1213 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1214 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1218 static const struct message WmSetRedrawFalseSeq[] =
1220 { WM_SETREDRAW, sent|wparam, 0 },
1224 static const struct message WmSetRedrawTrueSeq[] =
1226 { WM_SETREDRAW, sent|wparam, 1 },
1230 static const struct message WmEnableWindowSeq_1[] =
1232 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1233 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1234 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1238 static const struct message WmEnableWindowSeq_2[] =
1240 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1241 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1245 static const struct message WmGetScrollRangeSeq[] =
1247 { SBM_GETRANGE, sent },
1250 static const struct message WmGetScrollInfoSeq[] =
1252 { SBM_GETSCROLLINFO, sent },
1255 static const struct message WmSetScrollRangeSeq[] =
1257 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1258 sends SBM_SETSCROLLINFO.
1260 { SBM_SETSCROLLINFO, sent },
1263 /* SetScrollRange for a window without a non-client area */
1264 static const struct message WmSetScrollRangeHSeq_empty[] =
1266 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1269 static const struct message WmSetScrollRangeVSeq_empty[] =
1271 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1274 static const struct message WmSetScrollRangeHVSeq[] =
1276 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1277 { WM_NCCALCSIZE, sent|wparam, 1 },
1278 { WM_GETTEXT, sent|defwinproc|optional },
1279 { WM_ERASEBKGND, sent|optional },
1280 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1281 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1282 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1285 /* SetScrollRange for a window with a non-client area */
1286 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1288 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1289 { WM_NCCALCSIZE, sent|wparam, 1 },
1290 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1291 { WM_NCPAINT, sent|optional },
1292 { WM_GETTEXT, sent|defwinproc|optional },
1293 { WM_GETTEXT, sent|defwinproc|optional },
1294 { WM_ERASEBKGND, sent|optional },
1295 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1296 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1297 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1298 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1299 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1300 { WM_GETTEXT, sent|optional },
1301 { WM_GETTEXT, sent|optional },
1302 { WM_GETTEXT, sent|optional },
1303 { WM_GETTEXT, sent|optional },
1306 /* test if we receive the right sequence of messages */
1307 /* after calling ShowWindow( SW_SHOWNA) */
1308 static const struct message WmSHOWNAChildInvisParInvis[] = {
1309 { WM_SHOWWINDOW, sent|wparam, 1 },
1312 static const struct message WmSHOWNAChildVisParInvis[] = {
1313 { WM_SHOWWINDOW, sent|wparam, 1 },
1316 static const struct message WmSHOWNAChildVisParVis[] = {
1317 { WM_SHOWWINDOW, sent|wparam, 1 },
1318 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1321 static const struct message WmSHOWNAChildInvisParVis[] = {
1322 { WM_SHOWWINDOW, sent|wparam, 1 },
1323 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1324 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1325 { WM_ERASEBKGND, sent|optional },
1326 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1329 static const struct message WmSHOWNATopVisible[] = {
1330 { WM_SHOWWINDOW, sent|wparam, 1 },
1331 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1334 static const struct message WmSHOWNATopInvisible[] = {
1335 { WM_SHOWWINDOW, sent|wparam, 1 },
1336 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1337 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1338 { WM_NCPAINT, sent|wparam, 1 },
1339 { WM_GETTEXT, sent|defwinproc|optional },
1340 { WM_ERASEBKGND, sent|optional },
1341 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1342 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1343 { WM_NCPAINT, sent|wparam|optional, 1 },
1344 { WM_ERASEBKGND, sent|optional },
1345 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1346 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1351 static int after_end_dialog;
1352 static int sequence_cnt, sequence_size;
1353 static struct message* sequence;
1354 static int log_all_parent_messages;
1356 static void add_message(const struct message *msg)
1361 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1363 if (sequence_cnt == sequence_size)
1366 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1370 sequence[sequence_cnt].message = msg->message;
1371 sequence[sequence_cnt].flags = msg->flags;
1372 sequence[sequence_cnt].wParam = msg->wParam;
1373 sequence[sequence_cnt].lParam = msg->lParam;
1378 /* try to make sure pending X events have been processed before continuing */
1379 static void flush_events(void)
1383 DWORD time = GetTickCount() + diff;
1387 MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT );
1388 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1389 diff = time - GetTickCount();
1393 static void flush_sequence(void)
1395 HeapFree(GetProcessHeap(), 0, sequence);
1397 sequence_cnt = sequence_size = 0;
1400 #define ok_sequence( exp, contx, todo) \
1401 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1404 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1405 const char *file, int line)
1407 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1408 const struct message *actual;
1411 add_message(&end_of_sequence);
1415 while (expected->message && actual->message)
1417 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1419 if (expected->message == actual->message)
1421 if (expected->flags & wparam)
1423 if (expected->wParam != actual->wParam && todo)
1427 ok_( file, line) (FALSE,
1428 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1429 context, expected->message, expected->wParam, actual->wParam);
1433 ok_( file, line) (expected->wParam == actual->wParam,
1434 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1435 context, expected->message, expected->wParam, actual->wParam);
1437 if (expected->flags & lparam)
1439 if (expected->lParam != actual->lParam && todo)
1443 ok_( file, line) (FALSE,
1444 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1445 context, expected->message, expected->lParam, actual->lParam);
1449 ok_( file, line) (expected->lParam == actual->lParam,
1450 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1451 context, expected->message, expected->lParam, actual->lParam);
1453 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1457 ok_( file, line) (FALSE,
1458 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1459 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1463 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1464 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1465 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1466 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1467 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1468 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1469 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1470 "%s: the msg 0x%04x should have been %s\n",
1471 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1472 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1473 "%s: the msg 0x%04x was expected in %s\n",
1474 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1475 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1476 "%s: the msg 0x%04x should have been sent by a hook\n",
1477 context, expected->message);
1478 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1479 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1480 context, expected->message);
1484 /* silently drop winevent messages if there is no support for them */
1485 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1491 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1492 context, expected->message, actual->message);
1499 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1500 context, expected->message, actual->message);
1506 /* skip all optional trailing messages */
1507 while (expected->message && ((expected->flags & optional) ||
1508 ((expected->flags & winevent_hook) && !hEvent_hook)))
1514 if (expected->message || actual->message) {
1516 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1517 context, expected->message, actual->message);
1523 if (expected->message || actual->message)
1524 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1525 context, expected->message, actual->message);
1527 if( todo && !failcount) /* succeeded yet marked todo */
1529 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1535 /******************************** MDI test **********************************/
1537 /* CreateWindow for MDI frame window, initially visible */
1538 static const struct message WmCreateMDIframeSeq[] = {
1539 { HCBT_CREATEWND, hook },
1540 { WM_GETMINMAXINFO, sent },
1541 { WM_NCCREATE, sent },
1542 { WM_NCCALCSIZE, sent|wparam, 0 },
1543 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1544 { WM_CREATE, sent },
1545 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1546 { WM_SHOWWINDOW, sent|wparam, 1 },
1547 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1548 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1549 { HCBT_ACTIVATE, hook },
1550 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1551 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1552 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
1553 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
1554 { WM_NCACTIVATE, sent|wparam, 1 },
1555 { WM_GETTEXT, sent|defwinproc|optional },
1556 { WM_ACTIVATE, sent|wparam, 1 },
1557 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
1558 { HCBT_SETFOCUS, hook },
1559 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1560 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1561 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1562 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1563 /* Win9x adds SWP_NOZORDER below */
1564 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1565 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1566 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1567 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1571 /* DestroyWindow for MDI frame window, initially visible */
1572 static const struct message WmDestroyMDIframeSeq[] = {
1573 { HCBT_DESTROYWND, hook },
1574 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1575 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1576 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1578 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
1579 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1580 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1581 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1582 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1583 { WM_DESTROY, sent },
1584 { WM_NCDESTROY, sent },
1587 /* CreateWindow for MDI client window, initially visible */
1588 static const struct message WmCreateMDIclientSeq[] = {
1589 { HCBT_CREATEWND, hook },
1590 { WM_NCCREATE, sent },
1591 { WM_NCCALCSIZE, sent|wparam, 0 },
1592 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1593 { WM_CREATE, sent },
1594 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1595 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1596 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1598 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1599 { WM_SHOWWINDOW, sent|wparam, 1 },
1600 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1601 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1602 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1605 /* ShowWindow(SW_SHOW) for MDI client window */
1606 static const struct message WmShowMDIclientSeq[] = {
1607 { WM_SHOWWINDOW, sent|wparam, 1 },
1608 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1609 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1610 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1613 /* ShowWindow(SW_HIDE) for MDI client window */
1614 static const struct message WmHideMDIclientSeq[] = {
1615 { WM_SHOWWINDOW, sent|wparam, 0 },
1616 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1617 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
1618 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
1619 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1622 /* DestroyWindow for MDI client window, initially visible */
1623 static const struct message WmDestroyMDIclientSeq[] = {
1624 { HCBT_DESTROYWND, hook },
1625 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1626 { WM_SHOWWINDOW, sent|wparam, 0 },
1627 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1628 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1629 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1630 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1631 { WM_DESTROY, sent },
1632 { WM_NCDESTROY, sent },
1635 /* CreateWindow for MDI child window, initially visible */
1636 static const struct message WmCreateMDIchildVisibleSeq[] = {
1637 { HCBT_CREATEWND, hook },
1638 { WM_NCCREATE, sent },
1639 { WM_NCCALCSIZE, sent|wparam, 0 },
1640 { WM_CREATE, sent },
1641 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1642 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1644 /* Win2k sends wparam set to
1645 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1646 * while Win9x doesn't bother to set child window id according to
1647 * CLIENTCREATESTRUCT.idFirstChild
1649 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1650 { WM_SHOWWINDOW, sent|wparam, 1 },
1651 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1652 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1653 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1654 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1655 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1656 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1657 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1659 /* Win9x: message sequence terminates here. */
1661 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1662 { HCBT_SETFOCUS, hook }, /* in MDI client */
1663 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1664 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1665 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1666 { WM_SETFOCUS, sent }, /* in MDI client */
1667 { HCBT_SETFOCUS, hook },
1668 { WM_KILLFOCUS, sent }, /* in MDI client */
1669 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1670 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1671 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1672 { WM_SETFOCUS, sent|defwinproc },
1673 { WM_MDIACTIVATE, sent|defwinproc },
1676 /* CreateWindow for MDI child window with invisible parent */
1677 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1678 { HCBT_CREATEWND, hook },
1679 { WM_GETMINMAXINFO, sent },
1680 { WM_NCCREATE, sent },
1681 { WM_NCCALCSIZE, sent|wparam, 0 },
1682 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1683 { WM_CREATE, sent },
1684 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1685 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1687 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1688 { WM_SHOWWINDOW, sent|wparam, 1 },
1689 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1690 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1691 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1692 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1694 /* Win9x: message sequence terminates here. */
1696 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1697 { HCBT_SETFOCUS, hook }, /* in MDI client */
1698 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1699 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1700 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1701 { WM_SETFOCUS, sent }, /* in MDI client */
1702 { HCBT_SETFOCUS, hook },
1703 { WM_KILLFOCUS, sent }, /* in MDI client */
1704 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1705 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1706 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1707 { WM_SETFOCUS, sent|defwinproc },
1708 { WM_MDIACTIVATE, sent|defwinproc },
1711 /* DestroyWindow for MDI child window, initially visible */
1712 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1713 { HCBT_DESTROYWND, hook },
1714 /* Win2k sends wparam set to
1715 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1716 * while Win9x doesn't bother to set child window id according to
1717 * CLIENTCREATESTRUCT.idFirstChild
1719 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1720 { WM_SHOWWINDOW, sent|wparam, 0 },
1721 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1722 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1723 { WM_ERASEBKGND, sent|parent|optional },
1724 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1726 /* { WM_DESTROY, sent }
1727 * Win9x: message sequence terminates here.
1730 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1731 { WM_KILLFOCUS, sent },
1732 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1733 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1734 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1735 { WM_SETFOCUS, sent }, /* in MDI client */
1737 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1738 { WM_KILLFOCUS, sent }, /* in MDI client */
1739 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1740 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1741 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1742 { WM_SETFOCUS, sent }, /* in MDI client */
1744 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1746 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1747 { WM_KILLFOCUS, sent },
1748 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1749 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1750 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1751 { WM_SETFOCUS, sent }, /* in MDI client */
1753 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1754 { WM_KILLFOCUS, sent }, /* in MDI client */
1755 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1756 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1757 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1758 { WM_SETFOCUS, sent }, /* in MDI client */
1760 { WM_DESTROY, sent },
1762 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1763 { WM_KILLFOCUS, sent },
1764 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1765 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1766 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1767 { WM_SETFOCUS, sent }, /* in MDI client */
1769 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1770 { WM_KILLFOCUS, sent }, /* in MDI client */
1771 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1772 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1773 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1774 { WM_SETFOCUS, sent }, /* in MDI client */
1776 { WM_NCDESTROY, sent },
1779 /* CreateWindow for MDI child window, initially invisible */
1780 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1781 { HCBT_CREATEWND, hook },
1782 { WM_NCCREATE, sent },
1783 { WM_NCCALCSIZE, sent|wparam, 0 },
1784 { WM_CREATE, sent },
1785 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1786 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1788 /* Win2k sends wparam set to
1789 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1790 * while Win9x doesn't bother to set child window id according to
1791 * CLIENTCREATESTRUCT.idFirstChild
1793 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1796 /* DestroyWindow for MDI child window, initially invisible */
1797 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1798 { HCBT_DESTROYWND, hook },
1799 /* Win2k sends wparam set to
1800 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1801 * while Win9x doesn't bother to set child window id according to
1802 * CLIENTCREATESTRUCT.idFirstChild
1804 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1805 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1806 { WM_DESTROY, sent },
1807 { WM_NCDESTROY, sent },
1808 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
1809 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
1812 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1813 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1814 { HCBT_CREATEWND, hook },
1815 { WM_NCCREATE, sent },
1816 { WM_NCCALCSIZE, sent|wparam, 0 },
1817 { WM_CREATE, sent },
1818 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1819 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1821 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1822 { WM_GETMINMAXINFO, sent },
1823 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1824 { WM_NCCALCSIZE, sent|wparam, 1 },
1825 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1826 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1828 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1829 { WM_NCCALCSIZE, sent|wparam, 1 },
1830 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1831 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1832 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1833 /* Win2k sends wparam set to
1834 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1835 * while Win9x doesn't bother to set child window id according to
1836 * CLIENTCREATESTRUCT.idFirstChild
1838 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1839 { WM_SHOWWINDOW, sent|wparam, 1 },
1840 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1841 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1842 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1843 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1844 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1845 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1846 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1848 /* Win9x: message sequence terminates here. */
1850 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1851 { HCBT_SETFOCUS, hook }, /* in MDI client */
1852 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1853 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1854 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1855 { WM_SETFOCUS, sent }, /* in MDI client */
1856 { HCBT_SETFOCUS, hook },
1857 { WM_KILLFOCUS, sent }, /* in MDI client */
1858 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1859 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1860 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1861 { WM_SETFOCUS, sent|defwinproc },
1862 { WM_MDIACTIVATE, sent|defwinproc },
1864 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1865 { WM_NCCALCSIZE, sent|wparam, 1 },
1866 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1867 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1870 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1871 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
1872 /* restore the 1st MDI child */
1873 { WM_SETREDRAW, sent|wparam, 0 },
1874 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
1875 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1876 { WM_NCCALCSIZE, sent|wparam, 1 },
1877 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1878 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1879 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1881 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1882 { WM_NCCALCSIZE, sent|wparam, 1 },
1883 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1884 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1885 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1886 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
1887 /* create the 2nd MDI child */
1888 { HCBT_CREATEWND, hook },
1889 { WM_NCCREATE, sent },
1890 { WM_NCCALCSIZE, sent|wparam, 0 },
1891 { WM_CREATE, sent },
1892 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1893 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1895 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1896 { WM_GETMINMAXINFO, sent },
1897 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1898 { WM_NCCALCSIZE, sent|wparam, 1 },
1899 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1900 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1901 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1903 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1904 { WM_NCCALCSIZE, sent|wparam, 1 },
1905 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1906 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1907 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1908 /* Win2k sends wparam set to
1909 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1910 * while Win9x doesn't bother to set child window id according to
1911 * CLIENTCREATESTRUCT.idFirstChild
1913 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1914 { WM_SHOWWINDOW, sent|wparam, 1 },
1915 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1916 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1917 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1918 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1919 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1920 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1922 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1923 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1925 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1927 /* Win9x: message sequence terminates here. */
1929 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1930 { HCBT_SETFOCUS, hook },
1931 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
1932 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
1933 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1934 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1935 { WM_SETFOCUS, sent }, /* in MDI client */
1936 { HCBT_SETFOCUS, hook },
1937 { WM_KILLFOCUS, sent }, /* in MDI client */
1938 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1939 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1940 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1941 { WM_SETFOCUS, sent|defwinproc },
1943 { WM_MDIACTIVATE, sent|defwinproc },
1945 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1946 { WM_NCCALCSIZE, sent|wparam, 1 },
1947 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1948 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1951 /* WM_MDICREATE MDI child window, initially visible and maximized */
1952 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
1953 { WM_MDICREATE, sent },
1954 { HCBT_CREATEWND, hook },
1955 { WM_NCCREATE, sent },
1956 { WM_NCCALCSIZE, sent|wparam, 0 },
1957 { WM_CREATE, sent },
1958 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1959 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1961 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1962 { WM_GETMINMAXINFO, sent },
1963 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1964 { WM_NCCALCSIZE, sent|wparam, 1 },
1965 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1966 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1969 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1970 { WM_NCCALCSIZE, sent|wparam, 1 },
1971 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1972 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1973 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1975 /* Win2k sends wparam set to
1976 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1977 * while Win9x doesn't bother to set child window id according to
1978 * CLIENTCREATESTRUCT.idFirstChild
1980 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1981 { WM_SHOWWINDOW, sent|wparam, 1 },
1982 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1984 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1986 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1987 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1988 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1990 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1991 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1993 /* Win9x: message sequence terminates here. */
1995 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1996 { WM_SETFOCUS, sent|optional }, /* in MDI client */
1997 { HCBT_SETFOCUS, hook }, /* in MDI client */
1998 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1999 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2000 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2001 { HCBT_SETFOCUS, hook|optional },
2002 { WM_KILLFOCUS, sent }, /* in MDI client */
2003 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2004 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2005 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2006 { WM_SETFOCUS, sent|defwinproc },
2008 { WM_MDIACTIVATE, sent|defwinproc },
2011 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2012 { WM_NCCALCSIZE, sent|wparam, 1 },
2013 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2014 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2017 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2018 { WM_NCCALCSIZE, sent|wparam, 1 },
2019 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2020 { WM_MOVE, sent|defwinproc },
2021 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2024 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2025 { WM_NCCALCSIZE, sent|wparam, 1 },
2026 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2027 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2030 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2031 { WM_NCCALCSIZE, sent|wparam, 1 },
2032 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2033 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2035 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2036 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2037 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2038 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2039 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2043 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2044 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2045 { HCBT_CREATEWND, hook },
2046 { WM_GETMINMAXINFO, sent },
2047 { WM_NCCREATE, sent },
2048 { WM_NCCALCSIZE, sent|wparam, 0 },
2049 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2050 { WM_CREATE, sent },
2051 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2052 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2054 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2055 { WM_GETMINMAXINFO, sent },
2056 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
2057 { WM_GETMINMAXINFO, sent|defwinproc },
2058 { WM_NCCALCSIZE, sent|wparam, 1 },
2059 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|0x8000 },
2060 { WM_MOVE, sent|defwinproc },
2061 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2063 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2064 { WM_NCCALCSIZE, sent|wparam, 1 },
2065 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2066 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2067 { WM_NCCALCSIZE, sent|wparam, 1 }, /* MDI child */
2068 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2069 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2070 /* Win2k sends wparam set to
2071 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2072 * while Win9x doesn't bother to set child window id according to
2073 * CLIENTCREATESTRUCT.idFirstChild
2075 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2078 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2079 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2080 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2081 { HCBT_SYSCOMMAND, hook },
2082 { WM_CLOSE, sent|defwinproc },
2083 { WM_MDIDESTROY, sent }, /* in MDI client */
2085 /* bring the 1st MDI child to top */
2086 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2087 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2089 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2091 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2092 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2093 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2095 /* maximize the 1st MDI child */
2096 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2097 { WM_GETMINMAXINFO, sent|defwinproc },
2098 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
2099 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2100 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2101 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2102 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2104 /* restore the 2nd MDI child */
2105 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2106 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2107 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2108 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2110 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2112 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2113 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2115 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2117 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2119 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2120 { WM_NCCALCSIZE, sent|wparam, 1 },
2121 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2122 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2123 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2125 /* bring the 1st MDI child to top */
2126 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2127 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2128 { HCBT_SETFOCUS, hook },
2129 { WM_KILLFOCUS, sent|defwinproc },
2130 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2131 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2132 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2133 { WM_SETFOCUS, sent }, /* in MDI client */
2134 { HCBT_SETFOCUS, hook },
2135 { WM_KILLFOCUS, sent }, /* in MDI client */
2136 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2137 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2138 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2139 { WM_SETFOCUS, sent|defwinproc },
2140 { WM_MDIACTIVATE, sent|defwinproc },
2141 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2143 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2144 { WM_SHOWWINDOW, sent|wparam, 1 },
2145 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2146 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2147 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2148 { WM_MDIREFRESHMENU, sent },
2150 { HCBT_DESTROYWND, hook },
2151 /* Win2k sends wparam set to
2152 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2153 * while Win9x doesn't bother to set child window id according to
2154 * CLIENTCREATESTRUCT.idFirstChild
2156 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2157 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2158 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2159 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2160 { WM_ERASEBKGND, sent|parent|optional },
2161 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2163 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2164 { WM_DESTROY, sent|defwinproc },
2165 { WM_NCDESTROY, sent|defwinproc },
2168 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2169 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2170 { WM_MDIDESTROY, sent }, /* in MDI client */
2171 { WM_SHOWWINDOW, sent|wparam, 0 },
2172 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2173 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2174 { WM_ERASEBKGND, sent|parent|optional },
2175 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2177 { HCBT_SETFOCUS, hook },
2178 { WM_KILLFOCUS, sent },
2179 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2180 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2181 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2182 { WM_SETFOCUS, sent }, /* in MDI client */
2183 { HCBT_SETFOCUS, hook },
2184 { WM_KILLFOCUS, sent }, /* in MDI client */
2185 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2186 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2187 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2188 { WM_SETFOCUS, sent },
2191 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2192 { WM_NCCALCSIZE, sent|wparam, 1 },
2193 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2194 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2197 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2198 { WM_NCCALCSIZE, sent|wparam, 1 },
2199 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2200 { WM_MOVE, sent|defwinproc },
2201 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2204 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2205 { WM_NCCALCSIZE, sent|wparam, 1 },
2206 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2207 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2210 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2211 { WM_NCCALCSIZE, sent|wparam, 1 },
2212 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2213 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2216 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2217 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2218 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2219 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2222 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2223 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2224 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2225 { WM_MOVE, sent|defwinproc },
2226 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2229 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2230 { WM_NCCALCSIZE, sent|wparam, 1 },
2231 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2232 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2235 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2236 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2237 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2238 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2239 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2240 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2242 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2244 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2245 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2246 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2247 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2248 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2251 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2252 { WM_NCCALCSIZE, sent|wparam, 1 },
2253 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2254 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2256 { WM_NCACTIVATE, sent|wparam, 0 },
2257 { WM_MDIACTIVATE, sent },
2259 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2260 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2261 { WM_NCCALCSIZE, sent|wparam, 1 },
2263 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2265 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2266 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|0x8000 },
2267 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2270 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2271 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2272 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2273 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2276 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2277 { WM_NCCALCSIZE, sent|wparam, 1 },
2278 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2279 { WM_MOVE, sent|defwinproc },
2280 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2283 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2284 { WM_NCCALCSIZE, sent|wparam, 1 },
2285 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2286 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2287 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2288 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2289 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2290 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2291 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2293 { HCBT_SETFOCUS, hook },
2294 { WM_KILLFOCUS, sent },
2295 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2296 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2297 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2298 { WM_SETFOCUS, sent }, /* in MDI client */
2300 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2302 { HCBT_DESTROYWND, hook },
2303 /* Win2k sends wparam set to
2304 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2305 * while Win9x doesn't bother to set child window id according to
2306 * CLIENTCREATESTRUCT.idFirstChild
2308 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2310 { WM_SHOWWINDOW, sent|wparam, 0 },
2311 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2312 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2313 { WM_ERASEBKGND, sent|parent|optional },
2314 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2316 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2317 { WM_DESTROY, sent },
2318 { WM_NCDESTROY, sent },
2321 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2322 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2323 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2324 { WM_GETMINMAXINFO, sent },
2325 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2326 { WM_NCCALCSIZE, sent|wparam, 1 },
2327 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2328 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2330 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2331 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2332 { HCBT_SETFOCUS, hook },
2333 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2334 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2335 { WM_SETFOCUS, sent }, /* in MDI client */
2336 { HCBT_SETFOCUS, hook },
2337 { WM_KILLFOCUS, sent }, /* in MDI client */
2338 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2339 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2340 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2341 { WM_SETFOCUS, sent|defwinproc },
2342 { WM_MDIACTIVATE, sent|defwinproc },
2343 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2344 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2346 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2347 { WM_NCCALCSIZE, sent|wparam, 1 },
2348 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2349 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2350 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2353 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2354 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2355 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2356 { WM_GETMINMAXINFO, sent },
2357 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2358 { WM_GETMINMAXINFO, sent|defwinproc },
2359 { WM_NCCALCSIZE, sent|wparam, 1 },
2360 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2361 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2363 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2364 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2365 { HCBT_SETFOCUS, hook },
2366 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2367 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2368 { WM_SETFOCUS, sent }, /* in MDI client */
2369 { HCBT_SETFOCUS, hook },
2370 { WM_KILLFOCUS, sent }, /* in MDI client */
2371 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2372 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2373 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2374 { WM_SETFOCUS, sent|defwinproc },
2375 { WM_MDIACTIVATE, sent|defwinproc },
2376 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2377 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2380 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2381 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2382 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2383 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2384 { WM_GETMINMAXINFO, sent },
2385 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2386 { WM_GETMINMAXINFO, sent|defwinproc },
2387 { WM_NCCALCSIZE, sent|wparam, 1 },
2388 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2389 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2390 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
2391 { WM_MOVE, sent|defwinproc },
2392 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2394 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2395 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2396 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2397 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2398 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2399 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2401 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2402 { WM_NCCALCSIZE, sent|wparam, 1 },
2403 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2404 { WM_MOVE, sent|defwinproc },
2405 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2406 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
2408 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2409 { WM_NCCALCSIZE, sent|wparam, 1 },
2410 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2411 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2413 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2414 { WM_GETMINMAXINFO, sent|defwinproc },
2415 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2416 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2417 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2418 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
2419 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2420 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2421 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2422 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2424 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2425 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2426 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2427 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2430 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2431 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2432 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2433 { WM_GETMINMAXINFO, sent },
2434 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2435 { WM_NCCALCSIZE, sent|wparam, 1 },
2436 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2437 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2438 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2440 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2441 { WM_NCCALCSIZE, sent|wparam, 1 },
2442 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2443 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2444 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2447 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2448 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2449 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2450 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2451 { WM_NCCALCSIZE, sent|wparam, 1 },
2452 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2453 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2454 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2456 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2457 { WM_NCCALCSIZE, sent|wparam, 1 },
2458 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2459 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2460 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2463 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2464 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
2465 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2466 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
2467 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
2468 { WM_NCCALCSIZE, sent|wparam, 1 },
2469 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2470 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|0x8000 },
2471 { WM_MOVE, sent|defwinproc },
2472 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2473 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2474 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2475 { HCBT_SETFOCUS, hook },
2476 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2477 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2478 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2479 { WM_SETFOCUS, sent },
2482 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2483 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
2484 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
2485 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
2486 { WM_NCCALCSIZE, sent|wparam, 1 },
2487 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|0x8000 },
2488 { WM_MOVE, sent|defwinproc },
2489 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
2490 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
2491 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2492 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2493 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2494 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
2497 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2498 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2499 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2500 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2501 { WM_NCCALCSIZE, sent|wparam, 1 },
2502 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2503 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2504 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2505 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2507 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2508 { WM_NCCALCSIZE, sent|wparam, 1 },
2509 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2510 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2511 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2515 static HWND mdi_client;
2516 static WNDPROC old_mdi_client_proc;
2518 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2522 /* do not log painting messages */
2523 if (message != WM_PAINT &&
2524 message != WM_NCPAINT &&
2525 message != WM_SYNCPAINT &&
2526 message != WM_ERASEBKGND &&
2527 message != WM_NCPAINT &&
2528 message != WM_NCHITTEST &&
2529 message != WM_GETTEXT &&
2530 message != WM_MDIGETACTIVE &&
2531 message != WM_GETICON &&
2532 message != WM_DEVICECHANGE)
2534 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2538 case WM_WINDOWPOSCHANGING:
2539 case WM_WINDOWPOSCHANGED:
2541 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2543 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2544 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2545 winpos->hwnd, winpos->hwndInsertAfter,
2546 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2547 dump_winpos_flags(winpos->flags);
2549 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2550 * in the high word for internal purposes
2552 wParam = winpos->flags & 0xffff;
2553 /* We are not interested in the flags that don't match under XP and Win9x */
2554 wParam &= ~(SWP_NOZORDER);
2559 msg.message = message;
2560 msg.flags = sent|wparam|lparam;
2561 msg.wParam = wParam;
2562 msg.lParam = lParam;
2566 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2569 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2571 static long defwndproc_counter = 0;
2575 /* do not log painting messages */
2576 if (message != WM_PAINT &&
2577 message != WM_NCPAINT &&
2578 message != WM_SYNCPAINT &&
2579 message != WM_ERASEBKGND &&
2580 message != WM_NCPAINT &&
2581 message != WM_NCHITTEST &&
2582 message != WM_GETTEXT &&
2583 message != WM_GETICON &&
2584 message != WM_DEVICECHANGE)
2586 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2590 case WM_WINDOWPOSCHANGING:
2591 case WM_WINDOWPOSCHANGED:
2593 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2595 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2596 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2597 winpos->hwnd, winpos->hwndInsertAfter,
2598 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2599 dump_winpos_flags(winpos->flags);
2601 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2602 * in the high word for internal purposes
2604 wParam = winpos->flags & 0xffff;
2605 /* We are not interested in the flags that don't match under XP and Win9x */
2606 wParam &= ~(SWP_NOZORDER);
2610 case WM_MDIACTIVATE:
2612 HWND active, client = GetParent(hwnd);
2614 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2616 if (hwnd == (HWND)lParam) /* if we are being activated */
2617 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2619 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2624 msg.message = message;
2625 msg.flags = sent|wparam|lparam;
2626 if (defwndproc_counter) msg.flags |= defwinproc;
2627 msg.wParam = wParam;
2628 msg.lParam = lParam;
2632 defwndproc_counter++;
2633 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2634 defwndproc_counter--;
2639 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2641 static long defwndproc_counter = 0;
2645 /* do not log painting messages */
2646 if (message != WM_PAINT &&
2647 message != WM_NCPAINT &&
2648 message != WM_SYNCPAINT &&
2649 message != WM_ERASEBKGND &&
2650 message != WM_NCPAINT &&
2651 message != WM_NCHITTEST &&
2652 message != WM_GETTEXT &&
2653 message != WM_GETICON &&
2654 message != WM_DEVICECHANGE)
2656 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2660 case WM_WINDOWPOSCHANGING:
2661 case WM_WINDOWPOSCHANGED:
2663 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2665 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2666 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2667 winpos->hwnd, winpos->hwndInsertAfter,
2668 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2669 dump_winpos_flags(winpos->flags);
2671 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2672 * in the high word for internal purposes
2674 wParam = winpos->flags & 0xffff;
2675 /* We are not interested in the flags that don't match under XP and Win9x */
2676 wParam &= ~(SWP_NOZORDER);
2681 msg.message = message;
2682 msg.flags = sent|wparam|lparam;
2683 if (defwndproc_counter) msg.flags |= defwinproc;
2684 msg.wParam = wParam;
2685 msg.lParam = lParam;
2689 defwndproc_counter++;
2690 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2691 defwndproc_counter--;
2696 static BOOL mdi_RegisterWindowClasses(void)
2701 cls.lpfnWndProc = mdi_frame_wnd_proc;
2704 cls.hInstance = GetModuleHandleA(0);
2706 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2707 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2708 cls.lpszMenuName = NULL;
2709 cls.lpszClassName = "MDI_frame_class";
2710 if (!RegisterClassA(&cls)) return FALSE;
2712 cls.lpfnWndProc = mdi_child_wnd_proc;
2713 cls.lpszClassName = "MDI_child_class";
2714 if (!RegisterClassA(&cls)) return FALSE;
2716 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2717 old_mdi_client_proc = cls.lpfnWndProc;
2718 cls.hInstance = GetModuleHandleA(0);
2719 cls.lpfnWndProc = mdi_client_hook_proc;
2720 cls.lpszClassName = "MDI_client_class";
2721 if (!RegisterClassA(&cls)) assert(0);
2726 static void test_mdi_messages(void)
2728 MDICREATESTRUCTA mdi_cs;
2729 CLIENTCREATESTRUCT client_cs;
2730 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2732 HMENU hMenu = CreateMenu();
2734 assert(mdi_RegisterWindowClasses());
2738 trace("creating MDI frame window\n");
2739 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2740 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2741 WS_MAXIMIZEBOX | WS_VISIBLE,
2742 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2743 GetDesktopWindow(), hMenu,
2744 GetModuleHandleA(0), NULL);
2746 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
2748 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2749 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2751 trace("creating MDI client window\n");
2752 client_cs.hWindowMenu = 0;
2753 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2754 mdi_client = CreateWindowExA(0, "MDI_client_class",
2756 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2758 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2760 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2762 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2763 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2765 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2766 ok(!active_child, "wrong active MDI child %p\n", active_child);
2767 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2772 trace("creating invisible MDI child window\n");
2773 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2775 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2776 mdi_client, 0, GetModuleHandleA(0), NULL);
2780 ShowWindow(mdi_child, SW_SHOWNORMAL);
2781 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
2783 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2784 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2786 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2787 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2789 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2790 ok(!active_child, "wrong active MDI child %p\n", active_child);
2791 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2793 ShowWindow(mdi_child, SW_HIDE);
2794 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
2797 ShowWindow(mdi_child, SW_SHOW);
2798 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
2800 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2801 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2803 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2804 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2806 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2807 ok(!active_child, "wrong active MDI child %p\n", active_child);
2808 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2810 DestroyWindow(mdi_child);
2813 trace("creating visible MDI child window\n");
2814 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2815 WS_CHILD | WS_VISIBLE,
2816 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2817 mdi_client, 0, GetModuleHandleA(0), NULL);
2819 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
2821 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2822 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2824 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2825 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2827 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2828 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2829 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2832 DestroyWindow(mdi_child);
2833 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2835 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2836 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2838 /* Win2k: MDI client still returns a just destroyed child as active
2839 * Win9x: MDI client returns 0
2841 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2842 ok(active_child == mdi_child || /* win2k */
2843 !active_child, /* win9x */
2844 "wrong active MDI child %p\n", active_child);
2845 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2849 trace("creating invisible MDI child window\n");
2850 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2852 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2853 mdi_client, 0, GetModuleHandleA(0), NULL);
2855 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
2857 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
2858 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
2860 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2861 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2863 /* Win2k: MDI client still returns a just destroyed child as active
2864 * Win9x: MDI client returns mdi_child2
2866 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2867 ok(active_child == mdi_child || /* win2k */
2868 active_child == mdi_child2, /* win9x */
2869 "wrong active MDI child %p\n", active_child);
2870 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2873 ShowWindow(mdi_child2, SW_MAXIMIZE);
2874 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
2876 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2877 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2879 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2880 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2881 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2884 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2885 ok(GetFocus() == mdi_child2 || /* win2k */
2886 GetFocus() == 0, /* win9x */
2887 "wrong focus window %p\n", GetFocus());
2892 ShowWindow(mdi_child2, SW_HIDE);
2893 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2895 ShowWindow(mdi_child2, SW_RESTORE);
2896 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
2899 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2900 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2902 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2903 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2904 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2910 ShowWindow(mdi_child2, SW_HIDE);
2911 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2913 ShowWindow(mdi_child2, SW_SHOW);
2914 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
2916 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2917 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2919 ShowWindow(mdi_child2, SW_MAXIMIZE);
2920 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
2922 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2923 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2925 ShowWindow(mdi_child2, SW_RESTORE);
2926 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
2928 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2929 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2931 ShowWindow(mdi_child2, SW_MINIMIZE);
2932 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
2934 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2935 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2937 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2938 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2939 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2942 ShowWindow(mdi_child2, SW_RESTORE);
2943 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
2945 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2946 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2948 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2949 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2950 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2956 ShowWindow(mdi_child2, SW_HIDE);
2957 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2959 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2960 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2962 DestroyWindow(mdi_child2);
2963 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
2965 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2966 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2968 /* test for maximized MDI children */
2969 trace("creating maximized visible MDI child window 1\n");
2970 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2971 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2972 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2973 mdi_client, 0, GetModuleHandleA(0), NULL);
2975 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
2976 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2978 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2979 ok(GetFocus() == mdi_child || /* win2k */
2980 GetFocus() == 0, /* win9x */
2981 "wrong focus window %p\n", GetFocus());
2983 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2984 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2985 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2988 trace("creating maximized visible MDI child window 2\n");
2989 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2990 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2991 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2992 mdi_client, 0, GetModuleHandleA(0), NULL);
2994 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2995 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2996 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2998 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2999 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3001 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3002 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3003 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3006 trace("destroying maximized visible MDI child window 2\n");
3007 DestroyWindow(mdi_child2);
3008 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3010 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3012 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3013 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3015 /* Win2k: MDI client still returns a just destroyed child as active
3016 * Win9x: MDI client returns 0
3018 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3019 ok(active_child == mdi_child2 || /* win2k */
3020 !active_child, /* win9x */
3021 "wrong active MDI child %p\n", active_child);
3024 ShowWindow(mdi_child, SW_MAXIMIZE);
3025 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3028 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3029 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3031 trace("re-creating maximized visible MDI child window 2\n");
3032 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3033 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3034 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3035 mdi_client, 0, GetModuleHandleA(0), NULL);
3037 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3038 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3039 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3041 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3042 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3044 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3045 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3046 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3049 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3050 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3051 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3053 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3054 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3055 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3057 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3058 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3059 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3062 DestroyWindow(mdi_child);
3063 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3065 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3066 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3068 /* Win2k: MDI client still returns a just destroyed child as active
3069 * Win9x: MDI client returns 0
3071 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3072 ok(active_child == mdi_child || /* win2k */
3073 !active_child, /* win9x */
3074 "wrong active MDI child %p\n", active_child);
3077 trace("creating maximized invisible MDI child window\n");
3078 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3079 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3080 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3081 mdi_client, 0, GetModuleHandleA(0), NULL);
3083 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", TRUE);
3084 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3085 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3086 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3088 /* Win2k: MDI client still returns a just destroyed child as active
3089 * Win9x: MDI client returns 0
3091 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3092 ok(active_child == mdi_child || /* win2k */
3093 !active_child, /* win9x */
3094 "wrong active MDI child %p\n", active_child);
3097 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3098 ShowWindow(mdi_child2, SW_MAXIMIZE);
3099 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3100 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3101 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3102 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3104 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3105 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3106 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3109 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3112 /* end of test for maximized MDI children */
3114 mdi_cs.szClass = "MDI_child_Class";
3115 mdi_cs.szTitle = "MDI child";
3116 mdi_cs.hOwner = GetModuleHandleA(0);
3119 mdi_cs.cx = CW_USEDEFAULT;
3120 mdi_cs.cy = CW_USEDEFAULT;
3121 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3123 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3124 ok(mdi_child != 0, "MDI child creation failed\n");
3125 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3127 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3129 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3130 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3132 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3133 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3134 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3136 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3137 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3138 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3141 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3142 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3144 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3145 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3146 ok(!active_child, "wrong active MDI child %p\n", active_child);
3151 DestroyWindow(mdi_client);
3152 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3154 /* test maximization of MDI child with invisible parent */
3155 client_cs.hWindowMenu = 0;
3156 mdi_client = CreateWindow("MDI_client_class",
3158 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3160 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3161 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3163 ShowWindow(mdi_client, SW_HIDE);
3164 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3166 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3167 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3169 mdi_client, 0, GetModuleHandleA(0), NULL);
3170 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3172 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3173 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3174 zoomed = IsZoomed(mdi_child);
3175 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3177 ShowWindow(mdi_client, SW_SHOW);
3178 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3180 DestroyWindow(mdi_child);
3181 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3183 DestroyWindow(mdi_client);
3184 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3185 /* end of test for maximization of MDI child with invisible parent */
3187 DestroyWindow(mdi_frame);
3188 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3190 /************************* End of MDI test **********************************/
3192 static void test_WM_SETREDRAW(HWND hwnd)
3194 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3198 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3199 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3201 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3202 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3205 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3206 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3208 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3209 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3211 /* restore original WS_VISIBLE state */
3212 SetWindowLongA(hwnd, GWL_STYLE, style);
3217 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3221 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3223 /* explicitly ignore WM_GETICON message */
3224 if (message == WM_GETICON) return 0;
3231 case WM_DEVICECHANGE:
3236 case WM_WINDOWPOSCHANGING:
3237 case WM_WINDOWPOSCHANGED:
3239 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3241 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3242 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3243 winpos->hwnd, winpos->hwndInsertAfter,
3244 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3245 dump_winpos_flags(winpos->flags);
3247 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3248 * in the high word for internal purposes
3250 wParam = winpos->flags & 0xffff;
3251 /* We are not interested in the flags that don't match under XP and Win9x */
3252 wParam &= ~(SWP_NOZORDER);
3257 msg.message = message;
3258 msg.flags = sent|wparam|lparam;
3259 msg.wParam = wParam;
3260 msg.lParam = lParam;
3263 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3264 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3268 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3270 DWORD style, exstyle;
3274 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3275 style = GetWindowLongA(hwnd, GWL_STYLE);
3276 /* do not be confused by WS_DLGFRAME set */
3277 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3279 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3280 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3282 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3283 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3284 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3285 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3287 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3289 style = GetWindowLongA(hwnd, GWL_STYLE);
3290 if (set) ok(style & set, "style %08x should be set\n", set);
3291 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3293 /* a subsequent call should do nothing */
3294 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3295 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3296 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3300 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3301 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3302 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3303 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3304 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3305 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3308 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3310 DWORD style, exstyle;
3314 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3315 style = GetWindowLongA(hwnd, GWL_STYLE);
3316 /* do not be confused by WS_DLGFRAME set */
3317 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3319 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3320 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3322 si.cbSize = sizeof(si);
3323 si.fMask = SIF_RANGE;
3326 SetScrollInfo(hwnd, ctl, &si, TRUE);
3327 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3328 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3330 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3332 style = GetWindowLongA(hwnd, GWL_STYLE);
3333 if (set) ok(style & set, "style %08x should be set\n", set);
3334 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3336 /* a subsequent call should do nothing */
3337 SetScrollInfo(hwnd, ctl, &si, TRUE);
3338 if (style & WS_HSCROLL)
3339 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3340 else if (style & WS_VSCROLL)
3341 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3343 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3345 si.fMask = SIF_PAGE;
3347 SetScrollInfo(hwnd, ctl, &si, FALSE);
3348 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3352 SetScrollInfo(hwnd, ctl, &si, FALSE);
3353 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3355 si.fMask = SIF_RANGE;
3356 si.nMin = 0xdeadbeef;
3357 si.nMax = 0xdeadbeef;
3358 ret = GetScrollInfo(hwnd, ctl, &si);
3359 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3360 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3361 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3362 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3365 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3366 static void test_scroll_messages(HWND hwnd)
3374 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3375 ok( ret, "GetScrollRange error %d\n", GetLastError());
3376 if (sequence->message != WmGetScrollRangeSeq[0].message)
3377 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3378 /* values of min and max are undefined */
3381 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3382 ok( ret, "SetScrollRange error %d\n", GetLastError());
3383 if (sequence->message != WmSetScrollRangeSeq[0].message)
3384 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3389 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3390 ok( ret, "GetScrollRange error %d\n", GetLastError());
3391 if (sequence->message != WmGetScrollRangeSeq[0].message)
3392 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3393 /* values of min and max are undefined */
3396 si.cbSize = sizeof(si);
3397 si.fMask = SIF_RANGE;
3400 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3401 if (sequence->message != WmSetScrollRangeSeq[0].message)
3402 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3405 si.fMask = SIF_PAGE;
3407 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3408 if (sequence->message != WmSetScrollRangeSeq[0].message)
3409 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3414 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3415 if (sequence->message != WmSetScrollRangeSeq[0].message)
3416 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3419 si.fMask = SIF_RANGE;
3420 si.nMin = 0xdeadbeef;
3421 si.nMax = 0xdeadbeef;
3422 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3423 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3424 if (sequence->message != WmGetScrollInfoSeq[0].message)
3425 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3426 /* values of min and max are undefined */
3429 /* set WS_HSCROLL */
3430 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3431 /* clear WS_HSCROLL */
3432 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3434 /* set WS_HSCROLL */
3435 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3436 /* clear WS_HSCROLL */
3437 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3439 /* set WS_VSCROLL */
3440 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3441 /* clear WS_VSCROLL */
3442 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3444 /* set WS_VSCROLL */
3445 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3446 /* clear WS_VSCROLL */
3447 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3450 static void test_showwindow(void)
3455 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3456 100, 100, 200, 200, 0, 0, 0, NULL);
3457 ok (hwnd != 0, "Failed to create overlapped window\n");
3458 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3459 0, 0, 10, 10, hwnd, 0, 0, NULL);
3460 ok (hchild != 0, "Failed to create child\n");
3463 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3464 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3465 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3466 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3469 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3470 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3471 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3472 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3474 /* back to invisible */
3475 ShowWindow(hchild, SW_HIDE);
3476 ShowWindow(hwnd, SW_HIDE);
3478 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3479 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3480 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3481 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3483 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3484 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3486 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3487 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3488 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3490 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3491 ShowWindow( hwnd, SW_SHOW);
3493 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3494 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3495 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3498 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3499 ShowWindow( hchild, SW_HIDE);
3501 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3502 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3503 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3507 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3508 DestroyWindow(hchild);
3509 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3511 DestroyWindow(hwnd);
3516 * 1. Create invisible maximized popup window.
3517 * 2. Move and resize it.
3518 * 3. Show it maximized.
3520 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3521 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3522 100, 100, 200, 200, 0, 0, 0, NULL);
3523 ok (hwnd != 0, "Failed to create popup window\n");
3524 ok(IsZoomed(hwnd), "window should be maximized\n");
3525 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3528 GetWindowRect(hwnd, &rc);
3529 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3530 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3531 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3532 rc.left, rc.top, rc.right, rc.bottom);
3533 /* Reset window's size & position */
3534 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3535 ok(IsZoomed(hwnd), "window should be maximized\n");
3538 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3539 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3540 ok(IsZoomed(hwnd), "window should be maximized\n");
3541 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
3544 GetWindowRect(hwnd, &rc);
3545 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3546 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3547 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3548 rc.left, rc.top, rc.right, rc.bottom);
3549 DestroyWindow(hwnd);
3553 * 1. Create invisible maximized popup window.
3554 * 2. Show it maximized.
3556 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3557 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3558 100, 100, 200, 200, 0, 0, 0, NULL);
3559 ok (hwnd != 0, "Failed to create popup window\n");
3560 ok(IsZoomed(hwnd), "window should be maximized\n");
3561 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3564 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3565 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3566 ok(IsZoomed(hwnd), "window should be maximized\n");
3567 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
3569 DestroyWindow(hwnd);
3573 * 1. Create visible maximized popup window.
3575 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3576 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3577 100, 100, 200, 200, 0, 0, 0, NULL);
3578 ok (hwnd != 0, "Failed to create popup window\n");
3579 ok(IsZoomed(hwnd), "window should be maximized\n");
3580 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3582 DestroyWindow(hwnd);
3586 * 1. Create visible popup window.
3589 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3590 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3591 100, 100, 200, 200, 0, 0, 0, NULL);
3592 ok (hwnd != 0, "Failed to create popup window\n");
3593 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3594 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", TRUE);
3597 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3598 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3599 ok(IsZoomed(hwnd), "window should be maximized\n");
3600 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3602 DestroyWindow(hwnd);
3606 static void test_sys_menu(void)
3612 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3613 100, 100, 200, 200, 0, 0, 0, NULL);
3614 ok (hwnd != 0, "Failed to create overlapped window\n");
3618 /* test existing window without CS_NOCLOSE style */
3619 hmenu = GetSystemMenu(hwnd, FALSE);
3620 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3622 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3623 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3624 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3626 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3627 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3629 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3630 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3631 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3633 EnableMenuItem(hmenu, SC_CLOSE, 0);
3634 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3636 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3637 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3638 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3640 /* test whether removing WS_SYSMENU destroys a system menu */
3641 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
3642 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3644 hmenu = GetSystemMenu(hwnd, FALSE);
3645 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3647 DestroyWindow(hwnd);
3649 /* test new window with CS_NOCLOSE style */
3650 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3651 100, 100, 200, 200, 0, 0, 0, NULL);
3652 ok (hwnd != 0, "Failed to create overlapped window\n");
3654 hmenu = GetSystemMenu(hwnd, FALSE);
3655 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3657 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3658 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3660 DestroyWindow(hwnd);
3662 /* test new window without WS_SYSMENU style */
3663 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
3664 100, 100, 200, 200, 0, 0, 0, NULL);
3665 ok(hwnd != 0, "Failed to create overlapped window\n");
3667 hmenu = GetSystemMenu(hwnd, FALSE);
3668 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
3670 DestroyWindow(hwnd);
3673 /* test if we receive the right sequence of messages */
3674 static void test_messages(void)
3676 HWND hwnd, hparent, hchild;
3677 HWND hchild2, hbutton;
3684 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3685 100, 100, 200, 200, 0, 0, 0, NULL);
3686 ok (hwnd != 0, "Failed to create overlapped window\n");
3687 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3689 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3690 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
3691 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
3693 /* test WM_SETREDRAW on a not visible top level window */
3694 test_WM_SETREDRAW(hwnd);
3696 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3697 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
3698 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
3700 ok(GetActiveWindow() == hwnd, "window should be active\n");
3701 ok(GetFocus() == hwnd, "window should have input focus\n");
3702 ShowWindow(hwnd, SW_HIDE);
3703 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
3705 ShowWindow(hwnd, SW_SHOW);
3706 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
3708 ShowWindow(hwnd, SW_HIDE);
3709 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
3711 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3712 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
3714 ShowWindow(hwnd, SW_RESTORE);
3715 /* FIXME: add ok_sequence() here */
3718 ShowWindow(hwnd, SW_SHOW);
3719 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
3721 ok(GetActiveWindow() == hwnd, "window should be active\n");
3722 ok(GetFocus() == hwnd, "window should have input focus\n");
3723 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3724 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
3725 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
3726 ok(GetActiveWindow() == hwnd, "window should still be active\n");
3728 /* test WM_SETREDRAW on a visible top level window */
3729 ShowWindow(hwnd, SW_SHOW);
3730 test_WM_SETREDRAW(hwnd);
3732 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
3733 test_scroll_messages(hwnd);
3735 /* test resizing and moving */
3736 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
3737 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
3738 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
3739 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
3741 /* popups don't get WM_GETMINMAXINFO */
3742 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
3743 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3745 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
3746 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
3748 DestroyWindow(hwnd);
3749 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
3751 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3752 100, 100, 200, 200, 0, 0, 0, NULL);
3753 ok (hparent != 0, "Failed to create parent window\n");
3756 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
3757 0, 0, 10, 10, hparent, 0, 0, NULL);
3758 ok (hchild != 0, "Failed to create child window\n");
3759 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
3760 DestroyWindow(hchild);
3763 /* visible child window with a caption */
3764 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
3765 WS_CHILD | WS_VISIBLE | WS_CAPTION,
3766 0, 0, 10, 10, hparent, 0, 0, NULL);
3767 ok (hchild != 0, "Failed to create child window\n");
3768 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
3770 trace("testing scroll APIs on a visible child window %p\n", hchild);
3771 test_scroll_messages(hchild);
3773 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3774 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
3776 DestroyWindow(hchild);
3779 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3780 0, 0, 10, 10, hparent, 0, 0, NULL);
3781 ok (hchild != 0, "Failed to create child window\n");
3782 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3784 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
3785 100, 100, 50, 50, hparent, 0, 0, NULL);
3786 ok (hchild2 != 0, "Failed to create child2 window\n");
3789 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
3790 0, 100, 50, 50, hchild, 0, 0, NULL);
3791 ok (hbutton != 0, "Failed to create button window\n");
3793 /* test WM_SETREDRAW on a not visible child window */
3794 test_WM_SETREDRAW(hchild);
3796 ShowWindow(hchild, SW_SHOW);
3797 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3799 ShowWindow(hchild, SW_HIDE);
3800 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
3802 ShowWindow(hchild, SW_SHOW);
3803 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3805 /* test WM_SETREDRAW on a visible child window */
3806 test_WM_SETREDRAW(hchild);
3808 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
3809 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
3811 ShowWindow(hchild, SW_HIDE);
3813 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3814 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
3816 ShowWindow(hchild, SW_HIDE);
3818 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3819 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
3821 /* DestroyWindow sequence below expects that a child has focus */
3825 DestroyWindow(hchild);
3826 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
3827 DestroyWindow(hchild2);
3828 DestroyWindow(hbutton);
3831 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
3832 0, 0, 100, 100, hparent, 0, 0, NULL);
3833 ok (hchild != 0, "Failed to create child popup window\n");
3834 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
3835 DestroyWindow(hchild);
3837 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3839 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
3840 0, 0, 100, 100, hparent, 0, 0, NULL);
3841 ok (hchild != 0, "Failed to create popup window\n");
3842 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3843 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3844 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3846 ShowWindow(hchild, SW_SHOW);
3847 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3849 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3850 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3852 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3853 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
3854 DestroyWindow(hchild);
3856 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3857 * changes nothing in message sequences.
3860 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
3861 0, 0, 100, 100, hparent, 0, 0, NULL);
3862 ok (hchild != 0, "Failed to create popup window\n");
3863 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3864 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3865 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3867 ShowWindow(hchild, SW_SHOW);
3868 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3870 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3871 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3872 DestroyWindow(hchild);
3875 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
3876 0, 0, 100, 100, hparent, 0, 0, NULL);
3877 ok(hwnd != 0, "Failed to create custom dialog window\n");
3878 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
3881 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3882 test_scroll_messages(hwnd);
3886 after_end_dialog = 1;
3887 EndDialog( hwnd, 0 );
3888 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
3890 DestroyWindow(hwnd);
3891 after_end_dialog = 0;
3893 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
3894 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
3895 ok(hwnd != 0, "Failed to create custom dialog window\n");
3897 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
3898 ShowWindow(hwnd, SW_SHOW);
3899 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
3900 DestroyWindow(hwnd);
3903 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
3904 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
3906 DestroyWindow(hparent);
3909 /* Message sequence for SetMenu */
3910 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
3911 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
3913 hmenu = CreateMenu();
3914 ok (hmenu != 0, "Failed to create menu\n");
3915 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
3916 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3917 100, 100, 200, 200, 0, hmenu, 0, NULL);
3918 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3919 ok (SetMenu(hwnd, 0), "SetMenu\n");
3920 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
3921 ok (SetMenu(hwnd, 0), "SetMenu\n");
3922 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
3923 ShowWindow(hwnd, SW_SHOW);
3924 UpdateWindow( hwnd );
3925 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3927 ok (SetMenu(hwnd, 0), "SetMenu\n");
3928 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
3929 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
3930 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
3932 UpdateWindow( hwnd );
3933 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3935 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
3936 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3937 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
3939 DestroyWindow(hwnd);
3942 /* Message sequence for EnableWindow */
3943 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3944 100, 100, 200, 200, 0, 0, 0, NULL);
3945 ok (hparent != 0, "Failed to create parent window\n");
3946 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
3947 0, 0, 10, 10, hparent, 0, 0, NULL);
3948 ok (hchild != 0, "Failed to create child window\n");
3954 EnableWindow(hparent, FALSE);
3955 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
3957 EnableWindow(hparent, TRUE);
3958 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
3960 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3963 /* MsgWaitForMultipleObjects test */
3964 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3965 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
3967 PostMessageA(hparent, WM_USER, 0, 0);
3969 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3970 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
3972 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3973 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3975 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3976 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
3977 /* end of MsgWaitForMultipleObjects test */
3979 /* the following test causes an exception in user.exe under win9x */
3980 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
3982 DestroyWindow(hparent);
3986 PostMessageW( hparent, WM_USER+1, 0, 0 );
3987 /* PeekMessage(NULL) fails, but still removes the message */
3988 SetLastError(0xdeadbeef);
3989 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
3990 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
3991 GetLastError() == 0xdeadbeef, /* NT4 */
3992 "last error is %d\n", GetLastError() );
3993 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
3994 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
3996 DestroyWindow(hchild);
3997 DestroyWindow(hparent);
4001 static void invisible_parent_tests(void)
4003 HWND hparent, hchild;
4005 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4006 100, 100, 200, 200, 0, 0, 0, NULL);
4007 ok (hparent != 0, "Failed to create parent window\n");
4010 /* test showing child with hidden parent */
4012 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4013 0, 0, 10, 10, hparent, 0, 0, NULL);
4014 ok (hchild != 0, "Failed to create child window\n");
4015 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4017 ShowWindow( hchild, SW_MINIMIZE );
4018 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4019 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4020 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4025 ShowWindow( hchild, SW_MINIMIZE );
4026 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4028 DestroyWindow(hchild);
4029 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4030 0, 0, 10, 10, hparent, 0, 0, NULL);
4033 ShowWindow( hchild, SW_MAXIMIZE );
4034 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4035 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4036 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4041 ShowWindow( hchild, SW_MAXIMIZE );
4042 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4044 DestroyWindow(hchild);
4045 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4046 0, 0, 10, 10, hparent, 0, 0, NULL);
4049 ShowWindow( hchild, SW_RESTORE );
4050 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4051 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4052 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4054 DestroyWindow(hchild);
4055 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4056 0, 0, 10, 10, hparent, 0, 0, NULL);
4059 ShowWindow( hchild, SW_SHOWMINIMIZED );
4060 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4061 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4062 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4067 ShowWindow( hchild, SW_SHOWMINIMIZED );
4068 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4070 DestroyWindow(hchild);
4071 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4072 0, 0, 10, 10, hparent, 0, 0, NULL);
4075 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4076 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4077 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
4078 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4079 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4081 DestroyWindow(hchild);
4082 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4083 0, 0, 10, 10, hparent, 0, 0, NULL);
4086 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4087 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4088 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4089 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4094 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4095 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4097 DestroyWindow(hchild);
4098 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4099 0, 0, 10, 10, hparent, 0, 0, NULL);
4102 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4103 ShowWindow( hchild, SW_FORCEMINIMIZE );
4104 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4106 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4108 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4110 DestroyWindow(hchild);
4111 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4112 0, 0, 10, 10, hparent, 0, 0, NULL);
4115 ShowWindow( hchild, SW_SHOWNA );
4116 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4117 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4118 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4123 ShowWindow( hchild, SW_SHOWNA );
4124 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4126 DestroyWindow(hchild);
4127 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4128 0, 0, 10, 10, hparent, 0, 0, NULL);
4131 ShowWindow( hchild, SW_SHOW );
4132 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4133 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4134 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4139 ShowWindow( hchild, SW_SHOW );
4140 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4142 ShowWindow( hchild, SW_HIDE );
4143 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4144 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4145 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4147 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4148 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4149 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4150 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4152 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4153 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4154 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4155 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4157 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4159 DestroyWindow(hchild);
4160 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4162 DestroyWindow(hparent);
4166 /****************** button message test *************************/
4167 static const struct message WmSetFocusButtonSeq[] =
4169 { HCBT_SETFOCUS, hook },
4170 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4171 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4172 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4173 { WM_SETFOCUS, sent|wparam, 0 },
4174 { WM_CTLCOLORBTN, sent|defwinproc },
4177 static const struct message WmKillFocusButtonSeq[] =
4179 { HCBT_SETFOCUS, hook },
4180 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4181 { WM_KILLFOCUS, sent|wparam, 0 },
4182 { WM_CTLCOLORBTN, sent|defwinproc },
4183 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4184 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4187 static const struct message WmSetFocusStaticSeq[] =
4189 { HCBT_SETFOCUS, hook },
4190 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4191 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4192 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4193 { WM_SETFOCUS, sent|wparam, 0 },
4194 { WM_CTLCOLORSTATIC, sent|defwinproc },
4197 static const struct message WmKillFocusStaticSeq[] =
4199 { HCBT_SETFOCUS, hook },
4200 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4201 { WM_KILLFOCUS, sent|wparam, 0 },
4202 { WM_CTLCOLORSTATIC, sent|defwinproc },
4203 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4204 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4207 static const struct message WmLButtonDownSeq[] =
4209 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
4210 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4211 { HCBT_SETFOCUS, hook },
4212 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4213 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4214 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4215 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4216 { WM_CTLCOLORBTN, sent|defwinproc },
4217 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
4218 { WM_CTLCOLORBTN, sent|defwinproc },
4219 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4222 static const struct message WmLButtonUpSeq[] =
4224 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
4225 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
4226 { WM_CTLCOLORBTN, sent|defwinproc },
4227 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4228 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4229 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
4233 static WNDPROC old_button_proc;
4235 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4237 static long defwndproc_counter = 0;
4241 trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4243 /* explicitly ignore WM_GETICON message */
4244 if (message == WM_GETICON) return 0;
4246 msg.message = message;
4247 msg.flags = sent|wparam|lparam;
4248 if (defwndproc_counter) msg.flags |= defwinproc;
4249 msg.wParam = wParam;
4250 msg.lParam = lParam;
4253 if (message == BM_SETSTATE)
4254 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
4256 defwndproc_counter++;
4257 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
4258 defwndproc_counter--;
4263 static void subclass_button(void)
4267 if (!GetClassInfoA(0, "button", &cls)) assert(0);
4269 old_button_proc = cls.lpfnWndProc;
4271 cls.hInstance = GetModuleHandle(0);
4272 cls.lpfnWndProc = button_hook_proc;
4273 cls.lpszClassName = "my_button_class";
4274 if (!RegisterClassA(&cls)) assert(0);
4277 static void test_button_messages(void)
4283 const struct message *setfocus;
4284 const struct message *killfocus;
4286 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4287 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4288 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4289 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4290 { BS_CHECKBOX, DLGC_BUTTON,
4291 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4292 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4293 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4294 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4295 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4296 { BS_3STATE, DLGC_BUTTON,
4297 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4298 { BS_AUTO3STATE, DLGC_BUTTON,
4299 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4300 { BS_GROUPBOX, DLGC_STATIC,
4301 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4302 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4303 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4304 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4305 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4306 { BS_OWNERDRAW, DLGC_BUTTON,
4307 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4315 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4317 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4318 0, 0, 50, 14, 0, 0, 0, NULL);
4319 ok(hwnd != 0, "Failed to create button window\n");
4321 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4322 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4324 ShowWindow(hwnd, SW_SHOW);
4329 trace("button style %08x\n", button[i].style);
4331 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4334 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4336 DestroyWindow(hwnd);
4339 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4340 0, 0, 50, 14, 0, 0, 0, NULL);
4341 ok(hwnd != 0, "Failed to create button window\n");
4346 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4347 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4349 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4350 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
4351 DestroyWindow(hwnd);
4354 /****************** static message test *************************/
4355 static const struct message WmSetFontStaticSeq[] =
4357 { WM_SETFONT, sent },
4358 { WM_PAINT, sent|defwinproc },
4359 { WM_ERASEBKGND, sent|defwinproc },
4360 { WM_CTLCOLORSTATIC, sent|defwinproc },
4364 static WNDPROC old_static_proc;
4366 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4368 static long defwndproc_counter = 0;
4372 trace("static: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4374 /* explicitly ignore WM_GETICON message */
4375 if (message == WM_GETICON) return 0;
4377 msg.message = message;
4378 msg.flags = sent|wparam|lparam;
4379 if (defwndproc_counter) msg.flags |= defwinproc;
4380 msg.wParam = wParam;
4381 msg.lParam = lParam;
4385 defwndproc_counter++;
4386 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
4387 defwndproc_counter--;
4392 static void subclass_static(void)
4396 if (!GetClassInfoA(0, "static", &cls)) assert(0);
4398 old_static_proc = cls.lpfnWndProc;
4400 cls.hInstance = GetModuleHandle(0);
4401 cls.lpfnWndProc = static_hook_proc;
4402 cls.lpszClassName = "my_static_class";
4403 if (!RegisterClassA(&cls)) assert(0);
4406 static void test_static_messages(void)
4408 /* FIXME: make as comprehensive as the button message test */
4413 const struct message *setfont;
4415 { SS_LEFT, DLGC_STATIC,
4416 WmSetFontStaticSeq }
4424 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
4426 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
4427 0, 0, 50, 14, 0, 0, 0, NULL);
4428 ok(hwnd != 0, "Failed to create static window\n");
4430 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4431 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4433 ShowWindow(hwnd, SW_SHOW);
4438 trace("static style %08x\n", static_ctrl[i].style);
4439 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
4440 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
4442 DestroyWindow(hwnd);
4446 /************* painting message test ********************/
4448 void dump_region(HRGN hrgn)
4451 RGNDATA *data = NULL;
4456 printf( "null region\n" );
4459 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
4460 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
4461 GetRegionData( hrgn, size, data );
4462 printf("%d rects:", data->rdh.nCount );
4463 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
4464 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
4466 HeapFree( GetProcessHeap(), 0, data );
4469 static void check_update_rgn( HWND hwnd, HRGN hrgn )
4473 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
4474 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
4476 ret = GetUpdateRgn( hwnd, update, FALSE );
4477 ok( ret != ERROR, "GetUpdateRgn failed\n" );
4478 if (ret == NULLREGION)
4480 ok( !hrgn, "Update region shouldn't be empty\n" );
4484 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
4486 ok( 0, "Regions are different\n" );
4487 if (winetest_debug > 0)
4489 printf( "Update region: " );
4490 dump_region( update );
4491 printf( "Wanted region: " );
4492 dump_region( hrgn );
4496 GetRgnBox( update, &r1 );
4497 GetUpdateRect( hwnd, &r2, FALSE );
4498 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
4499 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
4500 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
4502 DeleteObject( tmp );
4503 DeleteObject( update );
4506 static const struct message WmInvalidateRgn[] = {
4507 { WM_NCPAINT, sent },
4508 { WM_GETTEXT, sent|defwinproc|optional },
4512 static const struct message WmGetUpdateRect[] = {
4513 { WM_NCPAINT, sent },
4514 { WM_GETTEXT, sent|defwinproc|optional },
4519 static const struct message WmInvalidateFull[] = {
4520 { WM_NCPAINT, sent|wparam, 1 },
4521 { WM_GETTEXT, sent|defwinproc|optional },
4525 static const struct message WmInvalidateErase[] = {
4526 { WM_NCPAINT, sent|wparam, 1 },
4527 { WM_GETTEXT, sent|defwinproc|optional },
4528 { WM_ERASEBKGND, sent },
4532 static const struct message WmInvalidatePaint[] = {
4534 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
4535 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4539 static const struct message WmInvalidateErasePaint[] = {
4541 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
4542 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4543 { WM_ERASEBKGND, sent|beginpaint },
4547 static const struct message WmInvalidateErasePaint2[] = {
4549 { WM_NCPAINT, sent|beginpaint },
4550 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4551 { WM_ERASEBKGND, sent|beginpaint },
4555 static const struct message WmErase[] = {
4556 { WM_ERASEBKGND, sent },
4560 static const struct message WmPaint[] = {
4565 static const struct message WmParentOnlyPaint[] = {
4566 { WM_PAINT, sent|parent },
4570 static const struct message WmInvalidateParent[] = {
4571 { WM_NCPAINT, sent|parent },
4572 { WM_GETTEXT, sent|defwinproc|parent|optional },
4573 { WM_ERASEBKGND, sent|parent },
4577 static const struct message WmInvalidateParentChild[] = {
4578 { WM_NCPAINT, sent|parent },
4579 { WM_GETTEXT, sent|defwinproc|parent|optional },
4580 { WM_ERASEBKGND, sent|parent },
4581 { WM_NCPAINT, sent },
4582 { WM_GETTEXT, sent|defwinproc|optional },
4583 { WM_ERASEBKGND, sent },
4587 static const struct message WmInvalidateParentChild2[] = {
4588 { WM_ERASEBKGND, sent|parent },
4589 { WM_NCPAINT, sent },
4590 { WM_GETTEXT, sent|defwinproc|optional },
4591 { WM_ERASEBKGND, sent },
4595 static const struct message WmParentPaint[] = {
4596 { WM_PAINT, sent|parent },
4601 static const struct message WmParentPaintNc[] = {
4602 { WM_PAINT, sent|parent },
4604 { WM_NCPAINT, sent|beginpaint },
4605 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4606 { WM_ERASEBKGND, sent|beginpaint },
4610 static const struct message WmChildPaintNc[] = {
4612 { WM_NCPAINT, sent|beginpaint },
4613 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4614 { WM_ERASEBKGND, sent|beginpaint },
4618 static const struct message WmParentErasePaint[] = {
4619 { WM_PAINT, sent|parent },
4620 { WM_NCPAINT, sent|parent|beginpaint },
4621 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4622 { WM_ERASEBKGND, sent|parent|beginpaint },
4624 { WM_NCPAINT, sent|beginpaint },
4625 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4626 { WM_ERASEBKGND, sent|beginpaint },
4630 static const struct message WmParentOnlyNcPaint[] = {
4631 { WM_PAINT, sent|parent },
4632 { WM_NCPAINT, sent|parent|beginpaint },
4633 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4637 static const struct message WmSetParentStyle[] = {
4638 { WM_STYLECHANGING, sent|parent },
4639 { WM_STYLECHANGED, sent|parent },
4643 static void test_paint_messages(void)
4649 HWND hparent, hchild;
4650 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
4651 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
4652 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4653 100, 100, 200, 200, 0, 0, 0, NULL);
4654 ok (hwnd != 0, "Failed to create overlapped window\n");
4656 ShowWindow( hwnd, SW_SHOW );
4657 UpdateWindow( hwnd );
4661 check_update_rgn( hwnd, 0 );
4662 SetRectRgn( hrgn, 10, 10, 20, 20 );
4663 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4664 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4665 check_update_rgn( hwnd, hrgn );
4666 SetRectRgn( hrgn2, 20, 20, 30, 30 );
4667 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
4668 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4669 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
4670 check_update_rgn( hwnd, hrgn );
4671 /* validate everything */
4672 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4673 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4674 check_update_rgn( hwnd, 0 );
4676 /* test empty region */
4677 SetRectRgn( hrgn, 10, 10, 10, 15 );
4678 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4679 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4680 check_update_rgn( hwnd, 0 );
4681 /* test empty rect */
4682 SetRect( &rect, 10, 10, 10, 15 );
4683 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
4684 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4685 check_update_rgn( hwnd, 0 );
4687 /* flush pending messages */
4688 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4691 GetClientRect( hwnd, &rect );
4692 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
4693 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
4694 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4696 trace("testing InvalidateRect(0, NULL, FALSE)\n");
4697 SetRectEmpty( &rect );
4698 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
4699 check_update_rgn( hwnd, hrgn );
4700 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4701 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4702 ok_sequence( WmPaint, "Paint", FALSE );
4703 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4704 check_update_rgn( hwnd, 0 );
4706 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4707 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4709 trace("testing ValidateRect(0, NULL)\n");
4710 SetRectEmpty( &rect );
4711 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
4712 check_update_rgn( hwnd, hrgn );
4713 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4714 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4715 ok_sequence( WmPaint, "Paint", FALSE );
4716 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4717 check_update_rgn( hwnd, 0 );
4719 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4720 SetLastError(0xdeadbeef);
4721 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4722 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
4723 check_update_rgn( hwnd, 0 );
4724 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4725 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4727 trace("testing ValidateRgn(0, NULL)\n");
4728 SetLastError(0xdeadbeef);
4729 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
4730 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
4731 check_update_rgn( hwnd, 0 );
4732 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4733 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4735 /* now with frame */
4736 SetRectRgn( hrgn, -5, -5, 20, 20 );
4738 /* flush pending messages */
4739 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4742 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4743 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4745 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4746 check_update_rgn( hwnd, hrgn );
4749 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4750 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4753 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4754 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
4756 GetClientRect( hwnd, &rect );
4757 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
4758 check_update_rgn( hwnd, hrgn );
4761 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
4762 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4765 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
4766 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
4767 check_update_rgn( hwnd, 0 );
4770 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
4771 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
4772 check_update_rgn( hwnd, 0 );
4775 SetRectRgn( hrgn, 0, 0, 100, 100 );
4776 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4777 SetRectRgn( hrgn, 0, 0, 50, 100 );
4778 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
4779 SetRectRgn( hrgn, 50, 0, 100, 100 );
4780 check_update_rgn( hwnd, hrgn );
4781 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4782 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
4783 check_update_rgn( hwnd, 0 );
4786 SetRectRgn( hrgn, 0, 0, 100, 100 );
4787 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4788 SetRectRgn( hrgn, 0, 0, 100, 50 );
4789 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4790 ok_sequence( WmErase, "Erase", FALSE );
4791 SetRectRgn( hrgn, 0, 50, 100, 100 );
4792 check_update_rgn( hwnd, hrgn );
4795 SetRectRgn( hrgn, 0, 0, 100, 100 );
4796 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4797 SetRectRgn( hrgn, 0, 0, 50, 50 );
4798 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
4799 ok_sequence( WmPaint, "Paint", FALSE );
4802 SetRectRgn( hrgn, -4, -4, -2, -2 );
4803 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4804 SetRectRgn( hrgn, -200, -200, -198, -198 );
4805 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
4806 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4809 SetRectRgn( hrgn, -4, -4, -2, -2 );
4810 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4811 SetRectRgn( hrgn, -4, -4, -3, -3 );
4812 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
4813 SetRectRgn( hrgn, 0, 0, 1, 1 );
4814 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
4815 ok_sequence( WmPaint, "Paint", FALSE );
4818 SetRectRgn( hrgn, -4, -4, -1, -1 );
4819 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4820 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
4821 /* make sure no WM_PAINT was generated */
4822 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4823 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4826 SetRectRgn( hrgn, -4, -4, -1, -1 );
4827 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4828 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
4830 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
4832 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
4833 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
4834 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
4835 ret = GetUpdateRect( hwnd, &rect, FALSE );
4836 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
4837 /* this will send WM_NCPAINT and validate the non client area */
4838 ret = GetUpdateRect( hwnd, &rect, TRUE );
4839 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
4841 DispatchMessage( &msg );
4843 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
4845 DestroyWindow( hwnd );
4847 /* now test with a child window */
4849 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4850 100, 100, 200, 200, 0, 0, 0, NULL);
4851 ok (hparent != 0, "Failed to create parent window\n");
4853 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
4854 10, 10, 100, 100, hparent, 0, 0, NULL);
4855 ok (hchild != 0, "Failed to create child window\n");
4857 ShowWindow( hparent, SW_SHOW );
4858 UpdateWindow( hparent );
4859 UpdateWindow( hchild );
4862 log_all_parent_messages++;
4864 SetRect( &rect, 0, 0, 50, 50 );
4865 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4866 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4867 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
4869 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4871 MapWindowPoints( hchild, hparent, &pt, 1 );
4872 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
4873 check_update_rgn( hchild, hrgn );
4874 SetRectRgn( hrgn, 0, 0, 50, 50 );
4875 check_update_rgn( hparent, hrgn );
4876 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4877 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
4878 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4879 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4881 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4882 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
4884 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4885 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4886 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
4887 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4888 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4890 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
4891 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4892 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
4894 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4896 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4897 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4898 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
4900 /* flush all paint messages */
4901 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4904 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
4905 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4906 SetRectRgn( hrgn, 0, 0, 50, 50 );
4907 check_update_rgn( hparent, hrgn );
4908 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4909 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4910 SetRectRgn( hrgn, 0, 0, 50, 50 );
4911 check_update_rgn( hparent, hrgn );
4913 /* flush all paint messages */
4914 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4915 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4918 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
4919 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4920 SetRectRgn( hrgn, 0, 0, 50, 50 );
4921 check_update_rgn( hparent, hrgn );
4922 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4923 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4924 SetRectRgn( hrgn2, 10, 10, 50, 50 );
4925 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
4926 check_update_rgn( hparent, hrgn );
4927 /* flush all paint messages */
4928 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4931 /* same as above but parent gets completely validated */
4932 SetRect( &rect, 20, 20, 30, 30 );
4933 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4934 SetRectRgn( hrgn, 20, 20, 30, 30 );
4935 check_update_rgn( hparent, hrgn );
4936 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4937 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4938 check_update_rgn( hparent, 0 ); /* no update region */
4939 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4940 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
4942 /* make sure RDW_VALIDATE on child doesn't have the same effect */
4944 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4945 SetRectRgn( hrgn, 20, 20, 30, 30 );
4946 check_update_rgn( hparent, hrgn );
4947 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
4948 SetRectRgn( hrgn, 20, 20, 30, 30 );
4949 check_update_rgn( hparent, hrgn );
4951 /* same as above but normal WM_PAINT doesn't validate parent */
4953 SetRect( &rect, 20, 20, 30, 30 );
4954 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4955 SetRectRgn( hrgn, 20, 20, 30, 30 );
4956 check_update_rgn( hparent, hrgn );
4957 /* no WM_PAINT in child while parent still pending */
4958 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4959 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4960 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4961 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
4964 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4965 /* no WM_PAINT in child while parent still pending */
4966 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4967 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4968 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
4969 /* now that parent is valid child should get WM_PAINT */
4970 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4971 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4972 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4973 ok_sequence( WmEmptySeq, "No other message", FALSE );
4975 /* same thing with WS_CLIPCHILDREN in parent */
4977 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4978 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4979 /* changing style invalidates non client area, but we need to invalidate something else to see it */
4980 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
4981 ok_sequence( WmEmptySeq, "No message", FALSE );
4982 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
4983 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
4986 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
4987 SetRectRgn( hrgn, 20, 20, 30, 30 );
4988 check_update_rgn( hparent, hrgn );
4989 /* no WM_PAINT in child while parent still pending */
4990 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4991 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4992 /* WM_PAINT in parent first */
4993 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4994 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
4996 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
4998 SetRect( &rect, 0, 0, 30, 30 );
4999 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
5000 SetRectRgn( hrgn, 0, 0, 30, 30 );
5001 check_update_rgn( hparent, hrgn );
5002 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5003 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
5005 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5007 SetRect( &rect, -10, 0, 30, 30 );
5008 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5009 SetRect( &rect, 0, 0, 20, 20 );
5010 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5011 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5012 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
5014 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5016 SetRect( &rect, -10, 0, 30, 30 );
5017 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5018 SetRect( &rect, 0, 0, 100, 100 );
5019 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5020 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5021 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
5022 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5023 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
5025 /* test RDW_INTERNALPAINT behavior */
5028 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
5029 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5030 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5032 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
5033 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5034 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5036 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5037 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5038 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5040 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
5041 UpdateWindow( hparent );
5042 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5044 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5045 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5046 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5047 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5048 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5049 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
5051 UpdateWindow( hparent );
5052 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5054 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5055 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5056 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5057 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5058 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5059 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5061 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5062 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5063 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5064 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5065 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5067 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
5068 UpdateWindow( hparent );
5069 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5071 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5072 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5073 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5074 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5075 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5076 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
5078 UpdateWindow( hparent );
5079 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5081 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5082 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5083 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5084 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5085 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5086 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5088 log_all_parent_messages--;
5089 DestroyWindow( hparent );
5090 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5092 DeleteObject( hrgn );
5093 DeleteObject( hrgn2 );
5102 static DWORD WINAPI thread_proc(void *param)
5105 struct wnd_event *wnd_event = (struct wnd_event *)param;
5107 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
5108 100, 100, 200, 200, 0, 0, 0, NULL);
5109 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
5111 SetEvent(wnd_event->event);
5113 while (GetMessage(&msg, 0, 0, 0))
5115 TranslateMessage(&msg);
5116 DispatchMessage(&msg);
5119 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
5124 static void test_interthread_messages(void)
5131 int len, expected_len;
5132 struct wnd_event wnd_event;
5135 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
5136 if (!wnd_event.event)
5138 trace("skipping interthread message test under win9x\n");
5142 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
5143 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
5145 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5147 CloseHandle(wnd_event.event);
5149 SetLastError(0xdeadbeef);
5150 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
5151 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %d\n", GetLastError());
5153 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5154 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5156 expected_len = lstrlenA("window caption text");
5157 memset(buf, 0, sizeof(buf));
5158 SetLastError(0xdeadbeef);
5159 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
5160 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
5161 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
5163 msg.hwnd = wnd_event.hwnd;
5164 msg.message = WM_GETTEXT;
5165 msg.wParam = sizeof(buf);
5166 msg.lParam = (LPARAM)buf;
5167 memset(buf, 0, sizeof(buf));
5168 SetLastError(0xdeadbeef);
5169 len = DispatchMessageA(&msg);
5170 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
5171 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
5173 /* the following test causes an exception in user.exe under win9x */
5174 msg.hwnd = wnd_event.hwnd;
5175 msg.message = WM_TIMER;
5177 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5178 SetLastError(0xdeadbeef);
5179 len = DispatchMessageA(&msg);
5180 ok(!len && GetLastError() == 0xdeadbeef,
5181 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
5183 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
5184 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5186 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5187 CloseHandle(hThread);
5189 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
5193 static const struct message WmVkN[] = {
5194 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5195 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5196 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5197 { WM_CHAR, wparam|lparam, 'n', 1 },
5198 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
5199 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5200 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5201 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5204 static const struct message WmShiftVkN[] = {
5205 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5206 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5207 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5208 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5209 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5210 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5211 { WM_CHAR, wparam|lparam, 'N', 1 },
5212 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
5213 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5214 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5215 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5216 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5217 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5218 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5221 static const struct message WmCtrlVkN[] = {
5222 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5223 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5224 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5225 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5226 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5227 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5228 { WM_CHAR, wparam|lparam, 0x000e, 1 },
5229 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
5230 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5231 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5232 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5233 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5234 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5235 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5238 static const struct message WmCtrlVkN_2[] = {
5239 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5240 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5241 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5242 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5243 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5244 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
5245 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5246 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5247 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5248 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5249 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5250 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5253 static const struct message WmAltVkN[] = {
5254 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5255 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5256 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5257 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5258 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
5259 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
5260 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
5261 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
5262 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
5263 { HCBT_SYSCOMMAND, hook },
5264 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
5265 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5266 { 0x00AE, sent|defwinproc|optional }, /* XP */
5267 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
5268 { WM_INITMENU, sent|defwinproc },
5269 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5270 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
5271 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
5272 { WM_CAPTURECHANGED, sent|defwinproc },
5273 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
5274 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5275 { WM_EXITMENULOOP, sent|defwinproc },
5276 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
5277 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
5278 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5279 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
5280 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5281 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5282 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5283 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5286 static const struct message WmAltVkN_2[] = {
5287 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5288 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5289 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5290 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5291 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
5292 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
5293 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5294 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
5295 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5296 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5297 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5298 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5301 static const struct message WmCtrlAltVkN[] = {
5302 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5303 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5304 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5305 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5306 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5307 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5308 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5309 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
5310 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
5311 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5312 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
5313 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5314 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5315 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5316 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5317 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5318 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5319 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5322 static const struct message WmCtrlShiftVkN[] = {
5323 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5324 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5325 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5326 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5327 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5328 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5329 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5330 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5331 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
5332 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5333 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5334 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5335 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5336 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5337 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5338 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5339 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5340 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5343 static const struct message WmCtrlAltShiftVkN[] = {
5344 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5345 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5346 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5347 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5348 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5349 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5350 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
5351 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
5352 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
5353 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5354 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
5355 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
5356 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5357 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
5358 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5359 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
5360 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
5361 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
5362 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5363 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5364 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5365 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5366 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5367 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5370 static const struct message WmAltPressRelease[] = {
5371 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5372 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5373 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5374 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5375 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5376 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5377 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
5378 { HCBT_SYSCOMMAND, hook },
5379 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
5380 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5381 { WM_INITMENU, sent|defwinproc },
5382 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5383 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
5384 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5386 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
5388 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5389 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
5390 { WM_CAPTURECHANGED, sent|defwinproc },
5391 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
5392 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5393 { WM_EXITMENULOOP, sent|defwinproc },
5394 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5395 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5396 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5399 static const struct message WmAltMouseButton[] = {
5400 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5401 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5402 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5403 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
5404 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
5405 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
5406 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
5407 { WM_LBUTTONUP, wparam, 0, 0 },
5408 { WM_LBUTTONUP, sent|wparam, 0, 0 },
5409 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5410 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5411 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5414 static const struct message WmF1Seq[] = {
5415 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
5416 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
5417 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
5418 { 0x4d, wparam|lparam, 0, 0 },
5419 { 0x4d, sent|wparam|lparam, 0, 0 },
5420 { WM_HELP, sent|defwinproc },
5421 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
5422 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
5423 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
5426 static const struct message WmVkAppsSeq[] = {
5427 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
5428 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
5429 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
5430 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
5431 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
5432 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
5433 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
5434 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
5438 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
5442 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
5444 struct message log_msg;
5446 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
5448 /* ignore some unwanted messages */
5449 if (msg.message == WM_MOUSEMOVE ||
5450 msg.message == WM_GETICON ||
5451 msg.message == WM_DEVICECHANGE)
5454 log_msg.message = msg.message;
5455 log_msg.flags = wparam|lparam;
5456 log_msg.wParam = msg.wParam;
5457 log_msg.lParam = msg.lParam;
5458 add_message(&log_msg);
5460 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
5462 TranslateMessage(&msg);
5463 DispatchMessage(&msg);
5468 static void test_accelerators(void)
5473 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5474 100, 100, 200, 200, 0, 0, 0, NULL);
5483 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
5485 state = GetKeyState(VK_SHIFT);
5486 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
5487 state = GetKeyState(VK_CAPITAL);
5488 ok(state == 0, "wrong CapsLock state %04x\n", state);
5490 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
5491 assert(hAccel != 0);
5493 pump_msg_loop(hwnd, 0);
5496 trace("testing VK_N press/release\n");
5498 keybd_event('N', 0, 0, 0);
5499 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5500 pump_msg_loop(hwnd, hAccel);
5501 ok_sequence(WmVkN, "VK_N press/release", FALSE);
5503 trace("testing Shift+VK_N press/release\n");
5505 keybd_event(VK_SHIFT, 0, 0, 0);
5506 keybd_event('N', 0, 0, 0);
5507 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5508 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5509 pump_msg_loop(hwnd, hAccel);
5510 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
5512 trace("testing Ctrl+VK_N press/release\n");
5514 keybd_event(VK_CONTROL, 0, 0, 0);
5515 keybd_event('N', 0, 0, 0);
5516 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5517 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5518 pump_msg_loop(hwnd, hAccel);
5519 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
5521 trace("testing Alt+VK_N press/release\n");
5523 keybd_event(VK_MENU, 0, 0, 0);
5524 keybd_event('N', 0, 0, 0);
5525 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5526 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5527 pump_msg_loop(hwnd, hAccel);
5528 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
5530 trace("testing Ctrl+Alt+VK_N press/release 1\n");
5532 keybd_event(VK_CONTROL, 0, 0, 0);
5533 keybd_event(VK_MENU, 0, 0, 0);
5534 keybd_event('N', 0, 0, 0);
5535 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5536 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5537 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5538 pump_msg_loop(hwnd, hAccel);
5539 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
5541 ret = DestroyAcceleratorTable(hAccel);
5542 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
5544 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
5545 assert(hAccel != 0);
5547 trace("testing VK_N press/release\n");
5549 keybd_event('N', 0, 0, 0);
5550 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5551 pump_msg_loop(hwnd, hAccel);
5552 ok_sequence(WmVkN, "VK_N press/release", FALSE);
5554 trace("testing Shift+VK_N press/release\n");
5556 keybd_event(VK_SHIFT, 0, 0, 0);
5557 keybd_event('N', 0, 0, 0);
5558 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5559 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5560 pump_msg_loop(hwnd, hAccel);
5561 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
5563 trace("testing Ctrl+VK_N press/release 2\n");
5565 keybd_event(VK_CONTROL, 0, 0, 0);
5566 keybd_event('N', 0, 0, 0);
5567 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5568 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5569 pump_msg_loop(hwnd, hAccel);
5570 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
5572 trace("testing Alt+VK_N press/release 2\n");
5574 keybd_event(VK_MENU, 0, 0, 0);
5575 keybd_event('N', 0, 0, 0);
5576 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5577 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5578 pump_msg_loop(hwnd, hAccel);
5579 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
5581 trace("testing Ctrl+Alt+VK_N press/release 2\n");
5583 keybd_event(VK_CONTROL, 0, 0, 0);
5584 keybd_event(VK_MENU, 0, 0, 0);
5585 keybd_event('N', 0, 0, 0);
5586 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5587 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5588 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5589 pump_msg_loop(hwnd, hAccel);
5590 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
5592 trace("testing Ctrl+Shift+VK_N press/release\n");
5594 keybd_event(VK_CONTROL, 0, 0, 0);
5595 keybd_event(VK_SHIFT, 0, 0, 0);
5596 keybd_event('N', 0, 0, 0);
5597 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5598 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5599 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5600 pump_msg_loop(hwnd, hAccel);
5601 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
5603 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
5605 keybd_event(VK_CONTROL, 0, 0, 0);
5606 keybd_event(VK_MENU, 0, 0, 0);
5607 keybd_event(VK_SHIFT, 0, 0, 0);
5608 keybd_event('N', 0, 0, 0);
5609 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5610 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5611 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5612 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5613 pump_msg_loop(hwnd, hAccel);
5614 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
5616 ret = DestroyAcceleratorTable(hAccel);
5617 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
5619 trace("testing Alt press/release\n");
5621 keybd_event(VK_MENU, 0, 0, 0);
5622 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5623 keybd_event(VK_MENU, 0, 0, 0);
5624 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5625 pump_msg_loop(hwnd, 0);
5626 /* this test doesn't pass in Wine for managed windows */
5627 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
5629 trace("testing Alt+MouseButton press/release\n");
5630 /* first, move mouse pointer inside of the window client area */
5631 GetClientRect(hwnd, &rc);
5632 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
5633 rc.left += (rc.right - rc.left)/2;
5634 rc.top += (rc.bottom - rc.top)/2;
5635 SetCursorPos(rc.left, rc.top);
5637 pump_msg_loop(hwnd, 0);
5639 keybd_event(VK_MENU, 0, 0, 0);
5640 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
5641 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
5642 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5643 pump_msg_loop(hwnd, 0);
5644 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
5646 trace("testing VK_F1 press/release\n");
5647 keybd_event(VK_F1, 0, 0, 0);
5648 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
5649 pump_msg_loop(hwnd, 0);
5650 ok_sequence(WmF1Seq, "F1 press/release", TRUE);
5652 trace("testing VK_APPS press/release\n");
5653 keybd_event(VK_APPS, 0, 0, 0);
5654 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
5655 pump_msg_loop(hwnd, 0);
5656 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
5658 DestroyWindow(hwnd);
5661 /************* window procedures ********************/
5663 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
5664 WPARAM wParam, LPARAM lParam)
5666 static long defwndproc_counter = 0;
5667 static long beginpaint_counter = 0;
5671 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5673 /* explicitly ignore WM_GETICON message */
5674 if (message == WM_GETICON) return 0;
5680 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
5681 ok((BOOL)wParam == !(style & WS_DISABLED),
5682 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
5686 case WM_CAPTURECHANGED:
5687 if (test_DestroyWindow_flag)
5689 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5690 if (style & WS_CHILD)
5691 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5692 else if (style & WS_POPUP)
5693 lParam = WND_POPUP_ID;
5695 lParam = WND_PARENT_ID;
5703 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
5704 capture = GetCapture();
5707 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
5708 trace("current capture %p, releasing...\n", capture);
5715 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
5716 if (test_DestroyWindow_flag)
5718 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5719 if (style & WS_CHILD)
5720 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5721 else if (style & WS_POPUP)
5722 lParam = WND_POPUP_ID;
5724 lParam = WND_PARENT_ID;
5728 /* test_accelerators() depends on this */
5735 case WM_DEVICECHANGE:
5738 case WM_WINDOWPOSCHANGING:
5739 case WM_WINDOWPOSCHANGED:
5741 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5743 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5744 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5745 winpos->hwnd, winpos->hwndInsertAfter,
5746 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5747 dump_winpos_flags(winpos->flags);
5749 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5750 * in the high word for internal purposes
5752 wParam = winpos->flags & 0xffff;
5753 /* We are not interested in the flags that don't match under XP and Win9x */
5754 wParam &= ~(SWP_NOZORDER);
5759 msg.message = message;
5760 msg.flags = sent|wparam|lparam;
5761 if (defwndproc_counter) msg.flags |= defwinproc;
5762 if (beginpaint_counter) msg.flags |= beginpaint;
5763 msg.wParam = wParam;
5764 msg.lParam = lParam;
5767 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
5769 HWND parent = GetParent(hwnd);
5771 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
5773 GetClientRect(parent, &rc);
5774 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
5776 trace("ptReserved = (%d,%d)\n"
5777 "ptMaxSize = (%d,%d)\n"
5778 "ptMaxPosition = (%d,%d)\n"
5779 "ptMinTrackSize = (%d,%d)\n"
5780 "ptMaxTrackSize = (%d,%d)\n",
5781 minmax->ptReserved.x, minmax->ptReserved.y,
5782 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
5783 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
5784 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
5785 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
5787 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
5788 minmax->ptMaxSize.x, rc.right);
5789 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
5790 minmax->ptMaxSize.y, rc.bottom);
5793 if (message == WM_PAINT)
5796 beginpaint_counter++;
5797 BeginPaint( hwnd, &ps );
5798 beginpaint_counter--;
5799 EndPaint( hwnd, &ps );
5803 defwndproc_counter++;
5804 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
5805 : DefWindowProcA(hwnd, message, wParam, lParam);
5806 defwndproc_counter--;
5811 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5813 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
5816 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5818 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
5821 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5823 static long defwndproc_counter = 0;
5827 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5829 /* explicitly ignore WM_GETICON message */
5830 if (message == WM_GETICON) return 0;
5832 msg.message = message;
5833 msg.flags = sent|wparam|lparam;
5834 if (defwndproc_counter) msg.flags |= defwinproc;
5835 msg.wParam = wParam;
5836 msg.lParam = lParam;
5839 if (message == WM_CREATE)
5841 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
5842 SetWindowLongA(hwnd, GWL_STYLE, style);
5845 defwndproc_counter++;
5846 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5847 defwndproc_counter--;
5852 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5854 static long defwndproc_counter = 0;
5855 static long beginpaint_counter = 0;
5859 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5861 /* explicitly ignore WM_GETICON message */
5862 if (message == WM_GETICON) return 0;
5864 if (log_all_parent_messages ||
5865 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
5866 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
5867 message == WM_ENABLE || message == WM_ENTERIDLE ||
5868 message == WM_IME_SETCONTEXT)
5882 INT ret = GetClipBox((HDC)wParam, &rc);
5884 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
5885 ret, rc.left, rc.top, rc.right, rc.bottom);
5889 case WM_WINDOWPOSCHANGING:
5890 case WM_WINDOWPOSCHANGED:
5892 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5894 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5895 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5896 winpos->hwnd, winpos->hwndInsertAfter,
5897 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5898 dump_winpos_flags(winpos->flags);
5900 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5901 * in the high word for internal purposes
5903 wParam = winpos->flags & 0xffff;
5904 /* We are not interested in the flags that don't match under XP and Win9x */
5905 wParam &= ~(SWP_NOZORDER);
5910 msg.message = message;
5911 msg.flags = sent|parent|wparam|lparam;
5912 if (defwndproc_counter) msg.flags |= defwinproc;
5913 if (beginpaint_counter) msg.flags |= beginpaint;
5914 msg.wParam = wParam;
5915 msg.lParam = lParam;
5919 if (message == WM_PAINT)
5922 beginpaint_counter++;
5923 BeginPaint( hwnd, &ps );
5924 beginpaint_counter--;
5925 EndPaint( hwnd, &ps );
5929 defwndproc_counter++;
5930 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5931 defwndproc_counter--;
5936 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5938 static long defwndproc_counter = 0;
5942 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5944 /* explicitly ignore WM_GETICON message */
5945 if (message == WM_GETICON) return 0;
5947 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
5948 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
5949 if (after_end_dialog)
5950 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
5952 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
5956 case WM_WINDOWPOSCHANGING:
5957 case WM_WINDOWPOSCHANGED:
5959 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5961 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5962 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5963 winpos->hwnd, winpos->hwndInsertAfter,
5964 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5965 dump_winpos_flags(winpos->flags);
5967 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5968 * in the high word for internal purposes
5970 wParam = winpos->flags & 0xffff;
5971 /* We are not interested in the flags that don't match under XP and Win9x */
5972 wParam &= ~(SWP_NOZORDER);
5977 msg.message = message;
5978 msg.flags = sent|wparam|lparam;
5979 if (defwndproc_counter) msg.flags |= defwinproc;
5980 msg.wParam = wParam;
5981 msg.lParam = lParam;
5984 defwndproc_counter++;
5985 ret = DefDlgProcA(hwnd, message, wParam, lParam);
5986 defwndproc_counter--;
5991 static void dump_winpos_flags(UINT flags)
5993 if (!winetest_debug) return;
5995 if (flags & SWP_SHOWWINDOW) printf("|SWP_SHOWWINDOW");
5996 if (flags & SWP_HIDEWINDOW) printf("|SWP_HIDEWINDOW");
5997 if (flags & SWP_NOACTIVATE) printf("|SWP_NOACTIVATE");
5998 if (flags & SWP_FRAMECHANGED) printf("|SWP_FRAMECHANGED");
5999 if (flags & SWP_NOCOPYBITS) printf("|SWP_NOCOPYBITS");
6000 if (flags & SWP_NOOWNERZORDER) printf("|SWP_NOOWNERZORDER");
6001 if (flags & SWP_NOSENDCHANGING) printf("|SWP_NOSENDCHANGING");
6002 if (flags & SWP_DEFERERASE) printf("|SWP_DEFERERASE");
6003 if (flags & SWP_ASYNCWINDOWPOS) printf("|SWP_ASYNCWINDOWPOS");
6004 if (flags & SWP_NOZORDER) printf("|SWP_NOZORDER");
6005 if (flags & SWP_NOREDRAW) printf("|SWP_NOREDRAW");
6006 if (flags & SWP_NOSIZE) printf("|SWP_NOSIZE");
6007 if (flags & SWP_NOMOVE) printf("|SWP_NOMOVE");
6008 if (flags & SWP_NOCLIENTSIZE) printf("|SWP_NOCLIENTSIZE");
6009 if (flags & SWP_NOCLIENTMOVE) printf("|SWP_NOCLIENTMOVE");
6011 #define DUMPED_FLAGS \
6017 SWP_FRAMECHANGED | \
6021 SWP_NOOWNERZORDER | \
6022 SWP_NOSENDCHANGING | \
6024 SWP_ASYNCWINDOWPOS | \
6025 SWP_NOCLIENTSIZE | \
6028 if(flags & ~DUMPED_FLAGS) printf("|0x%04x", flags & ~DUMPED_FLAGS);
6033 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6035 static long defwndproc_counter = 0;
6039 /* log only specific messages we are interested in */
6042 #if 0 /* probably log these as well */
6048 trace("WM_SHOWWINDOW %d\n", wParam);
6051 trace("WM_SIZE %d\n", wParam);
6056 case WM_GETMINMAXINFO:
6057 trace("WM_GETMINMAXINFO\n");
6060 case WM_WINDOWPOSCHANGING:
6061 case WM_WINDOWPOSCHANGED:
6063 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6065 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6066 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6067 winpos->hwnd, winpos->hwndInsertAfter,
6068 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6070 dump_winpos_flags(winpos->flags);
6072 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6073 * in the high word for internal purposes
6075 wParam = winpos->flags & 0xffff;
6076 /* We are not interested in the flags that don't match under XP and Win9x */
6077 wParam &= ~(SWP_NOZORDER);
6081 default: /* ignore */
6082 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6083 return DefWindowProcA(hwnd, message, wParam, lParam);
6086 msg.message = message;
6087 msg.flags = sent|wparam|lparam;
6088 if (defwndproc_counter) msg.flags |= defwinproc;
6089 msg.wParam = wParam;
6090 msg.lParam = lParam;
6093 defwndproc_counter++;
6094 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6095 defwndproc_counter--;
6100 static BOOL RegisterWindowClasses(void)
6105 cls.lpfnWndProc = MsgCheckProcA;
6108 cls.hInstance = GetModuleHandleA(0);
6110 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
6111 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6112 cls.lpszMenuName = NULL;
6113 cls.lpszClassName = "TestWindowClass";
6114 if(!RegisterClassA(&cls)) return FALSE;
6116 cls.lpfnWndProc = ShowWindowProcA;
6117 cls.lpszClassName = "ShowWindowClass";
6118 if(!RegisterClassA(&cls)) return FALSE;
6120 cls.lpfnWndProc = PopupMsgCheckProcA;
6121 cls.lpszClassName = "TestPopupClass";
6122 if(!RegisterClassA(&cls)) return FALSE;
6124 cls.lpfnWndProc = ParentMsgCheckProcA;
6125 cls.lpszClassName = "TestParentClass";
6126 if(!RegisterClassA(&cls)) return FALSE;
6128 cls.lpfnWndProc = DefWindowProcA;
6129 cls.lpszClassName = "SimpleWindowClass";
6130 if(!RegisterClassA(&cls)) return FALSE;
6132 cls.style = CS_NOCLOSE;
6133 cls.lpszClassName = "NoCloseWindowClass";
6134 if(!RegisterClassA(&cls)) return FALSE;
6136 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
6138 cls.hInstance = GetModuleHandleA(0);
6139 cls.hbrBackground = 0;
6140 cls.lpfnWndProc = TestDlgProcA;
6141 cls.lpszClassName = "TestDialogClass";
6142 if(!RegisterClassA(&cls)) return FALSE;
6147 static HHOOK hCBT_hook;
6148 static DWORD cbt_hook_thread_id;
6150 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6152 static const char * const CBT_code_name[10] = {
6159 "HCBT_CLICKSKIPPED",
6163 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
6167 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
6169 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6171 if (nCode == HCBT_CLICKSKIPPED)
6173 /* ignore this event, XP sends it a lot when switching focus between windows */
6174 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6177 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
6181 msg.message = nCode;
6182 msg.flags = hook|wparam|lparam;
6183 msg.wParam = wParam;
6184 msg.lParam = lParam;
6187 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6190 if (nCode == HCBT_DESTROYWND)
6192 if (test_DestroyWindow_flag)
6194 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
6195 if (style & WS_CHILD)
6196 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
6197 else if (style & WS_POPUP)
6198 lParam = WND_POPUP_ID;
6200 lParam = WND_PARENT_ID;
6204 /* Log also SetFocus(0) calls */
6205 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
6207 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6209 if (!lstrcmpiA(buf, "TestWindowClass") ||
6210 !lstrcmpiA(buf, "ShowWindowClass") ||
6211 !lstrcmpiA(buf, "TestParentClass") ||
6212 !lstrcmpiA(buf, "TestPopupClass") ||
6213 !lstrcmpiA(buf, "SimpleWindowClass") ||
6214 !lstrcmpiA(buf, "TestDialogClass") ||
6215 !lstrcmpiA(buf, "MDI_frame_class") ||
6216 !lstrcmpiA(buf, "MDI_client_class") ||
6217 !lstrcmpiA(buf, "MDI_child_class") ||
6218 !lstrcmpiA(buf, "my_button_class") ||
6219 !lstrcmpiA(buf, "my_edit_class") ||
6220 !lstrcmpiA(buf, "static") ||
6221 !lstrcmpiA(buf, "#32770"))
6225 msg.message = nCode;
6226 msg.flags = hook|wparam|lparam;
6227 msg.wParam = wParam;
6228 msg.lParam = lParam;
6232 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6235 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
6245 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6246 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
6248 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6250 /* ignore mouse cursor events */
6251 if (object_id == OBJID_CURSOR) return;
6253 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
6256 !lstrcmpiA(buf, "TestWindowClass") ||
6257 !lstrcmpiA(buf, "TestParentClass") ||
6258 !lstrcmpiA(buf, "TestPopupClass") ||
6259 !lstrcmpiA(buf, "SimpleWindowClass") ||
6260 !lstrcmpiA(buf, "TestDialogClass") ||
6261 !lstrcmpiA(buf, "MDI_frame_class") ||
6262 !lstrcmpiA(buf, "MDI_client_class") ||
6263 !lstrcmpiA(buf, "MDI_child_class") ||
6264 !lstrcmpiA(buf, "my_button_class") ||
6265 !lstrcmpiA(buf, "my_edit_class") ||
6266 !lstrcmpiA(buf, "static") ||
6267 !lstrcmpiA(buf, "#32770"))
6271 msg.message = event;
6272 msg.flags = winevent_hook|wparam|lparam;
6273 msg.wParam = object_id;
6274 msg.lParam = child_id;
6280 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
6281 static const WCHAR wszAnsi[] = {'U',0};
6283 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
6287 case CB_FINDSTRINGEXACT:
6288 trace("String: %p\n", (LPCWSTR)lParam);
6289 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
6291 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
6295 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
6298 static const struct message WmGetTextLengthAfromW[] = {
6299 { WM_GETTEXTLENGTH, sent },
6300 { WM_GETTEXT, sent },
6304 static const WCHAR testWindowClassW[] =
6305 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
6307 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
6309 /* dummy window proc for WM_GETTEXTLENGTH test */
6310 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
6314 case WM_GETTEXTLENGTH:
6315 return lstrlenW(dummy_window_text) + 37; /* some random length */
6317 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
6318 return lstrlenW( (LPWSTR)lp );
6320 return DefWindowProcW( hwnd, msg, wp, lp );
6324 static void test_message_conversion(void)
6326 static const WCHAR wszMsgConversionClass[] =
6327 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
6331 WNDPROC wndproc, newproc;
6335 cls.lpfnWndProc = MsgConversionProcW;
6338 cls.hInstance = GetModuleHandleW(NULL);
6340 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
6341 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
6342 cls.lpszMenuName = NULL;
6343 cls.lpszClassName = wszMsgConversionClass;
6344 /* this call will fail on Win9x, but that doesn't matter as this test is
6345 * meaningless on those platforms */
6346 if(!RegisterClassW(&cls)) return;
6349 cls.lpfnWndProc = MsgCheckProcW;
6352 cls.hInstance = GetModuleHandleW(0);
6354 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
6355 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6356 cls.lpszMenuName = NULL;
6357 cls.lpszClassName = testWindowClassW;
6358 if(!RegisterClassW(&cls)) return;
6360 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
6361 100, 100, 200, 200, 0, 0, 0, NULL);
6362 ok(hwnd != NULL, "Window creation failed\n");
6366 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
6367 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6368 ok(lRes == 0, "String should have been converted\n");
6369 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6370 ok(lRes == 1, "String shouldn't have been converted\n");
6374 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
6375 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6376 ok(lRes == 1, "String shouldn't have been converted\n");
6377 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6378 ok(lRes == 1, "String shouldn't have been converted\n");
6380 /* Synchronous messages */
6382 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6383 ok(lRes == 0, "String should have been converted\n");
6384 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6385 ok(lRes == 1, "String shouldn't have been converted\n");
6387 /* Asynchronous messages */
6390 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6391 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6392 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6394 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6395 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6396 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6398 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6399 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6400 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6402 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6403 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6404 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6406 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6407 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6408 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6410 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6411 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6412 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6414 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
6415 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6416 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6418 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
6419 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6420 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6422 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
6424 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
6425 WS_OVERLAPPEDWINDOW,
6426 100, 100, 200, 200, 0, 0, 0, NULL);
6429 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
6430 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
6431 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
6432 "got bad length %ld\n", lRes );
6435 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
6436 hwnd, WM_GETTEXTLENGTH, 0, 0);
6437 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
6438 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
6439 "got bad length %ld\n", lRes );
6441 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
6442 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
6443 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
6444 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
6445 NULL, 0, NULL, NULL ),
6446 "got bad length %ld\n", lRes );
6448 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
6449 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
6450 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
6451 NULL, 0, NULL, NULL ),
6452 "got bad length %ld\n", lRes );
6454 ret = DestroyWindow(hwnd);
6455 ok( ret, "DestroyWindow() error %d\n", GetLastError());
6465 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
6469 #define TIMER_ID 0x19
6471 static DWORD WINAPI timer_thread_proc(LPVOID x)
6473 struct timer_info *info = x;
6476 r = KillTimer(info->hWnd, 0x19);
6477 ok(r,"KillTimer failed in thread\n");
6478 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
6479 ok(r,"SetTimer failed in thread\n");
6480 ok(r==TIMER_ID,"SetTimer id different\n");
6481 r = SetEvent(info->handles[0]);
6482 ok(r,"SetEvent failed in thread\n");
6486 static void test_timers(void)
6488 struct timer_info info;
6491 info.hWnd = CreateWindow ("TestWindowClass", NULL,
6492 WS_OVERLAPPEDWINDOW ,
6493 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
6496 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
6497 ok(info.id, "SetTimer failed\n");
6498 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
6499 info.handles[0] = CreateEvent(NULL,0,0,NULL);
6500 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
6502 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
6504 WaitForSingleObject(info.handles[1], INFINITE);
6506 CloseHandle(info.handles[0]);
6507 CloseHandle(info.handles[1]);
6509 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
6511 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
6514 /* Various win events with arbitrary parameters */
6515 static const struct message WmWinEventsSeq[] = {
6516 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
6517 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6518 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
6519 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
6520 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
6521 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
6522 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
6523 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
6524 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
6525 /* our win event hook ignores OBJID_CURSOR events */
6526 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
6527 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
6528 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
6529 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
6530 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
6531 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
6532 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6533 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
6534 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
6535 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
6536 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
6537 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
6538 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
6539 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
6542 static const struct message WmWinEventCaretSeq[] = {
6543 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
6544 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
6545 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
6546 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
6549 static const struct message WmWinEventCaretSeq_2[] = {
6550 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
6551 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
6552 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
6555 static const struct message WmWinEventAlertSeq[] = {
6556 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
6559 static const struct message WmWinEventAlertSeq_2[] = {
6560 /* create window in the thread proc */
6561 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
6562 /* our test event */
6563 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
6566 static const struct message WmGlobalHookSeq_1[] = {
6567 /* create window in the thread proc */
6568 { HCBT_CREATEWND, hook|lparam, 0, 2 },
6569 /* our test events */
6570 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
6571 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
6574 static const struct message WmGlobalHookSeq_2[] = {
6575 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
6576 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
6577 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
6578 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
6582 static const struct message WmMouseLLHookSeq[] = {
6583 { WM_MOUSEMOVE, hook },
6584 { WM_LBUTTONUP, hook },
6585 { WM_MOUSEMOVE, hook },
6589 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
6599 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6600 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
6602 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6604 if (!lstrcmpiA(buf, "TestWindowClass") ||
6605 !lstrcmpiA(buf, "static"))
6609 msg.message = event;
6610 msg.flags = winevent_hook|wparam|lparam;
6611 msg.wParam = object_id;
6612 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
6618 static HHOOK hCBT_global_hook;
6619 static DWORD cbt_global_hook_thread_id;
6621 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6626 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
6628 if (nCode == HCBT_SYSCOMMAND)
6632 msg.message = nCode;
6633 msg.flags = hook|wparam|lparam;
6634 msg.wParam = wParam;
6635 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
6638 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6640 /* WH_MOUSE_LL hook */
6641 if (nCode == HC_ACTION)
6644 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
6646 /* we can't test for real mouse events */
6647 if (mhll->flags & LLMHF_INJECTED)
6649 msg.message = wParam;
6653 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6656 /* Log also SetFocus(0) calls */
6657 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
6659 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6661 if (!lstrcmpiA(buf, "TestWindowClass") ||
6662 !lstrcmpiA(buf, "static"))
6666 msg.message = nCode;
6667 msg.flags = hook|wparam|lparam;
6668 msg.wParam = wParam;
6669 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
6673 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6676 static DWORD WINAPI win_event_global_thread_proc(void *param)
6680 HANDLE hevent = *(HANDLE *)param;
6681 HMODULE user32 = GetModuleHandleA("user32.dll");
6682 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
6684 assert(pNotifyWinEvent);
6686 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6688 trace("created thread window %p\n", hwnd);
6690 *(HWND *)param = hwnd;
6693 /* this event should be received only by our new hook proc,
6694 * an old one does not expect an event from another thread.
6696 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
6699 while (GetMessage(&msg, 0, 0, 0))
6701 TranslateMessage(&msg);
6702 DispatchMessage(&msg);
6707 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
6711 HANDLE hevent = *(HANDLE *)param;
6714 /* these events should be received only by our new hook proc,
6715 * an old one does not expect an event from another thread.
6718 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6720 trace("created thread window %p\n", hwnd);
6722 *(HWND *)param = hwnd;
6724 /* Windows doesn't like when a thread plays games with the focus,
6725 that leads to all kinds of misbehaviours and failures to activate
6726 a window. So, better keep next lines commented out.
6730 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6731 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6735 while (GetMessage(&msg, 0, 0, 0))
6737 TranslateMessage(&msg);
6738 DispatchMessage(&msg);
6743 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
6747 HANDLE hevent = *(HANDLE *)param;
6749 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6751 trace("created thread window %p\n", hwnd);
6753 *(HWND *)param = hwnd;
6757 /* Windows doesn't like when a thread plays games with the focus,
6758 * that leads to all kinds of misbehaviours and failures to activate
6759 * a window. So, better don't generate a mouse click message below.
6761 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
6762 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6763 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
6766 while (GetMessage(&msg, 0, 0, 0))
6768 TranslateMessage(&msg);
6769 DispatchMessage(&msg);
6774 static void test_winevents(void)
6780 HANDLE hthread, hevent;
6782 HWINEVENTHOOK hhook;
6783 const struct message *events = WmWinEventsSeq;
6784 HMODULE user32 = GetModuleHandleA("user32.dll");
6785 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6786 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6787 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
6789 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
6790 WS_OVERLAPPEDWINDOW,
6791 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
6795 /****** start of global hook test *************/
6796 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6797 assert(hCBT_global_hook);
6799 hevent = CreateEventA(NULL, 0, 0, NULL);
6801 hwnd2 = (HWND)hevent;
6803 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
6804 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6806 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6808 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
6811 /* this one should be received only by old hook proc */
6812 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6813 /* this one should be received only by old hook proc */
6814 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6816 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
6818 ret = UnhookWindowsHookEx(hCBT_global_hook);
6819 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
6821 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6822 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6823 CloseHandle(hthread);
6824 CloseHandle(hevent);
6825 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6826 /****** end of global hook test *************/
6828 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
6830 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6838 /* this test doesn't pass under Win9x */
6839 /* win2k ignores events with hwnd == 0 */
6840 SetLastError(0xdeadbeef);
6841 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
6842 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
6843 GetLastError() == 0xdeadbeef, /* Win9x */
6844 "unexpected error %d\n", GetLastError());
6845 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6848 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
6849 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
6851 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
6853 /****** start of event filtering test *************/
6854 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6855 EVENT_OBJECT_SHOW, /* 0x8002 */
6856 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
6857 GetModuleHandleA(0), win_event_global_hook_proc,
6858 GetCurrentProcessId(), 0,
6859 WINEVENT_INCONTEXT);
6860 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
6862 hevent = CreateEventA(NULL, 0, 0, NULL);
6864 hwnd2 = (HWND)hevent;
6866 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6867 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6869 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6871 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
6874 /* this one should be received only by old hook proc */
6875 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6876 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6877 /* this one should be received only by old hook proc */
6878 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6880 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
6882 ret = pUnhookWinEvent(hhook);
6883 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
6885 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6886 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6887 CloseHandle(hthread);
6888 CloseHandle(hevent);
6889 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6890 /****** end of event filtering test *************/
6892 /****** start of out of context event test *************/
6893 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6894 EVENT_MIN, EVENT_MAX,
6895 0, win_event_global_hook_proc,
6896 GetCurrentProcessId(), 0,
6897 WINEVENT_OUTOFCONTEXT);
6898 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
6900 hevent = CreateEventA(NULL, 0, 0, NULL);
6902 hwnd2 = (HWND)hevent;
6906 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6907 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6909 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6911 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6912 /* process pending winevent messages */
6913 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6914 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
6917 /* this one should be received only by old hook proc */
6918 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6919 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6920 /* this one should be received only by old hook proc */
6921 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6923 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
6924 /* process pending winevent messages */
6925 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6926 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
6928 ret = pUnhookWinEvent(hhook);
6929 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
6931 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6932 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6933 CloseHandle(hthread);
6934 CloseHandle(hevent);
6935 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6936 /****** end of out of context event test *************/
6938 /****** start of MOUSE_LL hook test *************/
6939 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6940 /* WH_MOUSE_LL is not supported on Win9x platforms */
6941 if (!hCBT_global_hook)
6943 trace("Skipping WH_MOUSE_LL test on this platform\n");
6944 goto skip_mouse_ll_hook_test;
6947 hevent = CreateEventA(NULL, 0, 0, NULL);
6949 hwnd2 = (HWND)hevent;
6951 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
6952 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6954 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
6955 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6957 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
6960 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
6961 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6962 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
6964 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
6966 ret = UnhookWindowsHookEx(hCBT_global_hook);
6967 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
6969 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6970 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6971 CloseHandle(hthread);
6972 CloseHandle(hevent);
6973 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6974 /****** end of MOUSE_LL hook test *************/
6975 skip_mouse_ll_hook_test:
6977 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6980 static void test_set_hook(void)
6984 HWINEVENTHOOK hwinevent_hook;
6985 HMODULE user32 = GetModuleHandleA("user32.dll");
6986 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6987 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6989 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
6990 ok(hhook != 0, "local hook does not require hModule set to 0\n");
6991 UnhookWindowsHookEx(hhook);
6995 /* this test doesn't pass under Win9x: BUG! */
6996 SetLastError(0xdeadbeef);
6997 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
6998 ok(!hhook, "global hook requires hModule != 0\n");
6999 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
7002 SetLastError(0xdeadbeef);
7003 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
7004 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
7005 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
7006 GetLastError() == 0xdeadbeef, /* Win9x */
7007 "unexpected error %d\n", GetLastError());
7009 SetLastError(0xdeadbeef);
7010 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7011 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
7012 GetLastError() == 0xdeadbeef, /* Win9x */
7013 "unexpected error %d\n", GetLastError());
7015 if (!pSetWinEventHook || !pUnhookWinEvent) return;
7017 /* even process local incontext hooks require hmodule */
7018 SetLastError(0xdeadbeef);
7019 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7020 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
7021 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7022 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7023 GetLastError() == 0xdeadbeef, /* Win9x */
7024 "unexpected error %d\n", GetLastError());
7026 /* even thread local incontext hooks require hmodule */
7027 SetLastError(0xdeadbeef);
7028 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7029 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
7030 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7031 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7032 GetLastError() == 0xdeadbeef, /* Win9x */
7033 "unexpected error %d\n", GetLastError());
7037 /* these 3 tests don't pass under Win9x */
7038 SetLastError(0xdeadbeef);
7039 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
7040 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7041 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7042 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7044 SetLastError(0xdeadbeef);
7045 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
7046 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7047 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7048 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7050 SetLastError(0xdeadbeef);
7051 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7052 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
7053 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
7054 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
7057 SetLastError(0xdeadbeef);
7058 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
7059 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7060 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7061 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7062 ret = pUnhookWinEvent(hwinevent_hook);
7063 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7066 /* This call succeeds under win2k SP4, but fails under Wine.
7067 Does win2k test/use passed process id? */
7068 SetLastError(0xdeadbeef);
7069 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7070 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
7071 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7072 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7073 ret = pUnhookWinEvent(hwinevent_hook);
7074 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7077 SetLastError(0xdeadbeef);
7078 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
7079 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7080 GetLastError() == 0xdeadbeef, /* Win9x */
7081 "unexpected error %d\n", GetLastError());
7084 static const struct message ScrollWindowPaint1[] = {
7086 { WM_ERASEBKGND, sent|beginpaint },
7090 static const struct message ScrollWindowPaint2[] = {
7095 static void test_scrollwindowex(void)
7098 RECT rect={0,0,130,130};
7101 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7102 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
7103 100, 100, 200, 200, 0, 0, 0, NULL);
7104 ok (hwnd != 0, "Failed to create overlapped window\n");
7105 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
7106 WS_VISIBLE|WS_CAPTION|WS_CHILD,
7107 10, 10, 150, 150, hwnd, 0, 0, NULL);
7108 ok (hchild != 0, "Failed to create child\n");
7113 /* scroll without the child window */
7114 trace("start scroll\n");
7115 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7116 SW_ERASE|SW_INVALIDATE);
7117 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7118 trace("end scroll\n");
7120 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7121 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7125 /* Now without the SW_ERASE flag */
7126 trace("start scroll\n");
7127 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
7128 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7129 trace("end scroll\n");
7131 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7132 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
7136 /* now scroll the child window as well */
7137 trace("start scroll\n");
7138 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7139 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
7140 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7141 /* windows sometimes a WM_MOVE */
7142 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7144 trace("end scroll\n");
7146 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7147 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7151 /* now scroll with ScrollWindow() */
7152 trace("start scroll with ScrollWindow\n");
7153 ScrollWindow( hwnd, 5, 5, NULL, NULL);
7154 trace("end scroll\n");
7156 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7157 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
7159 ok(DestroyWindow(hchild), "failed to destroy window\n");
7160 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7164 static const struct message destroy_window_with_children[] = {
7165 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7166 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
7167 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
7168 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7169 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7170 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7171 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7172 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
7173 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7174 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7175 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7176 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7177 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7178 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7179 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7180 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7184 static void test_DestroyWindow(void)
7187 HWND parent, child1, child2, child3, child4, test;
7188 UINT child_id = WND_CHILD_ID + 1;
7190 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7191 100, 100, 200, 200, 0, 0, 0, NULL);
7192 assert(parent != 0);
7193 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7194 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
7195 assert(child1 != 0);
7196 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7197 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
7198 assert(child2 != 0);
7199 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7200 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
7201 assert(child3 != 0);
7202 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
7203 0, 0, 50, 50, parent, 0, 0, NULL);
7204 assert(child4 != 0);
7206 /* test owner/parent of child2 */
7207 test = GetParent(child2);
7208 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7209 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
7211 test = pGetAncestor(child2, GA_PARENT);
7212 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7214 test = GetWindow(child2, GW_OWNER);
7215 ok(!test, "wrong owner %p\n", test);
7217 test = SetParent(child2, parent);
7218 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
7220 /* test owner/parent of the parent */
7221 test = GetParent(parent);
7222 ok(!test, "wrong parent %p\n", test);
7224 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
7227 test = pGetAncestor(parent, GA_PARENT);
7228 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7230 test = GetWindow(parent, GW_OWNER);
7231 ok(!test, "wrong owner %p\n", test);
7233 /* test owner/parent of child1 */
7234 test = GetParent(child1);
7235 ok(test == parent, "wrong parent %p\n", test);
7236 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
7238 test = pGetAncestor(child1, GA_PARENT);
7239 ok(test == parent, "wrong parent %p\n", test);
7241 test = GetWindow(child1, GW_OWNER);
7242 ok(!test, "wrong owner %p\n", test);
7244 /* test owner/parent of child2 */
7245 test = GetParent(child2);
7246 ok(test == parent, "wrong parent %p\n", test);
7247 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
7249 test = pGetAncestor(child2, GA_PARENT);
7250 ok(test == parent, "wrong parent %p\n", test);
7252 test = GetWindow(child2, GW_OWNER);
7253 ok(!test, "wrong owner %p\n", test);
7255 /* test owner/parent of child3 */
7256 test = GetParent(child3);
7257 ok(test == child1, "wrong parent %p\n", test);
7258 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
7260 test = pGetAncestor(child3, GA_PARENT);
7261 ok(test == child1, "wrong parent %p\n", test);
7263 test = GetWindow(child3, GW_OWNER);
7264 ok(!test, "wrong owner %p\n", test);
7266 /* test owner/parent of child4 */
7267 test = GetParent(child4);
7268 ok(test == parent, "wrong parent %p\n", test);
7269 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
7271 test = pGetAncestor(child4, GA_PARENT);
7272 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7274 test = GetWindow(child4, GW_OWNER);
7275 ok(test == parent, "wrong owner %p\n", test);
7279 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
7280 parent, child1, child2, child3, child4);
7283 test = GetCapture();
7284 ok(test == child4, "wrong capture window %p\n", test);
7286 test_DestroyWindow_flag = TRUE;
7287 ret = DestroyWindow(parent);
7288 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7289 test_DestroyWindow_flag = FALSE;
7290 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
7292 ok(!IsWindow(parent), "parent still exists\n");
7293 ok(!IsWindow(child1), "child1 still exists\n");
7294 ok(!IsWindow(child2), "child2 still exists\n");
7295 ok(!IsWindow(child3), "child3 still exists\n");
7296 ok(!IsWindow(child4), "child4 still exists\n");
7298 test = GetCapture();
7299 ok(!test, "wrong capture window %p\n", test);
7303 static const struct message WmDispatchPaint[] = {
7304 { WM_NCPAINT, sent },
7305 { WM_GETTEXT, sent|defwinproc|optional },
7306 { WM_GETTEXT, sent|defwinproc|optional },
7307 { WM_ERASEBKGND, sent },
7311 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7313 if (message == WM_PAINT) return 0;
7314 return MsgCheckProcA( hwnd, message, wParam, lParam );
7317 static void test_DispatchMessage(void)
7322 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7323 100, 100, 200, 200, 0, 0, 0, NULL);
7324 ShowWindow( hwnd, SW_SHOW );
7325 UpdateWindow( hwnd );
7326 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7328 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
7330 SetRect( &rect, -5, -5, 5, 5 );
7331 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
7333 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
7335 if (msg.message != WM_PAINT) DispatchMessage( &msg );
7339 DispatchMessage( &msg );
7340 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
7341 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
7342 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
7343 if (++count > 10) break;
7346 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
7348 trace("now without DispatchMessage\n");
7350 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
7352 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
7354 if (msg.message != WM_PAINT) DispatchMessage( &msg );
7357 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
7359 /* this will send WM_NCCPAINT just like DispatchMessage does */
7360 GetUpdateRgn( hwnd, hrgn, TRUE );
7361 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
7362 DeleteObject( hrgn );
7363 GetClientRect( hwnd, &rect );
7364 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
7365 ok( !count, "Got multiple WM_PAINTs\n" );
7366 if (++count > 10) break;
7369 DestroyWindow(hwnd);
7373 static const struct message WmUser[] = {
7385 static DWORD CALLBACK send_msg_thread( LPVOID arg )
7387 struct sendmsg_info *info = arg;
7388 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
7389 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %d\n", GetLastError());
7393 static void wait_for_thread( HANDLE thread )
7395 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
7398 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
7402 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7404 if (message == WM_USER) Sleep(200);
7405 return MsgCheckProcA( hwnd, message, wParam, lParam );
7408 static void test_SendMessageTimeout(void)
7412 struct sendmsg_info info;
7415 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7416 100, 100, 200, 200, 0, 0, 0, NULL);
7417 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7420 info.timeout = 1000;
7421 info.ret = 0xdeadbeef;
7422 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7423 wait_for_thread( thread );
7424 CloseHandle( thread );
7425 ok( info.ret == 1, "SendMessageTimeout failed\n" );
7426 ok_sequence( WmUser, "WmUser", FALSE );
7429 info.ret = 0xdeadbeef;
7430 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7431 Sleep(100); /* SendMessageTimeout should timeout here */
7432 wait_for_thread( thread );
7433 CloseHandle( thread );
7434 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
7435 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
7437 /* 0 means infinite timeout */
7439 info.ret = 0xdeadbeef;
7440 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7442 wait_for_thread( thread );
7443 CloseHandle( thread );
7444 ok( info.ret == 1, "SendMessageTimeout failed\n" );
7445 ok_sequence( WmUser, "WmUser", FALSE );
7447 /* timeout is treated as signed despite the prototype */
7448 info.timeout = 0x7fffffff;
7449 info.ret = 0xdeadbeef;
7450 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7452 wait_for_thread( thread );
7453 CloseHandle( thread );
7454 ok( info.ret == 1, "SendMessageTimeout failed\n" );
7455 ok_sequence( WmUser, "WmUser", FALSE );
7457 info.timeout = 0x80000000;
7458 info.ret = 0xdeadbeef;
7459 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7461 wait_for_thread( thread );
7462 CloseHandle( thread );
7463 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
7464 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
7466 /* now check for timeout during message processing */
7467 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
7469 info.ret = 0xdeadbeef;
7470 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7471 wait_for_thread( thread );
7472 CloseHandle( thread );
7473 /* we should timeout but still get the message */
7474 ok( info.ret == 0, "SendMessageTimeout failed\n" );
7475 ok_sequence( WmUser, "WmUser", FALSE );
7477 DestroyWindow( info.hwnd );
7481 /****************** edit message test *************************/
7482 #define ID_EDIT 0x1234
7483 static const struct message sl_edit_setfocus[] =
7485 { HCBT_SETFOCUS, hook },
7486 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
7487 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7488 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7489 { WM_SETFOCUS, sent|wparam, 0 },
7490 { WM_CTLCOLOREDIT, sent|parent },
7491 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7492 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7493 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7496 static const struct message ml_edit_setfocus[] =
7498 { HCBT_SETFOCUS, hook },
7499 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
7500 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7501 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7502 { WM_SETFOCUS, sent|wparam, 0 },
7503 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7504 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7505 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7506 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7509 static const struct message sl_edit_killfocus[] =
7511 { HCBT_SETFOCUS, hook },
7512 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7513 { WM_KILLFOCUS, sent|wparam, 0 },
7514 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7515 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7516 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
7517 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
7518 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
7521 static const struct message sl_edit_lbutton_dblclk[] =
7523 { WM_LBUTTONDBLCLK, sent },
7524 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7527 static const struct message sl_edit_lbutton_down[] =
7529 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
7530 { HCBT_SETFOCUS, hook },
7531 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
7532 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7533 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7534 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
7535 { WM_CTLCOLOREDIT, sent|parent },
7536 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7537 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7538 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7539 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7540 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7541 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7542 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7543 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7546 static const struct message ml_edit_lbutton_down[] =
7548 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
7549 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7550 { HCBT_SETFOCUS, hook },
7551 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
7552 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7553 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7554 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
7555 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7556 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7557 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7560 static const struct message sl_edit_lbutton_up[] =
7562 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
7563 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7564 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
7565 { WM_CAPTURECHANGED, sent|defwinproc },
7566 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7569 static const struct message ml_edit_lbutton_up[] =
7571 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
7572 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
7573 { WM_CAPTURECHANGED, sent|defwinproc },
7577 static WNDPROC old_edit_proc;
7579 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7581 static long defwndproc_counter = 0;
7585 trace("edit: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
7587 /* explicitly ignore WM_GETICON message */
7588 if (message == WM_GETICON) return 0;
7590 msg.message = message;
7591 msg.flags = sent|wparam|lparam;
7592 if (defwndproc_counter) msg.flags |= defwinproc;
7593 msg.wParam = wParam;
7594 msg.lParam = lParam;
7597 defwndproc_counter++;
7598 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
7599 defwndproc_counter--;
7604 static void subclass_edit(void)
7608 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
7610 old_edit_proc = cls.lpfnWndProc;
7612 cls.hInstance = GetModuleHandle(0);
7613 cls.lpfnWndProc = edit_hook_proc;
7614 cls.lpszClassName = "my_edit_class";
7615 if (!RegisterClassA(&cls)) assert(0);
7618 static void test_edit_messages(void)
7624 log_all_parent_messages++;
7626 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
7627 100, 100, 200, 200, 0, 0, 0, NULL);
7628 ok (parent != 0, "Failed to create parent window\n");
7630 /* test single line edit */
7631 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
7632 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
7633 ok(hwnd != 0, "Failed to create edit window\n");
7635 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
7636 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
7638 ShowWindow(hwnd, SW_SHOW);
7644 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
7647 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
7653 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
7654 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
7660 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
7661 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
7663 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
7664 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
7666 DestroyWindow(hwnd);
7668 /* test multiline edit */
7669 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
7670 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
7671 ok(hwnd != 0, "Failed to create edit window\n");
7673 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
7674 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
7675 "wrong dlg_code %08x\n", dlg_code);
7677 ShowWindow(hwnd, SW_SHOW);
7683 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
7686 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
7692 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
7693 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
7699 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
7700 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
7702 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
7703 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
7705 DestroyWindow(hwnd);
7706 DestroyWindow(parent);
7708 log_all_parent_messages--;
7711 /**************************** End of Edit test ******************************/
7713 static const struct message WmKeyDownSkippedSeq[] =
7715 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
7718 static const struct message WmKeyUpSkippedSeq[] =
7720 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
7724 #define EV_START_STOP 0
7725 #define EV_SENDMSG 1
7731 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
7734 static DWORD CALLBACK send_msg_thread_2(void *param)
7737 struct peekmsg_info *info = param;
7739 trace("thread: waiting for start\n");
7740 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
7741 trace("thread: looping\n");
7745 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
7749 case WAIT_OBJECT_0 + EV_START_STOP:
7750 trace("thread: exiting\n");
7753 case WAIT_OBJECT_0 + EV_SENDMSG:
7754 trace("thread: sending message\n");
7755 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
7756 SetEvent(info->hevent[EV_ACK]);
7760 trace("unexpected return: %04x\n", ret);
7768 static void test_PeekMessage(void)
7773 UINT qs_all_input = QS_ALLINPUT;
7774 UINT qs_input = QS_INPUT;
7776 struct peekmsg_info info;
7778 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7779 100, 100, 200, 200, 0, 0, 0, NULL);
7781 ShowWindow(info.hwnd, SW_SHOW);
7782 UpdateWindow(info.hwnd);
7783 SetFocus(info.hwnd);
7785 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
7786 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
7787 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
7789 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
7792 trace("signalling to start looping\n");
7793 SetEvent(info.hevent[EV_START_STOP]);
7795 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7798 SetLastError(0xdeadbeef);
7799 qstatus = GetQueueStatus(qs_all_input);
7800 if (GetLastError() == ERROR_INVALID_FLAGS)
7802 trace("QS_RAWINPUT not supported on this platform\n");
7803 qs_all_input &= ~QS_RAWINPUT;
7804 qs_input &= ~QS_RAWINPUT;
7806 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
7808 trace("signalling to send message\n");
7809 SetEvent(info.hevent[EV_SENDMSG]);
7810 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7812 /* pass invalid QS_xxxx flags */
7813 SetLastError(0xdeadbeef);
7814 qstatus = GetQueueStatus(0xffffffff);
7815 ok(qstatus == 0, "GetQueueStatus should fail: %08x\n", qstatus);
7816 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
7818 qstatus = GetQueueStatus(qs_all_input);
7819 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
7820 "wrong qstatus %08x\n", qstatus);
7823 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
7825 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7827 ok_sequence(WmUser, "WmUser", FALSE);
7829 qstatus = GetQueueStatus(qs_all_input);
7830 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
7832 keybd_event('N', 0, 0, 0);
7833 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7834 qstatus = GetQueueStatus(qs_all_input);
7835 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
7836 "wrong qstatus %08x\n", qstatus);
7838 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7839 qstatus = GetQueueStatus(qs_all_input);
7840 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
7841 "wrong qstatus %08x\n", qstatus);
7843 InvalidateRect(info.hwnd, NULL, FALSE);
7844 qstatus = GetQueueStatus(qs_all_input);
7845 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7846 "wrong qstatus %08x\n", qstatus);
7848 trace("signalling to send message\n");
7849 SetEvent(info.hevent[EV_SENDMSG]);
7850 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7852 qstatus = GetQueueStatus(qs_all_input);
7853 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7854 "wrong qstatus %08x\n", qstatus);
7857 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
7860 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7863 ok_sequence(WmUser, "WmUser", FALSE);
7865 qstatus = GetQueueStatus(qs_all_input);
7867 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7868 "wrong qstatus %08x\n", qstatus);
7871 trace("signalling to send message\n");
7872 SetEvent(info.hevent[EV_SENDMSG]);
7873 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7875 qstatus = GetQueueStatus(qs_all_input);
7877 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7878 "wrong qstatus %08x\n", qstatus);
7882 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
7885 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7888 ok_sequence(WmUser, "WmUser", FALSE);
7890 qstatus = GetQueueStatus(qs_all_input);
7892 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7893 "wrong qstatus %08x\n", qstatus);
7897 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
7899 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
7900 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
7901 ret, msg.message, msg.wParam);
7903 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7905 qstatus = GetQueueStatus(qs_all_input);
7907 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
7908 "wrong qstatus %08x\n", qstatus);
7912 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
7915 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7918 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7920 qstatus = GetQueueStatus(qs_all_input);
7922 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
7923 "wrong qstatus %08x\n", qstatus);
7927 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
7928 ok(ret && msg.message == WM_PAINT,
7929 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
7930 DispatchMessageA(&msg);
7931 ok_sequence(WmPaint, "WmPaint", FALSE);
7933 qstatus = GetQueueStatus(qs_all_input);
7935 ok(qstatus == MAKELONG(0, QS_KEY),
7936 "wrong qstatus %08x\n", qstatus);
7940 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
7942 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7944 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7946 qstatus = GetQueueStatus(qs_all_input);
7948 ok(qstatus == MAKELONG(0, QS_KEY),
7949 "wrong qstatus %08x\n", qstatus);
7952 trace("signalling to send message\n");
7953 SetEvent(info.hevent[EV_SENDMSG]);
7954 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7956 qstatus = GetQueueStatus(qs_all_input);
7958 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
7959 "wrong qstatus %08x\n", qstatus);
7962 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7964 qstatus = GetQueueStatus(qs_all_input);
7966 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7967 "wrong qstatus %08x\n", qstatus);
7971 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
7972 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
7973 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
7974 ret, msg.message, msg.wParam);
7975 ok_sequence(WmUser, "WmUser", FALSE);
7977 qstatus = GetQueueStatus(qs_all_input);
7979 ok(qstatus == MAKELONG(0, QS_KEY),
7980 "wrong qstatus %08x\n", qstatus);
7984 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
7986 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7988 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7990 qstatus = GetQueueStatus(qs_all_input);
7992 ok(qstatus == MAKELONG(0, QS_KEY),
7993 "wrong qstatus %08x\n", qstatus);
7996 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7998 qstatus = GetQueueStatus(qs_all_input);
8000 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8001 "wrong qstatus %08x\n", qstatus);
8004 trace("signalling to send message\n");
8005 SetEvent(info.hevent[EV_SENDMSG]);
8006 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8008 qstatus = GetQueueStatus(qs_all_input);
8010 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8011 "wrong qstatus %08x\n", qstatus);
8015 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
8018 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8021 ok_sequence(WmUser, "WmUser", FALSE);
8023 qstatus = GetQueueStatus(qs_all_input);
8025 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8026 "wrong qstatus %08x\n", qstatus);
8030 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8032 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
8033 "got %d and %04x wParam %08x instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8034 ret, msg.message, msg.wParam);
8035 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
8038 qstatus = GetQueueStatus(qs_all_input);
8040 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8041 "wrong qstatus %08x\n", qstatus);
8045 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8047 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
8048 "got %d and %04x wParam %08x instead of TRUE and WM_KEYUP wParam 'N'\n",
8049 ret, msg.message, msg.wParam);
8050 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
8053 qstatus = GetQueueStatus(qs_all_input);
8055 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8056 "wrong qstatus %08x\n", qstatus);
8060 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
8062 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8064 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8066 qstatus = GetQueueStatus(qs_all_input);
8068 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8069 "wrong qstatus %08x\n", qstatus);
8073 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8075 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8076 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
8077 ret, msg.message, msg.wParam);
8079 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8081 qstatus = GetQueueStatus(qs_all_input);
8083 "wrong qstatus %08x\n", qstatus);
8086 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8088 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8090 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8092 qstatus = GetQueueStatus(qs_all_input);
8094 "wrong qstatus %08x\n", qstatus);
8096 /* test whether presence of the quit flag in the queue affects
8099 PostQuitMessage(0x1234abcd);
8101 qstatus = GetQueueStatus(qs_all_input);
8102 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8103 "wrong qstatus %08x\n", qstatus);
8105 PostMessageA(info.hwnd, WM_USER, 0, 0);
8107 qstatus = GetQueueStatus(qs_all_input);
8108 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8109 "wrong qstatus %08x\n", qstatus);
8112 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8113 ok(ret && msg.message == WM_USER,
8114 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
8115 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8117 qstatus = GetQueueStatus(qs_all_input);
8118 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8119 "wrong qstatus %08x\n", qstatus);
8122 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8123 ok(ret && msg.message == WM_QUIT,
8124 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
8125 ok(msg.wParam == 0x1234abcd, "got wParam %08x instead of 0x1234abcd\n", msg.wParam);
8126 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
8127 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8129 qstatus = GetQueueStatus(qs_all_input);
8131 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8132 "wrong qstatus %08x\n", qstatus);
8136 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8138 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8140 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8142 qstatus = GetQueueStatus(qs_all_input);
8144 "wrong qstatus %08x\n", qstatus);
8146 trace("signalling to exit\n");
8147 SetEvent(info.hevent[EV_START_STOP]);
8149 WaitForSingleObject(hthread, INFINITE);
8151 CloseHandle(hthread);
8152 CloseHandle(info.hevent[0]);
8153 CloseHandle(info.hevent[1]);
8154 CloseHandle(info.hevent[2]);
8156 DestroyWindow(info.hwnd);
8160 static void test_quit_message(void)
8165 /* test using PostQuitMessage */
8166 PostQuitMessage(0xbeef);
8168 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
8169 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
8170 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8171 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
8173 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
8174 ok(ret, "PostMessage failed with error %d\n", GetLastError());
8176 ret = GetMessage(&msg, NULL, 0, 0);
8177 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
8178 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
8180 /* note: WM_QUIT message received after WM_USER message */
8181 ret = GetMessage(&msg, NULL, 0, 0);
8182 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
8183 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8184 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
8186 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
8187 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
8189 /* now test with PostThreadMessage - different behaviour! */
8190 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
8192 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
8193 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
8194 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8195 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
8197 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
8198 ok(ret, "PostMessage failed with error %d\n", GetLastError());
8200 /* note: we receive the WM_QUIT message first this time */
8201 ret = GetMessage(&msg, NULL, 0, 0);
8202 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
8203 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8204 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
8206 ret = GetMessage(&msg, NULL, 0, 0);
8207 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
8208 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
8211 static const struct message WmMouseHoverSeq[] = {
8212 { WM_TIMER, sent|optional }, /* XP sends it */
8213 { WM_SYSTIMER, sent },
8214 { WM_MOUSEHOVER, sent|wparam, 0 },
8218 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
8221 DWORD start_ticks, end_ticks;
8223 start_ticks = GetTickCount();
8224 /* add some deviation (5%) to cover not expected delays */
8225 start_ticks += timeout / 20;
8229 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
8231 /* Timer proc messages are not dispatched to the window proc,
8232 * and therefore not logged.
8234 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
8236 struct message s_msg;
8238 s_msg.message = msg.message;
8239 s_msg.flags = sent|wparam|lparam;
8240 s_msg.wParam = msg.wParam;
8241 s_msg.lParam = msg.lParam;
8242 add_message(&s_msg);
8244 DispatchMessage(&msg);
8247 end_ticks = GetTickCount();
8249 /* inject WM_MOUSEMOVE to see how it changes tracking */
8250 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
8252 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8253 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8255 inject_mouse_move = FALSE;
8257 } while (start_ticks + timeout >= end_ticks);
8260 static void test_TrackMouseEvent(void)
8263 TRACKMOUSEEVENT tme;
8266 RECT rc_parent, rc_child;
8267 UINT default_hover_time, hover_width = 0, hover_height = 0;
8269 #define track_hover(track_hwnd, track_hover_time) \
8270 tme.cbSize = sizeof(tme); \
8271 tme.dwFlags = TME_HOVER; \
8272 tme.hwndTrack = track_hwnd; \
8273 tme.dwHoverTime = track_hover_time; \
8274 SetLastError(0xdeadbeef); \
8275 ret = TrackMouseEvent(&tme); \
8276 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
8278 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
8279 tme.cbSize = sizeof(tme); \
8280 tme.dwFlags = TME_QUERY; \
8281 tme.hwndTrack = (HWND)0xdeadbeef; \
8282 tme.dwHoverTime = 0xdeadbeef; \
8283 SetLastError(0xdeadbeef); \
8284 ret = TrackMouseEvent(&tme); \
8285 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
8286 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
8287 ok(tme.dwFlags == (expected_track_flags), \
8288 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
8289 ok(tme.hwndTrack == (expected_track_hwnd), \
8290 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
8291 ok(tme.dwHoverTime == (expected_hover_time), \
8292 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
8294 #define track_hover_cancel(track_hwnd) \
8295 tme.cbSize = sizeof(tme); \
8296 tme.dwFlags = TME_HOVER | TME_CANCEL; \
8297 tme.hwndTrack = track_hwnd; \
8298 tme.dwHoverTime = 0xdeadbeef; \
8299 SetLastError(0xdeadbeef); \
8300 ret = TrackMouseEvent(&tme); \
8301 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
8303 default_hover_time = 0xdeadbeef;
8304 SetLastError(0xdeadbeef);
8305 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
8306 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
8307 if (!ret) default_hover_time = 400;
8308 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
8310 SetLastError(0xdeadbeef);
8311 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
8312 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
8313 if (!ret) hover_width = 4;
8314 SetLastError(0xdeadbeef);
8315 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
8316 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
8317 if (!ret) hover_height = 4;
8318 trace("hover rect is %u x %d\n", hover_width, hover_height);
8320 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
8321 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8322 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8326 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
8327 WS_CHILD | WS_BORDER | WS_VISIBLE,
8328 50, 50, 200, 200, hwnd,
8336 tme.dwFlags = TME_QUERY;
8337 tme.hwndTrack = (HWND)0xdeadbeef;
8338 tme.dwHoverTime = 0xdeadbeef;
8339 SetLastError(0xdeadbeef);
8340 ret = TrackMouseEvent(&tme);
8341 ok(!ret, "TrackMouseEvent should fail\n");
8342 ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
8344 tme.cbSize = sizeof(tme);
8345 tme.dwFlags = TME_HOVER;
8346 tme.hwndTrack = (HWND)0xdeadbeef;
8347 tme.dwHoverTime = 0xdeadbeef;
8348 SetLastError(0xdeadbeef);
8349 ret = TrackMouseEvent(&tme);
8350 ok(!ret, "TrackMouseEvent should fail\n");
8351 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
8353 tme.cbSize = sizeof(tme);
8354 tme.dwFlags = TME_HOVER | TME_CANCEL;
8355 tme.hwndTrack = (HWND)0xdeadbeef;
8356 tme.dwHoverTime = 0xdeadbeef;
8357 SetLastError(0xdeadbeef);
8358 ret = TrackMouseEvent(&tme);
8359 ok(!ret, "TrackMouseEvent should fail\n");
8360 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
8362 GetWindowRect(hwnd, &rc_parent);
8363 GetWindowRect(hchild, &rc_child);
8364 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
8366 /* Process messages so that the system updates its internal current
8367 * window and hittest, otherwise TrackMouseEvent calls don't have any
8370 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8373 track_query(0, NULL, 0);
8374 track_hover(hchild, 0);
8375 track_query(0, NULL, 0);
8377 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8380 track_hover(hwnd, 0);
8381 track_query(TME_HOVER, hwnd, default_hover_time);
8383 pump_msg_loop_timeout(default_hover_time, FALSE);
8384 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
8386 track_query(0, NULL, 0);
8388 track_hover(hwnd, HOVER_DEFAULT);
8389 track_query(TME_HOVER, hwnd, default_hover_time);
8391 Sleep(default_hover_time / 2);
8392 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8393 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8395 track_query(TME_HOVER, hwnd, default_hover_time);
8397 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
8398 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
8400 track_query(0, NULL, 0);
8402 track_hover(hwnd, HOVER_DEFAULT);
8403 track_query(TME_HOVER, hwnd, default_hover_time);
8405 pump_msg_loop_timeout(default_hover_time, TRUE);
8406 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
8408 track_query(0, NULL, 0);
8410 track_hover(hwnd, HOVER_DEFAULT);
8411 track_query(TME_HOVER, hwnd, default_hover_time);
8412 track_hover_cancel(hwnd);
8414 DestroyWindow(hwnd);
8418 #undef track_hover_cancel
8422 static const struct message WmSetWindowRgn[] = {
8423 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8424 { WM_NCCALCSIZE, sent|wparam, 1 },
8425 { WM_NCPAINT, sent }, /* wparam != 1 */
8426 { WM_GETTEXT, sent|defwinproc|optional },
8427 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
8428 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8429 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8433 static const struct message WmSetWindowRgn_no_redraw[] = {
8434 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
8435 { WM_NCCALCSIZE, sent|wparam, 1 },
8436 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
8437 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8441 static const struct message WmSetWindowRgn_clear[] = {
8442 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8443 { WM_NCCALCSIZE, sent|wparam, 1 },
8444 { WM_NCPAINT, sent }, /* wparam != 1 */
8445 { WM_GETTEXT, sent|defwinproc|optional },
8446 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
8447 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8448 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
8449 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
8450 { WM_GETTEXT, sent|defwinproc|optional },
8451 { WM_ERASEBKGND, sent|optional },
8452 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8453 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8457 static void test_SetWindowRgn(void)
8460 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
8461 100, 100, 200, 200, 0, 0, 0, NULL);
8462 ok( hwnd != 0, "Failed to create overlapped window\n" );
8464 ShowWindow( hwnd, SW_SHOW );
8465 UpdateWindow( hwnd );
8469 trace("testing SetWindowRgn\n");
8470 hrgn = CreateRectRgn( 0, 0, 150, 150 );
8471 SetWindowRgn( hwnd, hrgn, TRUE );
8472 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
8474 hrgn = CreateRectRgn( 30, 30, 160, 160 );
8475 SetWindowRgn( hwnd, hrgn, FALSE );
8476 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
8478 hrgn = CreateRectRgn( 0, 0, 180, 180 );
8479 SetWindowRgn( hwnd, hrgn, TRUE );
8480 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
8482 SetWindowRgn( hwnd, 0, TRUE );
8483 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
8485 DestroyWindow( hwnd );
8488 /*************************** ShowWindow() test ******************************/
8489 static const struct message WmShowNormal[] = {
8490 { WM_SHOWWINDOW, sent|wparam, 1 },
8491 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8492 { HCBT_ACTIVATE, hook },
8493 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
8494 { HCBT_SETFOCUS, hook },
8495 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8498 static const struct message WmShow[] = {
8499 { WM_SHOWWINDOW, sent|wparam, 1 },
8500 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8501 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8502 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8503 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8504 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8507 static const struct message WmShowNoActivate_1[] = {
8508 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
8509 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
8510 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
8511 { WM_MOVE, sent|defwinproc },
8512 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8515 static const struct message WmShowNoActivate_2[] = {
8516 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
8517 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8518 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8519 { WM_MOVE, sent|defwinproc },
8520 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8521 { HCBT_SETFOCUS, hook },
8522 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
8523 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
8524 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
8527 static const struct message WmShowNA_1[] = {
8528 { WM_SHOWWINDOW, sent|wparam, 1 },
8529 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
8530 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8533 static const struct message WmShowNA_2[] = {
8534 { WM_SHOWWINDOW, sent|wparam, 1 },
8535 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
8538 static const struct message WmRestore_1[] = {
8539 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
8540 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8541 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8542 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8543 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8544 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8545 { WM_MOVE, sent|defwinproc },
8546 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8547 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
8550 static const struct message WmRestore_2[] = {
8551 { WM_SHOWWINDOW, sent|wparam, 1 },
8552 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8553 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8556 static const struct message WmRestore_3[] = {
8557 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
8558 { WM_GETMINMAXINFO, sent },
8559 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8560 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
8561 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
8562 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
8563 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8564 { WM_MOVE, sent|defwinproc },
8565 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8566 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
8569 static const struct message WmRestore_4[] = {
8570 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
8571 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8572 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8573 { WM_MOVE, sent|defwinproc },
8574 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8577 static const struct message WmRestore_5[] = {
8578 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
8579 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8580 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8581 { WM_MOVE, sent|defwinproc },
8582 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8585 static const struct message WmHide_1[] = {
8586 { WM_SHOWWINDOW, sent|wparam, 0 },
8587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8588 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8589 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
8592 static const struct message WmHide_2[] = {
8593 { WM_SHOWWINDOW, sent|wparam, 0 },
8594 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8595 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8598 static const struct message WmHide_3[] = {
8599 { WM_SHOWWINDOW, sent|wparam, 0 },
8600 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8601 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8602 { HCBT_SETFOCUS, hook },
8605 static const struct message WmShowMinimized_1[] = {
8606 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
8607 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8608 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8609 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8610 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8611 { WM_MOVE, sent|defwinproc },
8612 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8615 static const struct message WmMinimize_1[] = {
8616 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8617 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8618 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8619 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8620 { WM_MOVE, sent|defwinproc },
8621 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8624 static const struct message WmMinimize_2[] = {
8625 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8626 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8627 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8628 { WM_MOVE, sent|defwinproc },
8629 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8632 static const struct message WmMinimize_3[] = {
8633 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8634 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8635 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8636 { WM_MOVE, sent|defwinproc },
8637 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8640 static const struct message WmShowMinNoActivate[] = {
8641 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
8642 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
8643 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8646 static const struct message WmMinMax_1[] = {
8647 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
8650 static const struct message WmMinMax_2[] = {
8651 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8654 static const struct message WmMinMax_3[] = {
8655 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8658 static const struct message WmMinMax_4[] = {
8659 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
8662 static const struct message WmShowMaximized_1[] = {
8663 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8664 { WM_GETMINMAXINFO, sent },
8665 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8666 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8667 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8668 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8669 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8670 { WM_MOVE, sent|defwinproc },
8671 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8672 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
8675 static const struct message WmShowMaximized_2[] = {
8676 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8677 { WM_GETMINMAXINFO, sent },
8678 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
8679 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8680 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
8681 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
8682 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8683 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8684 { WM_MOVE, sent|defwinproc },
8685 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8686 { HCBT_SETFOCUS, hook },
8689 static const struct message WmShowMaximized_3[] = {
8690 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8691 { WM_GETMINMAXINFO, sent },
8692 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8693 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8694 { WM_MOVE, sent|defwinproc },
8695 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8699 static void test_ShowWindow(void)
8701 /* ShowWindow commands in random order */
8704 INT cmd; /* ShowWindow command */
8705 LPARAM ret; /* ShowWindow return value */
8706 DWORD style; /* window style after the command */
8707 const struct message *msg; /* message sequence the command produces */
8708 BOOL todo_msg; /* message sequence doesn't match what Wine does */
8711 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
8712 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8713 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
8714 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8715 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
8716 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
8717 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
8718 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
8719 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
8720 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
8721 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
8722 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
8723 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
8724 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8725 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
8726 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8727 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
8728 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8729 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, TRUE },
8730 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
8731 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8732 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
8733 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
8734 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8735 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
8736 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
8737 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
8738 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8739 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
8740 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
8741 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8742 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, TRUE },
8743 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8744 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, TRUE }, /* what does this mean?! */
8745 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, TRUE },
8746 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8747 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
8748 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8749 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8750 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, TRUE },
8751 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
8752 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
8753 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
8754 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, TRUE },
8755 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
8756 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
8757 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
8758 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
8759 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
8760 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
8761 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8762 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
8763 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8764 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, TRUE },
8765 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8766 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
8767 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
8774 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
8775 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
8780 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
8781 ok(style == 0, "expected style 0, got %08x\n", style);
8786 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
8788 static const char * const sw_cmd_name[13] =
8790 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
8791 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
8792 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
8793 "SW_NORMALNA" /* 0xCC */
8796 INT idx; /* index into the above array of names */
8798 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
8800 style = GetWindowLong(hwnd, GWL_STYLE);
8801 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
8802 ret = ShowWindow(hwnd, sw[i].cmd);
8803 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
8804 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
8805 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
8807 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
8808 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
8814 DestroyWindow(hwnd);
8820 HMODULE user32 = GetModuleHandleA("user32.dll");
8821 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
8822 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
8823 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
8824 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
8826 if (!RegisterWindowClasses()) assert(0);
8828 if (pSetWinEventHook)
8830 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8831 GetModuleHandleA(0),
8834 GetCurrentThreadId(),
8835 WINEVENT_INCONTEXT);
8836 assert(hEvent_hook);
8838 if (pIsWinEventHookInstalled)
8841 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
8842 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
8846 cbt_hook_thread_id = GetCurrentThreadId();
8847 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
8852 /* Fix message sequences before removing 4 lines below */
8854 if (pUnhookWinEvent && hEvent_hook)
8856 ret = pUnhookWinEvent(hEvent_hook);
8857 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8858 pUnhookWinEvent = 0;
8865 test_scrollwindowex();
8868 invisible_parent_tests();
8869 test_mdi_messages();
8870 test_button_messages();
8871 test_static_messages();
8872 test_paint_messages();
8873 test_interthread_messages();
8874 test_message_conversion();
8875 test_accelerators();
8878 test_DestroyWindow();
8879 test_DispatchMessage();
8880 test_SendMessageTimeout();
8881 test_edit_messages();
8882 test_quit_message();
8883 test_TrackMouseEvent();
8884 test_SetWindowRgn();
8887 UnhookWindowsHookEx(hCBT_hook);
8888 if (pUnhookWinEvent)
8890 ret = pUnhookWinEvent(hEvent_hook);
8891 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8892 SetLastError(0xdeadbeef);
8893 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
8894 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
8895 GetLastError() == 0xdeadbeef, /* Win9x */
8896 "unexpected error %d\n", GetLastError());