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 );
3700 /* now with frame */
3701 SetRectRgn( hrgn, -5, -5, 20, 20 );
3703 /* flush pending messages */
3704 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3707 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3708 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
3710 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
3711 check_update_rgn( hwnd, hrgn );
3714 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
3715 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
3718 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
3719 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
3721 GetClientRect( hwnd, &rect );
3722 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
3723 check_update_rgn( hwnd, hrgn );
3726 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
3727 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
3730 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
3731 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
3732 check_update_rgn( hwnd, 0 );
3735 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
3736 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
3737 check_update_rgn( hwnd, 0 );
3740 SetRectRgn( hrgn, 0, 0, 100, 100 );
3741 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
3742 SetRectRgn( hrgn, 0, 0, 50, 100 );
3743 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
3744 SetRectRgn( hrgn, 50, 0, 100, 100 );
3745 check_update_rgn( hwnd, hrgn );
3746 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
3747 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
3748 check_update_rgn( hwnd, 0 );
3751 SetRectRgn( hrgn, 0, 0, 100, 100 );
3752 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
3753 SetRectRgn( hrgn, 0, 0, 100, 50 );
3754 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
3755 ok_sequence( WmErase, "Erase", FALSE );
3756 SetRectRgn( hrgn, 0, 50, 100, 100 );
3757 check_update_rgn( hwnd, hrgn );
3760 SetRectRgn( hrgn, 0, 0, 100, 100 );
3761 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
3762 SetRectRgn( hrgn, 0, 0, 50, 50 );
3763 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
3764 ok_sequence( WmPaint, "Paint", FALSE );
3767 SetRectRgn( hrgn, -4, -4, -2, -2 );
3768 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3769 SetRectRgn( hrgn, -200, -200, -198, -198 );
3770 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
3771 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
3774 SetRectRgn( hrgn, -4, -4, -2, -2 );
3775 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3776 SetRectRgn( hrgn, -4, -4, -3, -3 );
3777 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
3778 SetRectRgn( hrgn, 0, 0, 1, 1 );
3779 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
3780 ok_sequence( WmPaint, "Paint", FALSE );
3783 SetRectRgn( hrgn, -4, -4, -1, -1 );
3784 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3785 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
3786 /* make sure no WM_PAINT was generated */
3787 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3788 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
3791 SetRectRgn( hrgn, -4, -4, -1, -1 );
3792 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
3793 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
3795 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
3797 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
3798 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
3799 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
3800 ret = GetUpdateRect( hwnd, &rect, FALSE );
3801 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
3802 /* this will send WM_NCPAINT and validate the non client area */
3803 ret = GetUpdateRect( hwnd, &rect, TRUE );
3804 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
3806 DispatchMessage( &msg );
3808 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
3810 DestroyWindow( hwnd );
3812 /* now test with a child window */
3814 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
3815 100, 100, 200, 200, 0, 0, 0, NULL);
3816 ok (hparent != 0, "Failed to create parent window\n");
3818 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
3819 10, 10, 100, 100, hparent, 0, 0, NULL);
3820 ok (hchild != 0, "Failed to create child window\n");
3822 ShowWindow( hparent, SW_SHOW );
3823 UpdateWindow( hparent );
3824 UpdateWindow( hchild );
3825 /* try to flush pending X expose events */
3826 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
3827 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3830 log_all_parent_messages++;
3832 SetRect( &rect, 0, 0, 50, 50 );
3833 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3834 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
3835 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
3837 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3839 MapWindowPoints( hchild, hparent, &pt, 1 );
3840 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
3841 check_update_rgn( hchild, hrgn );
3842 SetRectRgn( hrgn, 0, 0, 50, 50 );
3843 check_update_rgn( hparent, hrgn );
3844 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3845 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
3846 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
3847 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
3849 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3850 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
3852 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
3853 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3854 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
3855 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
3856 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
3858 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
3859 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
3860 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
3862 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
3864 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
3865 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3866 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
3868 /* flush all paint messages */
3869 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3872 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
3873 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
3874 SetRectRgn( hrgn, 0, 0, 50, 50 );
3875 check_update_rgn( hparent, hrgn );
3876 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
3877 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3878 SetRectRgn( hrgn, 0, 0, 50, 50 );
3879 check_update_rgn( hparent, hrgn );
3881 /* flush all paint messages */
3882 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3883 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
3886 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
3887 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3888 SetRectRgn( hrgn, 0, 0, 50, 50 );
3889 check_update_rgn( hparent, hrgn );
3890 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
3891 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3892 SetRectRgn( hrgn2, 10, 10, 50, 50 );
3893 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
3894 check_update_rgn( hparent, hrgn );
3895 /* flush all paint messages */
3896 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3899 /* same as above but parent gets completely validated */
3900 SetRect( &rect, 20, 20, 30, 30 );
3901 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3902 SetRectRgn( hrgn, 20, 20, 30, 30 );
3903 check_update_rgn( hparent, hrgn );
3904 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
3905 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3906 check_update_rgn( hparent, 0 ); /* no update region */
3907 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3908 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
3910 /* make sure RDW_VALIDATE on child doesn't have the same effect */
3912 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3913 SetRectRgn( hrgn, 20, 20, 30, 30 );
3914 check_update_rgn( hparent, hrgn );
3915 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
3916 SetRectRgn( hrgn, 20, 20, 30, 30 );
3917 check_update_rgn( hparent, hrgn );
3919 /* same as above but normal WM_PAINT doesn't validate parent */
3921 SetRect( &rect, 20, 20, 30, 30 );
3922 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3923 SetRectRgn( hrgn, 20, 20, 30, 30 );
3924 check_update_rgn( hparent, hrgn );
3925 /* no WM_PAINT in child while parent still pending */
3926 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3927 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
3928 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3929 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
3932 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
3933 /* no WM_PAINT in child while parent still pending */
3934 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3935 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
3936 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
3937 /* now that parent is valid child should get WM_PAINT */
3938 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3939 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
3940 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3941 ok_sequence( WmEmptySeq, "No other message", FALSE );
3943 /* same thing with WS_CLIPCHILDREN in parent */
3945 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
3946 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
3947 /* changing style invalidates non client area, but we need to invalidate something else to see it */
3948 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
3949 ok_sequence( WmEmptySeq, "No message", FALSE );
3950 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
3951 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
3954 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
3955 SetRectRgn( hrgn, 20, 20, 30, 30 );
3956 check_update_rgn( hparent, hrgn );
3957 /* no WM_PAINT in child while parent still pending */
3958 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3959 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
3960 /* WM_PAINT in parent first */
3961 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3962 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
3964 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
3966 SetRect( &rect, 0, 0, 30, 30 );
3967 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
3968 SetRectRgn( hrgn, 0, 0, 30, 30 );
3969 check_update_rgn( hparent, hrgn );
3970 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3971 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
3973 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
3975 SetRect( &rect, -10, 0, 30, 30 );
3976 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
3977 SetRect( &rect, 0, 0, 20, 20 );
3978 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
3979 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
3980 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
3982 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
3984 SetRect( &rect, -10, 0, 30, 30 );
3985 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
3986 SetRect( &rect, 0, 0, 100, 100 );
3987 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
3988 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
3989 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
3990 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
3991 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
3993 /* test RDW_INTERNALPAINT behavior */
3996 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
3997 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3998 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4000 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
4001 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4002 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4004 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4005 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4006 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4008 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
4009 UpdateWindow( hparent );
4010 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4012 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
4013 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4014 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4015 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4016 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4017 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
4019 UpdateWindow( hparent );
4020 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4022 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
4023 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4024 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4025 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4026 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4027 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4029 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4030 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4031 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4032 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4033 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4035 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
4036 UpdateWindow( hparent );
4037 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4039 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
4040 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4041 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4042 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4043 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4044 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
4046 UpdateWindow( hparent );
4047 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4049 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
4050 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4051 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4052 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4053 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4054 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4056 log_all_parent_messages--;
4057 DestroyWindow( hparent );
4058 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
4060 DeleteObject( hrgn );
4061 DeleteObject( hrgn2 );
4070 static DWORD WINAPI thread_proc(void *param)
4073 struct wnd_event *wnd_event = (struct wnd_event *)param;
4075 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
4076 100, 100, 200, 200, 0, 0, 0, NULL);
4077 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
4079 SetEvent(wnd_event->event);
4081 while (GetMessage(&msg, 0, 0, 0))
4083 TranslateMessage(&msg);
4084 DispatchMessage(&msg);
4087 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
4092 static void test_interthread_messages(void)
4099 int len, expected_len;
4100 struct wnd_event wnd_event;
4103 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
4104 if (!wnd_event.event)
4106 trace("skipping interthread message test under win9x\n");
4110 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
4111 ok(hThread != NULL, "CreateThread failed, error %ld\n", GetLastError());
4113 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4115 CloseHandle(wnd_event.event);
4117 SetLastError(0xdeadbeef);
4118 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
4119 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %ld\n", GetLastError());
4121 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4122 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %ld\n", GetLastError());
4124 expected_len = lstrlenA("window caption text");
4125 memset(buf, 0, sizeof(buf));
4126 SetLastError(0xdeadbeef);
4127 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
4128 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %ld, len %d, expected len %d\n", GetLastError(), len, expected_len);
4129 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
4131 msg.hwnd = wnd_event.hwnd;
4132 msg.message = WM_GETTEXT;
4133 msg.wParam = sizeof(buf);
4134 msg.lParam = (LPARAM)buf;
4135 memset(buf, 0, sizeof(buf));
4136 SetLastError(0xdeadbeef);
4137 len = DispatchMessageA(&msg);
4138 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
4139 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %ld\n", len, GetLastError());
4141 /* the following test causes an exception in user.exe under win9x */
4142 msg.hwnd = wnd_event.hwnd;
4143 msg.message = WM_TIMER;
4145 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4146 SetLastError(0xdeadbeef);
4147 len = DispatchMessageA(&msg);
4148 ok(!len && GetLastError() == 0xdeadbeef,
4149 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len, GetLastError());
4151 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
4152 ok( ret, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
4154 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4155 CloseHandle(hThread);
4157 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
4161 static const struct message WmVkN[] = {
4162 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4163 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4164 { WM_CHAR, wparam|lparam, 'n', 1 },
4165 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
4166 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4167 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4170 static const struct message WmShiftVkN[] = {
4171 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4172 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4173 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4174 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4175 { WM_CHAR, wparam|lparam, 'N', 1 },
4176 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
4177 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4178 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4179 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4180 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4183 static const struct message WmCtrlVkN[] = {
4184 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4185 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4186 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4187 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4188 { WM_CHAR, wparam|lparam, 0x000e, 1 },
4189 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4190 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4191 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4192 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4193 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4196 static const struct message WmCtrlVkN_2[] = {
4197 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4198 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4199 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4200 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4201 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4202 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4203 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4204 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4207 static const struct message WmAltVkN[] = {
4208 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4209 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4210 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4211 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4212 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
4213 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
4214 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
4215 { HCBT_SYSCOMMAND, hook },
4216 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4217 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4218 { WM_INITMENU, sent|defwinproc },
4219 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4220 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
4221 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4222 { WM_CAPTURECHANGED, sent|defwinproc },
4223 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
4224 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4225 { WM_EXITMENULOOP, sent|defwinproc },
4226 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
4227 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
4228 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4229 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4230 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4231 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4234 static const struct message WmAltVkN_2[] = {
4235 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4236 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4237 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4238 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
4239 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4240 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4241 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4242 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4245 static const struct message WmCtrlAltVkN[] = {
4246 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4247 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4248 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4249 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4250 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4251 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4252 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4253 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4254 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4255 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4256 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4257 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4260 static const struct message WmCtrlShiftVkN[] = {
4261 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4262 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4263 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4264 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4265 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4266 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
4267 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4268 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4269 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4270 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4271 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4272 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4275 static const struct message WmCtrlAltShiftVkN[] = {
4276 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4277 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4278 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4279 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4280 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
4281 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
4282 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4283 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
4284 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4285 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4286 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
4287 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
4288 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4289 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4290 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4291 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4294 static const struct message WmAltPressRelease[] = {
4295 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4296 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4297 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4298 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4299 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
4300 { HCBT_SYSCOMMAND, hook },
4301 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4302 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4303 { WM_INITMENU, sent|defwinproc },
4304 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4305 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
4306 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
4308 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4309 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
4310 { WM_CAPTURECHANGED, sent|defwinproc },
4311 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
4312 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4313 { WM_EXITMENULOOP, sent|defwinproc },
4314 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4315 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4318 static const struct message WmAltMouseButton[] = {
4319 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4320 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4321 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
4322 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
4323 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
4324 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
4325 { WM_LBUTTONUP, wparam, 0, 0 },
4326 { WM_LBUTTONUP, sent|wparam, 0, 0 },
4327 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4328 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4332 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
4336 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
4338 struct message log_msg;
4340 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
4342 /* ignore some unwanted messages */
4343 if (msg.message == WM_MOUSEMOVE ||
4344 msg.message == WM_GETICON ||
4345 msg.message == WM_DEVICECHANGE)
4348 log_msg.message = msg.message;
4349 log_msg.flags = wparam|lparam;
4350 log_msg.wParam = msg.wParam;
4351 log_msg.lParam = msg.lParam;
4352 add_message(&log_msg);
4354 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
4356 TranslateMessage(&msg);
4357 DispatchMessage(&msg);
4362 static void test_accelerators(void)
4367 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4368 100, 100, 200, 200, 0, 0, 0, NULL);
4374 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4376 state = GetKeyState(VK_SHIFT);
4377 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
4378 state = GetKeyState(VK_CAPITAL);
4379 ok(state == 0, "wrong CapsLock state %04x\n", state);
4381 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
4382 assert(hAccel != 0);
4384 pump_msg_loop(hwnd, 0);
4387 trace("testing VK_N press/release\n");
4389 keybd_event('N', 0, 0, 0);
4390 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4391 pump_msg_loop(hwnd, hAccel);
4392 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4394 trace("testing Shift+VK_N press/release\n");
4396 keybd_event(VK_SHIFT, 0, 0, 0);
4397 keybd_event('N', 0, 0, 0);
4398 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4399 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4400 pump_msg_loop(hwnd, hAccel);
4401 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4403 trace("testing Ctrl+VK_N press/release\n");
4405 keybd_event(VK_CONTROL, 0, 0, 0);
4406 keybd_event('N', 0, 0, 0);
4407 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4408 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4409 pump_msg_loop(hwnd, hAccel);
4410 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
4412 trace("testing Alt+VK_N press/release\n");
4414 keybd_event(VK_MENU, 0, 0, 0);
4415 keybd_event('N', 0, 0, 0);
4416 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4417 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4418 pump_msg_loop(hwnd, hAccel);
4419 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
4421 trace("testing Ctrl+Alt+VK_N press/release 1\n");
4423 keybd_event(VK_CONTROL, 0, 0, 0);
4424 keybd_event(VK_MENU, 0, 0, 0);
4425 keybd_event('N', 0, 0, 0);
4426 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4427 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4428 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4429 pump_msg_loop(hwnd, hAccel);
4430 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
4432 ret = DestroyAcceleratorTable(hAccel);
4433 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4435 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
4436 assert(hAccel != 0);
4438 trace("testing VK_N press/release\n");
4440 keybd_event('N', 0, 0, 0);
4441 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4442 pump_msg_loop(hwnd, hAccel);
4443 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4445 trace("testing Shift+VK_N press/release\n");
4447 keybd_event(VK_SHIFT, 0, 0, 0);
4448 keybd_event('N', 0, 0, 0);
4449 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4450 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4451 pump_msg_loop(hwnd, hAccel);
4452 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4454 trace("testing Ctrl+VK_N press/release 2\n");
4456 keybd_event(VK_CONTROL, 0, 0, 0);
4457 keybd_event('N', 0, 0, 0);
4458 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4459 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4460 pump_msg_loop(hwnd, hAccel);
4461 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
4463 trace("testing Alt+VK_N press/release 2\n");
4465 keybd_event(VK_MENU, 0, 0, 0);
4466 keybd_event('N', 0, 0, 0);
4467 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4468 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4469 pump_msg_loop(hwnd, hAccel);
4470 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
4472 trace("testing Ctrl+Alt+VK_N press/release 2\n");
4474 keybd_event(VK_CONTROL, 0, 0, 0);
4475 keybd_event(VK_MENU, 0, 0, 0);
4476 keybd_event('N', 0, 0, 0);
4477 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4478 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4479 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4480 pump_msg_loop(hwnd, hAccel);
4481 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
4483 trace("testing Ctrl+Shift+VK_N press/release\n");
4485 keybd_event(VK_CONTROL, 0, 0, 0);
4486 keybd_event(VK_SHIFT, 0, 0, 0);
4487 keybd_event('N', 0, 0, 0);
4488 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4489 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4490 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4491 pump_msg_loop(hwnd, hAccel);
4492 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
4494 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
4496 keybd_event(VK_CONTROL, 0, 0, 0);
4497 keybd_event(VK_MENU, 0, 0, 0);
4498 keybd_event(VK_SHIFT, 0, 0, 0);
4499 keybd_event('N', 0, 0, 0);
4500 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4501 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4502 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4503 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4504 pump_msg_loop(hwnd, hAccel);
4505 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
4507 ret = DestroyAcceleratorTable(hAccel);
4508 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4510 trace("testing Alt press/release\n");
4512 keybd_event(VK_MENU, 0, 0, 0);
4513 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4514 keybd_event(VK_MENU, 0, 0, 0);
4515 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4516 pump_msg_loop(hwnd, 0);
4517 /* this test doesn't pass in Wine for managed windows */
4518 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
4520 trace("testing Alt+MouseButton press/release\n");
4521 /* first, move mouse pointer inside of the window client area */
4522 GetClientRect(hwnd, &rc);
4523 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
4524 rc.left += (rc.right - rc.left)/2;
4525 rc.top += (rc.bottom - rc.top)/2;
4526 SetCursorPos(rc.left, rc.top);
4528 pump_msg_loop(hwnd, 0);
4530 keybd_event(VK_MENU, 0, 0, 0);
4531 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4532 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4533 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4534 pump_msg_loop(hwnd, 0);
4535 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
4537 DestroyWindow(hwnd);
4540 /************* window procedures ********************/
4542 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
4543 WPARAM wParam, LPARAM lParam)
4545 static long defwndproc_counter = 0;
4546 static long beginpaint_counter = 0;
4550 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4552 /* explicitly ignore WM_GETICON message */
4553 if (message == WM_GETICON) return 0;
4559 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
4560 ok((BOOL)wParam == !(style & WS_DISABLED),
4561 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
4565 case WM_CAPTURECHANGED:
4566 if (test_DestroyWindow_flag)
4568 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
4569 if (style & WS_CHILD)
4570 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
4571 else if (style & WS_POPUP)
4572 lParam = WND_POPUP_ID;
4574 lParam = WND_PARENT_ID;
4582 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
4583 capture = GetCapture();
4586 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
4587 trace("current capture %p, releasing...\n", capture);
4594 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
4595 if (test_DestroyWindow_flag)
4597 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
4598 if (style & WS_CHILD)
4599 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
4600 else if (style & WS_POPUP)
4601 lParam = WND_POPUP_ID;
4603 lParam = WND_PARENT_ID;
4607 /* test_accelerators() depends on this */
4614 case WM_DEVICECHANGE:
4617 case WM_WINDOWPOSCHANGING:
4618 case WM_WINDOWPOSCHANGED:
4620 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4622 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4623 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4624 winpos->hwnd, winpos->hwndInsertAfter,
4625 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
4627 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4628 * in the high word for internal purposes
4630 wParam = winpos->flags & 0xffff;
4635 msg.message = message;
4636 msg.flags = sent|wparam|lparam;
4637 if (defwndproc_counter) msg.flags |= defwinproc;
4638 if (beginpaint_counter) msg.flags |= beginpaint;
4639 msg.wParam = wParam;
4640 msg.lParam = lParam;
4643 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
4645 HWND parent = GetParent(hwnd);
4647 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
4649 GetClientRect(parent, &rc);
4650 trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
4652 trace("ptReserved = (%ld,%ld)\n"
4653 "ptMaxSize = (%ld,%ld)\n"
4654 "ptMaxPosition = (%ld,%ld)\n"
4655 "ptMinTrackSize = (%ld,%ld)\n"
4656 "ptMaxTrackSize = (%ld,%ld)\n",
4657 minmax->ptReserved.x, minmax->ptReserved.y,
4658 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
4659 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
4660 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
4661 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
4663 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %ld != %ld\n",
4664 minmax->ptMaxSize.x, rc.right);
4665 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %ld != %ld\n",
4666 minmax->ptMaxSize.y, rc.bottom);
4669 if (message == WM_PAINT)
4672 beginpaint_counter++;
4673 BeginPaint( hwnd, &ps );
4674 beginpaint_counter--;
4675 EndPaint( hwnd, &ps );
4679 defwndproc_counter++;
4680 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
4681 : DefWindowProcA(hwnd, message, wParam, lParam);
4682 defwndproc_counter--;
4687 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4689 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
4692 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4694 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
4697 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4699 static long defwndproc_counter = 0;
4703 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4705 /* explicitly ignore WM_GETICON message */
4706 if (message == WM_GETICON) return 0;
4708 msg.message = message;
4709 msg.flags = sent|wparam|lparam;
4710 if (defwndproc_counter) msg.flags |= defwinproc;
4711 msg.wParam = wParam;
4712 msg.lParam = lParam;
4715 if (message == WM_CREATE)
4717 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
4718 SetWindowLongA(hwnd, GWL_STYLE, style);
4721 defwndproc_counter++;
4722 ret = DefWindowProcA(hwnd, message, wParam, lParam);
4723 defwndproc_counter--;
4728 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4730 static long defwndproc_counter = 0;
4731 static long beginpaint_counter = 0;
4735 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4737 /* explicitly ignore WM_GETICON message */
4738 if (message == WM_GETICON) return 0;
4740 if (log_all_parent_messages ||
4741 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
4742 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
4743 message == WM_ENABLE || message == WM_ENTERIDLE ||
4744 message == WM_IME_SETCONTEXT)
4751 INT ret = GetClipBox((HDC)wParam, &rc);
4753 trace("WM_ERASEBKGND: GetClipBox()=%d, (%ld,%ld-%ld,%ld)\n",
4754 ret, rc.left, rc.top, rc.right, rc.bottom);
4758 case WM_WINDOWPOSCHANGING:
4759 case WM_WINDOWPOSCHANGED:
4761 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4763 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4764 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4765 winpos->hwnd, winpos->hwndInsertAfter,
4766 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
4768 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4769 * in the high word for internal purposes
4771 wParam = winpos->flags & 0xffff;
4776 msg.message = message;
4777 msg.flags = sent|parent|wparam|lparam;
4778 if (defwndproc_counter) msg.flags |= defwinproc;
4779 if (beginpaint_counter) msg.flags |= beginpaint;
4780 msg.wParam = wParam;
4781 msg.lParam = lParam;
4785 if (message == WM_PAINT)
4788 beginpaint_counter++;
4789 BeginPaint( hwnd, &ps );
4790 beginpaint_counter--;
4791 EndPaint( hwnd, &ps );
4795 defwndproc_counter++;
4796 ret = DefWindowProcA(hwnd, message, wParam, lParam);
4797 defwndproc_counter--;
4802 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4804 static long defwndproc_counter = 0;
4808 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4810 /* explicitly ignore WM_GETICON message */
4811 if (message == WM_GETICON) return 0;
4813 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
4814 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
4815 if (after_end_dialog)
4816 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
4818 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
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|wparam|lparam;
4842 if (defwndproc_counter) msg.flags |= defwinproc;
4843 msg.wParam = wParam;
4844 msg.lParam = lParam;
4847 defwndproc_counter++;
4848 ret = DefDlgProcA(hwnd, message, wParam, lParam);
4849 defwndproc_counter--;
4854 static BOOL RegisterWindowClasses(void)
4859 cls.lpfnWndProc = MsgCheckProcA;
4862 cls.hInstance = GetModuleHandleA(0);
4864 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
4865 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
4866 cls.lpszMenuName = NULL;
4867 cls.lpszClassName = "TestWindowClass";
4868 if(!RegisterClassA(&cls)) return FALSE;
4870 cls.lpfnWndProc = PopupMsgCheckProcA;
4871 cls.lpszClassName = "TestPopupClass";
4872 if(!RegisterClassA(&cls)) return FALSE;
4874 cls.lpfnWndProc = ParentMsgCheckProcA;
4875 cls.lpszClassName = "TestParentClass";
4876 if(!RegisterClassA(&cls)) return FALSE;
4878 cls.lpfnWndProc = DefWindowProcA;
4879 cls.lpszClassName = "SimpleWindowClass";
4880 if(!RegisterClassA(&cls)) return FALSE;
4882 cls.style = CS_NOCLOSE;
4883 cls.lpszClassName = "NoCloseWindowClass";
4884 if(!RegisterClassA(&cls)) return FALSE;
4886 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
4888 cls.hInstance = GetModuleHandleA(0);
4889 cls.hbrBackground = 0;
4890 cls.lpfnWndProc = TestDlgProcA;
4891 cls.lpszClassName = "TestDialogClass";
4892 if(!RegisterClassA(&cls)) return FALSE;
4897 static HHOOK hCBT_hook;
4898 static DWORD cbt_hook_thread_id;
4900 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
4902 static const char *CBT_code_name[10] = {
4909 "HCBT_CLICKSKIPPED",
4913 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
4917 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
4919 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
4921 if (nCode == HCBT_SYSCOMMAND)
4925 msg.message = nCode;
4926 msg.flags = hook|wparam|lparam;
4927 msg.wParam = wParam;
4928 msg.lParam = lParam;
4931 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
4934 if (nCode == HCBT_DESTROYWND)
4936 if (test_DestroyWindow_flag)
4938 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
4939 if (style & WS_CHILD)
4940 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
4941 else if (style & WS_POPUP)
4942 lParam = WND_POPUP_ID;
4944 lParam = WND_PARENT_ID;
4948 /* Log also SetFocus(0) calls */
4949 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
4951 if (GetClassNameA(hwnd, buf, sizeof(buf)))
4953 if (!lstrcmpiA(buf, "TestWindowClass") ||
4954 !lstrcmpiA(buf, "TestParentClass") ||
4955 !lstrcmpiA(buf, "TestPopupClass") ||
4956 !lstrcmpiA(buf, "SimpleWindowClass") ||
4957 !lstrcmpiA(buf, "TestDialogClass") ||
4958 !lstrcmpiA(buf, "MDI_frame_class") ||
4959 !lstrcmpiA(buf, "MDI_client_class") ||
4960 !lstrcmpiA(buf, "MDI_child_class") ||
4961 !lstrcmpiA(buf, "my_button_class") ||
4962 !lstrcmpiA(buf, "static") ||
4963 !lstrcmpiA(buf, "#32770"))
4967 msg.message = nCode;
4968 msg.flags = hook|wparam|lparam;
4969 msg.wParam = wParam;
4970 msg.lParam = lParam;
4974 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
4977 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
4987 trace("WEH:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
4988 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
4990 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
4992 /* ignore mouse cursor events */
4993 if (object_id == OBJID_CURSOR) return;
4995 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
4998 !lstrcmpiA(buf, "TestWindowClass") ||
4999 !lstrcmpiA(buf, "TestParentClass") ||
5000 !lstrcmpiA(buf, "TestPopupClass") ||
5001 !lstrcmpiA(buf, "SimpleWindowClass") ||
5002 !lstrcmpiA(buf, "TestDialogClass") ||
5003 !lstrcmpiA(buf, "MDI_frame_class") ||
5004 !lstrcmpiA(buf, "MDI_client_class") ||
5005 !lstrcmpiA(buf, "MDI_child_class") ||
5006 !lstrcmpiA(buf, "my_button_class") ||
5007 !lstrcmpiA(buf, "static") ||
5008 !lstrcmpiA(buf, "#32770"))
5012 msg.message = event;
5013 msg.flags = winevent_hook|wparam|lparam;
5014 msg.wParam = object_id;
5015 msg.lParam = child_id;
5021 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
5022 static const WCHAR wszAnsi[] = {'U',0};
5024 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5028 case CB_FINDSTRINGEXACT:
5029 trace("String: %p\n", (LPCWSTR)lParam);
5030 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
5032 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
5036 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
5039 static const struct message WmGetTextLengthAfromW[] = {
5040 { WM_GETTEXTLENGTH, sent },
5041 { WM_GETTEXT, sent },
5045 static const WCHAR testWindowClassW[] =
5046 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
5048 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
5050 /* dummy window proc for WM_GETTEXTLENGTH test */
5051 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
5055 case WM_GETTEXTLENGTH:
5056 return lstrlenW(dummy_window_text) + 37; /* some random length */
5058 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
5059 return lstrlenW( (LPWSTR)lp );
5061 return DefWindowProcW( hwnd, msg, wp, lp );
5065 static void test_message_conversion(void)
5067 static const WCHAR wszMsgConversionClass[] =
5068 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
5072 WNDPROC wndproc, newproc;
5076 cls.lpfnWndProc = MsgConversionProcW;
5079 cls.hInstance = GetModuleHandleW(NULL);
5081 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
5082 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
5083 cls.lpszMenuName = NULL;
5084 cls.lpszClassName = wszMsgConversionClass;
5085 /* this call will fail on Win9x, but that doesn't matter as this test is
5086 * meaningless on those platforms */
5087 if(!RegisterClassW(&cls)) return;
5090 cls.lpfnWndProc = MsgCheckProcW;
5093 cls.hInstance = GetModuleHandleW(0);
5095 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
5096 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5097 cls.lpszMenuName = NULL;
5098 cls.lpszClassName = testWindowClassW;
5099 if(!RegisterClassW(&cls)) return;
5101 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
5102 100, 100, 200, 200, 0, 0, 0, NULL);
5103 ok(hwnd != NULL, "Window creation failed\n");
5107 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
5108 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5109 ok(lRes == 0, "String should have been converted\n");
5110 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5111 ok(lRes == 1, "String shouldn't have been converted\n");
5115 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
5116 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5117 ok(lRes == 1, "String shouldn't have been converted\n");
5118 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5119 ok(lRes == 1, "String shouldn't have been converted\n");
5121 /* Synchronous messages */
5123 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5124 ok(lRes == 0, "String should have been converted\n");
5125 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5126 ok(lRes == 1, "String shouldn't have been converted\n");
5128 /* Asynchronous messages */
5131 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5132 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5133 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5135 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5136 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5137 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5139 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5140 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5141 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5143 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5144 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5145 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5147 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5148 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5149 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5151 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5152 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5153 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5155 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5156 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5157 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5159 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5160 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5161 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5163 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
5165 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
5166 WS_OVERLAPPEDWINDOW,
5167 100, 100, 200, 200, 0, 0, 0, NULL);
5170 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
5171 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5172 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5173 "got bad length %ld\n", lRes );
5176 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
5177 hwnd, WM_GETTEXTLENGTH, 0, 0);
5178 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5179 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5180 "got bad length %ld\n", lRes );
5182 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
5183 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
5184 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5185 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5186 NULL, 0, NULL, NULL ),
5187 "got bad length %ld\n", lRes );
5189 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
5190 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5191 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5192 NULL, 0, NULL, NULL ),
5193 "got bad length %ld\n", lRes );
5195 ret = DestroyWindow(hwnd);
5196 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5199 typedef struct _thread_info
5206 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
5210 #define TIMER_ID 0x19
5212 static DWORD WINAPI timer_thread_proc(LPVOID x)
5214 thread_info *info = x;
5217 r = KillTimer(info->hWnd, 0x19);
5218 ok(r,"KillTimer failed in thread\n");
5219 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
5220 ok(r,"SetTimer failed in thread\n");
5221 ok(r==TIMER_ID,"SetTimer id different\n");
5222 r = SetEvent(info->handles[0]);
5223 ok(r,"SetEvent failed in thread\n");
5227 static void test_timers(void)
5232 info.hWnd = CreateWindow ("TestWindowClass", NULL,
5233 WS_OVERLAPPEDWINDOW ,
5234 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5237 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
5238 ok(info.id, "SetTimer failed\n");
5239 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
5240 info.handles[0] = CreateEvent(NULL,0,0,NULL);
5241 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
5243 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
5245 WaitForSingleObject(info.handles[1], INFINITE);
5247 CloseHandle(info.handles[0]);
5248 CloseHandle(info.handles[1]);
5250 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
5252 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
5255 /* Various win events with arbitrary parameters */
5256 static const struct message WmWinEventsSeq[] = {
5257 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5258 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5259 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5260 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5261 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5262 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5263 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5264 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5265 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5266 /* our win event hook ignores OBJID_CURSOR events */
5267 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
5268 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
5269 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
5270 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
5271 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
5272 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5273 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5274 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5275 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5276 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5277 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5278 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5279 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5280 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5283 static const struct message WmWinEventCaretSeq[] = {
5284 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5285 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5286 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
5287 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5290 static const struct message WmWinEventCaretSeq_2[] = {
5291 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5292 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5293 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5296 static const struct message WmWinEventAlertSeq[] = {
5297 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
5300 static const struct message WmWinEventAlertSeq_2[] = {
5301 /* create window in the thread proc */
5302 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
5303 /* our test event */
5304 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
5307 static const struct message WmGlobalHookSeq_1[] = {
5308 /* create window in the thread proc */
5309 { HCBT_CREATEWND, hook|lparam, 0, 2 },
5310 /* our test events */
5311 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
5312 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
5315 static const struct message WmGlobalHookSeq_2[] = {
5316 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
5317 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
5318 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
5319 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
5323 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
5333 trace("WEH_2:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5334 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5336 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5338 if (!lstrcmpiA(buf, "TestWindowClass") ||
5339 !lstrcmpiA(buf, "static"))
5343 msg.message = event;
5344 msg.flags = winevent_hook|wparam|lparam;
5345 msg.wParam = object_id;
5346 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
5352 static HHOOK hCBT_global_hook;
5353 static DWORD cbt_global_hook_thread_id;
5355 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5360 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
5362 if (nCode == HCBT_SYSCOMMAND)
5366 msg.message = nCode;
5367 msg.flags = hook|wparam|lparam;
5368 msg.wParam = wParam;
5369 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5372 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5375 /* Log also SetFocus(0) calls */
5376 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5378 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5380 if (!lstrcmpiA(buf, "TestWindowClass") ||
5381 !lstrcmpiA(buf, "static"))
5385 msg.message = nCode;
5386 msg.flags = hook|wparam|lparam;
5387 msg.wParam = wParam;
5388 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5392 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5395 static DWORD WINAPI win_event_global_thread_proc(void *param)
5399 HANDLE hevent = *(HANDLE *)param;
5400 HMODULE user32 = GetModuleHandleA("user32.dll");
5401 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5403 assert(pNotifyWinEvent);
5405 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5407 trace("created thread window %p\n", hwnd);
5409 *(HWND *)param = hwnd;
5412 /* this event should be received only by our new hook proc,
5413 * an old one does not expect an event from another thread.
5415 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
5418 while (GetMessage(&msg, 0, 0, 0))
5420 TranslateMessage(&msg);
5421 DispatchMessage(&msg);
5426 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
5430 HANDLE hevent = *(HANDLE *)param;
5433 /* these events should be received only by our new hook proc,
5434 * an old one does not expect an event from another thread.
5437 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5439 trace("created thread window %p\n", hwnd);
5441 *(HWND *)param = hwnd;
5443 /* Windows doesn't like when a thread plays games with the focus,
5444 that leads to all kinds of misbehaviours and failures to activate
5445 a window. So, better keep next lines commented out.
5449 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5450 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5454 while (GetMessage(&msg, 0, 0, 0))
5456 TranslateMessage(&msg);
5457 DispatchMessage(&msg);
5462 static void test_winevents(void)
5468 HANDLE hthread, hevent;
5470 HWINEVENTHOOK hhook;
5471 const struct message *events = WmWinEventsSeq;
5472 HMODULE user32 = GetModuleHandleA("user32.dll");
5473 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
5474 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
5475 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5477 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
5478 WS_OVERLAPPEDWINDOW,
5479 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5483 /****** start of global hook test *************/
5484 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
5485 assert(hCBT_global_hook);
5487 hevent = CreateEventA(NULL, 0, 0, NULL);
5489 hwnd2 = (HWND)hevent;
5491 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
5492 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5494 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5496 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
5499 /* this one should be received only by old hook proc */
5500 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5501 /* this one should be received only by old hook proc */
5502 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5504 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
5506 ret = UnhookWindowsHookEx(hCBT_global_hook);
5507 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
5509 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5510 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5511 CloseHandle(hthread);
5512 CloseHandle(hevent);
5513 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5514 /****** end of global hook test *************/
5516 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
5518 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5524 #if 0 /* this test doesn't pass under Win9x */
5525 /* win2k ignores events with hwnd == 0 */
5526 SetLastError(0xdeadbeef);
5527 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
5528 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
5529 GetLastError() == 0xdeadbeef, /* Win9x */
5530 "unexpected error %ld\n", GetLastError());
5531 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
5534 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
5535 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
5537 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
5539 /****** start of event filtering test *************/
5540 hhook = (HWINEVENTHOOK)pSetWinEventHook(
5541 EVENT_OBJECT_SHOW, /* 0x8002 */
5542 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
5543 GetModuleHandleA(0), win_event_global_hook_proc,
5544 GetCurrentProcessId(), 0,
5545 WINEVENT_INCONTEXT);
5546 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
5548 hevent = CreateEventA(NULL, 0, 0, NULL);
5550 hwnd2 = (HWND)hevent;
5552 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
5553 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5555 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5557 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
5560 /* this one should be received only by old hook proc */
5561 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
5562 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
5563 /* this one should be received only by old hook proc */
5564 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
5566 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
5568 ret = pUnhookWinEvent(hhook);
5569 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5571 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5572 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5573 CloseHandle(hthread);
5574 CloseHandle(hevent);
5575 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5576 /****** end of event filtering test *************/
5578 /****** start of out of context event test *************/
5579 hhook = (HWINEVENTHOOK)pSetWinEventHook(
5580 EVENT_MIN, EVENT_MAX,
5581 0, win_event_global_hook_proc,
5582 GetCurrentProcessId(), 0,
5583 WINEVENT_OUTOFCONTEXT);
5584 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
5586 hevent = CreateEventA(NULL, 0, 0, NULL);
5588 hwnd2 = (HWND)hevent;
5592 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
5593 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5595 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5597 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
5598 /* process pending winevent messages */
5599 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
5600 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
5603 /* this one should be received only by old hook proc */
5604 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
5605 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
5606 /* this one should be received only by old hook proc */
5607 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
5609 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
5610 /* process pending winevent messages */
5611 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
5612 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
5614 ret = pUnhookWinEvent(hhook);
5615 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5617 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5618 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5619 CloseHandle(hthread);
5620 CloseHandle(hevent);
5621 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5622 /****** end of out of context event test *************/
5624 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5627 static void test_set_hook(void)
5631 HWINEVENTHOOK hwinevent_hook;
5632 HMODULE user32 = GetModuleHandleA("user32.dll");
5633 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
5634 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
5636 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
5637 ok(hhook != 0, "local hook does not require hModule set to 0\n");
5638 UnhookWindowsHookEx(hhook);
5640 #if 0 /* this test doesn't pass under Win9x: BUG! */
5641 SetLastError(0xdeadbeef);
5642 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
5643 ok(!hhook, "global hook requires hModule != 0\n");
5644 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %ld\n", GetLastError());
5647 SetLastError(0xdeadbeef);
5648 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
5649 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
5650 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
5651 GetLastError() == 0xdeadbeef, /* Win9x */
5652 "unexpected error %ld\n", GetLastError());
5654 SetLastError(0xdeadbeef);
5655 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
5656 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
5657 GetLastError() == 0xdeadbeef, /* Win9x */
5658 "unexpected error %ld\n", GetLastError());
5660 if (!pSetWinEventHook || !pUnhookWinEvent) return;
5662 /* even process local incontext hooks require hmodule */
5663 SetLastError(0xdeadbeef);
5664 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5665 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
5666 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
5667 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
5668 GetLastError() == 0xdeadbeef, /* Win9x */
5669 "unexpected error %ld\n", GetLastError());
5671 /* even thread local incontext hooks require hmodule */
5672 SetLastError(0xdeadbeef);
5673 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5674 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
5675 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
5676 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
5677 GetLastError() == 0xdeadbeef, /* Win9x */
5678 "unexpected error %ld\n", GetLastError());
5680 #if 0 /* these 3 tests don't pass under Win9x */
5681 SetLastError(0xdeadbeef);
5682 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
5683 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
5684 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
5685 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
5687 SetLastError(0xdeadbeef);
5688 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
5689 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
5690 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
5691 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
5693 SetLastError(0xdeadbeef);
5694 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5695 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
5696 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
5697 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %ld\n", GetLastError());
5700 SetLastError(0xdeadbeef);
5701 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
5702 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
5703 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
5704 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
5705 ret = pUnhookWinEvent(hwinevent_hook);
5706 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5709 /* This call succeeds under win2k SP4, but fails under Wine.
5710 Does win2k test/use passed process id? */
5711 SetLastError(0xdeadbeef);
5712 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
5713 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
5714 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
5715 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
5716 ret = pUnhookWinEvent(hwinevent_hook);
5717 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5720 SetLastError(0xdeadbeef);
5721 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
5722 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
5723 GetLastError() == 0xdeadbeef, /* Win9x */
5724 "unexpected error %ld\n", GetLastError());
5727 static const struct message ScrollWindowPaint1[] = {
5729 { WM_ERASEBKGND, sent|beginpaint },
5733 static const struct message ScrollWindowPaint2[] = {
5738 static void test_scrollwindowex(void)
5741 RECT rect={0,0,130,130};
5744 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
5745 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
5746 100, 100, 200, 200, 0, 0, 0, NULL);
5747 ok (hwnd != 0, "Failed to create overlapped window\n");
5748 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
5749 WS_VISIBLE|WS_CAPTION|WS_CHILD,
5750 10, 10, 150, 150, hwnd, 0, 0, NULL);
5751 ok (hchild != 0, "Failed to create child\n");
5753 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5756 /* scroll without the child window */
5757 trace("start scroll\n");
5758 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
5759 SW_ERASE|SW_INVALIDATE);
5760 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
5761 trace("end scroll\n");
5763 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5764 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
5766 /* Now without the SW_ERASE flag */
5767 trace("start scroll\n");
5768 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
5769 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
5770 trace("end scroll\n");
5772 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5773 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
5775 /* now scroll the child window as well */
5776 trace("start scroll\n");
5777 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
5778 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
5779 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
5780 /* windows sometimes a WM_MOVE */
5781 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
5783 trace("end scroll\n");
5785 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5786 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
5788 /* now scroll with ScrollWindow() */
5789 trace("start scroll with ScrollWindow\n");
5790 ScrollWindow( hwnd, 5, 5, NULL, NULL);
5791 trace("end scroll\n");
5793 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5794 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
5796 ok(DestroyWindow(hchild), "failed to destroy window\n");
5797 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5801 static const struct message destroy_window_with_children[] = {
5802 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
5803 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
5804 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
5805 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
5806 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
5807 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
5808 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
5809 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
5810 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
5811 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
5812 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
5813 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
5814 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
5815 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
5816 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
5817 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
5821 static void test_DestroyWindow(void)
5824 HWND parent, child1, child2, child3, child4, test;
5825 UINT child_id = WND_CHILD_ID + 1;
5827 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
5828 100, 100, 200, 200, 0, 0, 0, NULL);
5829 assert(parent != 0);
5830 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
5831 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
5832 assert(child1 != 0);
5833 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
5834 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
5835 assert(child2 != 0);
5836 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
5837 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
5838 assert(child3 != 0);
5839 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
5840 0, 0, 50, 50, parent, 0, 0, NULL);
5841 assert(child4 != 0);
5843 /* test owner/parent of child2 */
5844 test = GetParent(child2);
5845 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5846 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
5848 test = pGetAncestor(child2, GA_PARENT);
5849 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5851 test = GetWindow(child2, GW_OWNER);
5852 ok(!test, "wrong owner %p\n", test);
5854 test = SetParent(child2, parent);
5855 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
5857 /* test owner/parent of the parent */
5858 test = GetParent(parent);
5859 ok(!test, "wrong parent %p\n", test);
5861 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
5864 test = pGetAncestor(parent, GA_PARENT);
5865 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5867 test = GetWindow(parent, GW_OWNER);
5868 ok(!test, "wrong owner %p\n", test);
5870 /* test owner/parent of child1 */
5871 test = GetParent(child1);
5872 ok(test == parent, "wrong parent %p\n", test);
5873 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
5875 test = pGetAncestor(child1, GA_PARENT);
5876 ok(test == parent, "wrong parent %p\n", test);
5878 test = GetWindow(child1, GW_OWNER);
5879 ok(!test, "wrong owner %p\n", test);
5881 /* test owner/parent of child2 */
5882 test = GetParent(child2);
5883 ok(test == parent, "wrong parent %p\n", test);
5884 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
5886 test = pGetAncestor(child2, GA_PARENT);
5887 ok(test == parent, "wrong parent %p\n", test);
5889 test = GetWindow(child2, GW_OWNER);
5890 ok(!test, "wrong owner %p\n", test);
5892 /* test owner/parent of child3 */
5893 test = GetParent(child3);
5894 ok(test == child1, "wrong parent %p\n", test);
5895 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
5897 test = pGetAncestor(child3, GA_PARENT);
5898 ok(test == child1, "wrong parent %p\n", test);
5900 test = GetWindow(child3, GW_OWNER);
5901 ok(!test, "wrong owner %p\n", test);
5903 /* test owner/parent of child4 */
5904 test = GetParent(child4);
5905 ok(test == parent, "wrong parent %p\n", test);
5906 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
5908 test = pGetAncestor(child4, GA_PARENT);
5909 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
5911 test = GetWindow(child4, GW_OWNER);
5912 ok(test == parent, "wrong owner %p\n", test);
5916 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
5917 parent, child1, child2, child3, child4);
5920 test = GetCapture();
5921 ok(test == child4, "wrong capture window %p\n", test);
5923 test_DestroyWindow_flag = TRUE;
5924 ret = DestroyWindow(parent);
5925 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5926 test_DestroyWindow_flag = FALSE;
5927 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
5929 ok(!IsWindow(parent), "parent still exists\n");
5930 ok(!IsWindow(child1), "child1 still exists\n");
5931 ok(!IsWindow(child2), "child2 still exists\n");
5932 ok(!IsWindow(child3), "child3 still exists\n");
5933 ok(!IsWindow(child4), "child4 still exists\n");
5935 test = GetCapture();
5936 ok(!test, "wrong capture window %p\n", test);
5940 static const struct message WmDispatchPaint[] = {
5941 { WM_NCPAINT, sent },
5942 { WM_GETTEXT, sent|defwinproc|optional },
5943 { WM_GETTEXT, sent|defwinproc|optional },
5944 { WM_ERASEBKGND, sent },
5948 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5950 if (message == WM_PAINT) return 0;
5951 return MsgCheckProcA( hwnd, message, wParam, lParam );
5954 static void test_DispatchMessage(void)
5959 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
5960 100, 100, 200, 200, 0, 0, 0, NULL);
5961 ShowWindow( hwnd, SW_SHOW );
5962 UpdateWindow( hwnd );
5963 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5965 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
5967 SetRect( &rect, -5, -5, 5, 5 );
5968 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
5970 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5972 if (msg.message != WM_PAINT) DispatchMessage( &msg );
5976 DispatchMessage( &msg );
5977 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
5978 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
5979 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
5980 if (++count > 10) break;
5983 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
5985 trace("now without DispatchMessage\n");
5987 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
5989 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5991 if (msg.message != WM_PAINT) DispatchMessage( &msg );
5994 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
5996 /* this will send WM_NCCPAINT just like DispatchMessage does */
5997 GetUpdateRgn( hwnd, hrgn, TRUE );
5998 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
5999 DeleteObject( hrgn );
6000 GetClientRect( hwnd, &rect );
6001 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
6002 ok( !count, "Got multiple WM_PAINTs\n" );
6003 if (++count > 10) break;
6009 static const struct message WmUser[] = {
6021 static DWORD CALLBACK send_msg_thread( LPVOID arg )
6023 struct thread_info *info = arg;
6024 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
6025 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %ld\n", GetLastError());
6029 static void wait_for_thread( HANDLE thread )
6031 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
6034 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
6038 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6040 if (message == WM_USER) Sleep(200);
6041 return MsgCheckProcA( hwnd, message, wParam, lParam );
6044 static void test_SendMessageTimeout(void)
6048 struct thread_info info;
6050 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6051 100, 100, 200, 200, 0, 0, 0, NULL);
6052 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6055 info.timeout = 1000;
6056 info.ret = 0xdeadbeef;
6057 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, NULL );
6058 wait_for_thread( thread );
6059 CloseHandle( thread );
6060 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6061 ok_sequence( WmUser, "WmUser", FALSE );
6064 info.ret = 0xdeadbeef;
6065 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, NULL );
6066 Sleep(100); /* SendMessageTimeout should timeout here */
6067 wait_for_thread( thread );
6068 CloseHandle( thread );
6069 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6070 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6072 /* 0 means infinite timeout */
6074 info.ret = 0xdeadbeef;
6075 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, NULL );
6077 wait_for_thread( thread );
6078 CloseHandle( thread );
6079 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6080 ok_sequence( WmUser, "WmUser", FALSE );
6082 /* timeout is treated as signed despite the prototype */
6083 info.timeout = 0x7fffffff;
6084 info.ret = 0xdeadbeef;
6085 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, NULL );
6087 wait_for_thread( thread );
6088 CloseHandle( thread );
6089 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6090 ok_sequence( WmUser, "WmUser", FALSE );
6092 info.timeout = 0x80000000;
6093 info.ret = 0xdeadbeef;
6094 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, NULL );
6096 wait_for_thread( thread );
6097 CloseHandle( thread );
6098 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6099 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6101 /* now check for timeout during message processing */
6102 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
6104 info.ret = 0xdeadbeef;
6105 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, NULL );
6106 wait_for_thread( thread );
6107 CloseHandle( thread );
6108 /* we should timeout but still get the message */
6109 ok( info.ret == 0, "SendMessageTimeout failed\n" );
6110 ok_sequence( WmUser, "WmUser", FALSE );
6112 DestroyWindow( info.hwnd );
6119 HMODULE user32 = GetModuleHandleA("user32.dll");
6120 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6121 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6122 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
6123 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
6125 if (!RegisterWindowClasses()) assert(0);
6127 if (pSetWinEventHook)
6129 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6130 GetModuleHandleA(0),
6133 GetCurrentThreadId(),
6134 WINEVENT_INCONTEXT);
6135 assert(hEvent_hook);
6137 if (pIsWinEventHookInstalled)
6140 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
6141 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
6145 cbt_hook_thread_id = GetCurrentThreadId();
6146 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
6151 /* Fix message sequences before removing 3 lines below */
6152 ret = pUnhookWinEvent(hEvent_hook);
6153 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6154 pUnhookWinEvent = 0;
6157 test_scrollwindowex();
6159 test_mdi_messages();
6160 test_button_messages();
6161 test_paint_messages();
6162 test_interthread_messages();
6163 test_message_conversion();
6164 test_accelerators();
6167 test_DestroyWindow();
6168 test_DispatchMessage();
6169 test_SendMessageTimeout();
6171 UnhookWindowsHookEx(hCBT_hook);
6172 if (pUnhookWinEvent)
6174 ret = pUnhookWinEvent(hEvent_hook);
6175 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6176 SetLastError(0xdeadbeef);
6177 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
6178 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
6179 GetLastError() == 0xdeadbeef, /* Win9x */
6180 "unexpected error %ld\n", GetLastError());