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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #define _WIN32_WINNT 0x0500 /* For WM_CHANGEUISTATE */
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 WND_PARENT_ID 1
44 #define WND_POPUP_ID 2
45 #define WND_CHILD_ID 3
47 static BOOL test_DestroyWindow_flag;
48 static HWINEVENTHOOK hEvent_hook;
50 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
53 FIXME: add tests for these
54 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
55 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
56 WS_THICKFRAME: thick border
57 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
58 WS_BORDER (default for overlapped windows): single black border
59 none (default for child (and popup?) windows): no border
76 UINT message; /* the WM_* code */
77 msg_flags_t flags; /* message props */
78 WPARAM wParam; /* expected value of wParam */
79 LPARAM lParam; /* expected value of lParam */
82 /* Empty message sequence */
83 static const struct message WmEmptySeq[] =
87 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
88 static const struct message WmCreateOverlappedSeq[] = {
89 { HCBT_CREATEWND, hook },
90 { WM_GETMINMAXINFO, sent },
91 { WM_NCCREATE, sent },
92 { WM_NCCALCSIZE, sent|wparam, 0 },
93 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
95 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
98 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
99 * for a not visible overlapped window.
101 static const struct message WmSWP_ShowOverlappedSeq[] = {
102 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
103 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
104 { WM_NCPAINT, sent|wparam|optional, 1 },
105 { WM_GETTEXT, sent|defwinproc|optional },
106 { WM_ERASEBKGND, sent|optional },
107 { HCBT_ACTIVATE, hook },
108 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
109 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
110 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
111 { WM_ACTIVATEAPP, sent|wparam, 1 },
112 { WM_NCACTIVATE, sent|wparam, 1 },
113 { WM_GETTEXT, sent|defwinproc|optional },
114 { WM_ACTIVATE, sent|wparam, 1 },
115 { HCBT_SETFOCUS, hook },
116 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
117 { WM_IME_NOTIFY, sent|defwinproc|optional },
118 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
119 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
120 { WM_NCPAINT, sent|wparam|optional, 1 },
121 { WM_GETTEXT, sent|defwinproc|optional },
122 { WM_ERASEBKGND, sent|optional },
123 /* Win9x adds SWP_NOZORDER below */
124 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
125 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
126 { WM_NCPAINT, sent|wparam|optional, 1 },
127 { WM_ERASEBKGND, sent|optional },
130 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
131 * for a visible overlapped window.
133 static const struct message WmSWP_HideOverlappedSeq[] = {
134 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
135 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
136 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
140 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
141 * for a visible overlapped window.
143 static const struct message WmSWP_ResizeSeq[] = {
144 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE },
145 { WM_GETMINMAXINFO, sent|defwinproc },
146 { WM_NCCALCSIZE, sent|wparam, TRUE },
147 { WM_NCPAINT, sent|optional },
148 { WM_GETTEXT, sent|defwinproc|optional },
149 { WM_ERASEBKGND, sent|optional },
150 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
151 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
152 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
153 { WM_NCPAINT, sent|optional },
154 { WM_GETTEXT, sent|defwinproc|optional },
155 { WM_ERASEBKGND, sent|optional },
156 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
160 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
161 * for a visible popup window.
163 static const struct message WmSWP_ResizePopupSeq[] = {
164 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE },
165 { WM_NCCALCSIZE, sent|wparam, TRUE },
166 { WM_NCPAINT, sent|optional },
167 { WM_GETTEXT, sent|defwinproc|optional },
168 { WM_ERASEBKGND, sent|optional },
169 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
170 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
171 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
172 { WM_NCPAINT, sent|optional },
173 { WM_GETTEXT, sent|defwinproc|optional },
174 { WM_ERASEBKGND, sent|optional },
175 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
179 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
180 * for a visible overlapped window.
182 static const struct message WmSWP_MoveSeq[] = {
183 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE },
184 { WM_NCPAINT, sent|optional },
185 { WM_GETTEXT, sent|defwinproc|optional },
186 { WM_ERASEBKGND, sent|optional },
187 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE },
188 { WM_MOVE, sent|defwinproc|wparam, 0 },
189 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
193 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
194 SWP_NOZORDER|SWP_FRAMECHANGED)
195 * for a visible overlapped window with WS_CLIPCHILDREN style set.
197 static const struct message WmSWP_FrameChanged_clip[] = {
198 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
199 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
200 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
201 { WM_GETTEXT, sent|parent|defwinproc|optional },
202 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
203 { WM_NCPAINT, sent }, /* wparam != 1 */
204 { WM_ERASEBKGND, sent },
205 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
209 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
210 SWP_NOZORDER|SWP_FRAMECHANGED)
211 * for a visible overlapped window.
213 static const struct message WmSWP_FrameChangedDeferErase[] = {
214 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
215 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
216 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
217 { WM_PAINT, sent|parent },
218 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
219 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
221 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
222 { WM_ERASEBKGND, sent|beginpaint },
226 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
227 SWP_NOZORDER|SWP_FRAMECHANGED)
228 * for a visible overlapped window without WS_CLIPCHILDREN style set.
230 static const struct message WmSWP_FrameChanged_noclip[] = {
231 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
232 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
233 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
234 { WM_GETTEXT, sent|parent|defwinproc|optional },
235 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
236 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
238 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
239 { WM_ERASEBKGND, sent|beginpaint },
243 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
244 static const struct message WmShowOverlappedSeq[] = {
245 { WM_SHOWWINDOW, sent|wparam, 1 },
246 { WM_NCPAINT, sent|wparam|optional, 1 },
247 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
248 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
249 { WM_NCPAINT, sent|wparam|optional, 1 },
250 { WM_GETTEXT, sent|defwinproc|optional },
251 { WM_ERASEBKGND, sent|optional },
252 { HCBT_ACTIVATE, hook },
253 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
254 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
255 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
256 { WM_ACTIVATEAPP, sent|wparam, 1 },
257 { WM_NCACTIVATE, sent|wparam, 1 },
258 { WM_GETTEXT, sent|defwinproc|optional },
259 { WM_ACTIVATE, sent|wparam, 1 },
260 { HCBT_SETFOCUS, hook },
261 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
262 { WM_IME_NOTIFY, sent|defwinproc|optional },
263 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
264 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
265 { WM_NCPAINT, sent|wparam|optional, 1 },
266 { WM_GETTEXT, sent|defwinproc|optional },
267 { WM_ERASEBKGND, sent|optional },
268 /* Win9x adds SWP_NOZORDER below */
269 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
270 { WM_NCCALCSIZE, sent|optional },
271 { WM_NCPAINT, sent|optional },
272 { WM_ERASEBKGND, sent|optional },
273 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
274 * messages. Does that mean that CreateWindow doesn't set initial
275 * window dimensions for overlapped windows?
282 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
283 static const struct message WmShowMaxOverlappedSeq[] = {
284 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
285 { WM_GETMINMAXINFO, sent },
286 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
287 { WM_GETMINMAXINFO, sent|defwinproc },
288 { WM_NCCALCSIZE, sent|wparam, TRUE },
289 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
290 { HCBT_ACTIVATE, hook },
291 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
292 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
293 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
294 { WM_ACTIVATEAPP, sent|wparam, 1 },
295 { WM_NCACTIVATE, sent|wparam, 1 },
296 { WM_GETTEXT, sent|defwinproc|optional },
297 { WM_ACTIVATE, sent|wparam, 1 },
298 { HCBT_SETFOCUS, hook },
299 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
300 { WM_IME_NOTIFY, sent|defwinproc|optional },
301 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
302 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
303 { WM_NCPAINT, sent|wparam|optional, 1 },
304 { WM_GETTEXT, sent|defwinproc|optional },
305 { WM_ERASEBKGND, sent|optional },
306 /* Win9x adds SWP_NOZORDER below */
307 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
308 { WM_MOVE, sent|defwinproc },
309 { WM_SIZE, sent|defwinproc },
310 { WM_NCCALCSIZE, sent|optional },
311 { WM_NCPAINT, sent|optional },
312 { WM_ERASEBKGND, sent|optional },
313 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
314 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
317 /* ShowWindow(SW_HIDE) for a visible overlapped window */
318 static const struct message WmHideOverlappedSeq[] = {
319 { WM_SHOWWINDOW, sent|wparam, 0 },
320 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
321 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
322 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
325 { WM_NCACTIVATE, sent|wparam, 0 },
326 { WM_ACTIVATE, sent|wparam, 0 },
327 { WM_ACTIVATEAPP, sent|wparam, 0 },
328 { WM_KILLFOCUS, sent|wparam, 0 },
329 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
330 { WM_IME_NOTIFY, sent|optional|defwinproc },
333 /* DestroyWindow for a visible overlapped window */
334 static const struct message WmDestroyOverlappedSeq[] = {
335 { HCBT_DESTROYWND, hook },
336 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
337 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
338 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
339 { WM_NCACTIVATE, sent|wparam, 0 },
340 { WM_ACTIVATE, sent|wparam, 0 },
341 { WM_ACTIVATEAPP, sent|wparam, 0 },
342 { WM_KILLFOCUS, sent|wparam, 0 },
343 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
344 { WM_IME_NOTIFY, sent|optional|defwinproc },
345 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
346 { WM_DESTROY, sent },
347 { WM_NCDESTROY, sent },
350 /* CreateWindow (for a child popup window, not initially visible) */
351 static const struct message WmCreateChildPopupSeq[] = {
352 { HCBT_CREATEWND, hook },
353 { WM_NCCREATE, sent },
354 { WM_NCCALCSIZE, sent|wparam, 0 },
356 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
361 /* CreateWindow (for a popup window, not initially visible,
362 * which sets WS_VISIBLE in WM_CREATE handler)
364 static const struct message WmCreateInvisiblePopupSeq[] = {
365 { HCBT_CREATEWND, hook },
366 { WM_NCCREATE, sent },
367 { WM_NCCALCSIZE, sent|wparam, 0 },
369 { WM_STYLECHANGING, sent },
370 { WM_STYLECHANGED, sent },
371 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
376 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
377 * for a popup window with WS_VISIBLE style set
379 static const struct message WmShowVisiblePopupSeq_2[] = {
380 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
383 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
384 * for a popup window with WS_VISIBLE style set
386 static const struct message WmShowVisiblePopupSeq_3[] = {
387 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
388 { HCBT_ACTIVATE, hook },
389 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
390 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
391 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
392 { WM_NCACTIVATE, sent|wparam, 1 },
393 { WM_ACTIVATE, sent|wparam, 1 },
394 { HCBT_SETFOCUS, hook },
395 { WM_KILLFOCUS, sent|parent },
396 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
397 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
398 { WM_IME_NOTIFY, sent|defwinproc|optional },
399 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
400 { WM_SETFOCUS, sent|defwinproc },
403 /* CreateWindow (for child window, not initially visible) */
404 static const struct message WmCreateChildSeq[] = {
405 { HCBT_CREATEWND, hook },
406 { WM_NCCREATE, sent },
407 /* child is inserted into parent's child list after WM_NCCREATE returns */
408 { WM_NCCALCSIZE, sent|wparam, 0 },
410 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
413 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
416 /* CreateWindow (for maximized child window, not initially visible) */
417 static const struct message WmCreateMaximizedChildSeq[] = {
418 { HCBT_CREATEWND, hook },
419 { WM_NCCREATE, sent },
420 { WM_NCCALCSIZE, sent|wparam, 0 },
422 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
425 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
426 { WM_GETMINMAXINFO, sent },
427 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
428 { WM_NCCALCSIZE, sent|wparam, 1 },
429 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
430 { WM_SIZE, sent|defwinproc },
431 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
432 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
435 /* CreateWindow (for a child window, initially visible) */
436 static const struct message WmCreateVisibleChildSeq[] = {
437 { HCBT_CREATEWND, hook },
438 { WM_NCCREATE, sent },
439 /* child is inserted into parent's child list after WM_NCCREATE returns */
440 { WM_NCCALCSIZE, sent|wparam, 0 },
441 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
443 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
446 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
447 { WM_SHOWWINDOW, sent|wparam, 1 },
448 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
449 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
450 { WM_ERASEBKGND, sent|parent|optional },
451 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
452 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
455 /* ShowWindow(SW_SHOW) for a not visible child window */
456 static const struct message WmShowChildSeq[] = {
457 { WM_SHOWWINDOW, sent|wparam, 1 },
458 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
459 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
460 { WM_ERASEBKGND, sent|parent|optional },
461 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
464 /* ShowWindow(SW_HIDE) for a visible child window */
465 static const struct message WmHideChildSeq[] = {
466 { WM_SHOWWINDOW, sent|wparam, 0 },
467 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
468 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
469 { WM_ERASEBKGND, sent|parent|optional },
470 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
473 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
474 * for a not visible child window
476 static const struct message WmShowChildSeq_2[] = {
477 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
478 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
479 { WM_CHILDACTIVATE, sent },
480 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
483 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
484 * for a not visible child window
486 static const struct message WmShowChildSeq_3[] = {
487 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
488 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
489 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
492 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
493 * for a visible child window with a caption
495 static const struct message WmShowChildSeq_4[] = {
496 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
497 { WM_CHILDACTIVATE, sent },
500 /* ShowWindow(SW_SHOW) for child with invisible parent */
501 static const struct message WmShowChildInvisibleParentSeq[] = {
502 { WM_SHOWWINDOW, sent|wparam, 1 },
505 /* ShowWindow(SW_HIDE) for child with invisible parent */
506 static const struct message WmHideChildInvisibleParentSeq[] = {
507 { WM_SHOWWINDOW, sent|wparam, 0 },
510 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
511 static const struct message WmShowChildInvisibleParentSeq_2[] = {
512 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
513 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
514 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
517 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
518 static const struct message WmHideChildInvisibleParentSeq_2[] = {
519 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
520 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
521 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
524 /* DestroyWindow for a visible child window */
525 static const struct message WmDestroyChildSeq[] = {
526 { HCBT_DESTROYWND, hook },
527 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
528 { WM_SHOWWINDOW, sent|wparam, 0 },
529 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
530 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
531 { WM_ERASEBKGND, sent|parent|optional },
532 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
533 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
534 { WM_KILLFOCUS, sent },
535 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
536 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
537 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
538 { WM_SETFOCUS, sent|parent },
539 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
540 { WM_DESTROY, sent },
541 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
542 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
543 { WM_NCDESTROY, sent },
546 /* Moving the mouse in nonclient area */
547 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
548 { WM_NCHITTEST, sent },
549 { WM_SETCURSOR, sent },
550 { WM_NCMOUSEMOVE, posted },
553 /* Moving the mouse in client area */
554 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
555 { WM_NCHITTEST, sent },
556 { WM_SETCURSOR, sent },
557 { WM_MOUSEMOVE, posted },
560 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
561 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
562 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
563 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
564 { WM_GETMINMAXINFO, sent|defwinproc },
565 { WM_ENTERSIZEMOVE, sent|defwinproc },
566 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
567 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
568 { WM_MOVE, sent|defwinproc },
569 { WM_EXITSIZEMOVE, sent|defwinproc },
572 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
573 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
574 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
575 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
576 { WM_GETMINMAXINFO, sent|defwinproc },
577 { WM_ENTERSIZEMOVE, sent|defwinproc },
578 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
579 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
580 { WM_GETMINMAXINFO, sent|defwinproc },
581 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
582 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
583 { WM_GETTEXT, sent|defwinproc },
584 { WM_ERASEBKGND, sent|defwinproc },
585 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
586 { WM_MOVE, sent|defwinproc },
587 { WM_SIZE, sent|defwinproc },
588 { WM_EXITSIZEMOVE, sent|defwinproc },
591 /* Resizing child window with MoveWindow (32) */
592 static const struct message WmResizingChildWithMoveWindowSeq[] = {
593 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
594 { WM_NCCALCSIZE, sent|wparam, 1 },
595 { WM_ERASEBKGND, sent|optional },
596 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
597 { WM_MOVE, sent|defwinproc },
598 { WM_SIZE, sent|defwinproc },
599 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
602 /* Clicking on inactive button */
603 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
604 { WM_NCHITTEST, sent },
605 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
606 { WM_MOUSEACTIVATE, sent },
607 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
608 { WM_SETCURSOR, sent },
609 { WM_SETCURSOR, sent|parent|defwinproc },
610 { WM_LBUTTONDOWN, posted },
611 { WM_KILLFOCUS, posted|parent },
612 { WM_SETFOCUS, posted },
613 { WM_CTLCOLORBTN, posted|parent },
614 { BM_SETSTATE, posted },
615 { WM_CTLCOLORBTN, posted|parent },
616 { WM_LBUTTONUP, posted },
617 { BM_SETSTATE, posted },
618 { WM_CTLCOLORBTN, posted|parent },
619 { WM_COMMAND, posted|parent },
622 /* Reparenting a button (16/32) */
623 /* The last child (button) reparented gets topmost for its new parent. */
624 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
625 { WM_SHOWWINDOW, sent|wparam, 0 },
626 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
627 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
628 { WM_ERASEBKGND, sent|parent },
629 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
630 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOZORDER },
631 { WM_CHILDACTIVATE, sent },
632 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER },
633 { WM_MOVE, sent|defwinproc },
634 { WM_SHOWWINDOW, sent|wparam, 1 },
637 /* Creation of a custom dialog (32) */
638 static const struct message WmCreateCustomDialogSeq[] = {
639 { HCBT_CREATEWND, hook },
640 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
641 { WM_GETMINMAXINFO, sent },
642 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
643 { WM_NCCREATE, sent },
644 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
645 { WM_NCCALCSIZE, sent|wparam, 0 },
646 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
647 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
649 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
650 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
651 { WM_SHOWWINDOW, sent|wparam, 1 },
652 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
653 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
654 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
655 { HCBT_ACTIVATE, hook },
656 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
658 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
660 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
661 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
663 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
665 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
666 { WM_NCACTIVATE, sent|wparam, 1 },
667 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
668 { WM_GETTEXT, sent|optional|defwinproc },
669 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
670 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
671 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
672 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
673 { WM_GETTEXT, sent|optional|defwinproc },
674 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
675 { WM_ACTIVATE, sent|wparam, 1 },
676 { WM_KILLFOCUS, sent|parent },
677 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
678 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
679 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
680 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
681 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
682 { WM_IME_NOTIFY, sent|optional|defwinproc },
683 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
684 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
685 { WM_SETFOCUS, sent },
686 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
687 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
688 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
689 { WM_NCPAINT, sent|wparam, 1 },
690 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
691 { WM_GETTEXT, sent|optional|defwinproc },
692 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
693 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
694 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
695 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
696 { WM_GETTEXT, sent|optional|defwinproc },
697 { WM_ERASEBKGND, sent },
698 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
699 { WM_CTLCOLORDLG, sent|defwinproc },
700 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
701 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
702 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
703 { WM_GETTEXT, sent|optional },
704 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
705 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
706 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
707 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
708 { WM_GETTEXT, sent|optional },
709 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
710 { WM_NCCALCSIZE, sent|optional },
711 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
712 { WM_NCPAINT, sent|optional },
713 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
714 { WM_GETTEXT, sent|optional|defwinproc },
715 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
716 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
717 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
718 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
719 { WM_GETTEXT, sent|optional|defwinproc },
720 { WM_ERASEBKGND, sent|optional },
721 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
722 { WM_CTLCOLORDLG, sent|optional|defwinproc },
724 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
728 /* Calling EndDialog for a custom dialog (32) */
729 static const struct message WmEndCustomDialogSeq[] = {
730 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
731 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
732 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
733 { WM_GETTEXT, sent|optional },
734 { HCBT_ACTIVATE, hook },
735 { WM_NCACTIVATE, sent|wparam, 0 },
736 { WM_GETTEXT, sent|optional|defwinproc },
737 { WM_GETTEXT, sent|optional|defwinproc },
738 { WM_ACTIVATE, sent|wparam, 0 },
739 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
740 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
741 { HCBT_SETFOCUS, hook },
742 { WM_KILLFOCUS, sent },
743 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
744 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
745 { WM_IME_NOTIFY, sent|optional },
746 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
747 { WM_SETFOCUS, sent|parent|defwinproc },
750 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
751 static const struct message WmShowCustomDialogSeq[] = {
752 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
753 { WM_SHOWWINDOW, sent|wparam, 1 },
754 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
755 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
756 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
757 { HCBT_ACTIVATE, hook },
758 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
760 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
761 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
763 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
764 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
765 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
766 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
767 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
768 { WM_NCACTIVATE, sent|wparam, 1 },
769 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
770 { WM_ACTIVATE, sent|wparam, 1 },
772 { WM_KILLFOCUS, sent|parent },
773 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
774 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
775 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
776 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
777 { WM_IME_NOTIFY, sent|optional|defwinproc },
778 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
779 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
780 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
781 { WM_SETFOCUS, sent },
782 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
783 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
784 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
785 { WM_NCPAINT, sent|wparam, 1 },
786 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
787 { WM_ERASEBKGND, sent },
788 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
789 { WM_CTLCOLORDLG, sent|defwinproc },
791 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
792 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
795 /* Creation and destruction of a modal dialog (32) */
796 static const struct message WmModalDialogSeq[] = {
797 { WM_CANCELMODE, sent|parent },
798 { HCBT_SETFOCUS, hook },
799 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
800 { WM_KILLFOCUS, sent|parent },
801 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
802 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
803 { WM_ENABLE, sent|parent|wparam, 0 },
804 { HCBT_CREATEWND, hook },
805 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
806 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
807 { WM_SETFONT, sent },
808 { WM_INITDIALOG, sent },
809 { WM_CHANGEUISTATE, sent|optional },
810 { WM_SHOWWINDOW, sent },
811 { HCBT_ACTIVATE, hook },
812 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
813 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
814 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
815 { WM_NCACTIVATE, sent|wparam, 1 },
816 { WM_GETTEXT, sent|optional },
817 { WM_ACTIVATE, sent|wparam, 1 },
818 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE },
819 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
820 { WM_NCPAINT, sent },
821 { WM_GETTEXT, sent|optional },
822 { WM_ERASEBKGND, sent },
823 { WM_CTLCOLORDLG, sent },
824 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
825 { WM_GETTEXT, sent|optional },
826 { WM_NCCALCSIZE, sent|optional },
827 { WM_NCPAINT, sent|optional },
828 { WM_GETTEXT, sent|optional },
829 { WM_ERASEBKGND, sent|optional },
830 { WM_CTLCOLORDLG, sent|optional },
831 { WM_PAINT, sent|optional },
832 { WM_CTLCOLORBTN, sent },
833 { WM_ENTERIDLE, sent|parent|optional },
834 { WM_ENTERIDLE, sent|parent|optional },
835 { WM_ENTERIDLE, sent|parent|optional },
836 { WM_ENTERIDLE, sent|parent|optional },
837 { WM_ENTERIDLE, sent|parent|optional },
838 { WM_ENTERIDLE, sent|parent|optional },
839 { WM_ENTERIDLE, sent|parent|optional },
840 { WM_ENTERIDLE, sent|parent|optional },
841 { WM_ENTERIDLE, sent|parent|optional },
842 { WM_ENTERIDLE, sent|parent|optional },
843 { WM_ENTERIDLE, sent|parent|optional },
844 { WM_ENTERIDLE, sent|parent|optional },
845 { WM_ENTERIDLE, sent|parent|optional },
846 { WM_ENTERIDLE, sent|parent|optional },
847 { WM_ENTERIDLE, sent|parent|optional },
848 { WM_ENTERIDLE, sent|parent|optional },
849 { WM_ENTERIDLE, sent|parent|optional },
850 { WM_ENTERIDLE, sent|parent|optional },
851 { WM_ENTERIDLE, sent|parent|optional },
852 { WM_ENTERIDLE, sent|parent|optional },
854 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
855 { WM_ENABLE, sent|parent|wparam, 1 },
856 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE },
857 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
858 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
859 { WM_GETTEXT, sent|optional },
860 { HCBT_ACTIVATE, hook },
861 { WM_NCACTIVATE, sent|wparam, 0 },
862 { WM_GETTEXT, sent|optional },
863 { WM_ACTIVATE, sent|wparam, 0 },
864 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
865 { WM_WINDOWPOSCHANGING, sent|optional },
866 { HCBT_SETFOCUS, hook },
867 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
868 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
869 { WM_SETFOCUS, sent|parent|defwinproc },
870 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
871 { HCBT_DESTROYWND, hook },
872 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
873 { WM_DESTROY, sent },
874 { WM_NCDESTROY, sent },
877 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
878 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
879 /* (inside dialog proc, handling WM_INITDIALOG) */
880 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
881 { WM_NCCALCSIZE, sent },
882 { WM_NCACTIVATE, sent|parent|wparam, 0 },
883 { WM_GETTEXT, sent|defwinproc },
884 { WM_ACTIVATE, sent|parent|wparam, 0 },
885 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
886 { WM_WINDOWPOSCHANGING, sent|parent },
887 { WM_NCACTIVATE, sent|wparam, 1 },
888 { WM_ACTIVATE, sent|wparam, 1 },
889 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
890 { WM_SIZE, sent|defwinproc },
891 /* (setting focus) */
892 { WM_SHOWWINDOW, sent|wparam, 1 },
893 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
894 { WM_NCPAINT, sent },
895 { WM_GETTEXT, sent|defwinproc },
896 { WM_ERASEBKGND, sent },
897 { WM_CTLCOLORDLG, sent|defwinproc },
898 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
900 /* (bunch of WM_CTLCOLOR* for each control) */
901 { WM_PAINT, sent|parent },
902 { WM_ENTERIDLE, sent|parent|wparam, 0 },
903 { WM_SETCURSOR, sent|parent },
906 /* SetMenu for NonVisible windows with size change*/
907 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
908 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
909 { WM_NCCALCSIZE, sent|wparam, 1 },
910 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
911 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW },
912 { WM_MOVE, sent|defwinproc },
913 { WM_SIZE, sent|defwinproc },
914 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
915 { WM_GETTEXT, sent|optional },
916 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
919 /* SetMenu for NonVisible windows with no size change */
920 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
921 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
922 { WM_NCCALCSIZE, sent|wparam, 1 },
923 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
924 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
927 /* SetMenu for Visible windows with size change */
928 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
929 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
930 { WM_NCCALCSIZE, sent|wparam, 1 },
931 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
932 { WM_NCPAINT, sent }, /* wparam != 1 */
933 { WM_GETTEXT, sent|defwinproc|optional },
934 { WM_ERASEBKGND, sent|optional },
935 { WM_ACTIVATE, sent|optional },
936 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
937 { WM_MOVE, sent|defwinproc },
938 { WM_SIZE, sent|defwinproc },
939 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
940 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
941 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
942 { WM_ERASEBKGND, sent|optional },
945 /* SetMenu for Visible windows with no size change */
946 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
947 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
948 { WM_NCCALCSIZE, sent|wparam, 1 },
949 { WM_NCPAINT, sent }, /* wparam != 1 */
950 { WM_GETTEXT, sent|defwinproc|optional },
951 { WM_ERASEBKGND, sent|optional },
952 { WM_ACTIVATE, sent|optional },
953 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
954 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
957 /* DrawMenuBar for a visible window */
958 static const struct message WmDrawMenuBarSeq[] =
960 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
961 { WM_NCCALCSIZE, sent|wparam, 1 },
962 { WM_NCPAINT, sent }, /* wparam != 1 */
963 { WM_GETTEXT, sent|defwinproc|optional },
964 { WM_ERASEBKGND, sent|optional },
965 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
966 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
970 static const struct message WmSetRedrawFalseSeq[] =
972 { WM_SETREDRAW, sent|wparam, 0 },
976 static const struct message WmSetRedrawTrueSeq[] =
978 { WM_SETREDRAW, sent|wparam, 1 },
982 static const struct message WmEnableWindowSeq_1[] =
984 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
985 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
986 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
990 static const struct message WmEnableWindowSeq_2[] =
992 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
993 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
997 static const struct message WmGetScrollRangeSeq[] =
999 { SBM_GETRANGE, sent },
1002 static const struct message WmGetScrollInfoSeq[] =
1004 { SBM_GETSCROLLINFO, sent },
1007 static const struct message WmSetScrollRangeSeq[] =
1009 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1010 sends SBM_SETSCROLLINFO.
1012 { SBM_SETSCROLLINFO, sent },
1015 /* SetScrollRange for a window without a non-client area */
1016 static const struct message WmSetScrollRangeHSeq_empty[] =
1018 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1021 static const struct message WmSetScrollRangeVSeq_empty[] =
1023 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1026 static const struct message WmSetScrollRangeHVSeq[] =
1028 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
1029 { WM_NCCALCSIZE, sent|wparam, 1 },
1030 { WM_GETTEXT, sent|defwinproc|optional },
1031 { WM_ERASEBKGND, sent|optional },
1032 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1033 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1036 /* SetScrollRange for a window with a non-client area */
1037 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1039 { WM_WINDOWPOSCHANGING, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER*/ },
1040 { WM_NCCALCSIZE, sent|wparam, 1 },
1041 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1042 { WM_NCPAINT, sent|optional },
1043 { WM_GETTEXT, sent|defwinproc|optional },
1044 { WM_GETTEXT, sent|defwinproc|optional },
1045 { WM_ERASEBKGND, sent|optional },
1046 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1047 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|0x1000*/ },
1048 { WM_SIZE, sent|defwinproc },
1049 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1050 { WM_GETTEXT, sent|optional },
1051 { WM_GETTEXT, sent|optional },
1052 { WM_GETTEXT, sent|optional },
1053 { WM_GETTEXT, sent|optional },
1056 /* test if we receive the right sequence of messages */
1057 /* after calling ShowWindow( SW_SHOWNA) */
1058 static const struct message WmSHOWNAChildInvisParInvis[] = {
1059 { WM_SHOWWINDOW, sent|wparam, 1 },
1062 static const struct message WmSHOWNAChildVisParInvis[] = {
1063 { WM_SHOWWINDOW, sent|wparam, 1 },
1066 static const struct message WmSHOWNAChildVisParVis[] = {
1067 { WM_SHOWWINDOW, sent|wparam, 1 },
1068 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
1071 static const struct message WmSHOWNAChildInvisParVis[] = {
1072 { WM_SHOWWINDOW, sent|wparam, 1 },
1073 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER},
1074 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1075 { WM_ERASEBKGND, sent|optional },
1076 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1079 static const struct message WmSHOWNATopVisible[] = {
1080 { WM_SHOWWINDOW, sent|wparam, 1 },
1081 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1084 static const struct message WmSHOWNATopInvisible[] = {
1085 { WM_SHOWWINDOW, sent|wparam, 1 },
1086 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1087 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1088 { WM_NCPAINT, sent|wparam, 1 },
1089 { WM_GETTEXT, sent|defwinproc|optional },
1090 { WM_ERASEBKGND, sent|optional },
1091 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1092 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1093 { WM_NCPAINT, sent|wparam|optional, 1 },
1094 { WM_ERASEBKGND, sent|optional },
1100 static int after_end_dialog;
1101 static int sequence_cnt, sequence_size;
1102 static struct message* sequence;
1103 static int log_all_parent_messages;
1105 static void add_message(const struct message *msg)
1110 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1112 if (sequence_cnt == sequence_size)
1115 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1119 sequence[sequence_cnt].message = msg->message;
1120 sequence[sequence_cnt].flags = msg->flags;
1121 sequence[sequence_cnt].wParam = msg->wParam;
1122 sequence[sequence_cnt].lParam = msg->lParam;
1127 static void flush_sequence(void)
1129 HeapFree(GetProcessHeap(), 0, sequence);
1131 sequence_cnt = sequence_size = 0;
1134 #define ok_sequence( exp, contx, todo) \
1135 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1138 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1139 const char *file, int line)
1141 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1142 const struct message *actual;
1145 add_message(&end_of_sequence);
1149 while (expected->message && actual->message)
1151 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1153 if (expected->message == actual->message)
1155 if (expected->flags & wparam)
1157 if (expected->wParam != actual->wParam && todo)
1161 ok_( file, line) (FALSE,
1162 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1163 context, expected->message, expected->wParam, actual->wParam);
1167 ok_( file, line) (expected->wParam == actual->wParam,
1168 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1169 context, expected->message, expected->wParam, actual->wParam);
1171 if (expected->flags & lparam)
1172 ok_( file, line) (expected->lParam == actual->lParam,
1173 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1174 context, expected->message, expected->lParam, actual->lParam);
1175 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1176 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1177 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1178 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1179 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1180 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1181 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1182 "%s: the msg 0x%04x should have been %s\n",
1183 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1184 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1185 "%s: the msg 0x%04x was expected in %s\n",
1186 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1187 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1188 "%s: the msg 0x%04x should have been sent by a hook\n",
1189 context, expected->message);
1190 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1191 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1192 context, expected->message);
1196 /* silently drop winevent messages if there is no support for them */
1197 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1203 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1204 context, expected->message, actual->message);
1211 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1212 context, expected->message, actual->message);
1218 /* skip all optional trailing messages */
1219 while (expected->message && ((expected->flags & optional) ||
1220 ((expected->flags & winevent_hook) && !hEvent_hook)))
1226 if (expected->message || actual->message) {
1228 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1229 context, expected->message, actual->message);
1235 if (expected->message || actual->message)
1236 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1237 context, expected->message, actual->message);
1239 if( todo && !failcount) /* succeeded yet marked todo */
1241 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1247 /******************************** MDI test **********************************/
1249 /* CreateWindow for MDI frame window, initially visible */
1250 static const struct message WmCreateMDIframeSeq[] = {
1251 { HCBT_CREATEWND, hook },
1252 { WM_GETMINMAXINFO, sent },
1253 { WM_NCCREATE, sent },
1254 { WM_NCCALCSIZE, sent|wparam, 0 },
1255 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1256 { WM_CREATE, sent },
1257 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1258 { WM_SHOWWINDOW, sent|wparam, 1 },
1259 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1260 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1261 { HCBT_ACTIVATE, hook },
1262 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1263 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1264 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1265 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* Win9x */
1266 { WM_ACTIVATEAPP, sent|wparam, 1 },
1267 { WM_NCACTIVATE, sent|wparam, 1 },
1268 { WM_GETTEXT, sent|defwinproc|optional },
1269 { WM_ACTIVATE, sent|wparam, 1 },
1270 { HCBT_SETFOCUS, hook },
1271 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1272 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1273 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1274 /* Win9x adds SWP_NOZORDER below */
1275 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
1280 /* DestroyWindow for MDI frame window, initially visible */
1281 static const struct message WmDestroyMDIframeSeq[] = {
1282 { HCBT_DESTROYWND, hook },
1283 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1284 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1285 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1286 { WM_NCACTIVATE, sent|wparam, 0 },
1287 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1288 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1289 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1290 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1291 { WM_DESTROY, sent },
1292 { WM_NCDESTROY, sent },
1295 /* CreateWindow for MDI client window, initially visible */
1296 static const struct message WmCreateMDIclientSeq[] = {
1297 { HCBT_CREATEWND, hook },
1298 { WM_NCCREATE, sent },
1299 { WM_NCCALCSIZE, sent|wparam, 0 },
1300 { WM_CREATE, sent },
1301 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1304 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1305 { WM_SHOWWINDOW, sent|wparam, 1 },
1306 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1307 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1308 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1311 /* DestroyWindow for MDI client window, initially visible */
1312 static const struct message WmDestroyMDIclientSeq[] = {
1313 { HCBT_DESTROYWND, hook },
1314 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1315 { WM_SHOWWINDOW, sent|wparam, 0 },
1316 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1317 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1318 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1319 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1320 { WM_DESTROY, sent },
1321 { WM_NCDESTROY, sent },
1324 /* CreateWindow for MDI child window, initially visible */
1325 static const struct message WmCreateMDIchildVisibleSeq[] = {
1326 { HCBT_CREATEWND, hook },
1327 { WM_NCCREATE, sent },
1328 { WM_NCCALCSIZE, sent|wparam, 0 },
1329 { WM_CREATE, sent },
1330 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1333 /* Win2k sends wparam set to
1334 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1335 * while Win9x doesn't bother to set child window id according to
1336 * CLIENTCREATESTRUCT.idFirstChild
1338 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1339 { WM_SHOWWINDOW, sent|wparam, 1 },
1340 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1341 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1342 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1343 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1344 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1345 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1346 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1348 /* Win9x: message sequence terminates here. */
1350 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1351 { HCBT_SETFOCUS, hook }, /* in MDI client */
1352 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1353 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1354 { WM_SETFOCUS, sent }, /* in MDI client */
1355 { HCBT_SETFOCUS, hook },
1356 { WM_KILLFOCUS, sent }, /* in MDI client */
1357 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1358 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1359 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1360 { WM_SETFOCUS, sent|defwinproc },
1361 { WM_MDIACTIVATE, sent|defwinproc },
1364 /* DestroyWindow for MDI child window, initially visible */
1365 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1366 { HCBT_DESTROYWND, hook },
1367 /* Win2k sends wparam set to
1368 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1369 * while Win9x doesn't bother to set child window id according to
1370 * CLIENTCREATESTRUCT.idFirstChild
1372 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1373 { WM_SHOWWINDOW, sent|wparam, 0 },
1374 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1375 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1376 { WM_ERASEBKGND, sent|parent|optional },
1377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1379 /* { WM_DESTROY, sent }
1380 * Win9x: message sequence terminates here.
1383 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1384 { WM_KILLFOCUS, sent },
1385 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1386 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1387 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1388 { WM_SETFOCUS, sent }, /* in MDI client */
1390 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1391 { WM_KILLFOCUS, sent }, /* in MDI client */
1392 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1393 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1394 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1395 { WM_SETFOCUS, sent }, /* in MDI client */
1397 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1399 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1400 { WM_KILLFOCUS, sent },
1401 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1402 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1403 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1404 { WM_SETFOCUS, sent }, /* in MDI client */
1406 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1407 { WM_KILLFOCUS, sent }, /* in MDI client */
1408 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1409 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1410 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1411 { WM_SETFOCUS, sent }, /* in MDI client */
1413 { WM_DESTROY, sent },
1415 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1416 { WM_KILLFOCUS, sent },
1417 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1418 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1419 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1420 { WM_SETFOCUS, sent }, /* in MDI client */
1422 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1423 { WM_KILLFOCUS, sent }, /* in MDI client */
1424 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1425 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1426 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1427 { WM_SETFOCUS, sent }, /* in MDI client */
1429 { WM_NCDESTROY, sent },
1432 /* CreateWindow for MDI child window, initially invisible */
1433 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1434 { HCBT_CREATEWND, hook },
1435 { WM_NCCREATE, sent },
1436 { WM_NCCALCSIZE, sent|wparam, 0 },
1437 { WM_CREATE, sent },
1438 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1441 /* Win2k sends wparam set to
1442 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1443 * while Win9x doesn't bother to set child window id according to
1444 * CLIENTCREATESTRUCT.idFirstChild
1446 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1449 /* DestroyWindow for MDI child window, initially invisible */
1450 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1451 { HCBT_DESTROYWND, hook },
1452 /* Win2k sends wparam set to
1453 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1454 * while Win9x doesn't bother to set child window id according to
1455 * CLIENTCREATESTRUCT.idFirstChild
1457 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1458 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1459 { WM_DESTROY, sent },
1460 { WM_NCDESTROY, sent },
1463 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1464 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1465 { HCBT_CREATEWND, hook },
1466 { WM_NCCREATE, sent },
1467 { WM_NCCALCSIZE, sent|wparam, 0 },
1468 { WM_CREATE, sent },
1469 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1472 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1473 { WM_GETMINMAXINFO, sent },
1474 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1475 { WM_NCCALCSIZE, sent|wparam, 1 },
1476 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1477 { WM_SIZE, sent|defwinproc },
1479 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1480 { WM_NCCALCSIZE, sent|wparam, 1 },
1481 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1482 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1483 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1484 /* Win2k sends wparam set to
1485 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1486 * while Win9x doesn't bother to set child window id according to
1487 * CLIENTCREATESTRUCT.idFirstChild
1489 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1490 { WM_SHOWWINDOW, sent|wparam, 1 },
1491 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1492 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1493 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1494 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1495 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1496 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1497 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1499 /* Win9x: message sequence terminates here. */
1501 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1502 { HCBT_SETFOCUS, hook }, /* in MDI client */
1503 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1504 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1505 { WM_SETFOCUS, sent }, /* in MDI client */
1506 { HCBT_SETFOCUS, hook },
1507 { WM_KILLFOCUS, sent }, /* in MDI client */
1508 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1509 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1510 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1511 { WM_SETFOCUS, sent|defwinproc },
1512 { WM_MDIACTIVATE, sent|defwinproc },
1514 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1515 { WM_NCCALCSIZE, sent|wparam, 1 },
1516 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1517 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1520 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1521 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
1522 /* restore the 1st MDI child */
1523 { WM_SETREDRAW, sent|wparam, 0 },
1524 { HCBT_MINMAX, hook },
1525 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1526 { WM_NCCALCSIZE, sent|wparam, 1 },
1527 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1528 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1529 { WM_SIZE, sent|defwinproc },
1531 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1532 { WM_NCCALCSIZE, sent|wparam, 1 },
1533 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1534 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1535 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1536 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
1537 /* create the 2nd MDI child */
1538 { HCBT_CREATEWND, hook },
1539 { WM_NCCREATE, sent },
1540 { WM_NCCALCSIZE, sent|wparam, 0 },
1541 { WM_CREATE, sent },
1542 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1545 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1546 { WM_GETMINMAXINFO, sent },
1547 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1548 { WM_NCCALCSIZE, sent|wparam, 1 },
1549 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1550 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1551 { WM_SIZE, sent|defwinproc },
1553 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1554 { WM_NCCALCSIZE, sent|wparam, 1 },
1555 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1556 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1557 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1558 /* Win2k sends wparam set to
1559 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1560 * while Win9x doesn't bother to set child window id according to
1561 * CLIENTCREATESTRUCT.idFirstChild
1563 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1564 { WM_SHOWWINDOW, sent|wparam, 1 },
1565 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1566 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1567 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1568 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1569 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1570 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1572 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1573 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1575 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1577 /* Win9x: message sequence terminates here. */
1579 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1580 { HCBT_SETFOCUS, hook },
1581 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
1582 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
1583 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1584 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1585 { WM_SETFOCUS, sent }, /* in MDI client */
1586 { HCBT_SETFOCUS, hook },
1587 { WM_KILLFOCUS, sent }, /* in MDI client */
1588 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1589 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1590 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1591 { WM_SETFOCUS, sent|defwinproc },
1593 { WM_MDIACTIVATE, sent|defwinproc },
1595 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1596 { WM_NCCALCSIZE, sent|wparam, 1 },
1597 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1598 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1601 /* WM_MDICREATE MDI child window, initially visible and maximized */
1602 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
1603 { WM_MDICREATE, sent },
1604 { HCBT_CREATEWND, hook },
1605 { WM_NCCREATE, sent },
1606 { WM_NCCALCSIZE, sent|wparam, 0 },
1607 { WM_CREATE, sent },
1608 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1611 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1612 { WM_GETMINMAXINFO, sent },
1613 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1614 { WM_NCCALCSIZE, sent|wparam, 1 },
1615 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1616 { WM_SIZE, sent|defwinproc },
1619 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1620 { WM_NCCALCSIZE, sent|wparam, 1 },
1621 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1622 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1623 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1625 /* Win2k sends wparam set to
1626 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1627 * while Win9x doesn't bother to set child window id according to
1628 * CLIENTCREATESTRUCT.idFirstChild
1630 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1631 { WM_SHOWWINDOW, sent|wparam, 1 },
1632 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1634 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1636 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1637 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1638 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1640 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1641 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1643 /* Win9x: message sequence terminates here. */
1645 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1646 { HCBT_SETFOCUS, hook }, /* in MDI client */
1647 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1648 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1649 { WM_SETFOCUS, sent }, /* in MDI client */
1650 { HCBT_SETFOCUS, hook },
1651 { WM_KILLFOCUS, sent }, /* in MDI client */
1652 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1653 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1654 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1655 { WM_SETFOCUS, sent|defwinproc },
1657 { WM_MDIACTIVATE, sent|defwinproc },
1660 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1661 { WM_NCCALCSIZE, sent|wparam, 1 },
1662 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1663 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1666 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1667 { WM_NCCALCSIZE, sent|wparam, 1 },
1668 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1669 { WM_MOVE, sent|defwinproc },
1670 { WM_SIZE, sent|defwinproc },
1673 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1674 { WM_NCCALCSIZE, sent|wparam, 1 },
1675 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1679 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1680 { WM_NCCALCSIZE, sent|wparam, 1 },
1681 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1682 { WM_SIZE, sent|defwinproc },
1684 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1685 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1686 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1690 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
1691 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
1692 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
1693 { HCBT_SYSCOMMAND, hook },
1694 { WM_CLOSE, sent|defwinproc },
1695 { WM_MDIDESTROY, sent }, /* in MDI client */
1697 /* bring the 1st MDI child to top */
1698 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
1699 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
1701 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1703 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
1704 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1705 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1707 /* maximize the 1st MDI child */
1708 { HCBT_MINMAX, hook },
1709 { WM_GETMINMAXINFO, sent|defwinproc },
1710 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
1711 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1712 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
1713 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1714 { WM_SIZE, sent|defwinproc },
1716 /* restore the 2nd MDI child */
1717 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
1718 { HCBT_MINMAX, hook },
1719 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOZORDER|0x8000 },
1720 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1722 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1724 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1725 { WM_SIZE, sent|defwinproc },
1727 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1729 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
1731 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1732 { WM_NCCALCSIZE, sent|wparam, 1 },
1733 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1734 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1735 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1737 /* bring the 1st MDI child to top */
1738 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1739 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1740 { HCBT_SETFOCUS, hook },
1741 { WM_KILLFOCUS, sent|defwinproc },
1742 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
1743 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1744 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1745 { WM_SETFOCUS, sent }, /* in MDI client */
1746 { HCBT_SETFOCUS, hook },
1747 { WM_KILLFOCUS, sent }, /* in MDI client */
1748 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1749 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1750 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1751 { WM_SETFOCUS, sent|defwinproc },
1752 { WM_MDIACTIVATE, sent|defwinproc },
1753 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1755 /* apparently ShowWindow(SW_SHOW) on an MDI client */
1756 { WM_SHOWWINDOW, sent|wparam, 1 },
1757 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1758 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1759 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1760 { WM_MDIREFRESHMENU, sent },
1762 { HCBT_DESTROYWND, hook },
1763 /* Win2k sends wparam set to
1764 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1765 * while Win9x doesn't bother to set child window id according to
1766 * CLIENTCREATESTRUCT.idFirstChild
1768 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1769 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
1770 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1771 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1772 { WM_ERASEBKGND, sent|parent|optional },
1773 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1775 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1776 { WM_DESTROY, sent|defwinproc },
1777 { WM_NCDESTROY, sent|defwinproc },
1780 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
1781 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
1782 { WM_MDIDESTROY, sent }, /* in MDI client */
1783 { WM_SHOWWINDOW, sent|wparam, 0 },
1784 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1785 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1786 { WM_ERASEBKGND, sent|parent|optional },
1787 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1789 { HCBT_SETFOCUS, hook },
1790 { WM_KILLFOCUS, sent },
1791 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1792 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1793 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1794 { WM_SETFOCUS, sent }, /* in MDI client */
1795 { HCBT_SETFOCUS, hook },
1796 { WM_KILLFOCUS, sent }, /* in MDI client */
1797 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1798 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1799 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1800 { WM_SETFOCUS, sent },
1803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1804 { WM_NCCALCSIZE, sent|wparam, 1 },
1805 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1806 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1809 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1810 { WM_NCCALCSIZE, sent|wparam, 1 },
1811 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1812 { WM_MOVE, sent|defwinproc },
1813 { WM_SIZE, sent|defwinproc },
1816 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1817 { WM_NCCALCSIZE, sent|wparam, 1 },
1818 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1822 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1823 { WM_NCCALCSIZE, sent|wparam, 1 },
1824 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
1825 { WM_SIZE, sent|defwinproc },
1828 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1829 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
1830 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1831 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1834 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1835 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
1836 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1837 { WM_MOVE, sent|defwinproc },
1838 { WM_SIZE, sent|defwinproc },
1841 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1842 { WM_NCCALCSIZE, sent|wparam, 1 },
1843 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1847 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOZORDER },
1848 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
1849 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
1850 { WM_SIZE, sent|defwinproc },
1851 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1852 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1853 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1854 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1855 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1856 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1859 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1860 { WM_NCCALCSIZE, sent|wparam, 1 },
1861 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1862 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1864 { WM_NCACTIVATE, sent|wparam, 0 },
1865 { WM_MDIACTIVATE, sent },
1867 { HCBT_MINMAX, hook },
1868 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
1869 { WM_NCCALCSIZE, sent|wparam, 1 },
1871 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1873 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1874 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE|0x8000 },
1875 { WM_SIZE, sent|defwinproc },
1878 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1879 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
1880 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1881 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1884 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1885 { WM_NCCALCSIZE, sent|wparam, 1 },
1886 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1887 { WM_MOVE, sent|defwinproc },
1888 { WM_SIZE, sent|defwinproc },
1891 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1892 { WM_NCCALCSIZE, sent|wparam, 1 },
1893 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1895 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1896 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1897 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1899 { HCBT_SETFOCUS, hook },
1900 { WM_KILLFOCUS, sent },
1901 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1902 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1903 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1904 { WM_SETFOCUS, sent }, /* in MDI client */
1906 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1908 { HCBT_DESTROYWND, hook },
1909 /* Win2k sends wparam set to
1910 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1911 * while Win9x doesn't bother to set child window id according to
1912 * CLIENTCREATESTRUCT.idFirstChild
1914 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1916 { WM_SHOWWINDOW, sent|wparam, 0 },
1917 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1918 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1919 { WM_ERASEBKGND, sent|parent|optional },
1920 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1922 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1923 { WM_DESTROY, sent },
1924 { WM_NCDESTROY, sent },
1927 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
1928 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
1929 { HCBT_MINMAX, hook },
1930 { WM_GETMINMAXINFO, sent },
1931 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
1932 { WM_NCCALCSIZE, sent|wparam, 1 },
1933 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1934 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1936 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1937 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1938 { HCBT_SETFOCUS, hook },
1939 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1940 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1941 { WM_SETFOCUS, sent }, /* in MDI client */
1942 { HCBT_SETFOCUS, hook },
1943 { WM_KILLFOCUS, sent }, /* in MDI client */
1944 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1945 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1946 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1947 { WM_SETFOCUS, sent|defwinproc },
1948 { WM_MDIACTIVATE, sent|defwinproc },
1949 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1950 { WM_SIZE, sent|defwinproc },
1952 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1953 { WM_NCCALCSIZE, sent|wparam, 1 },
1954 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1955 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1956 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1959 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
1960 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
1961 { HCBT_MINMAX, hook },
1962 { WM_GETMINMAXINFO, sent },
1963 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1964 { WM_NCCALCSIZE, sent|wparam, 1 },
1965 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1966 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1967 { WM_SIZE, sent|defwinproc },
1969 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1970 { WM_NCCALCSIZE, sent|wparam, 1 },
1971 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|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 */
1976 /* ShowWindow(SW_RESTORE) for a visible MDI child window */
1977 static const struct message WmRestoreMDIchildVisibleSeq[] = {
1978 { HCBT_MINMAX, hook },
1979 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1980 { WM_NCCALCSIZE, sent|wparam, 1 },
1981 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1982 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1983 { WM_SIZE, sent|defwinproc },
1985 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1986 { WM_NCCALCSIZE, sent|wparam, 1 },
1987 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1988 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1989 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1992 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
1993 static const struct message WmRestoreMDIchildInisibleSeq[] = {
1994 { HCBT_MINMAX, hook },
1995 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
1996 { WM_NCCALCSIZE, sent|wparam, 1 },
1997 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1998 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1999 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2000 { WM_SIZE, sent|defwinproc },
2002 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2003 { WM_NCCALCSIZE, sent|wparam, 1 },
2004 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2005 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2006 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2010 static HWND mdi_client;
2011 static WNDPROC old_mdi_client_proc;
2013 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2017 /* do not log painting messages */
2018 if (message != WM_PAINT &&
2019 message != WM_ERASEBKGND &&
2020 message != WM_NCPAINT &&
2021 message != WM_NCHITTEST &&
2022 message != WM_GETTEXT &&
2023 message != WM_MDIGETACTIVE &&
2024 message != WM_GETICON &&
2025 message != WM_DEVICECHANGE)
2027 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2031 case WM_WINDOWPOSCHANGING:
2032 case WM_WINDOWPOSCHANGED:
2034 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2036 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2037 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2038 winpos->hwnd, winpos->hwndInsertAfter,
2039 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2041 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2042 * in the high word for internal purposes
2044 wParam = winpos->flags & 0xffff;
2049 msg.message = message;
2050 msg.flags = sent|wparam|lparam;
2051 msg.wParam = wParam;
2052 msg.lParam = lParam;
2056 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2059 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2061 static long defwndproc_counter = 0;
2065 /* do not log painting messages */
2066 if (message != WM_PAINT &&
2067 message != WM_ERASEBKGND &&
2068 message != WM_NCPAINT &&
2069 message != WM_NCHITTEST &&
2070 message != WM_GETTEXT &&
2071 message != WM_GETICON &&
2072 message != WM_DEVICECHANGE)
2074 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2078 case WM_WINDOWPOSCHANGING:
2079 case WM_WINDOWPOSCHANGED:
2081 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2083 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2084 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2085 winpos->hwnd, winpos->hwndInsertAfter,
2086 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2088 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2089 * in the high word for internal purposes
2091 wParam = winpos->flags & 0xffff;
2095 case WM_MDIACTIVATE:
2097 HWND active, client = GetParent(hwnd);
2099 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2101 if (hwnd == (HWND)lParam) /* if we are being activated */
2102 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2104 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2109 msg.message = message;
2110 msg.flags = sent|wparam|lparam;
2111 if (defwndproc_counter) msg.flags |= defwinproc;
2112 msg.wParam = wParam;
2113 msg.lParam = lParam;
2117 defwndproc_counter++;
2118 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2119 defwndproc_counter--;
2124 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2126 static long defwndproc_counter = 0;
2130 /* do not log painting messages */
2131 if (message != WM_PAINT &&
2132 message != WM_ERASEBKGND &&
2133 message != WM_NCPAINT &&
2134 message != WM_NCHITTEST &&
2135 message != WM_GETTEXT &&
2136 message != WM_GETICON &&
2137 message != WM_DEVICECHANGE)
2139 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2143 case WM_WINDOWPOSCHANGING:
2144 case WM_WINDOWPOSCHANGED:
2146 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2148 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2149 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2150 winpos->hwnd, winpos->hwndInsertAfter,
2151 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2153 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2154 * in the high word for internal purposes
2156 wParam = winpos->flags & 0xffff;
2161 msg.message = message;
2162 msg.flags = sent|wparam|lparam;
2163 if (defwndproc_counter) msg.flags |= defwinproc;
2164 msg.wParam = wParam;
2165 msg.lParam = lParam;
2169 defwndproc_counter++;
2170 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2171 defwndproc_counter--;
2176 static BOOL mdi_RegisterWindowClasses(void)
2181 cls.lpfnWndProc = mdi_frame_wnd_proc;
2184 cls.hInstance = GetModuleHandleA(0);
2186 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2187 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2188 cls.lpszMenuName = NULL;
2189 cls.lpszClassName = "MDI_frame_class";
2190 if (!RegisterClassA(&cls)) return FALSE;
2192 cls.lpfnWndProc = mdi_child_wnd_proc;
2193 cls.lpszClassName = "MDI_child_class";
2194 if (!RegisterClassA(&cls)) return FALSE;
2196 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2197 old_mdi_client_proc = cls.lpfnWndProc;
2198 cls.hInstance = GetModuleHandleA(0);
2199 cls.lpfnWndProc = mdi_client_hook_proc;
2200 cls.lpszClassName = "MDI_client_class";
2201 if (!RegisterClassA(&cls)) assert(0);
2206 static void test_mdi_messages(void)
2208 MDICREATESTRUCTA mdi_cs;
2209 CLIENTCREATESTRUCT client_cs;
2210 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2212 HMENU hMenu = CreateMenu();
2214 assert(mdi_RegisterWindowClasses());
2218 trace("creating MDI frame window\n");
2219 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2220 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2221 WS_MAXIMIZEBOX | WS_VISIBLE,
2222 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2223 GetDesktopWindow(), hMenu,
2224 GetModuleHandleA(0), NULL);
2226 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", TRUE);
2228 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2229 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2231 trace("creating MDI client window\n");
2232 client_cs.hWindowMenu = 0;
2233 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2234 mdi_client = CreateWindowExA(0, "MDI_client_class",
2236 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2238 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2240 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2242 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2243 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2245 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2246 ok(!active_child, "wrong active MDI child %p\n", active_child);
2247 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2252 trace("creating invisible MDI child window\n");
2253 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2255 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2256 mdi_client, 0, GetModuleHandleA(0), NULL);
2260 ShowWindow(mdi_child, SW_SHOWNORMAL);
2261 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
2263 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2264 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2266 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2267 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2269 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2270 ok(!active_child, "wrong active MDI child %p\n", active_child);
2271 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2273 ShowWindow(mdi_child, SW_HIDE);
2274 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
2277 ShowWindow(mdi_child, SW_SHOW);
2278 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
2280 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2281 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2283 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2284 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2286 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2287 ok(!active_child, "wrong active MDI child %p\n", active_child);
2288 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2290 DestroyWindow(mdi_child);
2293 trace("creating visible MDI child window\n");
2294 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2295 WS_CHILD | WS_VISIBLE,
2296 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2297 mdi_client, 0, GetModuleHandleA(0), NULL);
2299 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
2301 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2302 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2304 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2305 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2307 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2308 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2309 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2312 DestroyWindow(mdi_child);
2313 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2315 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2316 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2318 /* Win2k: MDI client still returns a just destroyed child as active
2319 * Win9x: MDI client returns 0
2321 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2322 ok(active_child == mdi_child || /* win2k */
2323 !active_child, /* win9x */
2324 "wrong active MDI child %p\n", active_child);
2325 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2329 trace("creating invisible MDI child window\n");
2330 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2332 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2333 mdi_client, 0, GetModuleHandleA(0), NULL);
2335 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
2337 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
2338 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
2340 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2341 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2343 /* Win2k: MDI client still returns a just destroyed child as active
2344 * Win9x: MDI client returns mdi_child2
2346 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2347 ok(active_child == mdi_child || /* win2k */
2348 active_child == mdi_child2, /* win9x */
2349 "wrong active MDI child %p\n", active_child);
2350 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2353 ShowWindow(mdi_child2, SW_MAXIMIZE);
2354 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", TRUE);
2356 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2357 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2359 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2360 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2361 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2364 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2365 ok(GetFocus() == mdi_child2 || /* win2k */
2366 GetFocus() == 0, /* win9x */
2367 "wrong focus window %p\n", GetFocus());
2372 ShowWindow(mdi_child2, SW_HIDE);
2373 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2375 ShowWindow(mdi_child2, SW_RESTORE);
2376 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", TRUE);
2379 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2380 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2382 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2383 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2384 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2390 ShowWindow(mdi_child2, SW_HIDE);
2391 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2393 ShowWindow(mdi_child2, SW_SHOW);
2394 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
2396 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2397 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2399 ShowWindow(mdi_child2, SW_MAXIMIZE);
2400 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", TRUE);
2402 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2403 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2405 ShowWindow(mdi_child2, SW_RESTORE);
2406 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):MDI child", TRUE);
2408 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2409 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2414 ShowWindow(mdi_child2, SW_HIDE);
2415 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2417 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2418 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2420 DestroyWindow(mdi_child2);
2421 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
2423 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2424 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2426 /* test for maximized MDI children */
2427 trace("creating maximized visible MDI child window 1\n");
2428 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2429 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2430 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2431 mdi_client, 0, GetModuleHandleA(0), NULL);
2433 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
2434 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2436 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2437 ok(GetFocus() == mdi_child || /* win2k */
2438 GetFocus() == 0, /* win9x */
2439 "wrong focus window %p\n", GetFocus());
2441 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2442 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2443 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2446 trace("creating maximized visible MDI child window 2\n");
2447 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2448 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2449 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2450 mdi_client, 0, GetModuleHandleA(0), NULL);
2452 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2453 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2454 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2456 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2457 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2459 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2460 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2461 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2464 trace("destroying maximized visible MDI child window 2\n");
2465 DestroyWindow(mdi_child2);
2466 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2468 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2470 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2471 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2473 /* Win2k: MDI client still returns a just destroyed child as active
2474 * Win9x: MDI client returns 0
2476 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2477 ok(active_child == mdi_child2 || /* win2k */
2478 !active_child, /* win9x */
2479 "wrong active MDI child %p\n", active_child);
2482 ShowWindow(mdi_child, SW_MAXIMIZE);
2483 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2486 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2487 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2489 trace("re-creating maximized visible MDI child window 2\n");
2490 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2491 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2492 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2493 mdi_client, 0, GetModuleHandleA(0), NULL);
2495 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2496 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2497 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2499 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2500 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2502 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2503 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2504 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2507 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
2508 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
2509 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
2511 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2512 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2513 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2515 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2516 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2517 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2520 DestroyWindow(mdi_child);
2521 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2523 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2524 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2526 /* Win2k: MDI client still returns a just destroyed child as active
2527 * Win9x: MDI client returns 0
2529 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2530 ok(active_child == mdi_child || /* win2k */
2531 !active_child, /* win9x */
2532 "wrong active MDI child %p\n", active_child);
2534 /* end of test for maximized MDI children */
2536 mdi_cs.szClass = "MDI_child_Class";
2537 mdi_cs.szTitle = "MDI child";
2538 mdi_cs.hOwner = GetModuleHandleA(0);
2541 mdi_cs.cx = CW_USEDEFAULT;
2542 mdi_cs.cy = CW_USEDEFAULT;
2543 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
2545 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
2546 ok(mdi_child != 0, "MDI child creation failed\n");
2547 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
2549 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
2551 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2552 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2554 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
2555 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2556 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2558 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2559 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2560 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2563 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
2564 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
2566 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
2567 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2568 ok(!active_child, "wrong active MDI child %p\n", active_child);
2573 DestroyWindow(mdi_client);
2574 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
2576 DestroyWindow(mdi_frame);
2577 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
2579 /************************* End of MDI test **********************************/
2581 static void test_WM_SETREDRAW(HWND hwnd)
2583 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
2587 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
2588 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
2590 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
2591 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
2594 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
2595 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
2597 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
2598 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
2600 /* restore original WS_VISIBLE state */
2601 SetWindowLongA(hwnd, GWL_STYLE, style);
2606 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2610 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2612 /* explicitly ignore WM_GETICON message */
2613 if (message == WM_GETICON) return 0;
2617 case WM_WINDOWPOSCHANGING:
2618 case WM_WINDOWPOSCHANGED:
2620 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2622 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2623 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2624 winpos->hwnd, winpos->hwndInsertAfter,
2625 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2627 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2628 * in the high word for internal purposes
2630 wParam = winpos->flags & 0xffff;
2635 msg.message = message;
2636 msg.flags = sent|wparam|lparam;
2637 msg.wParam = wParam;
2638 msg.lParam = lParam;
2641 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
2642 if (message == WM_TIMER) EndDialog( hwnd, 0 );
2646 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
2648 DWORD style, exstyle;
2652 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2653 style = GetWindowLongA(hwnd, GWL_STYLE);
2654 /* do not be confused by WS_DLGFRAME set */
2655 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
2657 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
2658 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
2660 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
2661 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
2662 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
2663 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
2665 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
2667 style = GetWindowLongA(hwnd, GWL_STYLE);
2668 if (set) ok(style & set, "style %08lx should be set\n", set);
2669 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
2671 /* a subsequent call should do nothing */
2672 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
2673 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
2674 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2678 trace("Ignore GetScrollRange error below if you are on Win9x\n");
2679 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
2680 ok( ret, "GetScrollRange(%d) error %ld\n", ctl, GetLastError());
2681 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2682 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
2683 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
2686 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
2688 DWORD style, exstyle;
2692 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2693 style = GetWindowLongA(hwnd, GWL_STYLE);
2694 /* do not be confused by WS_DLGFRAME set */
2695 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
2697 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
2698 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
2700 si.cbSize = sizeof(si);
2701 si.fMask = SIF_RANGE;
2704 SetScrollInfo(hwnd, ctl, &si, TRUE);
2705 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
2706 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
2708 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
2710 style = GetWindowLongA(hwnd, GWL_STYLE);
2711 if (set) ok(style & set, "style %08lx should be set\n", set);
2712 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
2714 /* a subsequent call should do nothing */
2715 SetScrollInfo(hwnd, ctl, &si, TRUE);
2716 if (style & WS_HSCROLL)
2717 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2718 else if (style & WS_VSCROLL)
2719 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2721 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2723 si.fMask = SIF_PAGE;
2725 SetScrollInfo(hwnd, ctl, &si, FALSE);
2726 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2730 SetScrollInfo(hwnd, ctl, &si, FALSE);
2731 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2733 si.fMask = SIF_RANGE;
2734 si.nMin = 0xdeadbeef;
2735 si.nMax = 0xdeadbeef;
2736 ret = GetScrollInfo(hwnd, ctl, &si);
2737 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
2738 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2739 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
2740 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
2743 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
2744 static void test_scroll_messages(HWND hwnd)
2752 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
2753 ok( ret, "GetScrollRange error %ld\n", GetLastError());
2754 if (sequence->message != WmGetScrollRangeSeq[0].message)
2755 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
2756 /* values of min and max are undefined */
2759 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
2760 ok( ret, "SetScrollRange error %ld\n", GetLastError());
2761 if (sequence->message != WmSetScrollRangeSeq[0].message)
2762 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
2767 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
2768 ok( ret, "GetScrollRange error %ld\n", GetLastError());
2769 if (sequence->message != WmGetScrollRangeSeq[0].message)
2770 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
2771 /* values of min and max are undefined */
2774 si.cbSize = sizeof(si);
2775 si.fMask = SIF_RANGE;
2778 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
2779 if (sequence->message != WmSetScrollRangeSeq[0].message)
2780 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2783 si.fMask = SIF_PAGE;
2785 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
2786 if (sequence->message != WmSetScrollRangeSeq[0].message)
2787 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2792 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
2793 if (sequence->message != WmSetScrollRangeSeq[0].message)
2794 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2797 si.fMask = SIF_RANGE;
2798 si.nMin = 0xdeadbeef;
2799 si.nMax = 0xdeadbeef;
2800 ret = GetScrollInfo(hwnd, SB_CTL, &si);
2801 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
2802 if (sequence->message != WmGetScrollInfoSeq[0].message)
2803 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2804 /* values of min and max are undefined */
2807 /* set WS_HSCROLL */
2808 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
2809 /* clear WS_HSCROLL */
2810 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
2812 /* set WS_HSCROLL */
2813 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
2814 /* clear WS_HSCROLL */
2815 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
2817 /* set WS_VSCROLL */
2818 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
2819 /* clear WS_VSCROLL */
2820 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
2822 /* set WS_VSCROLL */
2823 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
2824 /* clear WS_VSCROLL */
2825 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
2828 static void test_showwindow(void)
2832 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
2833 100, 100, 200, 200, 0, 0, 0, NULL);
2834 ok (hwnd != 0, "Failed to create overlapped window\n");
2835 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
2836 0, 0, 10, 10, hwnd, 0, 0, NULL);
2837 ok (hchild != 0, "Failed to create child\n");
2840 /* ShowWindow( SW_SHOWNA) for invisible top level window */
2841 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
2842 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
2843 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
2846 /* ShowWindow( SW_SHOWNA) for now visible top level window */
2847 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
2848 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
2849 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
2851 /* back to invisible */
2852 ShowWindow(hchild, SW_HIDE);
2853 ShowWindow(hwnd, SW_HIDE);
2855 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
2856 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
2857 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
2858 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", TRUE);
2860 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
2861 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
2863 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
2864 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
2865 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", TRUE);
2867 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
2868 ShowWindow( hwnd, SW_SHOW);
2870 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
2871 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
2872 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
2875 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
2876 ShowWindow( hchild, SW_HIDE);
2878 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
2879 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
2880 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
2884 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
2885 DestroyWindow(hchild);
2886 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
2888 DestroyWindow(hwnd);
2892 static void test_sys_menu(HWND hwnd)
2897 /* test existing window without CS_NOCLOSE style */
2898 hmenu = GetSystemMenu(hwnd, FALSE);
2899 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
2901 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
2902 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
2903 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
2905 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
2906 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
2908 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
2909 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
2910 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
2912 EnableMenuItem(hmenu, SC_CLOSE, 0);
2913 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
2915 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
2916 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
2917 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
2919 /* test new window with CS_NOCLOSE style */
2920 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2921 100, 100, 200, 200, 0, 0, 0, NULL);
2922 ok (hwnd != 0, "Failed to create overlapped window\n");
2924 hmenu = GetSystemMenu(hwnd, FALSE);
2925 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
2927 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
2928 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
2930 DestroyWindow(hwnd);
2933 /* test if we receive the right sequence of messages */
2934 static void test_messages(void)
2936 HWND hwnd, hparent, hchild;
2937 HWND hchild2, hbutton;
2944 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
2945 100, 100, 200, 200, 0, 0, 0, NULL);
2946 ok (hwnd != 0, "Failed to create overlapped window\n");
2947 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
2949 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
2950 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
2951 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
2953 /* test WM_SETREDRAW on a not visible top level window */
2954 test_WM_SETREDRAW(hwnd);
2956 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
2957 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
2958 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
2960 ok(GetActiveWindow() == hwnd, "window should be active\n");
2961 ok(GetFocus() == hwnd, "window should have input focus\n");
2962 ShowWindow(hwnd, SW_HIDE);
2963 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
2965 ShowWindow(hwnd, SW_SHOW);
2966 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
2968 ShowWindow(hwnd, SW_HIDE);
2969 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
2971 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
2972 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
2974 ShowWindow(hwnd, SW_RESTORE);
2975 /* FIXME: add ok_sequence() here */
2978 ShowWindow(hwnd, SW_SHOW);
2979 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
2981 ok(GetActiveWindow() == hwnd, "window should be active\n");
2982 ok(GetFocus() == hwnd, "window should have input focus\n");
2983 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
2984 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
2985 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
2986 ok(GetActiveWindow() == hwnd, "window should still be active\n");
2988 /* test WM_SETREDRAW on a visible top level window */
2989 ShowWindow(hwnd, SW_SHOW);
2990 test_WM_SETREDRAW(hwnd);
2992 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
2993 test_scroll_messages(hwnd);
2995 /* test resizing and moving */
2996 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
2997 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
2998 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE );
2999 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
3001 /* popups don't get WM_GETMINMAXINFO */
3002 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
3003 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3005 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3006 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
3008 test_sys_menu(hwnd);
3011 DestroyWindow(hwnd);
3012 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
3014 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3015 100, 100, 200, 200, 0, 0, 0, NULL);
3016 ok (hparent != 0, "Failed to create parent window\n");
3019 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
3020 0, 0, 10, 10, hparent, 0, 0, NULL);
3021 ok (hchild != 0, "Failed to create child window\n");
3022 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", TRUE);
3023 DestroyWindow(hchild);
3026 /* visible child window with a caption */
3027 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
3028 WS_CHILD | WS_VISIBLE | WS_CAPTION,
3029 0, 0, 10, 10, hparent, 0, 0, NULL);
3030 ok (hchild != 0, "Failed to create child window\n");
3031 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
3033 trace("testing scroll APIs on a visible child window %p\n", hchild);
3034 test_scroll_messages(hchild);
3036 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3037 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
3039 DestroyWindow(hchild);
3042 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3043 0, 0, 10, 10, hparent, 0, 0, NULL);
3044 ok (hchild != 0, "Failed to create child window\n");
3045 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3047 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
3048 100, 100, 50, 50, hparent, 0, 0, NULL);
3049 ok (hchild2 != 0, "Failed to create child2 window\n");
3052 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
3053 0, 100, 50, 50, hchild, 0, 0, NULL);
3054 ok (hbutton != 0, "Failed to create button window\n");
3056 /* test WM_SETREDRAW on a not visible child window */
3057 test_WM_SETREDRAW(hchild);
3059 ShowWindow(hchild, SW_SHOW);
3060 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3062 ShowWindow(hchild, SW_HIDE);
3063 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
3065 ShowWindow(hchild, SW_SHOW);
3066 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3068 /* test WM_SETREDRAW on a visible child window */
3069 test_WM_SETREDRAW(hchild);
3071 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
3072 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
3074 ShowWindow(hchild, SW_HIDE);
3076 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3077 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
3079 ShowWindow(hchild, SW_HIDE);
3081 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3082 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
3084 /* DestroyWindow sequence below expects that a child has focus */
3088 DestroyWindow(hchild);
3089 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
3090 DestroyWindow(hchild2);
3091 DestroyWindow(hbutton);
3094 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
3095 0, 0, 100, 100, hparent, 0, 0, NULL);
3096 ok (hchild != 0, "Failed to create child popup window\n");
3097 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
3098 DestroyWindow(hchild);
3100 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3102 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
3103 0, 0, 100, 100, hparent, 0, 0, NULL);
3104 ok (hchild != 0, "Failed to create popup window\n");
3105 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3106 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3107 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3109 ShowWindow(hchild, SW_SHOW);
3110 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3112 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3113 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3115 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3116 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
3117 DestroyWindow(hchild);
3119 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3120 * changes nothing in message sequences.
3123 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
3124 0, 0, 100, 100, hparent, 0, 0, NULL);
3125 ok (hchild != 0, "Failed to create popup window\n");
3126 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3127 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3128 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3130 ShowWindow(hchild, SW_SHOW);
3131 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3133 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3134 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3135 DestroyWindow(hchild);
3138 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
3139 0, 0, 100, 100, hparent, 0, 0, NULL);
3140 ok(hwnd != 0, "Failed to create custom dialog window\n");
3141 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
3144 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3145 test_scroll_messages(hwnd);
3149 after_end_dialog = 1;
3150 EndDialog( hwnd, 0 );
3151 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
3153 DestroyWindow(hwnd);
3154 after_end_dialog = 0;
3156 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
3157 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
3158 ok(hwnd != 0, "Failed to create custom dialog window\n");
3160 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
3161 ShowWindow(hwnd, SW_SHOW);
3162 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
3163 DestroyWindow(hwnd);
3166 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
3167 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
3169 /* test showing child with hidden parent */
3170 ShowWindow( hparent, SW_HIDE );
3173 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3174 0, 0, 10, 10, hparent, 0, 0, NULL);
3175 ok (hchild != 0, "Failed to create child window\n");
3176 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3178 ShowWindow( hchild, SW_SHOW );
3179 ok_sequence(WmShowChildInvisibleParentSeq, "ShowWindow:show child with invisible parent", TRUE);
3180 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3181 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3183 ShowWindow( hchild, SW_HIDE );
3184 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", TRUE);
3185 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
3186 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3188 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3189 ok_sequence(WmShowChildInvisibleParentSeq_2, "SetWindowPos:show child with invisible parent", FALSE);
3190 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3191 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3193 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3194 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
3195 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
3196 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3198 DestroyWindow(hchild);
3199 DestroyWindow(hparent);
3202 /* Message sequence for SetMenu */
3203 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
3204 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
3206 hmenu = CreateMenu();
3207 ok (hmenu != 0, "Failed to create menu\n");
3208 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
3209 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3210 100, 100, 200, 200, 0, hmenu, 0, NULL);
3211 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3212 ok (SetMenu(hwnd, 0), "SetMenu\n");
3213 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
3214 ok (SetMenu(hwnd, 0), "SetMenu\n");
3215 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
3216 ShowWindow(hwnd, SW_SHOW);
3217 UpdateWindow( hwnd );
3218 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3220 ok (SetMenu(hwnd, 0), "SetMenu\n");
3221 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
3222 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
3223 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
3225 UpdateWindow( hwnd );
3226 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3228 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
3229 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3230 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
3232 DestroyWindow(hwnd);
3235 /* Message sequence for EnableWindow */
3236 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3237 100, 100, 200, 200, 0, 0, 0, NULL);
3238 ok (hparent != 0, "Failed to create parent window\n");
3239 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
3240 0, 0, 10, 10, hparent, 0, 0, NULL);
3241 ok (hchild != 0, "Failed to create child window\n");
3246 EnableWindow(hparent, FALSE);
3247 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
3249 EnableWindow(hparent, TRUE);
3250 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
3252 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3255 /* MsgWaitForMultipleObjects test */
3256 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3257 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3259 PostMessageA(hparent, WM_USER, 0, 0);
3261 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3262 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %lx\n", ret);
3264 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3265 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3267 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3268 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3269 /* end of MsgWaitForMultipleObjects test */
3271 /* the following test causes an exception in user.exe under win9x */
3272 if (!PostMessageW( hparent, WM_USER, 0, 0 )) return;
3273 PostMessageW( hparent, WM_USER+1, 0, 0 );
3274 /* PeekMessage(NULL) fails, but still removes the message */
3275 SetLastError(0xdeadbeef);
3276 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
3277 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
3278 GetLastError() == 0xdeadbeef, /* NT4 */
3279 "last error is %ld\n", GetLastError() );
3280 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
3281 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
3283 DestroyWindow(hchild);
3284 DestroyWindow(hparent);
3290 /****************** button message test *************************/
3291 static const struct message WmSetFocusButtonSeq[] =
3293 { HCBT_SETFOCUS, hook },
3294 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3295 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3296 { WM_SETFOCUS, sent|wparam, 0 },
3297 { WM_CTLCOLORBTN, sent|defwinproc },
3300 static const struct message WmKillFocusButtonSeq[] =
3302 { HCBT_SETFOCUS, hook },
3303 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3304 { WM_KILLFOCUS, sent|wparam, 0 },
3305 { WM_CTLCOLORBTN, sent|defwinproc },
3306 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3309 static const struct message WmSetFocusStaticSeq[] =
3311 { HCBT_SETFOCUS, hook },
3312 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3313 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3314 { WM_SETFOCUS, sent|wparam, 0 },
3315 { WM_CTLCOLORSTATIC, sent|defwinproc },
3318 static const struct message WmKillFocusStaticSeq[] =
3320 { HCBT_SETFOCUS, hook },
3321 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3322 { WM_KILLFOCUS, sent|wparam, 0 },
3323 { WM_CTLCOLORSTATIC, sent|defwinproc },
3324 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3327 static const struct message WmLButtonDownSeq[] =
3329 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
3330 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
3331 { HCBT_SETFOCUS, hook },
3332 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3333 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3334 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
3335 { WM_CTLCOLORBTN, sent|defwinproc },
3336 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
3337 { WM_CTLCOLORBTN, sent|defwinproc },
3338 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3341 static const struct message WmLButtonUpSeq[] =
3343 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
3344 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
3345 { WM_CTLCOLORBTN, sent|defwinproc },
3346 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3347 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
3348 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
3352 static WNDPROC old_button_proc;
3354 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3356 static long defwndproc_counter = 0;
3360 trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3362 /* explicitly ignore WM_GETICON message */
3363 if (message == WM_GETICON) return 0;
3365 msg.message = message;
3366 msg.flags = sent|wparam|lparam;
3367 if (defwndproc_counter) msg.flags |= defwinproc;
3368 msg.wParam = wParam;
3369 msg.lParam = lParam;
3372 if (message == BM_SETSTATE)
3373 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
3375 defwndproc_counter++;
3376 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
3377 defwndproc_counter--;
3382 static void subclass_button(void)
3386 if (!GetClassInfoA(0, "button", &cls)) assert(0);
3388 old_button_proc = cls.lpfnWndProc;
3390 cls.hInstance = GetModuleHandle(0);
3391 cls.lpfnWndProc = button_hook_proc;
3392 cls.lpszClassName = "my_button_class";
3393 if (!RegisterClassA(&cls)) assert(0);
3396 static void test_button_messages(void)
3402 const struct message *setfocus;
3403 const struct message *killfocus;
3405 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
3406 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3407 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
3408 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3409 { BS_CHECKBOX, DLGC_BUTTON,
3410 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3411 { BS_AUTOCHECKBOX, DLGC_BUTTON,
3412 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3413 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
3414 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3415 { BS_3STATE, DLGC_BUTTON,
3416 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3417 { BS_AUTO3STATE, DLGC_BUTTON,
3418 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3419 { BS_GROUPBOX, DLGC_STATIC,
3420 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3421 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
3422 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3423 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
3424 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3425 { BS_OWNERDRAW, DLGC_BUTTON,
3426 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
3434 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
3436 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
3437 0, 0, 50, 14, 0, 0, 0, NULL);
3438 ok(hwnd != 0, "Failed to create button window\n");
3440 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
3441 ok(dlg_code == button[i].dlg_code, "%d: wrong dlg_code %08lx\n", i, dlg_code);
3443 ShowWindow(hwnd, SW_SHOW);
3448 trace("button style %08lx\n", button[i].style);
3450 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
3453 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
3455 DestroyWindow(hwnd);
3458 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
3459 0, 0, 50, 14, 0, 0, 0, NULL);
3460 ok(hwnd != 0, "Failed to create button window\n");
3465 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
3466 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
3468 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
3469 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
3470 DestroyWindow(hwnd);
3473 /************* painting message test ********************/
3475 void dump_region(HRGN hrgn)
3478 RGNDATA *data = NULL;
3483 printf( "null region\n" );
3486 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
3487 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
3488 GetRegionData( hrgn, size, data );
3489 printf("%ld rects:", data->rdh.nCount );
3490 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
3491 printf( " (%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
3493 HeapFree( GetProcessHeap(), 0, data );
3496 static void check_update_rgn( HWND hwnd, HRGN hrgn )
3500 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
3501 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
3503 ret = GetUpdateRgn( hwnd, update, FALSE );
3504 ok( ret != ERROR, "GetUpdateRgn failed\n" );
3505 if (ret == NULLREGION)
3507 ok( !hrgn, "Update region shouldn't be empty\n" );
3511 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
3513 ok( 0, "Regions are different\n" );
3514 if (winetest_debug > 0)
3516 printf( "Update region: " );
3517 dump_region( update );
3518 printf( "Wanted region: " );
3519 dump_region( hrgn );
3523 GetRgnBox( update, &r1 );
3524 GetUpdateRect( hwnd, &r2, FALSE );
3525 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
3526 "Rectangles are different: %ld,%ld-%ld,%ld / %ld,%ld-%ld,%ld\n",
3527 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
3529 DeleteObject( tmp );
3530 DeleteObject( update );
3533 static const struct message WmInvalidateRgn[] = {
3534 { WM_NCPAINT, sent },
3535 { WM_GETTEXT, sent|defwinproc|optional },
3539 static const struct message WmGetUpdateRect[] = {
3540 { WM_NCPAINT, sent },
3541 { WM_GETTEXT, sent|defwinproc|optional },
3546 static const struct message WmInvalidateFull[] = {
3547 { WM_NCPAINT, sent|wparam, 1 },
3548 { WM_GETTEXT, sent|defwinproc|optional },
3552 static const struct message WmInvalidateErase[] = {
3553 { WM_NCPAINT, sent|wparam, 1 },
3554 { WM_GETTEXT, sent|defwinproc|optional },
3555 { WM_ERASEBKGND, sent },
3559 static const struct message WmInvalidatePaint[] = {
3561 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
3562 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3566 static const struct message WmInvalidateErasePaint[] = {
3568 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
3569 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3570 { WM_ERASEBKGND, sent|beginpaint },
3574 static const struct message WmInvalidateErasePaint2[] = {
3576 { WM_NCPAINT, sent|beginpaint },
3577 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3578 { WM_ERASEBKGND, sent|beginpaint },
3582 static const struct message WmErase[] = {
3583 { WM_ERASEBKGND, sent },
3587 static const struct message WmPaint[] = {
3592 static const struct message WmParentOnlyPaint[] = {
3593 { WM_PAINT, sent|parent },
3597 static const struct message WmInvalidateParent[] = {
3598 { WM_NCPAINT, sent|parent },
3599 { WM_GETTEXT, sent|defwinproc|parent|optional },
3600 { WM_ERASEBKGND, sent|parent },
3604 static const struct message WmInvalidateParentChild[] = {
3605 { WM_NCPAINT, sent|parent },
3606 { WM_GETTEXT, sent|defwinproc|parent|optional },
3607 { WM_ERASEBKGND, sent|parent },
3608 { WM_NCPAINT, sent },
3609 { WM_GETTEXT, sent|defwinproc|optional },
3610 { WM_ERASEBKGND, sent },
3614 static const struct message WmInvalidateParentChild2[] = {
3615 { WM_ERASEBKGND, sent|parent },
3616 { WM_NCPAINT, sent },
3617 { WM_GETTEXT, sent|defwinproc|optional },
3618 { WM_ERASEBKGND, sent },
3622 static const struct message WmParentPaint[] = {
3623 { WM_PAINT, sent|parent },
3628 static const struct message WmParentPaintNc[] = {
3629 { WM_PAINT, sent|parent },
3631 { WM_NCPAINT, sent|beginpaint },
3632 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3633 { WM_ERASEBKGND, sent|beginpaint },
3637 static const struct message WmChildPaintNc[] = {
3639 { WM_NCPAINT, sent|beginpaint },
3640 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3641 { WM_ERASEBKGND, sent|beginpaint },
3645 static const struct message WmParentErasePaint[] = {
3646 { WM_PAINT, sent|parent },
3647 { WM_NCPAINT, sent|parent|beginpaint },
3648 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
3649 { WM_ERASEBKGND, sent|parent|beginpaint },
3651 { WM_NCPAINT, sent|beginpaint },
3652 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3653 { WM_ERASEBKGND, sent|beginpaint },
3657 static const struct message WmParentOnlyNcPaint[] = {
3658 { WM_PAINT, sent|parent },
3659 { WM_NCPAINT, sent|parent|beginpaint },
3660 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
3664 static const struct message WmSetParentStyle[] = {
3665 { WM_STYLECHANGING, sent|parent },
3666 { WM_STYLECHANGED, sent|parent },
3670 static void test_paint_messages(void)
3675 HWND hparent, hchild;
3676 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
3677 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
3678 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3679 100, 100, 200, 200, 0, 0, 0, NULL);
3680 ok (hwnd != 0, "Failed to create overlapped window\n");
3682 ShowWindow( hwnd, SW_SHOW );
3683 UpdateWindow( hwnd );
3685 /* try to flush pending X expose events */
3686 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
3687 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3689 check_update_rgn( hwnd, 0 );
3690 SetRectRgn( hrgn, 10, 10, 20, 20 );
3691 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
3692 check_update_rgn( hwnd, hrgn );
3693 SetRectRgn( hrgn2, 20, 20, 30, 30 );
3694 RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
3695 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
3696 check_update_rgn( hwnd, hrgn );
3697 /* validate everything */
3698 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
3699 check_update_rgn( hwnd, 0 );
3701 /* flush pending messages */
3702 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3705 GetClientRect( hwnd, &rect );
3706 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
3707 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
3708 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
3710 trace("testing InvalidateRect(0, NULL, FALSE)\n");
3711 SetRectEmpty( &rect );
3712 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
3713 check_update_rgn( hwnd, hrgn );
3714 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
3715 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3716 ok_sequence( WmPaint, "Paint", FALSE );
3717 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
3718 check_update_rgn( hwnd, 0 );
3720 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
3721 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
3723 trace("testing ValidateRect(0, NULL)\n");
3724 SetRectEmpty( &rect );
3725 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail");
3726 check_update_rgn( hwnd, hrgn );
3727 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
3728 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3729 ok_sequence( WmPaint, "Paint", FALSE );
3730 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
3731 check_update_rgn( hwnd, 0 );
3733 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
3734 SetLastError(0xdeadbeef);
3735 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
3736 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
3737 check_update_rgn( hwnd, 0 );
3738 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3739 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
3741 trace("testing ValidateRgn(0, NULL)\n");
3742 SetLastError(0xdeadbeef);
3743 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail");
3744 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
3745 check_update_rgn( hwnd, 0 );
3746 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3747 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
3749 /* now with frame */
3750 SetRectRgn( hrgn, -5, -5, 20, 20 );
3752 /* flush pending messages */
3753 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3756 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3757 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
3759 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
3760 check_update_rgn( hwnd, hrgn );
3763 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
3764 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
3767 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
3768 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
3770 GetClientRect( hwnd, &rect );
3771 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
3772 check_update_rgn( hwnd, hrgn );
3775 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
3776 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
3779 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
3780 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
3781 check_update_rgn( hwnd, 0 );
3784 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
3785 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
3786 check_update_rgn( hwnd, 0 );
3789 SetRectRgn( hrgn, 0, 0, 100, 100 );
3790 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
3791 SetRectRgn( hrgn, 0, 0, 50, 100 );
3792 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
3793 SetRectRgn( hrgn, 50, 0, 100, 100 );
3794 check_update_rgn( hwnd, hrgn );
3795 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
3796 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
3797 check_update_rgn( hwnd, 0 );
3800 SetRectRgn( hrgn, 0, 0, 100, 100 );
3801 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
3802 SetRectRgn( hrgn, 0, 0, 100, 50 );
3803 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
3804 ok_sequence( WmErase, "Erase", FALSE );
3805 SetRectRgn( hrgn, 0, 50, 100, 100 );
3806 check_update_rgn( hwnd, hrgn );
3809 SetRectRgn( hrgn, 0, 0, 100, 100 );
3810 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
3811 SetRectRgn( hrgn, 0, 0, 50, 50 );
3812 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
3813 ok_sequence( WmPaint, "Paint", FALSE );
3816 SetRectRgn( hrgn, -4, -4, -2, -2 );
3817 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3818 SetRectRgn( hrgn, -200, -200, -198, -198 );
3819 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
3820 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
3823 SetRectRgn( hrgn, -4, -4, -2, -2 );
3824 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3825 SetRectRgn( hrgn, -4, -4, -3, -3 );
3826 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
3827 SetRectRgn( hrgn, 0, 0, 1, 1 );
3828 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
3829 ok_sequence( WmPaint, "Paint", FALSE );
3832 SetRectRgn( hrgn, -4, -4, -1, -1 );
3833 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3834 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
3835 /* make sure no WM_PAINT was generated */
3836 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3837 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
3840 SetRectRgn( hrgn, -4, -4, -1, -1 );
3841 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3842 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
3844 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
3846 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
3847 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
3848 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
3849 ret = GetUpdateRect( hwnd, &rect, FALSE );
3850 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
3851 /* this will send WM_NCPAINT and validate the non client area */
3852 ret = GetUpdateRect( hwnd, &rect, TRUE );
3853 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
3855 DispatchMessage( &msg );
3857 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
3859 DestroyWindow( hwnd );
3861 /* now test with a child window */
3863 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
3864 100, 100, 200, 200, 0, 0, 0, NULL);
3865 ok (hparent != 0, "Failed to create parent window\n");
3867 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
3868 10, 10, 100, 100, hparent, 0, 0, NULL);
3869 ok (hchild != 0, "Failed to create child window\n");
3871 ShowWindow( hparent, SW_SHOW );
3872 UpdateWindow( hparent );
3873 UpdateWindow( hchild );
3874 /* try to flush pending X expose events */
3875 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
3876 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3879 log_all_parent_messages++;
3881 SetRect( &rect, 0, 0, 50, 50 );
3882 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3883 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
3884 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
3886 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3888 MapWindowPoints( hchild, hparent, &pt, 1 );
3889 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
3890 check_update_rgn( hchild, hrgn );
3891 SetRectRgn( hrgn, 0, 0, 50, 50 );
3892 check_update_rgn( hparent, hrgn );
3893 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3894 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
3895 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
3896 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
3898 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3899 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
3901 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
3902 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3903 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
3904 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
3905 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
3907 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
3908 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
3909 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
3911 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
3913 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
3914 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3915 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
3917 /* flush all paint messages */
3918 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3921 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
3922 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
3923 SetRectRgn( hrgn, 0, 0, 50, 50 );
3924 check_update_rgn( hparent, hrgn );
3925 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
3926 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3927 SetRectRgn( hrgn, 0, 0, 50, 50 );
3928 check_update_rgn( hparent, hrgn );
3930 /* flush all paint messages */
3931 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3932 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
3935 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
3936 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3937 SetRectRgn( hrgn, 0, 0, 50, 50 );
3938 check_update_rgn( hparent, hrgn );
3939 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
3940 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3941 SetRectRgn( hrgn2, 10, 10, 50, 50 );
3942 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
3943 check_update_rgn( hparent, hrgn );
3944 /* flush all paint messages */
3945 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3948 /* same as above but parent gets completely validated */
3949 SetRect( &rect, 20, 20, 30, 30 );
3950 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3951 SetRectRgn( hrgn, 20, 20, 30, 30 );
3952 check_update_rgn( hparent, hrgn );
3953 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
3954 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3955 check_update_rgn( hparent, 0 ); /* no update region */
3956 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3957 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
3959 /* make sure RDW_VALIDATE on child doesn't have the same effect */
3961 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3962 SetRectRgn( hrgn, 20, 20, 30, 30 );
3963 check_update_rgn( hparent, hrgn );
3964 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
3965 SetRectRgn( hrgn, 20, 20, 30, 30 );
3966 check_update_rgn( hparent, hrgn );
3968 /* same as above but normal WM_PAINT doesn't validate parent */
3970 SetRect( &rect, 20, 20, 30, 30 );
3971 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3972 SetRectRgn( hrgn, 20, 20, 30, 30 );
3973 check_update_rgn( hparent, hrgn );
3974 /* no WM_PAINT in child while parent still pending */
3975 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3976 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
3977 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3978 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
3981 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3982 /* no WM_PAINT in child while parent still pending */
3983 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3984 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
3985 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
3986 /* now that parent is valid child should get WM_PAINT */
3987 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3988 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3989 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3990 ok_sequence( WmEmptySeq, "No other message", FALSE );
3992 /* same thing with WS_CLIPCHILDREN in parent */
3994 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
3995 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
3996 /* changing style invalidates non client area, but we need to invalidate something else to see it */
3997 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
3998 ok_sequence( WmEmptySeq, "No message", FALSE );
3999 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
4000 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
4003 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
4004 SetRectRgn( hrgn, 20, 20, 30, 30 );
4005 check_update_rgn( hparent, hrgn );
4006 /* no WM_PAINT in child while parent still pending */
4007 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4008 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4009 /* WM_PAINT in parent first */
4010 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4011 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
4013 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
4015 SetRect( &rect, 0, 0, 30, 30 );
4016 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
4017 SetRectRgn( hrgn, 0, 0, 30, 30 );
4018 check_update_rgn( hparent, hrgn );
4019 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4020 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
4022 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4024 SetRect( &rect, -10, 0, 30, 30 );
4025 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4026 SetRect( &rect, 0, 0, 20, 20 );
4027 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4028 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4029 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
4031 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4033 SetRect( &rect, -10, 0, 30, 30 );
4034 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4035 SetRect( &rect, 0, 0, 100, 100 );
4036 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4037 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4038 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
4039 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4040 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
4042 /* test RDW_INTERNALPAINT behavior */
4045 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
4046 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4047 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4049 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
4050 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4051 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4053 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4054 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4055 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4057 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
4058 UpdateWindow( hparent );
4059 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4061 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
4062 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4063 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4064 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4065 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4066 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
4068 UpdateWindow( hparent );
4069 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4071 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
4072 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4073 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4074 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4075 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4076 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4078 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4079 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4080 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4081 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4082 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4084 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
4085 UpdateWindow( hparent );
4086 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4088 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
4089 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4090 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4091 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4092 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4093 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
4095 UpdateWindow( hparent );
4096 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4098 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
4099 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4100 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4101 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4102 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4103 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4105 log_all_parent_messages--;
4106 DestroyWindow( hparent );
4107 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
4109 DeleteObject( hrgn );
4110 DeleteObject( hrgn2 );
4119 static DWORD WINAPI thread_proc(void *param)
4122 struct wnd_event *wnd_event = (struct wnd_event *)param;
4124 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
4125 100, 100, 200, 200, 0, 0, 0, NULL);
4126 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
4128 SetEvent(wnd_event->event);
4130 while (GetMessage(&msg, 0, 0, 0))
4132 TranslateMessage(&msg);
4133 DispatchMessage(&msg);
4136 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
4141 static void test_interthread_messages(void)
4148 int len, expected_len;
4149 struct wnd_event wnd_event;
4152 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
4153 if (!wnd_event.event)
4155 trace("skipping interthread message test under win9x\n");
4159 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
4160 ok(hThread != NULL, "CreateThread failed, error %ld\n", GetLastError());
4162 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4164 CloseHandle(wnd_event.event);
4166 SetLastError(0xdeadbeef);
4167 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
4168 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %ld\n", GetLastError());
4170 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4171 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %ld\n", GetLastError());
4173 expected_len = lstrlenA("window caption text");
4174 memset(buf, 0, sizeof(buf));
4175 SetLastError(0xdeadbeef);
4176 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
4177 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %ld, len %d, expected len %d\n", GetLastError(), len, expected_len);
4178 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
4180 msg.hwnd = wnd_event.hwnd;
4181 msg.message = WM_GETTEXT;
4182 msg.wParam = sizeof(buf);
4183 msg.lParam = (LPARAM)buf;
4184 memset(buf, 0, sizeof(buf));
4185 SetLastError(0xdeadbeef);
4186 len = DispatchMessageA(&msg);
4187 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
4188 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %ld\n", len, GetLastError());
4190 /* the following test causes an exception in user.exe under win9x */
4191 msg.hwnd = wnd_event.hwnd;
4192 msg.message = WM_TIMER;
4194 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4195 SetLastError(0xdeadbeef);
4196 len = DispatchMessageA(&msg);
4197 ok(!len && GetLastError() == 0xdeadbeef,
4198 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len, GetLastError());
4200 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
4201 ok( ret, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
4203 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4204 CloseHandle(hThread);
4206 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
4210 static const struct message WmVkN[] = {
4211 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4212 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4213 { WM_CHAR, wparam|lparam, 'n', 1 },
4214 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
4215 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4216 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4219 static const struct message WmShiftVkN[] = {
4220 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4221 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4222 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4223 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4224 { WM_CHAR, wparam|lparam, 'N', 1 },
4225 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
4226 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4227 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4228 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4229 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4232 static const struct message WmCtrlVkN[] = {
4233 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4234 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4235 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4236 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4237 { WM_CHAR, wparam|lparam, 0x000e, 1 },
4238 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4239 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4240 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4241 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4242 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4245 static const struct message WmCtrlVkN_2[] = {
4246 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4247 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4248 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4249 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4250 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4251 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4252 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4253 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4256 static const struct message WmAltVkN[] = {
4257 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4258 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4259 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4260 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4261 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
4262 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
4263 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
4264 { HCBT_SYSCOMMAND, hook },
4265 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4266 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4267 { WM_INITMENU, sent|defwinproc },
4268 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4269 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
4270 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4271 { WM_CAPTURECHANGED, sent|defwinproc },
4272 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
4273 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4274 { WM_EXITMENULOOP, sent|defwinproc },
4275 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
4276 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
4277 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4278 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4279 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4280 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4283 static const struct message WmAltVkN_2[] = {
4284 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4285 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4286 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4287 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
4288 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4289 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4290 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4291 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4294 static const struct message WmCtrlAltVkN[] = {
4295 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4296 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4297 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4298 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4299 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4300 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4301 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4302 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4303 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4304 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4305 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4306 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4309 static const struct message WmCtrlShiftVkN[] = {
4310 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4311 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4312 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4313 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4314 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4315 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
4316 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4317 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4318 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4319 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4320 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4321 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4324 static const struct message WmCtrlAltShiftVkN[] = {
4325 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4326 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4327 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4328 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4329 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
4330 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
4331 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4332 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
4333 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4334 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4335 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
4336 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
4337 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4338 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4339 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4340 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4343 static const struct message WmAltPressRelease[] = {
4344 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4345 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4346 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4347 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4348 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
4349 { HCBT_SYSCOMMAND, hook },
4350 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4351 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4352 { WM_INITMENU, sent|defwinproc },
4353 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4354 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
4355 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
4357 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4358 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
4359 { WM_CAPTURECHANGED, sent|defwinproc },
4360 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
4361 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4362 { WM_EXITMENULOOP, sent|defwinproc },
4363 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4364 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4367 static const struct message WmAltMouseButton[] = {
4368 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4369 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4370 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
4371 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
4372 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
4373 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
4374 { WM_LBUTTONUP, wparam, 0, 0 },
4375 { WM_LBUTTONUP, sent|wparam, 0, 0 },
4376 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4377 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4380 static const struct message WmF1Seq[] = {
4381 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
4382 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
4383 { 0x4d, wparam|lparam, 0, 0 },
4384 { 0x4d, sent|wparam|lparam, 0, 0 },
4385 { WM_HELP, sent|defwinproc },
4386 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
4387 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
4391 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
4395 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
4397 struct message log_msg;
4399 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
4401 /* ignore some unwanted messages */
4402 if (msg.message == WM_MOUSEMOVE ||
4403 msg.message == WM_GETICON ||
4404 msg.message == WM_DEVICECHANGE)
4407 log_msg.message = msg.message;
4408 log_msg.flags = wparam|lparam;
4409 log_msg.wParam = msg.wParam;
4410 log_msg.lParam = msg.lParam;
4411 add_message(&log_msg);
4413 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
4415 TranslateMessage(&msg);
4416 DispatchMessage(&msg);
4421 static void test_accelerators(void)
4426 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4427 100, 100, 200, 200, 0, 0, 0, NULL);
4433 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4435 state = GetKeyState(VK_SHIFT);
4436 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
4437 state = GetKeyState(VK_CAPITAL);
4438 ok(state == 0, "wrong CapsLock state %04x\n", state);
4440 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
4441 assert(hAccel != 0);
4443 pump_msg_loop(hwnd, 0);
4446 trace("testing VK_N press/release\n");
4448 keybd_event('N', 0, 0, 0);
4449 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4450 pump_msg_loop(hwnd, hAccel);
4451 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4453 trace("testing Shift+VK_N press/release\n");
4455 keybd_event(VK_SHIFT, 0, 0, 0);
4456 keybd_event('N', 0, 0, 0);
4457 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4458 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4459 pump_msg_loop(hwnd, hAccel);
4460 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4462 trace("testing Ctrl+VK_N press/release\n");
4464 keybd_event(VK_CONTROL, 0, 0, 0);
4465 keybd_event('N', 0, 0, 0);
4466 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4467 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4468 pump_msg_loop(hwnd, hAccel);
4469 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
4471 trace("testing Alt+VK_N press/release\n");
4473 keybd_event(VK_MENU, 0, 0, 0);
4474 keybd_event('N', 0, 0, 0);
4475 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4476 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4477 pump_msg_loop(hwnd, hAccel);
4478 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
4480 trace("testing Ctrl+Alt+VK_N press/release 1\n");
4482 keybd_event(VK_CONTROL, 0, 0, 0);
4483 keybd_event(VK_MENU, 0, 0, 0);
4484 keybd_event('N', 0, 0, 0);
4485 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4486 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4487 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4488 pump_msg_loop(hwnd, hAccel);
4489 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
4491 ret = DestroyAcceleratorTable(hAccel);
4492 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4494 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
4495 assert(hAccel != 0);
4497 trace("testing VK_N press/release\n");
4499 keybd_event('N', 0, 0, 0);
4500 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4501 pump_msg_loop(hwnd, hAccel);
4502 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4504 trace("testing Shift+VK_N press/release\n");
4506 keybd_event(VK_SHIFT, 0, 0, 0);
4507 keybd_event('N', 0, 0, 0);
4508 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4509 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4510 pump_msg_loop(hwnd, hAccel);
4511 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4513 trace("testing Ctrl+VK_N press/release 2\n");
4515 keybd_event(VK_CONTROL, 0, 0, 0);
4516 keybd_event('N', 0, 0, 0);
4517 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4518 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4519 pump_msg_loop(hwnd, hAccel);
4520 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
4522 trace("testing Alt+VK_N press/release 2\n");
4524 keybd_event(VK_MENU, 0, 0, 0);
4525 keybd_event('N', 0, 0, 0);
4526 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4527 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4528 pump_msg_loop(hwnd, hAccel);
4529 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
4531 trace("testing Ctrl+Alt+VK_N press/release 2\n");
4533 keybd_event(VK_CONTROL, 0, 0, 0);
4534 keybd_event(VK_MENU, 0, 0, 0);
4535 keybd_event('N', 0, 0, 0);
4536 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4537 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4538 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4539 pump_msg_loop(hwnd, hAccel);
4540 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
4542 trace("testing Ctrl+Shift+VK_N press/release\n");
4544 keybd_event(VK_CONTROL, 0, 0, 0);
4545 keybd_event(VK_SHIFT, 0, 0, 0);
4546 keybd_event('N', 0, 0, 0);
4547 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4548 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4549 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4550 pump_msg_loop(hwnd, hAccel);
4551 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
4553 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
4555 keybd_event(VK_CONTROL, 0, 0, 0);
4556 keybd_event(VK_MENU, 0, 0, 0);
4557 keybd_event(VK_SHIFT, 0, 0, 0);
4558 keybd_event('N', 0, 0, 0);
4559 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4560 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4561 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4562 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4563 pump_msg_loop(hwnd, hAccel);
4564 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
4566 ret = DestroyAcceleratorTable(hAccel);
4567 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4569 trace("testing Alt press/release\n");
4571 keybd_event(VK_MENU, 0, 0, 0);
4572 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4573 keybd_event(VK_MENU, 0, 0, 0);
4574 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4575 pump_msg_loop(hwnd, 0);
4576 /* this test doesn't pass in Wine for managed windows */
4577 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
4579 trace("testing Alt+MouseButton press/release\n");
4580 /* first, move mouse pointer inside of the window client area */
4581 GetClientRect(hwnd, &rc);
4582 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
4583 rc.left += (rc.right - rc.left)/2;
4584 rc.top += (rc.bottom - rc.top)/2;
4585 SetCursorPos(rc.left, rc.top);
4587 pump_msg_loop(hwnd, 0);
4589 keybd_event(VK_MENU, 0, 0, 0);
4590 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4591 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4592 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4593 pump_msg_loop(hwnd, 0);
4594 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
4596 keybd_event(VK_F1, 0, 0, 0);
4597 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
4598 pump_msg_loop(hwnd, 0);
4599 ok_sequence(WmF1Seq, "F1 press/release", TRUE);
4601 DestroyWindow(hwnd);
4604 /************* window procedures ********************/
4606 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
4607 WPARAM wParam, LPARAM lParam)
4609 static long defwndproc_counter = 0;
4610 static long beginpaint_counter = 0;
4614 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4616 /* explicitly ignore WM_GETICON message */
4617 if (message == WM_GETICON) return 0;
4623 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
4624 ok((BOOL)wParam == !(style & WS_DISABLED),
4625 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
4629 case WM_CAPTURECHANGED:
4630 if (test_DestroyWindow_flag)
4632 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
4633 if (style & WS_CHILD)
4634 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
4635 else if (style & WS_POPUP)
4636 lParam = WND_POPUP_ID;
4638 lParam = WND_PARENT_ID;
4646 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
4647 capture = GetCapture();
4650 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
4651 trace("current capture %p, releasing...\n", capture);
4658 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
4659 if (test_DestroyWindow_flag)
4661 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
4662 if (style & WS_CHILD)
4663 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
4664 else if (style & WS_POPUP)
4665 lParam = WND_POPUP_ID;
4667 lParam = WND_PARENT_ID;
4671 /* test_accelerators() depends on this */
4678 case WM_DEVICECHANGE:
4681 case WM_WINDOWPOSCHANGING:
4682 case WM_WINDOWPOSCHANGED:
4684 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4686 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4687 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4688 winpos->hwnd, winpos->hwndInsertAfter,
4689 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
4691 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4692 * in the high word for internal purposes
4694 wParam = winpos->flags & 0xffff;
4699 msg.message = message;
4700 msg.flags = sent|wparam|lparam;
4701 if (defwndproc_counter) msg.flags |= defwinproc;
4702 if (beginpaint_counter) msg.flags |= beginpaint;
4703 msg.wParam = wParam;
4704 msg.lParam = lParam;
4707 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
4709 HWND parent = GetParent(hwnd);
4711 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
4713 GetClientRect(parent, &rc);
4714 trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
4716 trace("ptReserved = (%ld,%ld)\n"
4717 "ptMaxSize = (%ld,%ld)\n"
4718 "ptMaxPosition = (%ld,%ld)\n"
4719 "ptMinTrackSize = (%ld,%ld)\n"
4720 "ptMaxTrackSize = (%ld,%ld)\n",
4721 minmax->ptReserved.x, minmax->ptReserved.y,
4722 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
4723 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
4724 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
4725 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
4727 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %ld != %ld\n",
4728 minmax->ptMaxSize.x, rc.right);
4729 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %ld != %ld\n",
4730 minmax->ptMaxSize.y, rc.bottom);
4733 if (message == WM_PAINT)
4736 beginpaint_counter++;
4737 BeginPaint( hwnd, &ps );
4738 beginpaint_counter--;
4739 EndPaint( hwnd, &ps );
4743 defwndproc_counter++;
4744 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
4745 : DefWindowProcA(hwnd, message, wParam, lParam);
4746 defwndproc_counter--;
4751 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4753 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
4756 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4758 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
4761 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4763 static long defwndproc_counter = 0;
4767 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4769 /* explicitly ignore WM_GETICON message */
4770 if (message == WM_GETICON) return 0;
4772 msg.message = message;
4773 msg.flags = sent|wparam|lparam;
4774 if (defwndproc_counter) msg.flags |= defwinproc;
4775 msg.wParam = wParam;
4776 msg.lParam = lParam;
4779 if (message == WM_CREATE)
4781 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
4782 SetWindowLongA(hwnd, GWL_STYLE, style);
4785 defwndproc_counter++;
4786 ret = DefWindowProcA(hwnd, message, wParam, lParam);
4787 defwndproc_counter--;
4792 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4794 static long defwndproc_counter = 0;
4795 static long beginpaint_counter = 0;
4799 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4801 /* explicitly ignore WM_GETICON message */
4802 if (message == WM_GETICON) return 0;
4804 if (log_all_parent_messages ||
4805 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
4806 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
4807 message == WM_ENABLE || message == WM_ENTERIDLE ||
4808 message == WM_IME_SETCONTEXT)
4815 INT ret = GetClipBox((HDC)wParam, &rc);
4817 trace("WM_ERASEBKGND: GetClipBox()=%d, (%ld,%ld-%ld,%ld)\n",
4818 ret, rc.left, rc.top, rc.right, rc.bottom);
4822 case WM_WINDOWPOSCHANGING:
4823 case WM_WINDOWPOSCHANGED:
4825 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4827 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4828 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4829 winpos->hwnd, winpos->hwndInsertAfter,
4830 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
4832 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4833 * in the high word for internal purposes
4835 wParam = winpos->flags & 0xffff;
4840 msg.message = message;
4841 msg.flags = sent|parent|wparam|lparam;
4842 if (defwndproc_counter) msg.flags |= defwinproc;
4843 if (beginpaint_counter) msg.flags |= beginpaint;
4844 msg.wParam = wParam;
4845 msg.lParam = lParam;
4849 if (message == WM_PAINT)
4852 beginpaint_counter++;
4853 BeginPaint( hwnd, &ps );
4854 beginpaint_counter--;
4855 EndPaint( hwnd, &ps );
4859 defwndproc_counter++;
4860 ret = DefWindowProcA(hwnd, message, wParam, lParam);
4861 defwndproc_counter--;
4866 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4868 static long defwndproc_counter = 0;
4872 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4874 /* explicitly ignore WM_GETICON message */
4875 if (message == WM_GETICON) return 0;
4877 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
4878 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4879 if (after_end_dialog)
4880 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
4882 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
4886 case WM_WINDOWPOSCHANGING:
4887 case WM_WINDOWPOSCHANGED:
4889 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4891 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4892 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4893 winpos->hwnd, winpos->hwndInsertAfter,
4894 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
4896 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4897 * in the high word for internal purposes
4899 wParam = winpos->flags & 0xffff;
4904 msg.message = message;
4905 msg.flags = sent|wparam|lparam;
4906 if (defwndproc_counter) msg.flags |= defwinproc;
4907 msg.wParam = wParam;
4908 msg.lParam = lParam;
4911 defwndproc_counter++;
4912 ret = DefDlgProcA(hwnd, message, wParam, lParam);
4913 defwndproc_counter--;
4918 static BOOL RegisterWindowClasses(void)
4923 cls.lpfnWndProc = MsgCheckProcA;
4926 cls.hInstance = GetModuleHandleA(0);
4928 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
4929 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
4930 cls.lpszMenuName = NULL;
4931 cls.lpszClassName = "TestWindowClass";
4932 if(!RegisterClassA(&cls)) return FALSE;
4934 cls.lpfnWndProc = PopupMsgCheckProcA;
4935 cls.lpszClassName = "TestPopupClass";
4936 if(!RegisterClassA(&cls)) return FALSE;
4938 cls.lpfnWndProc = ParentMsgCheckProcA;
4939 cls.lpszClassName = "TestParentClass";
4940 if(!RegisterClassA(&cls)) return FALSE;
4942 cls.lpfnWndProc = DefWindowProcA;
4943 cls.lpszClassName = "SimpleWindowClass";
4944 if(!RegisterClassA(&cls)) return FALSE;
4946 cls.style = CS_NOCLOSE;
4947 cls.lpszClassName = "NoCloseWindowClass";
4948 if(!RegisterClassA(&cls)) return FALSE;
4950 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
4952 cls.hInstance = GetModuleHandleA(0);
4953 cls.hbrBackground = 0;
4954 cls.lpfnWndProc = TestDlgProcA;
4955 cls.lpszClassName = "TestDialogClass";
4956 if(!RegisterClassA(&cls)) return FALSE;
4961 static HHOOK hCBT_hook;
4962 static DWORD cbt_hook_thread_id;
4964 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
4966 static const char *CBT_code_name[10] = {
4973 "HCBT_CLICKSKIPPED",
4977 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
4981 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
4983 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
4985 if (nCode == HCBT_SYSCOMMAND)
4989 msg.message = nCode;
4990 msg.flags = hook|wparam|lparam;
4991 msg.wParam = wParam;
4992 msg.lParam = lParam;
4995 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
4998 if (nCode == HCBT_DESTROYWND)
5000 if (test_DestroyWindow_flag)
5002 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
5003 if (style & WS_CHILD)
5004 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
5005 else if (style & WS_POPUP)
5006 lParam = WND_POPUP_ID;
5008 lParam = WND_PARENT_ID;
5012 /* Log also SetFocus(0) calls */
5013 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5015 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5017 if (!lstrcmpiA(buf, "TestWindowClass") ||
5018 !lstrcmpiA(buf, "TestParentClass") ||
5019 !lstrcmpiA(buf, "TestPopupClass") ||
5020 !lstrcmpiA(buf, "SimpleWindowClass") ||
5021 !lstrcmpiA(buf, "TestDialogClass") ||
5022 !lstrcmpiA(buf, "MDI_frame_class") ||
5023 !lstrcmpiA(buf, "MDI_client_class") ||
5024 !lstrcmpiA(buf, "MDI_child_class") ||
5025 !lstrcmpiA(buf, "my_button_class") ||
5026 !lstrcmpiA(buf, "static") ||
5027 !lstrcmpiA(buf, "#32770"))
5031 msg.message = nCode;
5032 msg.flags = hook|wparam|lparam;
5033 msg.wParam = wParam;
5034 msg.lParam = lParam;
5038 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5041 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
5051 trace("WEH:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5052 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5054 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5056 /* ignore mouse cursor events */
5057 if (object_id == OBJID_CURSOR) return;
5059 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
5062 !lstrcmpiA(buf, "TestWindowClass") ||
5063 !lstrcmpiA(buf, "TestParentClass") ||
5064 !lstrcmpiA(buf, "TestPopupClass") ||
5065 !lstrcmpiA(buf, "SimpleWindowClass") ||
5066 !lstrcmpiA(buf, "TestDialogClass") ||
5067 !lstrcmpiA(buf, "MDI_frame_class") ||
5068 !lstrcmpiA(buf, "MDI_client_class") ||
5069 !lstrcmpiA(buf, "MDI_child_class") ||
5070 !lstrcmpiA(buf, "my_button_class") ||
5071 !lstrcmpiA(buf, "static") ||
5072 !lstrcmpiA(buf, "#32770"))
5076 msg.message = event;
5077 msg.flags = winevent_hook|wparam|lparam;
5078 msg.wParam = object_id;
5079 msg.lParam = child_id;
5085 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
5086 static const WCHAR wszAnsi[] = {'U',0};
5088 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5092 case CB_FINDSTRINGEXACT:
5093 trace("String: %p\n", (LPCWSTR)lParam);
5094 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
5096 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
5100 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
5103 static const struct message WmGetTextLengthAfromW[] = {
5104 { WM_GETTEXTLENGTH, sent },
5105 { WM_GETTEXT, sent },
5109 static const WCHAR testWindowClassW[] =
5110 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
5112 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
5114 /* dummy window proc for WM_GETTEXTLENGTH test */
5115 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
5119 case WM_GETTEXTLENGTH:
5120 return lstrlenW(dummy_window_text) + 37; /* some random length */
5122 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
5123 return lstrlenW( (LPWSTR)lp );
5125 return DefWindowProcW( hwnd, msg, wp, lp );
5129 static void test_message_conversion(void)
5131 static const WCHAR wszMsgConversionClass[] =
5132 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
5136 WNDPROC wndproc, newproc;
5140 cls.lpfnWndProc = MsgConversionProcW;
5143 cls.hInstance = GetModuleHandleW(NULL);
5145 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
5146 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
5147 cls.lpszMenuName = NULL;
5148 cls.lpszClassName = wszMsgConversionClass;
5149 /* this call will fail on Win9x, but that doesn't matter as this test is
5150 * meaningless on those platforms */
5151 if(!RegisterClassW(&cls)) return;
5154 cls.lpfnWndProc = MsgCheckProcW;
5157 cls.hInstance = GetModuleHandleW(0);
5159 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
5160 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5161 cls.lpszMenuName = NULL;
5162 cls.lpszClassName = testWindowClassW;
5163 if(!RegisterClassW(&cls)) return;
5165 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
5166 100, 100, 200, 200, 0, 0, 0, NULL);
5167 ok(hwnd != NULL, "Window creation failed\n");
5171 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
5172 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5173 ok(lRes == 0, "String should have been converted\n");
5174 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5175 ok(lRes == 1, "String shouldn't have been converted\n");
5179 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
5180 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5181 ok(lRes == 1, "String shouldn't have been converted\n");
5182 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5183 ok(lRes == 1, "String shouldn't have been converted\n");
5185 /* Synchronous messages */
5187 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5188 ok(lRes == 0, "String should have been converted\n");
5189 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5190 ok(lRes == 1, "String shouldn't have been converted\n");
5192 /* Asynchronous messages */
5195 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5196 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5197 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5199 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5200 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5201 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5203 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5204 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5205 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5207 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5208 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5209 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5211 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5212 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5213 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5215 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5216 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5217 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5219 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5220 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5221 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5223 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5224 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5225 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5227 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
5229 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
5230 WS_OVERLAPPEDWINDOW,
5231 100, 100, 200, 200, 0, 0, 0, NULL);
5234 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
5235 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5236 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5237 "got bad length %ld\n", lRes );
5240 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
5241 hwnd, WM_GETTEXTLENGTH, 0, 0);
5242 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5243 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5244 "got bad length %ld\n", lRes );
5246 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
5247 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
5248 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5249 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5250 NULL, 0, NULL, NULL ),
5251 "got bad length %ld\n", lRes );
5253 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
5254 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5255 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5256 NULL, 0, NULL, NULL ),
5257 "got bad length %ld\n", lRes );
5259 ret = DestroyWindow(hwnd);
5260 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5263 typedef struct _thread_info
5270 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
5274 #define TIMER_ID 0x19
5276 static DWORD WINAPI timer_thread_proc(LPVOID x)
5278 thread_info *info = x;
5281 r = KillTimer(info->hWnd, 0x19);
5282 ok(r,"KillTimer failed in thread\n");
5283 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
5284 ok(r,"SetTimer failed in thread\n");
5285 ok(r==TIMER_ID,"SetTimer id different\n");
5286 r = SetEvent(info->handles[0]);
5287 ok(r,"SetEvent failed in thread\n");
5291 static void test_timers(void)
5296 info.hWnd = CreateWindow ("TestWindowClass", NULL,
5297 WS_OVERLAPPEDWINDOW ,
5298 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5301 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
5302 ok(info.id, "SetTimer failed\n");
5303 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
5304 info.handles[0] = CreateEvent(NULL,0,0,NULL);
5305 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
5307 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
5309 WaitForSingleObject(info.handles[1], INFINITE);
5311 CloseHandle(info.handles[0]);
5312 CloseHandle(info.handles[1]);
5314 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
5316 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
5319 /* Various win events with arbitrary parameters */
5320 static const struct message WmWinEventsSeq[] = {
5321 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5322 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5323 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5324 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5325 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5326 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5327 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5328 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5329 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5330 /* our win event hook ignores OBJID_CURSOR events */
5331 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
5332 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
5333 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
5334 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
5335 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
5336 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5337 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5338 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5339 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5340 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5341 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5342 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5343 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5344 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5347 static const struct message WmWinEventCaretSeq[] = {
5348 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5349 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5350 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
5351 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5354 static const struct message WmWinEventCaretSeq_2[] = {
5355 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5356 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5357 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5360 static const struct message WmWinEventAlertSeq[] = {
5361 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
5364 static const struct message WmWinEventAlertSeq_2[] = {
5365 /* create window in the thread proc */
5366 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
5367 /* our test event */
5368 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
5371 static const struct message WmGlobalHookSeq_1[] = {
5372 /* create window in the thread proc */
5373 { HCBT_CREATEWND, hook|lparam, 0, 2 },
5374 /* our test events */
5375 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
5376 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
5379 static const struct message WmGlobalHookSeq_2[] = {
5380 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
5381 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
5382 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
5383 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
5387 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
5397 trace("WEH_2:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5398 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5400 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5402 if (!lstrcmpiA(buf, "TestWindowClass") ||
5403 !lstrcmpiA(buf, "static"))
5407 msg.message = event;
5408 msg.flags = winevent_hook|wparam|lparam;
5409 msg.wParam = object_id;
5410 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
5416 static HHOOK hCBT_global_hook;
5417 static DWORD cbt_global_hook_thread_id;
5419 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5424 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
5426 if (nCode == HCBT_SYSCOMMAND)
5430 msg.message = nCode;
5431 msg.flags = hook|wparam|lparam;
5432 msg.wParam = wParam;
5433 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5436 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5439 /* Log also SetFocus(0) calls */
5440 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5442 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5444 if (!lstrcmpiA(buf, "TestWindowClass") ||
5445 !lstrcmpiA(buf, "static"))
5449 msg.message = nCode;
5450 msg.flags = hook|wparam|lparam;
5451 msg.wParam = wParam;
5452 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5456 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5459 static DWORD WINAPI win_event_global_thread_proc(void *param)
5463 HANDLE hevent = *(HANDLE *)param;
5464 HMODULE user32 = GetModuleHandleA("user32.dll");
5465 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5467 assert(pNotifyWinEvent);
5469 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5471 trace("created thread window %p\n", hwnd);
5473 *(HWND *)param = hwnd;
5476 /* this event should be received only by our new hook proc,
5477 * an old one does not expect an event from another thread.
5479 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
5482 while (GetMessage(&msg, 0, 0, 0))
5484 TranslateMessage(&msg);
5485 DispatchMessage(&msg);
5490 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
5494 HANDLE hevent = *(HANDLE *)param;
5497 /* these events should be received only by our new hook proc,
5498 * an old one does not expect an event from another thread.
5501 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5503 trace("created thread window %p\n", hwnd);
5505 *(HWND *)param = hwnd;
5507 /* Windows doesn't like when a thread plays games with the focus,
5508 that leads to all kinds of misbehaviours and failures to activate
5509 a window. So, better keep next lines commented out.
5513 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5514 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5518 while (GetMessage(&msg, 0, 0, 0))
5520 TranslateMessage(&msg);
5521 DispatchMessage(&msg);
5526 static void test_winevents(void)
5532 HANDLE hthread, hevent;
5534 HWINEVENTHOOK hhook;
5535 const struct message *events = WmWinEventsSeq;
5536 HMODULE user32 = GetModuleHandleA("user32.dll");
5537 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
5538 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
5539 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5541 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
5542 WS_OVERLAPPEDWINDOW,
5543 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5547 /****** start of global hook test *************/
5548 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
5549 assert(hCBT_global_hook);
5551 hevent = CreateEventA(NULL, 0, 0, NULL);
5553 hwnd2 = (HWND)hevent;
5555 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
5556 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5558 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5560 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
5563 /* this one should be received only by old hook proc */
5564 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5565 /* this one should be received only by old hook proc */
5566 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5568 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
5570 ret = UnhookWindowsHookEx(hCBT_global_hook);
5571 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
5573 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5574 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5575 CloseHandle(hthread);
5576 CloseHandle(hevent);
5577 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5578 /****** end of global hook test *************/
5580 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
5582 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5588 #if 0 /* this test doesn't pass under Win9x */
5589 /* win2k ignores events with hwnd == 0 */
5590 SetLastError(0xdeadbeef);
5591 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
5592 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
5593 GetLastError() == 0xdeadbeef, /* Win9x */
5594 "unexpected error %ld\n", GetLastError());
5595 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
5598 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
5599 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
5601 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
5603 /****** start of event filtering test *************/
5604 hhook = (HWINEVENTHOOK)pSetWinEventHook(
5605 EVENT_OBJECT_SHOW, /* 0x8002 */
5606 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
5607 GetModuleHandleA(0), win_event_global_hook_proc,
5608 GetCurrentProcessId(), 0,
5609 WINEVENT_INCONTEXT);
5610 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
5612 hevent = CreateEventA(NULL, 0, 0, NULL);
5614 hwnd2 = (HWND)hevent;
5616 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
5617 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5619 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5621 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
5624 /* this one should be received only by old hook proc */
5625 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
5626 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
5627 /* this one should be received only by old hook proc */
5628 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
5630 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
5632 ret = pUnhookWinEvent(hhook);
5633 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5635 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5636 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5637 CloseHandle(hthread);
5638 CloseHandle(hevent);
5639 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5640 /****** end of event filtering test *************/
5642 /****** start of out of context event test *************/
5643 hhook = (HWINEVENTHOOK)pSetWinEventHook(
5644 EVENT_MIN, EVENT_MAX,
5645 0, win_event_global_hook_proc,
5646 GetCurrentProcessId(), 0,
5647 WINEVENT_OUTOFCONTEXT);
5648 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
5650 hevent = CreateEventA(NULL, 0, 0, NULL);
5652 hwnd2 = (HWND)hevent;
5656 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
5657 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5659 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5661 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
5662 /* process pending winevent messages */
5663 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
5664 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
5667 /* this one should be received only by old hook proc */
5668 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
5669 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
5670 /* this one should be received only by old hook proc */
5671 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
5673 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
5674 /* process pending winevent messages */
5675 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
5676 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
5678 ret = pUnhookWinEvent(hhook);
5679 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5681 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5682 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5683 CloseHandle(hthread);
5684 CloseHandle(hevent);
5685 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5686 /****** end of out of context event test *************/
5688 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5691 static void test_set_hook(void)
5695 HWINEVENTHOOK hwinevent_hook;
5696 HMODULE user32 = GetModuleHandleA("user32.dll");
5697 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
5698 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
5700 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
5701 ok(hhook != 0, "local hook does not require hModule set to 0\n");
5702 UnhookWindowsHookEx(hhook);
5704 #if 0 /* this test doesn't pass under Win9x: BUG! */
5705 SetLastError(0xdeadbeef);
5706 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
5707 ok(!hhook, "global hook requires hModule != 0\n");
5708 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %ld\n", GetLastError());
5711 SetLastError(0xdeadbeef);
5712 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
5713 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
5714 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
5715 GetLastError() == 0xdeadbeef, /* Win9x */
5716 "unexpected error %ld\n", GetLastError());
5718 SetLastError(0xdeadbeef);
5719 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
5720 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
5721 GetLastError() == 0xdeadbeef, /* Win9x */
5722 "unexpected error %ld\n", GetLastError());
5724 if (!pSetWinEventHook || !pUnhookWinEvent) return;
5726 /* even process local incontext hooks require hmodule */
5727 SetLastError(0xdeadbeef);
5728 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5729 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
5730 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
5731 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
5732 GetLastError() == 0xdeadbeef, /* Win9x */
5733 "unexpected error %ld\n", GetLastError());
5735 /* even thread local incontext hooks require hmodule */
5736 SetLastError(0xdeadbeef);
5737 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5738 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
5739 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
5740 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
5741 GetLastError() == 0xdeadbeef, /* Win9x */
5742 "unexpected error %ld\n", GetLastError());
5744 #if 0 /* these 3 tests don't pass under Win9x */
5745 SetLastError(0xdeadbeef);
5746 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
5747 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
5748 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
5749 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
5751 SetLastError(0xdeadbeef);
5752 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
5753 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
5754 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
5755 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
5757 SetLastError(0xdeadbeef);
5758 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5759 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
5760 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
5761 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %ld\n", GetLastError());
5764 SetLastError(0xdeadbeef);
5765 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
5766 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
5767 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
5768 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
5769 ret = pUnhookWinEvent(hwinevent_hook);
5770 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5773 /* This call succeeds under win2k SP4, but fails under Wine.
5774 Does win2k test/use passed process id? */
5775 SetLastError(0xdeadbeef);
5776 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5777 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
5778 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
5779 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
5780 ret = pUnhookWinEvent(hwinevent_hook);
5781 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5784 SetLastError(0xdeadbeef);
5785 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
5786 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
5787 GetLastError() == 0xdeadbeef, /* Win9x */
5788 "unexpected error %ld\n", GetLastError());
5791 static const struct message ScrollWindowPaint1[] = {
5793 { WM_ERASEBKGND, sent|beginpaint },
5797 static const struct message ScrollWindowPaint2[] = {
5802 static void test_scrollwindowex(void)
5805 RECT rect={0,0,130,130};
5808 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
5809 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
5810 100, 100, 200, 200, 0, 0, 0, NULL);
5811 ok (hwnd != 0, "Failed to create overlapped window\n");
5812 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
5813 WS_VISIBLE|WS_CAPTION|WS_CHILD,
5814 10, 10, 150, 150, hwnd, 0, 0, NULL);
5815 ok (hchild != 0, "Failed to create child\n");
5817 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5820 /* scroll without the child window */
5821 trace("start scroll\n");
5822 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
5823 SW_ERASE|SW_INVALIDATE);
5824 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
5825 trace("end scroll\n");
5827 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5828 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
5830 /* Now without the SW_ERASE flag */
5831 trace("start scroll\n");
5832 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
5833 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
5834 trace("end scroll\n");
5836 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5837 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
5839 /* now scroll the child window as well */
5840 trace("start scroll\n");
5841 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
5842 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
5843 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
5844 /* windows sometimes a WM_MOVE */
5845 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
5847 trace("end scroll\n");
5849 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5850 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
5852 /* now scroll with ScrollWindow() */
5853 trace("start scroll with ScrollWindow\n");
5854 ScrollWindow( hwnd, 5, 5, NULL, NULL);
5855 trace("end scroll\n");
5857 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5858 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
5860 ok(DestroyWindow(hchild), "failed to destroy window\n");
5861 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5865 static const struct message destroy_window_with_children[] = {
5866 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
5867 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
5868 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
5869 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
5870 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
5871 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
5872 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
5873 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
5874 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
5875 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
5876 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
5877 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
5878 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
5879 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
5880 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
5881 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
5885 static void test_DestroyWindow(void)
5888 HWND parent, child1, child2, child3, child4, test;
5889 UINT child_id = WND_CHILD_ID + 1;
5891 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
5892 100, 100, 200, 200, 0, 0, 0, NULL);
5893 assert(parent != 0);
5894 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
5895 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
5896 assert(child1 != 0);
5897 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
5898 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
5899 assert(child2 != 0);
5900 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
5901 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
5902 assert(child3 != 0);
5903 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
5904 0, 0, 50, 50, parent, 0, 0, NULL);
5905 assert(child4 != 0);
5907 /* test owner/parent of child2 */
5908 test = GetParent(child2);
5909 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5910 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
5912 test = pGetAncestor(child2, GA_PARENT);
5913 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5915 test = GetWindow(child2, GW_OWNER);
5916 ok(!test, "wrong owner %p\n", test);
5918 test = SetParent(child2, parent);
5919 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
5921 /* test owner/parent of the parent */
5922 test = GetParent(parent);
5923 ok(!test, "wrong parent %p\n", test);
5925 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
5928 test = pGetAncestor(parent, GA_PARENT);
5929 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5931 test = GetWindow(parent, GW_OWNER);
5932 ok(!test, "wrong owner %p\n", test);
5934 /* test owner/parent of child1 */
5935 test = GetParent(child1);
5936 ok(test == parent, "wrong parent %p\n", test);
5937 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
5939 test = pGetAncestor(child1, GA_PARENT);
5940 ok(test == parent, "wrong parent %p\n", test);
5942 test = GetWindow(child1, GW_OWNER);
5943 ok(!test, "wrong owner %p\n", test);
5945 /* test owner/parent of child2 */
5946 test = GetParent(child2);
5947 ok(test == parent, "wrong parent %p\n", test);
5948 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
5950 test = pGetAncestor(child2, GA_PARENT);
5951 ok(test == parent, "wrong parent %p\n", test);
5953 test = GetWindow(child2, GW_OWNER);
5954 ok(!test, "wrong owner %p\n", test);
5956 /* test owner/parent of child3 */
5957 test = GetParent(child3);
5958 ok(test == child1, "wrong parent %p\n", test);
5959 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
5961 test = pGetAncestor(child3, GA_PARENT);
5962 ok(test == child1, "wrong parent %p\n", test);
5964 test = GetWindow(child3, GW_OWNER);
5965 ok(!test, "wrong owner %p\n", test);
5967 /* test owner/parent of child4 */
5968 test = GetParent(child4);
5969 ok(test == parent, "wrong parent %p\n", test);
5970 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
5972 test = pGetAncestor(child4, GA_PARENT);
5973 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5975 test = GetWindow(child4, GW_OWNER);
5976 ok(test == parent, "wrong owner %p\n", test);
5980 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
5981 parent, child1, child2, child3, child4);
5984 test = GetCapture();
5985 ok(test == child4, "wrong capture window %p\n", test);
5987 test_DestroyWindow_flag = TRUE;
5988 ret = DestroyWindow(parent);
5989 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5990 test_DestroyWindow_flag = FALSE;
5991 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
5993 ok(!IsWindow(parent), "parent still exists\n");
5994 ok(!IsWindow(child1), "child1 still exists\n");
5995 ok(!IsWindow(child2), "child2 still exists\n");
5996 ok(!IsWindow(child3), "child3 still exists\n");
5997 ok(!IsWindow(child4), "child4 still exists\n");
5999 test = GetCapture();
6000 ok(!test, "wrong capture window %p\n", test);
6004 static const struct message WmDispatchPaint[] = {
6005 { WM_NCPAINT, sent },
6006 { WM_GETTEXT, sent|defwinproc|optional },
6007 { WM_GETTEXT, sent|defwinproc|optional },
6008 { WM_ERASEBKGND, sent },
6012 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6014 if (message == WM_PAINT) return 0;
6015 return MsgCheckProcA( hwnd, message, wParam, lParam );
6018 static void test_DispatchMessage(void)
6023 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6024 100, 100, 200, 200, 0, 0, 0, NULL);
6025 ShowWindow( hwnd, SW_SHOW );
6026 UpdateWindow( hwnd );
6027 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6029 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
6031 SetRect( &rect, -5, -5, 5, 5 );
6032 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6034 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6036 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6040 DispatchMessage( &msg );
6041 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
6042 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6043 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
6044 if (++count > 10) break;
6047 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
6049 trace("now without DispatchMessage\n");
6051 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6053 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6055 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6058 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
6060 /* this will send WM_NCCPAINT just like DispatchMessage does */
6061 GetUpdateRgn( hwnd, hrgn, TRUE );
6062 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6063 DeleteObject( hrgn );
6064 GetClientRect( hwnd, &rect );
6065 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
6066 ok( !count, "Got multiple WM_PAINTs\n" );
6067 if (++count > 10) break;
6073 static const struct message WmUser[] = {
6085 static DWORD CALLBACK send_msg_thread( LPVOID arg )
6087 struct thread_info *info = arg;
6088 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
6089 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %ld\n", GetLastError());
6093 static void wait_for_thread( HANDLE thread )
6095 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
6098 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
6102 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6104 if (message == WM_USER) Sleep(200);
6105 return MsgCheckProcA( hwnd, message, wParam, lParam );
6108 static void test_SendMessageTimeout(void)
6112 struct thread_info info;
6115 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6116 100, 100, 200, 200, 0, 0, 0, NULL);
6117 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6120 info.timeout = 1000;
6121 info.ret = 0xdeadbeef;
6122 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6123 wait_for_thread( thread );
6124 CloseHandle( thread );
6125 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6126 ok_sequence( WmUser, "WmUser", FALSE );
6129 info.ret = 0xdeadbeef;
6130 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6131 Sleep(100); /* SendMessageTimeout should timeout here */
6132 wait_for_thread( thread );
6133 CloseHandle( thread );
6134 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6135 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6137 /* 0 means infinite timeout */
6139 info.ret = 0xdeadbeef;
6140 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6142 wait_for_thread( thread );
6143 CloseHandle( thread );
6144 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6145 ok_sequence( WmUser, "WmUser", FALSE );
6147 /* timeout is treated as signed despite the prototype */
6148 info.timeout = 0x7fffffff;
6149 info.ret = 0xdeadbeef;
6150 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6152 wait_for_thread( thread );
6153 CloseHandle( thread );
6154 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6155 ok_sequence( WmUser, "WmUser", FALSE );
6157 info.timeout = 0x80000000;
6158 info.ret = 0xdeadbeef;
6159 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6161 wait_for_thread( thread );
6162 CloseHandle( thread );
6163 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6164 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6166 /* now check for timeout during message processing */
6167 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
6169 info.ret = 0xdeadbeef;
6170 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6171 wait_for_thread( thread );
6172 CloseHandle( thread );
6173 /* we should timeout but still get the message */
6174 ok( info.ret == 0, "SendMessageTimeout failed\n" );
6175 ok_sequence( WmUser, "WmUser", FALSE );
6177 DestroyWindow( info.hwnd );
6184 HMODULE user32 = GetModuleHandleA("user32.dll");
6185 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6186 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6187 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
6188 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
6190 if (!RegisterWindowClasses()) assert(0);
6192 if (pSetWinEventHook)
6194 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6195 GetModuleHandleA(0),
6198 GetCurrentThreadId(),
6199 WINEVENT_INCONTEXT);
6200 assert(hEvent_hook);
6202 if (pIsWinEventHookInstalled)
6205 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
6206 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
6210 cbt_hook_thread_id = GetCurrentThreadId();
6211 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
6216 /* Fix message sequences before removing 3 lines below */
6217 ret = pUnhookWinEvent(hEvent_hook);
6218 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6219 pUnhookWinEvent = 0;
6222 test_scrollwindowex();
6224 test_mdi_messages();
6225 test_button_messages();
6226 test_paint_messages();
6227 test_interthread_messages();
6228 test_message_conversion();
6229 test_accelerators();
6232 test_DestroyWindow();
6233 test_DispatchMessage();
6234 test_SendMessageTimeout();
6236 UnhookWindowsHookEx(hCBT_hook);
6237 if (pUnhookWinEvent)
6239 ret = pUnhookWinEvent(hEvent_hook);
6240 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6241 SetLastError(0xdeadbeef);
6242 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
6243 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
6244 GetLastError() == 0xdeadbeef, /* Win9x */
6245 "unexpected error %ld\n", GetLastError());