2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
43 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
45 #define WND_PARENT_ID 1
46 #define WND_POPUP_ID 2
47 #define WND_CHILD_ID 3
49 static BOOL test_DestroyWindow_flag;
50 static HWINEVENTHOOK hEvent_hook;
52 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
55 FIXME: add tests for these
56 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
57 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
58 WS_THICKFRAME: thick border
59 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
60 WS_BORDER (default for overlapped windows): single black border
61 none (default for child (and popup?) windows): no border
78 UINT message; /* the WM_* code */
79 msg_flags_t flags; /* message props */
80 WPARAM wParam; /* expected value of wParam */
81 LPARAM lParam; /* expected value of lParam */
84 /* Empty message sequence */
85 static const struct message WmEmptySeq[] =
89 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
90 static const struct message WmCreateOverlappedSeq[] = {
91 { HCBT_CREATEWND, hook },
92 { WM_GETMINMAXINFO, sent },
93 { WM_NCCREATE, sent },
94 { WM_NCCALCSIZE, sent|wparam, 0 },
95 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
97 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
100 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
101 * for a not visible overlapped window.
103 static const struct message WmSWP_ShowOverlappedSeq[] = {
104 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
105 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
106 { WM_NCPAINT, sent|wparam|optional, 1 },
107 { WM_GETTEXT, sent|defwinproc|optional },
108 { WM_ERASEBKGND, sent|optional },
109 { HCBT_ACTIVATE, hook },
110 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
111 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
112 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
113 { WM_ACTIVATEAPP, sent|wparam, 1 },
114 { WM_NCACTIVATE, sent|wparam, 1 },
115 { WM_GETTEXT, sent|defwinproc|optional },
116 { WM_ACTIVATE, sent|wparam, 1 },
117 { HCBT_SETFOCUS, hook },
118 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
119 { WM_IME_NOTIFY, sent|defwinproc|optional },
120 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
121 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
122 { WM_NCPAINT, sent|wparam|optional, 1 },
123 { WM_GETTEXT, sent|defwinproc|optional },
124 { WM_ERASEBKGND, sent|optional },
125 /* Win9x adds SWP_NOZORDER below */
126 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
127 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
128 { WM_NCPAINT, sent|wparam|optional, 1 },
129 { WM_ERASEBKGND, sent|optional },
130 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
133 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
134 * for a visible overlapped window.
136 static const struct message WmSWP_HideOverlappedSeq[] = {
137 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
138 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
139 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
143 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
144 * for a visible overlapped window.
146 static const struct message WmSWP_ResizeSeq[] = {
147 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE },
148 { WM_GETMINMAXINFO, sent|defwinproc },
149 { WM_NCCALCSIZE, sent|wparam, TRUE },
150 { WM_NCPAINT, sent|optional },
151 { WM_GETTEXT, sent|defwinproc|optional },
152 { WM_ERASEBKGND, sent|optional },
153 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
154 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
155 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
156 { WM_NCPAINT, sent|optional },
157 { WM_GETTEXT, sent|defwinproc|optional },
158 { WM_ERASEBKGND, sent|optional },
159 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
160 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
164 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
165 * for a visible popup window.
167 static const struct message WmSWP_ResizePopupSeq[] = {
168 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE },
169 { WM_NCCALCSIZE, sent|wparam, TRUE },
170 { WM_NCPAINT, sent|optional },
171 { WM_GETTEXT, sent|defwinproc|optional },
172 { WM_ERASEBKGND, sent|optional },
173 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
174 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
175 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
176 { WM_NCPAINT, sent|optional },
177 { WM_GETTEXT, sent|defwinproc|optional },
178 { WM_ERASEBKGND, sent|optional },
179 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
183 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
184 * for a visible overlapped window.
186 static const struct message WmSWP_MoveSeq[] = {
187 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE },
188 { WM_NCPAINT, sent|optional },
189 { WM_GETTEXT, sent|defwinproc|optional },
190 { WM_ERASEBKGND, sent|optional },
191 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE },
192 { WM_MOVE, sent|defwinproc|wparam, 0 },
193 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
197 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
198 SWP_NOZORDER|SWP_FRAMECHANGED)
199 * for a visible overlapped window with WS_CLIPCHILDREN style set.
201 static const struct message WmSWP_FrameChanged_clip[] = {
202 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
203 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
204 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
205 { WM_GETTEXT, sent|parent|defwinproc|optional },
206 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
207 { WM_NCPAINT, sent }, /* wparam != 1 */
208 { WM_ERASEBKGND, sent },
209 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
210 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
214 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
215 SWP_NOZORDER|SWP_FRAMECHANGED)
216 * for a visible overlapped window.
218 static const struct message WmSWP_FrameChangedDeferErase[] = {
219 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
220 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
221 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
222 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
223 { WM_PAINT, sent|parent },
224 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
225 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
227 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
228 { WM_ERASEBKGND, sent|beginpaint },
232 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
233 SWP_NOZORDER|SWP_FRAMECHANGED)
234 * for a visible overlapped window without WS_CLIPCHILDREN style set.
236 static const struct message WmSWP_FrameChanged_noclip[] = {
237 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
238 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
239 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
240 { WM_GETTEXT, sent|parent|defwinproc|optional },
241 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
242 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
243 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
245 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
246 { WM_ERASEBKGND, sent|beginpaint },
250 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
251 static const struct message WmShowOverlappedSeq[] = {
252 { WM_SHOWWINDOW, sent|wparam, 1 },
253 { WM_NCPAINT, sent|wparam|optional, 1 },
254 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
255 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
256 { WM_NCPAINT, sent|wparam|optional, 1 },
257 { WM_GETTEXT, sent|defwinproc|optional },
258 { WM_ERASEBKGND, sent|optional },
259 { HCBT_ACTIVATE, hook },
260 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
261 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
262 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
263 { WM_NCPAINT, sent|wparam|optional, 1 },
264 { WM_ACTIVATEAPP, sent|wparam, 1 },
265 { WM_NCACTIVATE, sent|wparam, 1 },
266 { WM_GETTEXT, sent|defwinproc|optional },
267 { WM_ACTIVATE, sent|wparam, 1 },
268 { HCBT_SETFOCUS, hook },
269 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
270 { WM_IME_NOTIFY, sent|defwinproc|optional },
271 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
272 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
273 { WM_NCPAINT, sent|wparam|optional, 1 },
274 { WM_GETTEXT, sent|defwinproc|optional },
275 { WM_ERASEBKGND, sent|optional },
276 /* Win9x adds SWP_NOZORDER below */
277 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
278 { WM_NCCALCSIZE, sent|optional },
279 { WM_NCPAINT, sent|optional },
280 { WM_ERASEBKGND, sent|optional },
281 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
282 * messages. Does that mean that CreateWindow doesn't set initial
283 * window dimensions for overlapped windows?
290 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
291 static const struct message WmShowMaxOverlappedSeq[] = {
292 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
293 { WM_GETMINMAXINFO, sent },
294 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
295 { WM_GETMINMAXINFO, sent|defwinproc },
296 { WM_NCCALCSIZE, sent|wparam, TRUE },
297 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
298 { HCBT_ACTIVATE, hook },
299 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
300 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
301 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
302 { WM_ACTIVATEAPP, sent|wparam, 1 },
303 { WM_NCACTIVATE, sent|wparam, 1 },
304 { WM_GETTEXT, sent|defwinproc|optional },
305 { WM_ACTIVATE, sent|wparam, 1 },
306 { HCBT_SETFOCUS, hook },
307 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
308 { WM_IME_NOTIFY, sent|defwinproc|optional },
309 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
310 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
311 { WM_NCPAINT, sent|wparam|optional, 1 },
312 { WM_GETTEXT, sent|defwinproc|optional },
313 { WM_ERASEBKGND, sent|optional },
314 /* Win9x adds SWP_NOZORDER below */
315 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
316 { WM_MOVE, sent|defwinproc },
317 { WM_SIZE, sent|defwinproc },
318 { WM_NCCALCSIZE, sent|optional },
319 { WM_NCPAINT, sent|optional },
320 { WM_ERASEBKGND, sent|optional },
321 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
322 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
325 /* ShowWindow(SW_HIDE) for a visible overlapped window */
326 static const struct message WmHideOverlappedSeq[] = {
327 { WM_SHOWWINDOW, sent|wparam, 0 },
328 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
329 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
330 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
331 { WM_SIZE, sent|optional }, /* XP doesn't send it */
332 { WM_MOVE, sent|optional }, /* XP doesn't send it */
333 { WM_NCACTIVATE, sent|wparam, 0 },
334 { WM_ACTIVATE, sent|wparam, 0 },
335 { WM_ACTIVATEAPP, sent|wparam, 0 },
336 { WM_KILLFOCUS, sent|wparam, 0 },
337 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
338 { WM_IME_NOTIFY, sent|optional|defwinproc },
341 /* DestroyWindow for a visible overlapped window */
342 static const struct message WmDestroyOverlappedSeq[] = {
343 { HCBT_DESTROYWND, hook },
344 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
345 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
346 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
347 { WM_NCACTIVATE, sent|wparam, 0 },
348 { WM_ACTIVATE, sent|wparam, 0 },
349 { WM_ACTIVATEAPP, sent|wparam, 0 },
350 { WM_KILLFOCUS, sent|wparam, 0 },
351 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
352 { WM_IME_NOTIFY, sent|optional|defwinproc },
353 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
354 { WM_DESTROY, sent },
355 { WM_NCDESTROY, sent },
358 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
359 static const struct message WmCreateMaxPopupSeq[] = {
360 { HCBT_CREATEWND, hook },
361 { WM_NCCREATE, sent },
362 { WM_NCCALCSIZE, sent|wparam, 0 },
366 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
367 { WM_GETMINMAXINFO, sent },
368 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000*/ },
369 { WM_NCCALCSIZE, sent|wparam, TRUE },
370 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000*/ },
371 { WM_MOVE, sent|defwinproc },
372 { WM_SIZE, sent|defwinproc },
373 { WM_SHOWWINDOW, sent|wparam, 1 },
374 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
375 { HCBT_ACTIVATE, hook },
376 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
377 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
378 { WM_ACTIVATEAPP, sent|wparam, 1 },
379 { WM_NCACTIVATE, sent|wparam, 1 },
380 { WM_ACTIVATE, sent|wparam, 1 },
381 { HCBT_SETFOCUS, hook },
382 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
383 { WM_SYNCPAINT, sent|wparam|optional, 4 },
384 { WM_NCPAINT, sent|wparam|optional, 1 },
385 { WM_ERASEBKGND, sent|optional },
386 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE },
389 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
390 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
391 { HCBT_CREATEWND, hook },
392 { WM_NCCREATE, sent },
393 { WM_NCCALCSIZE, sent|wparam, 0 },
397 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
398 { WM_GETMINMAXINFO, sent },
399 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000*/ },
400 { WM_NCCALCSIZE, sent|wparam, TRUE },
401 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000*/ },
402 { WM_MOVE, sent|defwinproc },
403 { WM_SIZE, sent|defwinproc },
406 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
407 static const struct message WmShowMaxPopupResizedSeq[] = {
408 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
409 { WM_GETMINMAXINFO, sent },
410 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
411 { WM_NCCALCSIZE, sent|wparam, TRUE },
412 { HCBT_ACTIVATE, hook },
413 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
414 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
415 { WM_ACTIVATEAPP, sent|wparam, 1 },
416 { WM_NCACTIVATE, sent|wparam, 1 },
417 { WM_ACTIVATE, sent|wparam, 1 },
418 { HCBT_SETFOCUS, hook },
419 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
420 { WM_NCPAINT, sent|wparam|optional, 1 },
421 { WM_ERASEBKGND, sent|optional },
422 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOZORDER },
423 /* WinNT4.0 sends WM_MOVE */
424 { WM_MOVE, sent|defwinproc|optional },
425 { WM_SIZE, sent|defwinproc },
428 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
429 static const struct message WmShowMaxPopupSeq[] = {
430 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
431 { WM_GETMINMAXINFO, sent },
432 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
433 { WM_NCCALCSIZE, sent|wparam, TRUE },
434 { HCBT_ACTIVATE, hook },
435 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
436 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
437 { WM_ACTIVATEAPP, sent|wparam, 1 },
438 { WM_NCACTIVATE, sent|wparam, 1 },
439 { WM_ACTIVATE, sent|wparam, 1 },
440 { HCBT_SETFOCUS, hook },
441 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
442 { WM_SYNCPAINT, sent|wparam|optional, 4 },
443 { WM_NCPAINT, sent|wparam|optional, 1 },
444 { WM_ERASEBKGND, sent|optional },
445 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
448 /* CreateWindow(WS_VISIBLE) for popup window */
449 static const struct message WmCreatePopupSeq[] = {
450 { HCBT_CREATEWND, hook },
451 { WM_NCCREATE, sent },
452 { WM_NCCALCSIZE, sent|wparam, 0 },
456 { WM_SHOWWINDOW, sent|wparam, 1 },
457 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
458 { HCBT_ACTIVATE, hook },
459 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
460 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
461 { WM_NCPAINT, sent|wparam|optional, 1 },
462 { WM_ERASEBKGND, sent|optional },
463 { WM_ACTIVATEAPP, sent|wparam, 1 },
464 { WM_NCACTIVATE, sent|wparam, 1 },
465 { WM_ACTIVATE, sent|wparam, 1 },
466 { HCBT_SETFOCUS, hook },
467 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
468 { WM_SYNCPAINT, sent|wparam|optional, 4 },
469 { WM_NCPAINT, sent|wparam|optional, 1 },
470 { WM_ERASEBKGND, sent|optional },
471 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE },
474 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
475 static const struct message WmShowVisMaxPopupSeq[] = {
476 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
477 { WM_GETMINMAXINFO, sent },
478 { WM_GETTEXT, sent|optional },
479 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
480 { WM_NCCALCSIZE, sent|wparam, TRUE },
481 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
482 { WM_NCPAINT, sent|wparam|optional, 1 },
483 { WM_ERASEBKGND, sent|optional },
484 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOZORDER|0x8000 },
485 { WM_MOVE, sent|defwinproc },
486 { WM_SIZE, sent|defwinproc },
489 /* CreateWindow (for a child popup window, not initially visible) */
490 static const struct message WmCreateChildPopupSeq[] = {
491 { HCBT_CREATEWND, hook },
492 { WM_NCCREATE, sent },
493 { WM_NCCALCSIZE, sent|wparam, 0 },
495 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
500 /* CreateWindow (for a popup window, not initially visible,
501 * which sets WS_VISIBLE in WM_CREATE handler)
503 static const struct message WmCreateInvisiblePopupSeq[] = {
504 { HCBT_CREATEWND, hook },
505 { WM_NCCREATE, sent },
506 { WM_NCCALCSIZE, sent|wparam, 0 },
508 { WM_STYLECHANGING, sent },
509 { WM_STYLECHANGED, sent },
510 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
515 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
516 * for a popup window with WS_VISIBLE style set
518 static const struct message WmShowVisiblePopupSeq_2[] = {
519 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
522 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
523 * for a popup window with WS_VISIBLE style set
525 static const struct message WmShowVisiblePopupSeq_3[] = {
526 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
527 { HCBT_ACTIVATE, hook },
528 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
529 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
530 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
531 { WM_NCACTIVATE, sent|wparam, 1 },
532 { WM_ACTIVATE, sent|wparam, 1 },
533 { HCBT_SETFOCUS, hook },
534 { WM_KILLFOCUS, sent|parent },
535 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
536 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
537 { WM_IME_NOTIFY, sent|defwinproc|optional },
538 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
539 { WM_SETFOCUS, sent|defwinproc },
542 /* CreateWindow (for child window, not initially visible) */
543 static const struct message WmCreateChildSeq[] = {
544 { HCBT_CREATEWND, hook },
545 { WM_NCCREATE, sent },
546 /* child is inserted into parent's child list after WM_NCCREATE returns */
547 { WM_NCCALCSIZE, sent|wparam, 0 },
549 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
552 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
555 /* CreateWindow (for maximized child window, not initially visible) */
556 static const struct message WmCreateMaximizedChildSeq[] = {
557 { HCBT_CREATEWND, hook },
558 { WM_NCCREATE, sent },
559 { WM_NCCALCSIZE, sent|wparam, 0 },
561 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
564 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
565 { WM_GETMINMAXINFO, sent },
566 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
567 { WM_NCCALCSIZE, sent|wparam, 1 },
568 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
569 { WM_SIZE, sent|defwinproc },
570 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
571 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
574 /* CreateWindow (for a child window, initially visible) */
575 static const struct message WmCreateVisibleChildSeq[] = {
576 { HCBT_CREATEWND, hook },
577 { WM_NCCREATE, sent },
578 /* child is inserted into parent's child list after WM_NCCREATE returns */
579 { WM_NCCALCSIZE, sent|wparam, 0 },
580 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
582 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
585 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
586 { WM_SHOWWINDOW, sent|wparam, 1 },
587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
588 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
589 { WM_ERASEBKGND, sent|parent|optional },
590 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
591 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
592 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
595 /* ShowWindow(SW_SHOW) for a not visible child window */
596 static const struct message WmShowChildSeq[] = {
597 { WM_SHOWWINDOW, sent|wparam, 1 },
598 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
599 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
600 { WM_ERASEBKGND, sent|parent|optional },
601 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
604 /* ShowWindow(SW_HIDE) for a visible child window */
605 static const struct message WmHideChildSeq[] = {
606 { WM_SHOWWINDOW, sent|wparam, 0 },
607 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
608 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
609 { WM_ERASEBKGND, sent|parent|optional },
610 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
613 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
614 * for a not visible child window
616 static const struct message WmShowChildSeq_2[] = {
617 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
618 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
619 { WM_CHILDACTIVATE, sent },
620 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
623 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
624 * for a not visible child window
626 static const struct message WmShowChildSeq_3[] = {
627 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
628 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
629 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
632 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
633 * for a visible child window with a caption
635 static const struct message WmShowChildSeq_4[] = {
636 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
637 { WM_CHILDACTIVATE, sent },
640 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
641 static const struct message WmShowChildInvisibleParentSeq_1[] = {
642 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
643 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
644 { WM_NCCALCSIZE, sent|wparam, 1 },
645 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
646 { WM_MOVE, sent|defwinproc },
647 { WM_SIZE, sent|defwinproc },
648 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
649 /* FIXME: Wine creates an icon/title window while Windows doesn't */
650 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
651 { WM_GETTEXT, sent|optional },
654 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
655 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
656 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
659 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
660 static const struct message WmShowChildInvisibleParentSeq_2[] = {
661 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
662 { WM_GETMINMAXINFO, sent },
663 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
664 { WM_NCCALCSIZE, sent|wparam, 1 },
665 { WM_CHILDACTIVATE, sent },
666 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
667 { WM_SIZE, sent|defwinproc },
668 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
671 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
672 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
673 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
676 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
677 static const struct message WmShowChildInvisibleParentSeq_3[] = {
678 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
679 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
680 { WM_NCCALCSIZE, sent|wparam, 1 },
681 { WM_CHILDACTIVATE, sent },
682 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
683 { WM_MOVE, sent|defwinproc },
684 { WM_SIZE, sent|defwinproc },
685 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
686 /* FIXME: Wine creates an icon/title window while Windows doesn't */
687 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
688 { WM_GETTEXT, sent|optional },
691 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
692 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
693 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
696 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
697 static const struct message WmShowChildInvisibleParentSeq_4[] = {
698 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
699 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCOPYBITS|0x8000 },
700 { WM_NCCALCSIZE, sent|wparam, 1 },
701 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
702 { WM_MOVE, sent|defwinproc },
703 { WM_SIZE, sent|defwinproc },
704 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
705 /* FIXME: Wine creates an icon/title window while Windows doesn't */
706 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
707 { WM_GETTEXT, sent|optional },
710 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
711 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
712 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
715 /* ShowWindow(SW_SHOW) for child with invisible parent */
716 static const struct message WmShowChildInvisibleParentSeq_5[] = {
717 { WM_SHOWWINDOW, sent|wparam, 1 },
720 /* ShowWindow(SW_HIDE) for child with invisible parent */
721 static const struct message WmHideChildInvisibleParentSeq[] = {
722 { WM_SHOWWINDOW, sent|wparam, 0 },
725 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
726 static const struct message WmShowChildInvisibleParentSeq_6[] = {
727 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
728 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
729 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
732 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
733 static const struct message WmHideChildInvisibleParentSeq_2[] = {
734 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
735 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
736 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
739 /* DestroyWindow for a visible child window */
740 static const struct message WmDestroyChildSeq[] = {
741 { HCBT_DESTROYWND, hook },
742 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
743 { WM_SHOWWINDOW, sent|wparam, 0 },
744 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
745 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
746 { WM_ERASEBKGND, sent|parent|optional },
747 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
748 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
749 { WM_KILLFOCUS, sent },
750 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
751 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
752 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
753 { WM_SETFOCUS, sent|parent },
754 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
755 { WM_DESTROY, sent },
756 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
757 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
758 { WM_NCDESTROY, sent },
761 /* DestroyWindow for a visible child window with invisible parent */
762 static const struct message WmDestroyInvisibleChildSeq[] = {
763 { HCBT_DESTROYWND, hook },
764 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
765 { WM_SHOWWINDOW, sent|wparam, 0 },
766 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
767 { WM_DESTROY, sent },
768 { WM_NCDESTROY, sent },
771 /* Moving the mouse in nonclient area */
772 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
773 { WM_NCHITTEST, sent },
774 { WM_SETCURSOR, sent },
775 { WM_NCMOUSEMOVE, posted },
778 /* Moving the mouse in client area */
779 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
780 { WM_NCHITTEST, sent },
781 { WM_SETCURSOR, sent },
782 { WM_MOUSEMOVE, posted },
785 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
786 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
787 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
788 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
789 { WM_GETMINMAXINFO, sent|defwinproc },
790 { WM_ENTERSIZEMOVE, sent|defwinproc },
791 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
792 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
793 { WM_MOVE, sent|defwinproc },
794 { WM_EXITSIZEMOVE, sent|defwinproc },
797 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
798 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
799 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
800 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
801 { WM_GETMINMAXINFO, sent|defwinproc },
802 { WM_ENTERSIZEMOVE, sent|defwinproc },
803 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
804 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
805 { WM_GETMINMAXINFO, sent|defwinproc },
806 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
807 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
808 { WM_GETTEXT, sent|defwinproc },
809 { WM_ERASEBKGND, sent|defwinproc },
810 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
811 { WM_MOVE, sent|defwinproc },
812 { WM_SIZE, sent|defwinproc },
813 { WM_EXITSIZEMOVE, sent|defwinproc },
816 /* Resizing child window with MoveWindow (32) */
817 static const struct message WmResizingChildWithMoveWindowSeq[] = {
818 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
819 { WM_NCCALCSIZE, sent|wparam, 1 },
820 { WM_ERASEBKGND, sent|optional },
821 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
822 { WM_MOVE, sent|defwinproc },
823 { WM_SIZE, sent|defwinproc },
824 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
827 /* Clicking on inactive button */
828 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
829 { WM_NCHITTEST, sent },
830 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
831 { WM_MOUSEACTIVATE, sent },
832 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
833 { WM_SETCURSOR, sent },
834 { WM_SETCURSOR, sent|parent|defwinproc },
835 { WM_LBUTTONDOWN, posted },
836 { WM_KILLFOCUS, posted|parent },
837 { WM_SETFOCUS, posted },
838 { WM_CTLCOLORBTN, posted|parent },
839 { BM_SETSTATE, posted },
840 { WM_CTLCOLORBTN, posted|parent },
841 { WM_LBUTTONUP, posted },
842 { BM_SETSTATE, posted },
843 { WM_CTLCOLORBTN, posted|parent },
844 { WM_COMMAND, posted|parent },
847 /* Reparenting a button (16/32) */
848 /* The last child (button) reparented gets topmost for its new parent. */
849 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
850 { WM_SHOWWINDOW, sent|wparam, 0 },
851 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
852 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
853 { WM_ERASEBKGND, sent|parent },
854 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
855 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOZORDER },
856 { WM_CHILDACTIVATE, sent },
857 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER },
858 { WM_MOVE, sent|defwinproc },
859 { WM_SHOWWINDOW, sent|wparam, 1 },
862 /* Creation of a custom dialog (32) */
863 static const struct message WmCreateCustomDialogSeq[] = {
864 { HCBT_CREATEWND, hook },
865 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
866 { WM_GETMINMAXINFO, sent },
867 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
868 { WM_NCCREATE, sent },
869 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
870 { WM_NCCALCSIZE, sent|wparam, 0 },
871 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
872 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
874 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
875 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
876 { WM_SHOWWINDOW, sent|wparam, 1 },
877 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
878 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
879 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
880 { HCBT_ACTIVATE, hook },
881 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
883 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
885 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
886 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
888 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
890 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
891 { WM_NCACTIVATE, sent|wparam, 1 },
892 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
893 { WM_GETTEXT, sent|optional|defwinproc },
894 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
895 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
896 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
897 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
898 { WM_GETTEXT, sent|optional|defwinproc },
899 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
900 { WM_ACTIVATE, sent|wparam, 1 },
901 { WM_KILLFOCUS, sent|parent },
902 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
903 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
904 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
905 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
906 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
907 { WM_IME_NOTIFY, sent|optional|defwinproc },
908 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
909 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
910 { WM_SETFOCUS, sent },
911 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
912 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
913 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
914 { WM_NCPAINT, sent|wparam, 1 },
915 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
916 { WM_GETTEXT, sent|optional|defwinproc },
917 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
918 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
919 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
920 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
921 { WM_GETTEXT, sent|optional|defwinproc },
922 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
923 { WM_ERASEBKGND, sent },
924 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
925 { WM_CTLCOLORDLG, sent|defwinproc },
926 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
927 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
928 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
929 { WM_GETTEXT, sent|optional },
930 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
931 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
932 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
933 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
934 { WM_GETTEXT, sent|optional },
935 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
936 { WM_NCCALCSIZE, sent|optional },
937 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
938 { WM_NCPAINT, sent|optional },
939 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
940 { WM_GETTEXT, sent|optional|defwinproc },
941 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
942 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
943 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
944 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
945 { WM_GETTEXT, sent|optional|defwinproc },
946 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
947 { WM_ERASEBKGND, sent|optional },
948 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
949 { WM_CTLCOLORDLG, sent|optional|defwinproc },
950 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
951 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
953 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
957 /* Calling EndDialog for a custom dialog (32) */
958 static const struct message WmEndCustomDialogSeq[] = {
959 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
960 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
961 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
962 { WM_GETTEXT, sent|optional },
963 { HCBT_ACTIVATE, hook },
964 { WM_NCACTIVATE, sent|wparam, 0 },
965 { WM_GETTEXT, sent|optional|defwinproc },
966 { WM_GETTEXT, sent|optional|defwinproc },
967 { WM_ACTIVATE, sent|wparam, 0 },
968 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
969 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
970 { HCBT_SETFOCUS, hook },
971 { WM_KILLFOCUS, sent },
972 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
973 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
974 { WM_IME_NOTIFY, sent|optional },
975 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
976 { WM_SETFOCUS, sent|parent|defwinproc },
979 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
980 static const struct message WmShowCustomDialogSeq[] = {
981 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
982 { WM_SHOWWINDOW, sent|wparam, 1 },
983 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
984 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
985 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
986 { HCBT_ACTIVATE, hook },
987 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
989 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
990 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
992 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
993 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
994 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
995 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
996 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
997 { WM_NCACTIVATE, sent|wparam, 1 },
998 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
999 { WM_ACTIVATE, sent|wparam, 1 },
1001 { WM_KILLFOCUS, sent|parent },
1002 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1003 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1004 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1005 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1006 { WM_IME_NOTIFY, sent|optional|defwinproc },
1007 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1008 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1009 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1010 { WM_SETFOCUS, sent },
1011 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1012 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1013 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1014 { WM_NCPAINT, sent|wparam, 1 },
1015 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1016 { WM_ERASEBKGND, sent },
1017 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1018 { WM_CTLCOLORDLG, sent|defwinproc },
1020 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1021 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1024 /* Creation and destruction of a modal dialog (32) */
1025 static const struct message WmModalDialogSeq[] = {
1026 { WM_CANCELMODE, sent|parent },
1027 { HCBT_SETFOCUS, hook },
1028 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1029 { WM_KILLFOCUS, sent|parent },
1030 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1031 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1032 { WM_ENABLE, sent|parent|wparam, 0 },
1033 { HCBT_CREATEWND, hook },
1034 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1035 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1036 { WM_SETFONT, sent },
1037 { WM_INITDIALOG, sent },
1038 { WM_CHANGEUISTATE, sent|optional },
1039 { WM_SHOWWINDOW, sent },
1040 { HCBT_ACTIVATE, hook },
1041 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1042 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1043 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1044 { WM_NCACTIVATE, sent|wparam, 1 },
1045 { WM_GETTEXT, sent|optional },
1046 { WM_ACTIVATE, sent|wparam, 1 },
1047 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE },
1048 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1049 { WM_NCPAINT, sent },
1050 { WM_GETTEXT, sent|optional },
1051 { WM_ERASEBKGND, sent },
1052 { WM_CTLCOLORDLG, sent },
1053 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1054 { WM_GETTEXT, sent|optional },
1055 { WM_NCCALCSIZE, sent|optional },
1056 { WM_NCPAINT, sent|optional },
1057 { WM_GETTEXT, sent|optional },
1058 { WM_ERASEBKGND, sent|optional },
1059 { WM_CTLCOLORDLG, sent|optional },
1060 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1061 { WM_PAINT, sent|optional },
1062 { WM_CTLCOLORBTN, sent },
1063 { WM_ENTERIDLE, sent|parent|optional },
1064 { WM_ENTERIDLE, sent|parent|optional },
1065 { WM_ENTERIDLE, sent|parent|optional },
1066 { WM_ENTERIDLE, sent|parent|optional },
1067 { WM_ENTERIDLE, sent|parent|optional },
1068 { WM_ENTERIDLE, sent|parent|optional },
1069 { WM_ENTERIDLE, sent|parent|optional },
1070 { WM_ENTERIDLE, sent|parent|optional },
1071 { WM_ENTERIDLE, sent|parent|optional },
1072 { WM_ENTERIDLE, sent|parent|optional },
1073 { WM_ENTERIDLE, sent|parent|optional },
1074 { WM_ENTERIDLE, sent|parent|optional },
1075 { WM_ENTERIDLE, sent|parent|optional },
1076 { WM_ENTERIDLE, sent|parent|optional },
1077 { WM_ENTERIDLE, sent|parent|optional },
1078 { WM_ENTERIDLE, sent|parent|optional },
1079 { WM_ENTERIDLE, sent|parent|optional },
1080 { WM_ENTERIDLE, sent|parent|optional },
1081 { WM_ENTERIDLE, sent|parent|optional },
1082 { WM_ENTERIDLE, sent|parent|optional },
1084 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1085 { WM_ENABLE, sent|parent|wparam, 1 },
1086 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE },
1087 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1088 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1089 { WM_GETTEXT, sent|optional },
1090 { HCBT_ACTIVATE, hook },
1091 { WM_NCACTIVATE, sent|wparam, 0 },
1092 { WM_GETTEXT, sent|optional },
1093 { WM_ACTIVATE, sent|wparam, 0 },
1094 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1095 { WM_WINDOWPOSCHANGING, sent|optional },
1096 { HCBT_SETFOCUS, hook },
1097 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1098 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1099 { WM_SETFOCUS, sent|parent|defwinproc },
1100 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1101 { HCBT_DESTROYWND, hook },
1102 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1103 { WM_DESTROY, sent },
1104 { WM_NCDESTROY, sent },
1107 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1108 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1109 /* (inside dialog proc, handling WM_INITDIALOG) */
1110 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1111 { WM_NCCALCSIZE, sent },
1112 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1113 { WM_GETTEXT, sent|defwinproc },
1114 { WM_ACTIVATE, sent|parent|wparam, 0 },
1115 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1116 { WM_WINDOWPOSCHANGING, sent|parent },
1117 { WM_NCACTIVATE, sent|wparam, 1 },
1118 { WM_ACTIVATE, sent|wparam, 1 },
1119 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1120 { WM_SIZE, sent|defwinproc },
1121 /* (setting focus) */
1122 { WM_SHOWWINDOW, sent|wparam, 1 },
1123 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1124 { WM_NCPAINT, sent },
1125 { WM_GETTEXT, sent|defwinproc },
1126 { WM_ERASEBKGND, sent },
1127 { WM_CTLCOLORDLG, sent|defwinproc },
1128 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1130 /* (bunch of WM_CTLCOLOR* for each control) */
1131 { WM_PAINT, sent|parent },
1132 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1133 { WM_SETCURSOR, sent|parent },
1136 /* SetMenu for NonVisible windows with size change*/
1137 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1138 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1139 { WM_NCCALCSIZE, sent|wparam, 1 },
1140 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1141 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW },
1142 { WM_MOVE, sent|defwinproc },
1143 { WM_SIZE, sent|defwinproc },
1144 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1145 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1146 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1147 { WM_GETTEXT, sent|optional },
1148 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1151 /* SetMenu for NonVisible windows with no size change */
1152 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1153 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1154 { WM_NCCALCSIZE, sent|wparam, 1 },
1155 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1156 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1159 /* SetMenu for Visible windows with size change */
1160 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1161 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1162 { WM_NCCALCSIZE, sent|wparam, 1 },
1163 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1164 { WM_NCPAINT, sent }, /* wparam != 1 */
1165 { WM_GETTEXT, sent|defwinproc|optional },
1166 { WM_ERASEBKGND, sent|optional },
1167 { WM_ACTIVATE, sent|optional },
1168 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1169 { WM_MOVE, sent|defwinproc },
1170 { WM_SIZE, sent|defwinproc },
1171 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1172 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1173 { WM_ERASEBKGND, sent|optional },
1174 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1175 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1178 /* SetMenu for Visible windows with no size change */
1179 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1180 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1181 { WM_NCCALCSIZE, sent|wparam, 1 },
1182 { WM_NCPAINT, sent }, /* wparam != 1 */
1183 { WM_GETTEXT, sent|defwinproc|optional },
1184 { WM_ERASEBKGND, sent|optional },
1185 { WM_ACTIVATE, sent|optional },
1186 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1187 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1190 /* DrawMenuBar for a visible window */
1191 static const struct message WmDrawMenuBarSeq[] =
1193 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1194 { WM_NCCALCSIZE, sent|wparam, 1 },
1195 { WM_NCPAINT, sent }, /* wparam != 1 */
1196 { WM_GETTEXT, sent|defwinproc|optional },
1197 { WM_ERASEBKGND, sent|optional },
1198 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1199 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1203 static const struct message WmSetRedrawFalseSeq[] =
1205 { WM_SETREDRAW, sent|wparam, 0 },
1209 static const struct message WmSetRedrawTrueSeq[] =
1211 { WM_SETREDRAW, sent|wparam, 1 },
1215 static const struct message WmEnableWindowSeq_1[] =
1217 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1218 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1219 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1223 static const struct message WmEnableWindowSeq_2[] =
1225 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1226 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1230 static const struct message WmGetScrollRangeSeq[] =
1232 { SBM_GETRANGE, sent },
1235 static const struct message WmGetScrollInfoSeq[] =
1237 { SBM_GETSCROLLINFO, sent },
1240 static const struct message WmSetScrollRangeSeq[] =
1242 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1243 sends SBM_SETSCROLLINFO.
1245 { SBM_SETSCROLLINFO, sent },
1248 /* SetScrollRange for a window without a non-client area */
1249 static const struct message WmSetScrollRangeHSeq_empty[] =
1251 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1254 static const struct message WmSetScrollRangeVSeq_empty[] =
1256 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1259 static const struct message WmSetScrollRangeHVSeq[] =
1261 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
1262 { WM_NCCALCSIZE, sent|wparam, 1 },
1263 { WM_GETTEXT, sent|defwinproc|optional },
1264 { WM_ERASEBKGND, sent|optional },
1265 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1266 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1267 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1270 /* SetScrollRange for a window with a non-client area */
1271 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1273 { WM_WINDOWPOSCHANGING, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER*/ },
1274 { WM_NCCALCSIZE, sent|wparam, 1 },
1275 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1276 { WM_NCPAINT, sent|optional },
1277 { WM_GETTEXT, sent|defwinproc|optional },
1278 { WM_GETTEXT, sent|defwinproc|optional },
1279 { WM_ERASEBKGND, sent|optional },
1280 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1281 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|0x1000*/ },
1282 { WM_SIZE, sent|defwinproc },
1283 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1284 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1285 { WM_GETTEXT, sent|optional },
1286 { WM_GETTEXT, sent|optional },
1287 { WM_GETTEXT, sent|optional },
1288 { WM_GETTEXT, sent|optional },
1291 /* test if we receive the right sequence of messages */
1292 /* after calling ShowWindow( SW_SHOWNA) */
1293 static const struct message WmSHOWNAChildInvisParInvis[] = {
1294 { WM_SHOWWINDOW, sent|wparam, 1 },
1297 static const struct message WmSHOWNAChildVisParInvis[] = {
1298 { WM_SHOWWINDOW, sent|wparam, 1 },
1301 static const struct message WmSHOWNAChildVisParVis[] = {
1302 { WM_SHOWWINDOW, sent|wparam, 1 },
1303 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
1306 static const struct message WmSHOWNAChildInvisParVis[] = {
1307 { WM_SHOWWINDOW, sent|wparam, 1 },
1308 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER},
1309 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1310 { WM_ERASEBKGND, sent|optional },
1311 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1314 static const struct message WmSHOWNATopVisible[] = {
1315 { WM_SHOWWINDOW, sent|wparam, 1 },
1316 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1319 static const struct message WmSHOWNATopInvisible[] = {
1320 { WM_SHOWWINDOW, sent|wparam, 1 },
1321 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1322 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1323 { WM_NCPAINT, sent|wparam, 1 },
1324 { WM_GETTEXT, sent|defwinproc|optional },
1325 { WM_ERASEBKGND, sent|optional },
1326 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1327 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1328 { WM_NCPAINT, sent|wparam|optional, 1 },
1329 { WM_ERASEBKGND, sent|optional },
1330 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1336 static int after_end_dialog;
1337 static int sequence_cnt, sequence_size;
1338 static struct message* sequence;
1339 static int log_all_parent_messages;
1341 static void add_message(const struct message *msg)
1346 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1348 if (sequence_cnt == sequence_size)
1351 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1355 sequence[sequence_cnt].message = msg->message;
1356 sequence[sequence_cnt].flags = msg->flags;
1357 sequence[sequence_cnt].wParam = msg->wParam;
1358 sequence[sequence_cnt].lParam = msg->lParam;
1363 /* try to make sure pending X events have been processed before continuing */
1364 static void flush_events(void)
1368 DWORD time = GetTickCount() + diff;
1372 MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT );
1373 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1374 diff = time - GetTickCount();
1378 static void flush_sequence(void)
1380 HeapFree(GetProcessHeap(), 0, sequence);
1382 sequence_cnt = sequence_size = 0;
1385 #define ok_sequence( exp, contx, todo) \
1386 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1389 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1390 const char *file, int line)
1392 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1393 const struct message *actual;
1396 add_message(&end_of_sequence);
1400 while (expected->message && actual->message)
1402 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1404 if (expected->message == actual->message)
1406 if (expected->flags & wparam)
1408 if (expected->wParam != actual->wParam && todo)
1412 ok_( file, line) (FALSE,
1413 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1414 context, expected->message, expected->wParam, actual->wParam);
1418 ok_( file, line) (expected->wParam == actual->wParam,
1419 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1420 context, expected->message, expected->wParam, actual->wParam);
1422 if (expected->flags & lparam)
1424 if (expected->lParam != actual->lParam && todo)
1428 ok_( file, line) (FALSE,
1429 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1430 context, expected->message, expected->lParam, actual->lParam);
1434 ok_( file, line) (expected->lParam == actual->lParam,
1435 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1436 context, expected->message, expected->lParam, actual->lParam);
1438 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1439 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1440 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1441 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1442 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1443 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1444 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1445 "%s: the msg 0x%04x should have been %s\n",
1446 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1447 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1448 "%s: the msg 0x%04x was expected in %s\n",
1449 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1450 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1451 "%s: the msg 0x%04x should have been sent by a hook\n",
1452 context, expected->message);
1453 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1454 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1455 context, expected->message);
1459 /* silently drop winevent messages if there is no support for them */
1460 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1466 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1467 context, expected->message, actual->message);
1474 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1475 context, expected->message, actual->message);
1481 /* skip all optional trailing messages */
1482 while (expected->message && ((expected->flags & optional) ||
1483 ((expected->flags & winevent_hook) && !hEvent_hook)))
1489 if (expected->message || actual->message) {
1491 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1492 context, expected->message, actual->message);
1498 if (expected->message || actual->message)
1499 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1500 context, expected->message, actual->message);
1502 if( todo && !failcount) /* succeeded yet marked todo */
1504 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1510 /******************************** MDI test **********************************/
1512 /* CreateWindow for MDI frame window, initially visible */
1513 static const struct message WmCreateMDIframeSeq[] = {
1514 { HCBT_CREATEWND, hook },
1515 { WM_GETMINMAXINFO, sent },
1516 { WM_NCCREATE, sent },
1517 { WM_NCCALCSIZE, sent|wparam, 0 },
1518 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1519 { WM_CREATE, sent },
1520 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1521 { WM_SHOWWINDOW, sent|wparam, 1 },
1522 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1523 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1524 { HCBT_ACTIVATE, hook },
1525 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1526 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1527 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1528 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* Win9x */
1529 { WM_ACTIVATEAPP, sent|wparam, 1 },
1530 { WM_NCACTIVATE, sent|wparam, 1 },
1531 { WM_GETTEXT, sent|defwinproc|optional },
1532 { WM_ACTIVATE, sent|wparam, 1 },
1533 { HCBT_SETFOCUS, hook },
1534 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1535 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1536 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1537 /* Win9x adds SWP_NOZORDER below */
1538 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
1539 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1540 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1545 /* DestroyWindow for MDI frame window, initially visible */
1546 static const struct message WmDestroyMDIframeSeq[] = {
1547 { HCBT_DESTROYWND, hook },
1548 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1549 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1550 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1551 { WM_NCACTIVATE, sent|wparam, 0 },
1552 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1553 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1554 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1555 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1556 { WM_DESTROY, sent },
1557 { WM_NCDESTROY, sent },
1560 /* CreateWindow for MDI client window, initially visible */
1561 static const struct message WmCreateMDIclientSeq[] = {
1562 { HCBT_CREATEWND, hook },
1563 { WM_NCCREATE, sent },
1564 { WM_NCCALCSIZE, sent|wparam, 0 },
1565 { WM_CREATE, sent },
1566 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1569 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1570 { WM_SHOWWINDOW, sent|wparam, 1 },
1571 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1572 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1573 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1576 /* ShowWindow(SW_SHOW) for MDI client window */
1577 static const struct message WmShowMDIclientSeq[] = {
1578 { WM_SHOWWINDOW, sent|wparam, 1 },
1579 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1580 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1581 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1584 /* ShowWindow(SW_HIDE) for MDI client window */
1585 static const struct message WmHideMDIclientSeq[] = {
1586 { WM_SHOWWINDOW, sent|wparam, 0 },
1587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1588 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1589 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1592 /* DestroyWindow for MDI client window, initially visible */
1593 static const struct message WmDestroyMDIclientSeq[] = {
1594 { HCBT_DESTROYWND, hook },
1595 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1596 { WM_SHOWWINDOW, sent|wparam, 0 },
1597 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1598 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1599 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1600 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1601 { WM_DESTROY, sent },
1602 { WM_NCDESTROY, sent },
1605 /* CreateWindow for MDI child window, initially visible */
1606 static const struct message WmCreateMDIchildVisibleSeq[] = {
1607 { HCBT_CREATEWND, hook },
1608 { WM_NCCREATE, sent },
1609 { WM_NCCALCSIZE, sent|wparam, 0 },
1610 { WM_CREATE, sent },
1611 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1614 /* Win2k sends wparam set to
1615 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1616 * while Win9x doesn't bother to set child window id according to
1617 * CLIENTCREATESTRUCT.idFirstChild
1619 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1620 { WM_SHOWWINDOW, sent|wparam, 1 },
1621 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1622 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1623 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1624 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1625 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1626 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1627 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1629 /* Win9x: message sequence terminates here. */
1631 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1632 { HCBT_SETFOCUS, hook }, /* in MDI client */
1633 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1634 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1635 { WM_SETFOCUS, sent }, /* in MDI client */
1636 { HCBT_SETFOCUS, hook },
1637 { WM_KILLFOCUS, sent }, /* in MDI client */
1638 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1639 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1640 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1641 { WM_SETFOCUS, sent|defwinproc },
1642 { WM_MDIACTIVATE, sent|defwinproc },
1645 /* CreateWindow for MDI child window with invisible parent */
1646 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1647 { HCBT_CREATEWND, hook },
1648 { WM_GETMINMAXINFO, sent },
1649 { WM_NCCREATE, sent },
1650 { WM_NCCALCSIZE, sent|wparam, 0 },
1651 { WM_CREATE, sent },
1652 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1655 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1656 { WM_SHOWWINDOW, sent|wparam, 1 },
1657 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1658 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1659 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1660 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1662 /* Win9x: message sequence terminates here. */
1664 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1665 { HCBT_SETFOCUS, hook }, /* in MDI client */
1666 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1667 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1668 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1669 { WM_SETFOCUS, sent }, /* in MDI client */
1670 { HCBT_SETFOCUS, hook },
1671 { WM_KILLFOCUS, sent }, /* in MDI client */
1672 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1673 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1674 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1675 { WM_SETFOCUS, sent|defwinproc },
1676 { WM_MDIACTIVATE, sent|defwinproc },
1679 /* DestroyWindow for MDI child window, initially visible */
1680 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1681 { HCBT_DESTROYWND, hook },
1682 /* Win2k sends wparam set to
1683 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1684 * while Win9x doesn't bother to set child window id according to
1685 * CLIENTCREATESTRUCT.idFirstChild
1687 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1688 { WM_SHOWWINDOW, sent|wparam, 0 },
1689 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1690 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1691 { WM_ERASEBKGND, sent|parent|optional },
1692 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1694 /* { WM_DESTROY, sent }
1695 * Win9x: message sequence terminates here.
1698 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1699 { WM_KILLFOCUS, sent },
1700 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1701 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1702 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1703 { WM_SETFOCUS, sent }, /* in MDI client */
1705 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1706 { WM_KILLFOCUS, sent }, /* in MDI client */
1707 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1708 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1709 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1710 { WM_SETFOCUS, sent }, /* in MDI client */
1712 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1714 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1715 { WM_KILLFOCUS, sent },
1716 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1717 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1718 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1719 { WM_SETFOCUS, sent }, /* in MDI client */
1721 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1722 { WM_KILLFOCUS, sent }, /* in MDI client */
1723 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1724 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1725 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1726 { WM_SETFOCUS, sent }, /* in MDI client */
1728 { WM_DESTROY, sent },
1730 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1731 { WM_KILLFOCUS, sent },
1732 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1733 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1734 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1735 { WM_SETFOCUS, sent }, /* in MDI client */
1737 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1738 { WM_KILLFOCUS, sent }, /* in MDI client */
1739 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1740 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1741 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1742 { WM_SETFOCUS, sent }, /* in MDI client */
1744 { WM_NCDESTROY, sent },
1747 /* CreateWindow for MDI child window, initially invisible */
1748 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1749 { HCBT_CREATEWND, hook },
1750 { WM_NCCREATE, sent },
1751 { WM_NCCALCSIZE, sent|wparam, 0 },
1752 { WM_CREATE, sent },
1753 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1756 /* Win2k sends wparam set to
1757 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1758 * while Win9x doesn't bother to set child window id according to
1759 * CLIENTCREATESTRUCT.idFirstChild
1761 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1764 /* DestroyWindow for MDI child window, initially invisible */
1765 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1766 { HCBT_DESTROYWND, hook },
1767 /* Win2k sends wparam set to
1768 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1769 * while Win9x doesn't bother to set child window id according to
1770 * CLIENTCREATESTRUCT.idFirstChild
1772 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1773 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1774 { WM_DESTROY, sent },
1775 { WM_NCDESTROY, sent },
1778 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1779 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1780 { HCBT_CREATEWND, hook },
1781 { WM_NCCREATE, sent },
1782 { WM_NCCALCSIZE, sent|wparam, 0 },
1783 { WM_CREATE, sent },
1784 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1787 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1788 { WM_GETMINMAXINFO, sent },
1789 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1790 { WM_NCCALCSIZE, sent|wparam, 1 },
1791 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1792 { WM_SIZE, sent|defwinproc },
1794 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1795 { WM_NCCALCSIZE, sent|wparam, 1 },
1796 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1797 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1798 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1799 /* Win2k sends wparam set to
1800 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1801 * while Win9x doesn't bother to set child window id according to
1802 * CLIENTCREATESTRUCT.idFirstChild
1804 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1805 { WM_SHOWWINDOW, sent|wparam, 1 },
1806 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1807 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1808 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1809 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1810 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1811 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1812 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1814 /* Win9x: message sequence terminates here. */
1816 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1817 { HCBT_SETFOCUS, hook }, /* in MDI client */
1818 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1819 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1820 { WM_SETFOCUS, sent }, /* in MDI client */
1821 { HCBT_SETFOCUS, hook },
1822 { WM_KILLFOCUS, sent }, /* in MDI client */
1823 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1824 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1825 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1826 { WM_SETFOCUS, sent|defwinproc },
1827 { WM_MDIACTIVATE, sent|defwinproc },
1829 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1830 { WM_NCCALCSIZE, sent|wparam, 1 },
1831 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1832 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1835 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1836 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
1837 /* restore the 1st MDI child */
1838 { WM_SETREDRAW, sent|wparam, 0 },
1839 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
1840 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1841 { WM_NCCALCSIZE, sent|wparam, 1 },
1842 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1843 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1844 { WM_SIZE, sent|defwinproc },
1846 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1847 { WM_NCCALCSIZE, sent|wparam, 1 },
1848 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1849 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1850 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1851 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
1852 /* create the 2nd MDI child */
1853 { HCBT_CREATEWND, hook },
1854 { WM_NCCREATE, sent },
1855 { WM_NCCALCSIZE, sent|wparam, 0 },
1856 { WM_CREATE, sent },
1857 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1860 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1861 { WM_GETMINMAXINFO, sent },
1862 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1863 { WM_NCCALCSIZE, sent|wparam, 1 },
1864 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1865 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1866 { WM_SIZE, sent|defwinproc },
1868 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1869 { WM_NCCALCSIZE, sent|wparam, 1 },
1870 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1871 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1872 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1873 /* Win2k sends wparam set to
1874 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1875 * while Win9x doesn't bother to set child window id according to
1876 * CLIENTCREATESTRUCT.idFirstChild
1878 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1879 { WM_SHOWWINDOW, sent|wparam, 1 },
1880 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1881 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1882 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1883 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1884 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1885 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1887 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1888 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1890 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1892 /* Win9x: message sequence terminates here. */
1894 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1895 { HCBT_SETFOCUS, hook },
1896 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
1897 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
1898 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1899 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1900 { WM_SETFOCUS, sent }, /* in MDI client */
1901 { HCBT_SETFOCUS, hook },
1902 { WM_KILLFOCUS, sent }, /* in MDI client */
1903 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1904 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1905 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1906 { WM_SETFOCUS, sent|defwinproc },
1908 { WM_MDIACTIVATE, sent|defwinproc },
1910 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1911 { WM_NCCALCSIZE, sent|wparam, 1 },
1912 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1913 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1916 /* WM_MDICREATE MDI child window, initially visible and maximized */
1917 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
1918 { WM_MDICREATE, sent },
1919 { HCBT_CREATEWND, hook },
1920 { WM_NCCREATE, sent },
1921 { WM_NCCALCSIZE, sent|wparam, 0 },
1922 { WM_CREATE, sent },
1923 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1926 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1927 { WM_GETMINMAXINFO, sent },
1928 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1929 { WM_NCCALCSIZE, sent|wparam, 1 },
1930 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1931 { WM_SIZE, sent|defwinproc },
1934 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1935 { WM_NCCALCSIZE, sent|wparam, 1 },
1936 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1937 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1938 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1940 /* Win2k sends wparam set to
1941 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1942 * while Win9x doesn't bother to set child window id according to
1943 * CLIENTCREATESTRUCT.idFirstChild
1945 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1946 { WM_SHOWWINDOW, sent|wparam, 1 },
1947 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1949 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1951 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1952 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1953 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1955 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1956 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1958 /* Win9x: message sequence terminates here. */
1960 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1961 { HCBT_SETFOCUS, hook }, /* in MDI client */
1962 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1963 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1964 { WM_SETFOCUS, sent }, /* in MDI client */
1965 { HCBT_SETFOCUS, hook },
1966 { WM_KILLFOCUS, sent }, /* in MDI client */
1967 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1968 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1969 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1970 { WM_SETFOCUS, sent|defwinproc },
1972 { WM_MDIACTIVATE, sent|defwinproc },
1975 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1976 { WM_NCCALCSIZE, sent|wparam, 1 },
1977 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1978 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1981 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1982 { WM_NCCALCSIZE, sent|wparam, 1 },
1983 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1984 { WM_MOVE, sent|defwinproc },
1985 { WM_SIZE, sent|defwinproc },
1988 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1989 { WM_NCCALCSIZE, sent|wparam, 1 },
1990 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1994 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1995 { WM_NCCALCSIZE, sent|wparam, 1 },
1996 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1997 { WM_SIZE, sent|defwinproc },
1999 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2000 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2001 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2002 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2003 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2007 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2008 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2009 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2010 { HCBT_SYSCOMMAND, hook },
2011 { WM_CLOSE, sent|defwinproc },
2012 { WM_MDIDESTROY, sent }, /* in MDI client */
2014 /* bring the 1st MDI child to top */
2015 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2016 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2018 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2020 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2021 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2022 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2024 /* maximize the 1st MDI child */
2025 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2026 { WM_GETMINMAXINFO, sent|defwinproc },
2027 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
2028 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2029 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2030 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2031 { WM_SIZE, sent|defwinproc },
2033 /* restore the 2nd MDI child */
2034 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2035 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2036 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOZORDER|0x8000 },
2037 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2039 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2041 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2042 { WM_SIZE, sent|defwinproc },
2044 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2046 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2048 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2049 { WM_NCCALCSIZE, sent|wparam, 1 },
2050 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2051 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2052 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2054 /* bring the 1st MDI child to top */
2055 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2056 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2057 { HCBT_SETFOCUS, hook },
2058 { WM_KILLFOCUS, sent|defwinproc },
2059 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2060 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2061 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2062 { WM_SETFOCUS, sent }, /* in MDI client */
2063 { HCBT_SETFOCUS, hook },
2064 { WM_KILLFOCUS, sent }, /* in MDI client */
2065 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2066 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2067 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2068 { WM_SETFOCUS, sent|defwinproc },
2069 { WM_MDIACTIVATE, sent|defwinproc },
2070 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2072 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2073 { WM_SHOWWINDOW, sent|wparam, 1 },
2074 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2075 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2076 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2077 { WM_MDIREFRESHMENU, sent },
2079 { HCBT_DESTROYWND, hook },
2080 /* Win2k sends wparam set to
2081 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2082 * while Win9x doesn't bother to set child window id according to
2083 * CLIENTCREATESTRUCT.idFirstChild
2085 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2086 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2087 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2088 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2089 { WM_ERASEBKGND, sent|parent|optional },
2090 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2092 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2093 { WM_DESTROY, sent|defwinproc },
2094 { WM_NCDESTROY, sent|defwinproc },
2097 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2098 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2099 { WM_MDIDESTROY, sent }, /* in MDI client */
2100 { WM_SHOWWINDOW, sent|wparam, 0 },
2101 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2102 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2103 { WM_ERASEBKGND, sent|parent|optional },
2104 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2106 { HCBT_SETFOCUS, hook },
2107 { WM_KILLFOCUS, sent },
2108 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2109 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2110 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2111 { WM_SETFOCUS, sent }, /* in MDI client */
2112 { HCBT_SETFOCUS, hook },
2113 { WM_KILLFOCUS, sent }, /* in MDI client */
2114 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2115 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2116 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2117 { WM_SETFOCUS, sent },
2120 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2121 { WM_NCCALCSIZE, sent|wparam, 1 },
2122 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2123 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2126 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2127 { WM_NCCALCSIZE, sent|wparam, 1 },
2128 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2129 { WM_MOVE, sent|defwinproc },
2130 { WM_SIZE, sent|defwinproc },
2133 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2134 { WM_NCCALCSIZE, sent|wparam, 1 },
2135 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2139 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2140 { WM_NCCALCSIZE, sent|wparam, 1 },
2141 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2142 { WM_SIZE, sent|defwinproc },
2145 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2146 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2147 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2148 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2151 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2152 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2153 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2154 { WM_MOVE, sent|defwinproc },
2155 { WM_SIZE, sent|defwinproc },
2158 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2159 { WM_NCCALCSIZE, sent|wparam, 1 },
2160 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2164 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOZORDER },
2165 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2166 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2167 { WM_SIZE, sent|defwinproc },
2168 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2169 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2171 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2173 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2174 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2175 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2176 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2177 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2180 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2181 { WM_NCCALCSIZE, sent|wparam, 1 },
2182 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2183 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2185 { WM_NCACTIVATE, sent|wparam, 0 },
2186 { WM_MDIACTIVATE, sent },
2188 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2189 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2190 { WM_NCCALCSIZE, sent|wparam, 1 },
2192 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2194 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2195 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE|0x8000 },
2196 { WM_SIZE, sent|defwinproc },
2199 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2200 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2201 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2202 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2205 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2206 { WM_NCCALCSIZE, sent|wparam, 1 },
2207 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2208 { WM_MOVE, sent|defwinproc },
2209 { WM_SIZE, sent|defwinproc },
2212 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2213 { WM_NCCALCSIZE, sent|wparam, 1 },
2214 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2216 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2217 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2218 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2219 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2220 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2222 { HCBT_SETFOCUS, hook },
2223 { WM_KILLFOCUS, sent },
2224 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2225 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2226 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2227 { WM_SETFOCUS, sent }, /* in MDI client */
2229 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2231 { HCBT_DESTROYWND, hook },
2232 /* Win2k sends wparam set to
2233 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2234 * while Win9x doesn't bother to set child window id according to
2235 * CLIENTCREATESTRUCT.idFirstChild
2237 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2239 { WM_SHOWWINDOW, sent|wparam, 0 },
2240 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2241 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2242 { WM_ERASEBKGND, sent|parent|optional },
2243 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2245 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2246 { WM_DESTROY, sent },
2247 { WM_NCDESTROY, sent },
2250 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2251 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2252 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2253 { WM_GETMINMAXINFO, sent },
2254 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2255 { WM_NCCALCSIZE, sent|wparam, 1 },
2256 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2257 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2259 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2260 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2261 { HCBT_SETFOCUS, hook },
2262 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2263 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2264 { WM_SETFOCUS, sent }, /* in MDI client */
2265 { HCBT_SETFOCUS, hook },
2266 { WM_KILLFOCUS, sent }, /* in MDI client */
2267 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2268 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2269 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2270 { WM_SETFOCUS, sent|defwinproc },
2271 { WM_MDIACTIVATE, sent|defwinproc },
2272 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2273 { WM_SIZE, sent|defwinproc },
2275 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2276 { WM_NCCALCSIZE, sent|wparam, 1 },
2277 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2278 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2279 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2282 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2283 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2284 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2285 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2286 { WM_GETMINMAXINFO, sent },
2287 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2288 { WM_GETMINMAXINFO, sent|defwinproc },
2289 { WM_NCCALCSIZE, sent|wparam, 1 },
2290 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2291 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2292 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000 },
2293 { WM_MOVE, sent|defwinproc },
2294 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2296 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2297 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2298 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2299 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2301 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2302 { WM_NCCALCSIZE, sent|wparam, 1 },
2303 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2304 { WM_MOVE, sent|defwinproc },
2305 { WM_SIZE, sent|defwinproc },
2306 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2308 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2309 { WM_NCCALCSIZE, sent|wparam, 1 },
2310 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2313 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOZORDER },
2314 { WM_GETMINMAXINFO, sent|defwinproc },
2315 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2316 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2317 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2318 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2319 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2321 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2324 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2325 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2326 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2327 { WM_GETMINMAXINFO, sent },
2328 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2329 { WM_NCCALCSIZE, sent|wparam, 1 },
2330 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2331 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2332 { WM_SIZE, sent|defwinproc },
2334 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2335 { WM_NCCALCSIZE, sent|wparam, 1 },
2336 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2337 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2338 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2341 /* ShowWindow(SW_RESTORE) for a visible MDI child window */
2342 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2343 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2344 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2345 { WM_NCCALCSIZE, sent|wparam, 1 },
2346 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2347 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2348 { WM_SIZE, sent|defwinproc },
2350 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2351 { WM_NCCALCSIZE, sent|wparam, 1 },
2352 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2353 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2354 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2357 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2358 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2359 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2360 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2361 { WM_NCCALCSIZE, sent|wparam, 1 },
2362 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2363 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2364 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2365 { WM_SIZE, sent|defwinproc },
2367 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2368 { WM_NCCALCSIZE, sent|wparam, 1 },
2369 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2370 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2371 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2375 static HWND mdi_client;
2376 static WNDPROC old_mdi_client_proc;
2378 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2382 /* do not log painting messages */
2383 if (message != WM_PAINT &&
2384 message != WM_ERASEBKGND &&
2385 message != WM_NCPAINT &&
2386 message != WM_NCHITTEST &&
2387 message != WM_GETTEXT &&
2388 message != WM_MDIGETACTIVE &&
2389 message != WM_GETICON &&
2390 message != WM_DEVICECHANGE)
2392 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2396 case WM_WINDOWPOSCHANGING:
2397 case WM_WINDOWPOSCHANGED:
2399 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2401 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2402 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2403 winpos->hwnd, winpos->hwndInsertAfter,
2404 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2406 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2407 * in the high word for internal purposes
2409 wParam = winpos->flags & 0xffff;
2414 msg.message = message;
2415 msg.flags = sent|wparam|lparam;
2416 msg.wParam = wParam;
2417 msg.lParam = lParam;
2421 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2424 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2426 static long defwndproc_counter = 0;
2430 /* do not log painting messages */
2431 if (message != WM_PAINT &&
2432 message != WM_ERASEBKGND &&
2433 message != WM_NCPAINT &&
2434 message != WM_NCHITTEST &&
2435 message != WM_GETTEXT &&
2436 message != WM_GETICON &&
2437 message != WM_DEVICECHANGE)
2439 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2443 case WM_WINDOWPOSCHANGING:
2444 case WM_WINDOWPOSCHANGED:
2446 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2448 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2449 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2450 winpos->hwnd, winpos->hwndInsertAfter,
2451 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2453 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2454 * in the high word for internal purposes
2456 wParam = winpos->flags & 0xffff;
2460 case WM_MDIACTIVATE:
2462 HWND active, client = GetParent(hwnd);
2464 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2466 if (hwnd == (HWND)lParam) /* if we are being activated */
2467 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2469 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2474 msg.message = message;
2475 msg.flags = sent|wparam|lparam;
2476 if (defwndproc_counter) msg.flags |= defwinproc;
2477 msg.wParam = wParam;
2478 msg.lParam = lParam;
2482 defwndproc_counter++;
2483 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2484 defwndproc_counter--;
2489 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2491 static long defwndproc_counter = 0;
2495 /* do not log painting messages */
2496 if (message != WM_PAINT &&
2497 message != WM_ERASEBKGND &&
2498 message != WM_NCPAINT &&
2499 message != WM_NCHITTEST &&
2500 message != WM_GETTEXT &&
2501 message != WM_GETICON &&
2502 message != WM_DEVICECHANGE)
2504 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2508 case WM_WINDOWPOSCHANGING:
2509 case WM_WINDOWPOSCHANGED:
2511 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2513 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2514 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2515 winpos->hwnd, winpos->hwndInsertAfter,
2516 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2518 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2519 * in the high word for internal purposes
2521 wParam = winpos->flags & 0xffff;
2526 msg.message = message;
2527 msg.flags = sent|wparam|lparam;
2528 if (defwndproc_counter) msg.flags |= defwinproc;
2529 msg.wParam = wParam;
2530 msg.lParam = lParam;
2534 defwndproc_counter++;
2535 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2536 defwndproc_counter--;
2541 static BOOL mdi_RegisterWindowClasses(void)
2546 cls.lpfnWndProc = mdi_frame_wnd_proc;
2549 cls.hInstance = GetModuleHandleA(0);
2551 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2552 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2553 cls.lpszMenuName = NULL;
2554 cls.lpszClassName = "MDI_frame_class";
2555 if (!RegisterClassA(&cls)) return FALSE;
2557 cls.lpfnWndProc = mdi_child_wnd_proc;
2558 cls.lpszClassName = "MDI_child_class";
2559 if (!RegisterClassA(&cls)) return FALSE;
2561 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2562 old_mdi_client_proc = cls.lpfnWndProc;
2563 cls.hInstance = GetModuleHandleA(0);
2564 cls.lpfnWndProc = mdi_client_hook_proc;
2565 cls.lpszClassName = "MDI_client_class";
2566 if (!RegisterClassA(&cls)) assert(0);
2571 static void test_mdi_messages(void)
2573 MDICREATESTRUCTA mdi_cs;
2574 CLIENTCREATESTRUCT client_cs;
2575 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2577 HMENU hMenu = CreateMenu();
2579 assert(mdi_RegisterWindowClasses());
2583 trace("creating MDI frame window\n");
2584 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2585 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2586 WS_MAXIMIZEBOX | WS_VISIBLE,
2587 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2588 GetDesktopWindow(), hMenu,
2589 GetModuleHandleA(0), NULL);
2591 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", TRUE);
2593 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2594 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2596 trace("creating MDI client window\n");
2597 client_cs.hWindowMenu = 0;
2598 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2599 mdi_client = CreateWindowExA(0, "MDI_client_class",
2601 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2603 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2605 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2607 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2608 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2610 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2611 ok(!active_child, "wrong active MDI child %p\n", active_child);
2612 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2617 trace("creating invisible MDI child window\n");
2618 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2620 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2621 mdi_client, 0, GetModuleHandleA(0), NULL);
2625 ShowWindow(mdi_child, SW_SHOWNORMAL);
2626 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
2628 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2629 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2631 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2632 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2634 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2635 ok(!active_child, "wrong active MDI child %p\n", active_child);
2636 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2638 ShowWindow(mdi_child, SW_HIDE);
2639 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
2642 ShowWindow(mdi_child, SW_SHOW);
2643 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
2645 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2646 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2648 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2649 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2651 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2652 ok(!active_child, "wrong active MDI child %p\n", active_child);
2653 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2655 DestroyWindow(mdi_child);
2658 trace("creating visible MDI child window\n");
2659 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2660 WS_CHILD | WS_VISIBLE,
2661 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2662 mdi_client, 0, GetModuleHandleA(0), NULL);
2664 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
2666 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2667 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2669 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2670 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2672 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2673 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2674 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2677 DestroyWindow(mdi_child);
2678 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2680 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2681 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2683 /* Win2k: MDI client still returns a just destroyed child as active
2684 * Win9x: MDI client returns 0
2686 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2687 ok(active_child == mdi_child || /* win2k */
2688 !active_child, /* win9x */
2689 "wrong active MDI child %p\n", active_child);
2690 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2694 trace("creating invisible MDI child window\n");
2695 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2697 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2698 mdi_client, 0, GetModuleHandleA(0), NULL);
2700 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
2702 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
2703 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
2705 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2706 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2708 /* Win2k: MDI client still returns a just destroyed child as active
2709 * Win9x: MDI client returns mdi_child2
2711 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2712 ok(active_child == mdi_child || /* win2k */
2713 active_child == mdi_child2, /* win9x */
2714 "wrong active MDI child %p\n", active_child);
2715 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2718 ShowWindow(mdi_child2, SW_MAXIMIZE);
2719 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", TRUE);
2721 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2722 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2724 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2725 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2726 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2729 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2730 ok(GetFocus() == mdi_child2 || /* win2k */
2731 GetFocus() == 0, /* win9x */
2732 "wrong focus window %p\n", GetFocus());
2737 ShowWindow(mdi_child2, SW_HIDE);
2738 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2740 ShowWindow(mdi_child2, SW_RESTORE);
2741 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", TRUE);
2744 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2745 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2747 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2748 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2749 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2755 ShowWindow(mdi_child2, SW_HIDE);
2756 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2758 ShowWindow(mdi_child2, SW_SHOW);
2759 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
2761 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2762 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2764 ShowWindow(mdi_child2, SW_MAXIMIZE);
2765 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", TRUE);
2767 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2768 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2770 ShowWindow(mdi_child2, SW_RESTORE);
2771 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):MDI child", TRUE);
2773 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2774 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2779 ShowWindow(mdi_child2, SW_HIDE);
2780 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2782 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2783 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2785 DestroyWindow(mdi_child2);
2786 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
2788 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2789 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2791 /* test for maximized MDI children */
2792 trace("creating maximized visible MDI child window 1\n");
2793 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2794 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2795 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2796 mdi_client, 0, GetModuleHandleA(0), NULL);
2798 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
2799 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2801 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2802 ok(GetFocus() == mdi_child || /* win2k */
2803 GetFocus() == 0, /* win9x */
2804 "wrong focus window %p\n", GetFocus());
2806 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2807 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2808 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2811 trace("creating maximized visible MDI child window 2\n");
2812 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2813 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2814 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2815 mdi_client, 0, GetModuleHandleA(0), NULL);
2817 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2818 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2819 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2821 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2822 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2824 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2825 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2826 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2829 trace("destroying maximized visible MDI child window 2\n");
2830 DestroyWindow(mdi_child2);
2831 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2833 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2835 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2836 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2838 /* Win2k: MDI client still returns a just destroyed child as active
2839 * Win9x: MDI client returns 0
2841 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2842 ok(active_child == mdi_child2 || /* win2k */
2843 !active_child, /* win9x */
2844 "wrong active MDI child %p\n", active_child);
2847 ShowWindow(mdi_child, SW_MAXIMIZE);
2848 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2851 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2852 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2854 trace("re-creating maximized visible MDI child window 2\n");
2855 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2856 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2857 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2858 mdi_client, 0, GetModuleHandleA(0), NULL);
2860 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2861 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2862 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2864 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2865 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2867 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2868 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2869 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2872 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
2873 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
2874 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
2876 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2877 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2878 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2880 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2881 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2882 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2885 DestroyWindow(mdi_child);
2886 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2888 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2889 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2891 /* Win2k: MDI client still returns a just destroyed child as active
2892 * Win9x: MDI client returns 0
2894 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2895 ok(active_child == mdi_child || /* win2k */
2896 !active_child, /* win9x */
2897 "wrong active MDI child %p\n", active_child);
2899 /* end of test for maximized MDI children */
2901 mdi_cs.szClass = "MDI_child_Class";
2902 mdi_cs.szTitle = "MDI child";
2903 mdi_cs.hOwner = GetModuleHandleA(0);
2906 mdi_cs.cx = CW_USEDEFAULT;
2907 mdi_cs.cy = CW_USEDEFAULT;
2908 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
2910 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
2911 ok(mdi_child != 0, "MDI child creation failed\n");
2912 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
2914 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
2916 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2917 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2919 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
2920 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2921 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2923 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2924 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2925 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2928 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
2929 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
2931 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
2932 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2933 ok(!active_child, "wrong active MDI child %p\n", active_child);
2938 DestroyWindow(mdi_client);
2939 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
2941 /* test maximization of MDI child with invisible parent */
2942 client_cs.hWindowMenu = 0;
2943 mdi_client = CreateWindow("MDI_client_class",
2945 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
2947 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2948 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
2950 ShowWindow(mdi_client, SW_HIDE);
2951 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
2953 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2954 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
2956 mdi_client, 0, GetModuleHandleA(0), NULL);
2957 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
2959 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
2960 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
2961 zoomed = IsZoomed(mdi_child);
2962 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2964 ShowWindow(mdi_client, SW_SHOW);
2965 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
2967 DestroyWindow(mdi_child);
2968 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
2970 DestroyWindow(mdi_client);
2971 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
2972 /* end of test for maximization of MDI child with invisible parent */
2974 DestroyWindow(mdi_frame);
2975 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
2977 /************************* End of MDI test **********************************/
2979 static void test_WM_SETREDRAW(HWND hwnd)
2981 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
2985 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
2986 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
2988 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
2989 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
2992 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
2993 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
2995 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
2996 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
2998 /* restore original WS_VISIBLE state */
2999 SetWindowLongA(hwnd, GWL_STYLE, style);
3004 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3008 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3010 /* explicitly ignore WM_GETICON message */
3011 if (message == WM_GETICON) return 0;
3015 case WM_WINDOWPOSCHANGING:
3016 case WM_WINDOWPOSCHANGED:
3018 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3020 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3021 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3022 winpos->hwnd, winpos->hwndInsertAfter,
3023 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3025 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3026 * in the high word for internal purposes
3028 wParam = winpos->flags & 0xffff;
3033 msg.message = message;
3034 msg.flags = sent|wparam|lparam;
3035 msg.wParam = wParam;
3036 msg.lParam = lParam;
3039 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3040 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3044 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3046 DWORD style, exstyle;
3050 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3051 style = GetWindowLongA(hwnd, GWL_STYLE);
3052 /* do not be confused by WS_DLGFRAME set */
3053 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3055 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
3056 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
3058 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3059 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
3060 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3061 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3063 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3065 style = GetWindowLongA(hwnd, GWL_STYLE);
3066 if (set) ok(style & set, "style %08lx should be set\n", set);
3067 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
3069 /* a subsequent call should do nothing */
3070 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3071 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
3072 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3076 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3077 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3078 ok( ret, "GetScrollRange(%d) error %ld\n", ctl, GetLastError());
3079 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3080 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3081 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3084 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3086 DWORD style, exstyle;
3090 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3091 style = GetWindowLongA(hwnd, GWL_STYLE);
3092 /* do not be confused by WS_DLGFRAME set */
3093 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3095 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
3096 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
3098 si.cbSize = sizeof(si);
3099 si.fMask = SIF_RANGE;
3102 SetScrollInfo(hwnd, ctl, &si, TRUE);
3103 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3104 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3106 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3108 style = GetWindowLongA(hwnd, GWL_STYLE);
3109 if (set) ok(style & set, "style %08lx should be set\n", set);
3110 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
3112 /* a subsequent call should do nothing */
3113 SetScrollInfo(hwnd, ctl, &si, TRUE);
3114 if (style & WS_HSCROLL)
3115 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3116 else if (style & WS_VSCROLL)
3117 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3119 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3121 si.fMask = SIF_PAGE;
3123 SetScrollInfo(hwnd, ctl, &si, FALSE);
3124 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3128 SetScrollInfo(hwnd, ctl, &si, FALSE);
3129 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3131 si.fMask = SIF_RANGE;
3132 si.nMin = 0xdeadbeef;
3133 si.nMax = 0xdeadbeef;
3134 ret = GetScrollInfo(hwnd, ctl, &si);
3135 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
3136 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3137 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3138 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3141 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3142 static void test_scroll_messages(HWND hwnd)
3150 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3151 ok( ret, "GetScrollRange error %ld\n", GetLastError());
3152 if (sequence->message != WmGetScrollRangeSeq[0].message)
3153 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3154 /* values of min and max are undefined */
3157 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3158 ok( ret, "SetScrollRange error %ld\n", GetLastError());
3159 if (sequence->message != WmSetScrollRangeSeq[0].message)
3160 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3165 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3166 ok( ret, "GetScrollRange error %ld\n", GetLastError());
3167 if (sequence->message != WmGetScrollRangeSeq[0].message)
3168 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3169 /* values of min and max are undefined */
3172 si.cbSize = sizeof(si);
3173 si.fMask = SIF_RANGE;
3176 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3177 if (sequence->message != WmSetScrollRangeSeq[0].message)
3178 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3181 si.fMask = SIF_PAGE;
3183 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3184 if (sequence->message != WmSetScrollRangeSeq[0].message)
3185 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3190 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3191 if (sequence->message != WmSetScrollRangeSeq[0].message)
3192 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3195 si.fMask = SIF_RANGE;
3196 si.nMin = 0xdeadbeef;
3197 si.nMax = 0xdeadbeef;
3198 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3199 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
3200 if (sequence->message != WmGetScrollInfoSeq[0].message)
3201 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3202 /* values of min and max are undefined */
3205 /* set WS_HSCROLL */
3206 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3207 /* clear WS_HSCROLL */
3208 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3210 /* set WS_HSCROLL */
3211 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3212 /* clear WS_HSCROLL */
3213 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3215 /* set WS_VSCROLL */
3216 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3217 /* clear WS_VSCROLL */
3218 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3220 /* set WS_VSCROLL */
3221 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3222 /* clear WS_VSCROLL */
3223 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3226 static void test_showwindow(void)
3231 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3232 100, 100, 200, 200, 0, 0, 0, NULL);
3233 ok (hwnd != 0, "Failed to create overlapped window\n");
3234 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3235 0, 0, 10, 10, hwnd, 0, 0, NULL);
3236 ok (hchild != 0, "Failed to create child\n");
3239 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3240 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3241 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3242 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3245 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3246 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3247 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3248 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3250 /* back to invisible */
3251 ShowWindow(hchild, SW_HIDE);
3252 ShowWindow(hwnd, SW_HIDE);
3254 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3255 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3256 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3257 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3259 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3260 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3262 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3263 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3264 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3266 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3267 ShowWindow( hwnd, SW_SHOW);
3269 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3270 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3271 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3274 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3275 ShowWindow( hchild, SW_HIDE);
3277 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3278 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3279 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3283 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3284 DestroyWindow(hchild);
3285 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3287 DestroyWindow(hwnd);
3292 * 1. Create invisible maximized popup window.
3293 * 2. Move and resize it.
3294 * 3. Show it maximized.
3296 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3297 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3298 100, 100, 200, 200, 0, 0, 0, NULL);
3299 ok (hwnd != 0, "Failed to create popup window\n");
3300 ok(IsZoomed(hwnd), "window should be maximized\n");
3301 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3304 GetWindowRect(hwnd, &rc);
3305 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3306 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3307 "Invalid maximized size before ShowWindow (%ld,%ld)-(%ld,%ld)\n",
3308 rc.left, rc.top, rc.right, rc.bottom);
3309 /* Reset window's size & position */
3310 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3311 ok(IsZoomed(hwnd), "window should be maximized\n");
3314 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3315 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3316 ok(IsZoomed(hwnd), "window should be maximized\n");
3317 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3320 GetWindowRect(hwnd, &rc);
3321 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3322 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3323 "Invalid maximized size after ShowWindow (%ld,%ld)-(%ld,%ld)\n",
3324 rc.left, rc.top, rc.right, rc.bottom);
3325 DestroyWindow(hwnd);
3329 * 1. Create invisible maximized popup window.
3330 * 2. Show it maximized.
3332 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3333 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3334 100, 100, 200, 200, 0, 0, 0, NULL);
3335 ok (hwnd != 0, "Failed to create popup window\n");
3336 ok(IsZoomed(hwnd), "window should be maximized\n");
3337 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3340 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3341 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3342 ok(IsZoomed(hwnd), "window should be maximized\n");
3343 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3345 DestroyWindow(hwnd);
3349 * 1. Create visible maximized popup window.
3351 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3352 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3353 100, 100, 200, 200, 0, 0, 0, NULL);
3354 ok (hwnd != 0, "Failed to create popup window\n");
3355 ok(IsZoomed(hwnd), "window should be maximized\n");
3356 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3358 DestroyWindow(hwnd);
3362 * 1. Create visible popup window.
3365 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3366 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3367 100, 100, 200, 200, 0, 0, 0, NULL);
3368 ok (hwnd != 0, "Failed to create popup window\n");
3369 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3370 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", TRUE);
3373 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3374 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3375 ok(IsZoomed(hwnd), "window should be maximized\n");
3376 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", TRUE);
3378 DestroyWindow(hwnd);
3382 static void test_sys_menu(HWND hwnd)
3387 /* test existing window without CS_NOCLOSE style */
3388 hmenu = GetSystemMenu(hwnd, FALSE);
3389 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
3391 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3392 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3393 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3395 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3396 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3398 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3399 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3400 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3402 EnableMenuItem(hmenu, SC_CLOSE, 0);
3403 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3405 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3406 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3407 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3409 /* test new window with CS_NOCLOSE style */
3410 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3411 100, 100, 200, 200, 0, 0, 0, NULL);
3412 ok (hwnd != 0, "Failed to create overlapped window\n");
3414 hmenu = GetSystemMenu(hwnd, FALSE);
3415 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
3417 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3418 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3420 DestroyWindow(hwnd);
3423 /* test if we receive the right sequence of messages */
3424 static void test_messages(void)
3426 HWND hwnd, hparent, hchild;
3427 HWND hchild2, hbutton;
3434 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3435 100, 100, 200, 200, 0, 0, 0, NULL);
3436 ok (hwnd != 0, "Failed to create overlapped window\n");
3437 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3439 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3440 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
3441 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
3443 /* test WM_SETREDRAW on a not visible top level window */
3444 test_WM_SETREDRAW(hwnd);
3446 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3447 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
3448 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
3450 ok(GetActiveWindow() == hwnd, "window should be active\n");
3451 ok(GetFocus() == hwnd, "window should have input focus\n");
3452 ShowWindow(hwnd, SW_HIDE);
3453 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
3455 ShowWindow(hwnd, SW_SHOW);
3456 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
3458 ShowWindow(hwnd, SW_HIDE);
3459 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
3461 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3462 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
3464 ShowWindow(hwnd, SW_RESTORE);
3465 /* FIXME: add ok_sequence() here */
3468 ShowWindow(hwnd, SW_SHOW);
3469 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
3471 ok(GetActiveWindow() == hwnd, "window should be active\n");
3472 ok(GetFocus() == hwnd, "window should have input focus\n");
3473 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3474 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
3475 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
3476 ok(GetActiveWindow() == hwnd, "window should still be active\n");
3478 /* test WM_SETREDRAW on a visible top level window */
3479 ShowWindow(hwnd, SW_SHOW);
3480 test_WM_SETREDRAW(hwnd);
3482 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
3483 test_scroll_messages(hwnd);
3485 /* test resizing and moving */
3486 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3487 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
3488 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE );
3489 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
3491 /* popups don't get WM_GETMINMAXINFO */
3492 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
3493 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3495 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3496 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
3498 test_sys_menu(hwnd);
3501 DestroyWindow(hwnd);
3502 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
3504 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3505 100, 100, 200, 200, 0, 0, 0, NULL);
3506 ok (hparent != 0, "Failed to create parent window\n");
3509 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
3510 0, 0, 10, 10, hparent, 0, 0, NULL);
3511 ok (hchild != 0, "Failed to create child window\n");
3512 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", TRUE);
3513 DestroyWindow(hchild);
3516 /* visible child window with a caption */
3517 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
3518 WS_CHILD | WS_VISIBLE | WS_CAPTION,
3519 0, 0, 10, 10, hparent, 0, 0, NULL);
3520 ok (hchild != 0, "Failed to create child window\n");
3521 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
3523 trace("testing scroll APIs on a visible child window %p\n", hchild);
3524 test_scroll_messages(hchild);
3526 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3527 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
3529 DestroyWindow(hchild);
3532 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3533 0, 0, 10, 10, hparent, 0, 0, NULL);
3534 ok (hchild != 0, "Failed to create child window\n");
3535 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3537 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
3538 100, 100, 50, 50, hparent, 0, 0, NULL);
3539 ok (hchild2 != 0, "Failed to create child2 window\n");
3542 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
3543 0, 100, 50, 50, hchild, 0, 0, NULL);
3544 ok (hbutton != 0, "Failed to create button window\n");
3546 /* test WM_SETREDRAW on a not visible child window */
3547 test_WM_SETREDRAW(hchild);
3549 ShowWindow(hchild, SW_SHOW);
3550 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3552 ShowWindow(hchild, SW_HIDE);
3553 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
3555 ShowWindow(hchild, SW_SHOW);
3556 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3558 /* test WM_SETREDRAW on a visible child window */
3559 test_WM_SETREDRAW(hchild);
3561 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
3562 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
3564 ShowWindow(hchild, SW_HIDE);
3566 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3567 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
3569 ShowWindow(hchild, SW_HIDE);
3571 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3572 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
3574 /* DestroyWindow sequence below expects that a child has focus */
3578 DestroyWindow(hchild);
3579 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
3580 DestroyWindow(hchild2);
3581 DestroyWindow(hbutton);
3584 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
3585 0, 0, 100, 100, hparent, 0, 0, NULL);
3586 ok (hchild != 0, "Failed to create child popup window\n");
3587 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
3588 DestroyWindow(hchild);
3590 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3592 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
3593 0, 0, 100, 100, hparent, 0, 0, NULL);
3594 ok (hchild != 0, "Failed to create popup window\n");
3595 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3596 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3597 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3599 ShowWindow(hchild, SW_SHOW);
3600 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3602 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3603 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3605 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3606 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
3607 DestroyWindow(hchild);
3609 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3610 * changes nothing in message sequences.
3613 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
3614 0, 0, 100, 100, hparent, 0, 0, NULL);
3615 ok (hchild != 0, "Failed to create popup window\n");
3616 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3617 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3618 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3620 ShowWindow(hchild, SW_SHOW);
3621 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3623 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3624 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3625 DestroyWindow(hchild);
3628 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
3629 0, 0, 100, 100, hparent, 0, 0, NULL);
3630 ok(hwnd != 0, "Failed to create custom dialog window\n");
3631 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
3634 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3635 test_scroll_messages(hwnd);
3639 after_end_dialog = 1;
3640 EndDialog( hwnd, 0 );
3641 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
3643 DestroyWindow(hwnd);
3644 after_end_dialog = 0;
3646 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
3647 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
3648 ok(hwnd != 0, "Failed to create custom dialog window\n");
3650 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
3651 ShowWindow(hwnd, SW_SHOW);
3652 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
3653 DestroyWindow(hwnd);
3656 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
3657 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
3659 DestroyWindow(hparent);
3662 /* Message sequence for SetMenu */
3663 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
3664 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
3666 hmenu = CreateMenu();
3667 ok (hmenu != 0, "Failed to create menu\n");
3668 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
3669 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3670 100, 100, 200, 200, 0, hmenu, 0, NULL);
3671 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3672 ok (SetMenu(hwnd, 0), "SetMenu\n");
3673 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
3674 ok (SetMenu(hwnd, 0), "SetMenu\n");
3675 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
3676 ShowWindow(hwnd, SW_SHOW);
3677 UpdateWindow( hwnd );
3678 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3680 ok (SetMenu(hwnd, 0), "SetMenu\n");
3681 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
3682 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
3683 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
3685 UpdateWindow( hwnd );
3686 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3688 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
3689 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3690 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
3692 DestroyWindow(hwnd);
3695 /* Message sequence for EnableWindow */
3696 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3697 100, 100, 200, 200, 0, 0, 0, NULL);
3698 ok (hparent != 0, "Failed to create parent window\n");
3699 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
3700 0, 0, 10, 10, hparent, 0, 0, NULL);
3701 ok (hchild != 0, "Failed to create child window\n");
3706 EnableWindow(hparent, FALSE);
3707 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
3709 EnableWindow(hparent, TRUE);
3710 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
3712 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3715 /* MsgWaitForMultipleObjects test */
3716 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3717 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3719 PostMessageA(hparent, WM_USER, 0, 0);
3721 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3722 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %lx\n", ret);
3724 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3725 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3727 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3728 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3729 /* end of MsgWaitForMultipleObjects test */
3731 /* the following test causes an exception in user.exe under win9x */
3732 if (!PostMessageW( hparent, WM_USER, 0, 0 )) return;
3733 PostMessageW( hparent, WM_USER+1, 0, 0 );
3734 /* PeekMessage(NULL) fails, but still removes the message */
3735 SetLastError(0xdeadbeef);
3736 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
3737 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
3738 GetLastError() == 0xdeadbeef, /* NT4 */
3739 "last error is %ld\n", GetLastError() );
3740 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
3741 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
3743 DestroyWindow(hchild);
3744 DestroyWindow(hparent);
3750 static void invisible_parent_tests(void)
3752 HWND hparent, hchild;
3754 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
3755 100, 100, 200, 200, 0, 0, 0, NULL);
3756 ok (hparent != 0, "Failed to create parent window\n");
3759 /* test showing child with hidden parent */
3761 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3762 0, 0, 10, 10, hparent, 0, 0, NULL);
3763 ok (hchild != 0, "Failed to create child window\n");
3764 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3766 ShowWindow( hchild, SW_MINIMIZE );
3767 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
3768 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3769 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3773 ShowWindow( hchild, SW_MINIMIZE );
3774 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
3776 DestroyWindow(hchild);
3777 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3778 0, 0, 10, 10, hparent, 0, 0, NULL);
3781 ShowWindow( hchild, SW_MAXIMIZE );
3782 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
3783 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3784 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3788 ShowWindow( hchild, SW_MAXIMIZE );
3789 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
3791 DestroyWindow(hchild);
3792 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3793 0, 0, 10, 10, hparent, 0, 0, NULL);
3796 ShowWindow( hchild, SW_SHOWMINIMIZED );
3797 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
3798 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3799 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3803 ShowWindow( hchild, SW_SHOWMINIMIZED );
3804 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
3806 DestroyWindow(hchild);
3807 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3808 0, 0, 10, 10, hparent, 0, 0, NULL);
3811 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
3812 ShowWindow( hchild, SW_SHOWMAXIMIZED );
3813 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
3814 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3815 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3817 DestroyWindow(hchild);
3818 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3819 0, 0, 10, 10, hparent, 0, 0, NULL);
3822 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
3823 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
3824 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3825 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3829 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
3830 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
3832 DestroyWindow(hchild);
3833 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3834 0, 0, 10, 10, hparent, 0, 0, NULL);
3837 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
3838 ShowWindow( hchild, SW_FORCEMINIMIZE );
3839 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
3841 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
3843 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3845 DestroyWindow(hchild);
3846 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3847 0, 0, 10, 10, hparent, 0, 0, NULL);
3850 ShowWindow( hchild, SW_SHOWNA );
3851 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
3852 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3853 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3857 ShowWindow( hchild, SW_SHOWNA );
3858 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
3860 DestroyWindow(hchild);
3861 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3862 0, 0, 10, 10, hparent, 0, 0, NULL);
3865 ShowWindow( hchild, SW_SHOW );
3866 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
3867 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3868 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3872 ShowWindow( hchild, SW_SHOW );
3873 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
3875 ShowWindow( hchild, SW_HIDE );
3876 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
3877 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
3878 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3880 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3881 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
3882 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3883 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3885 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3886 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
3887 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
3888 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3890 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3892 DestroyWindow(hchild);
3893 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
3895 DestroyWindow(hparent);
3899 /****************** button message test *************************/
3900 static const struct message WmSetFocusButtonSeq[] =
3902 { HCBT_SETFOCUS, hook },
3903 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3904 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3905 { WM_SETFOCUS, sent|wparam, 0 },
3906 { WM_CTLCOLORBTN, sent|defwinproc },
3909 static const struct message WmKillFocusButtonSeq[] =
3911 { HCBT_SETFOCUS, hook },
3912 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3913 { WM_KILLFOCUS, sent|wparam, 0 },
3914 { WM_CTLCOLORBTN, sent|defwinproc },
3915 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3918 static const struct message WmSetFocusStaticSeq[] =
3920 { HCBT_SETFOCUS, hook },
3921 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3922 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3923 { WM_SETFOCUS, sent|wparam, 0 },
3924 { WM_CTLCOLORSTATIC, sent|defwinproc },
3927 static const struct message WmKillFocusStaticSeq[] =
3929 { HCBT_SETFOCUS, hook },
3930 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3931 { WM_KILLFOCUS, sent|wparam, 0 },
3932 { WM_CTLCOLORSTATIC, sent|defwinproc },
3933 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3936 static const struct message WmLButtonDownSeq[] =
3938 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
3939 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
3940 { HCBT_SETFOCUS, hook },
3941 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3942 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3943 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
3944 { WM_CTLCOLORBTN, sent|defwinproc },
3945 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
3946 { WM_CTLCOLORBTN, sent|defwinproc },
3947 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3950 static const struct message WmLButtonUpSeq[] =
3952 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
3953 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
3954 { WM_CTLCOLORBTN, sent|defwinproc },
3955 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3956 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
3957 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
3961 static WNDPROC old_button_proc;
3963 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3965 static long defwndproc_counter = 0;
3969 trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3971 /* explicitly ignore WM_GETICON message */
3972 if (message == WM_GETICON) return 0;
3974 msg.message = message;
3975 msg.flags = sent|wparam|lparam;
3976 if (defwndproc_counter) msg.flags |= defwinproc;
3977 msg.wParam = wParam;
3978 msg.lParam = lParam;
3981 if (message == BM_SETSTATE)
3982 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
3984 defwndproc_counter++;
3985 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
3986 defwndproc_counter--;
3991 static void subclass_button(void)
3995 if (!GetClassInfoA(0, "button", &cls)) assert(0);
3997 old_button_proc = cls.lpfnWndProc;
3999 cls.hInstance = GetModuleHandle(0);
4000 cls.lpfnWndProc = button_hook_proc;
4001 cls.lpszClassName = "my_button_class";
4002 if (!RegisterClassA(&cls)) assert(0);
4005 static void test_button_messages(void)
4011 const struct message *setfocus;
4012 const struct message *killfocus;
4014 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4015 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4016 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4017 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4018 { BS_CHECKBOX, DLGC_BUTTON,
4019 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4020 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4021 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4022 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4023 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4024 { BS_3STATE, DLGC_BUTTON,
4025 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4026 { BS_AUTO3STATE, DLGC_BUTTON,
4027 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4028 { BS_GROUPBOX, DLGC_STATIC,
4029 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4030 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4031 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4032 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4033 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4034 { BS_OWNERDRAW, DLGC_BUTTON,
4035 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4043 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4045 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4046 0, 0, 50, 14, 0, 0, 0, NULL);
4047 ok(hwnd != 0, "Failed to create button window\n");
4049 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4050 ok(dlg_code == button[i].dlg_code, "%d: wrong dlg_code %08lx\n", i, dlg_code);
4052 ShowWindow(hwnd, SW_SHOW);
4057 trace("button style %08lx\n", button[i].style);
4059 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4062 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4064 DestroyWindow(hwnd);
4067 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4068 0, 0, 50, 14, 0, 0, 0, NULL);
4069 ok(hwnd != 0, "Failed to create button window\n");
4074 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4075 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4077 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4078 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
4079 DestroyWindow(hwnd);
4082 /************* painting message test ********************/
4084 void dump_region(HRGN hrgn)
4087 RGNDATA *data = NULL;
4092 printf( "null region\n" );
4095 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
4096 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
4097 GetRegionData( hrgn, size, data );
4098 printf("%ld rects:", data->rdh.nCount );
4099 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
4100 printf( " (%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
4102 HeapFree( GetProcessHeap(), 0, data );
4105 static void check_update_rgn( HWND hwnd, HRGN hrgn )
4109 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
4110 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
4112 ret = GetUpdateRgn( hwnd, update, FALSE );
4113 ok( ret != ERROR, "GetUpdateRgn failed\n" );
4114 if (ret == NULLREGION)
4116 ok( !hrgn, "Update region shouldn't be empty\n" );
4120 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
4122 ok( 0, "Regions are different\n" );
4123 if (winetest_debug > 0)
4125 printf( "Update region: " );
4126 dump_region( update );
4127 printf( "Wanted region: " );
4128 dump_region( hrgn );
4132 GetRgnBox( update, &r1 );
4133 GetUpdateRect( hwnd, &r2, FALSE );
4134 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
4135 "Rectangles are different: %ld,%ld-%ld,%ld / %ld,%ld-%ld,%ld\n",
4136 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
4138 DeleteObject( tmp );
4139 DeleteObject( update );
4142 static const struct message WmInvalidateRgn[] = {
4143 { WM_NCPAINT, sent },
4144 { WM_GETTEXT, sent|defwinproc|optional },
4148 static const struct message WmGetUpdateRect[] = {
4149 { WM_NCPAINT, sent },
4150 { WM_GETTEXT, sent|defwinproc|optional },
4155 static const struct message WmInvalidateFull[] = {
4156 { WM_NCPAINT, sent|wparam, 1 },
4157 { WM_GETTEXT, sent|defwinproc|optional },
4161 static const struct message WmInvalidateErase[] = {
4162 { WM_NCPAINT, sent|wparam, 1 },
4163 { WM_GETTEXT, sent|defwinproc|optional },
4164 { WM_ERASEBKGND, sent },
4168 static const struct message WmInvalidatePaint[] = {
4170 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
4171 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4175 static const struct message WmInvalidateErasePaint[] = {
4177 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
4178 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4179 { WM_ERASEBKGND, sent|beginpaint },
4183 static const struct message WmInvalidateErasePaint2[] = {
4185 { WM_NCPAINT, sent|beginpaint },
4186 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4187 { WM_ERASEBKGND, sent|beginpaint },
4191 static const struct message WmErase[] = {
4192 { WM_ERASEBKGND, sent },
4196 static const struct message WmPaint[] = {
4201 static const struct message WmParentOnlyPaint[] = {
4202 { WM_PAINT, sent|parent },
4206 static const struct message WmInvalidateParent[] = {
4207 { WM_NCPAINT, sent|parent },
4208 { WM_GETTEXT, sent|defwinproc|parent|optional },
4209 { WM_ERASEBKGND, sent|parent },
4213 static const struct message WmInvalidateParentChild[] = {
4214 { WM_NCPAINT, sent|parent },
4215 { WM_GETTEXT, sent|defwinproc|parent|optional },
4216 { WM_ERASEBKGND, sent|parent },
4217 { WM_NCPAINT, sent },
4218 { WM_GETTEXT, sent|defwinproc|optional },
4219 { WM_ERASEBKGND, sent },
4223 static const struct message WmInvalidateParentChild2[] = {
4224 { WM_ERASEBKGND, sent|parent },
4225 { WM_NCPAINT, sent },
4226 { WM_GETTEXT, sent|defwinproc|optional },
4227 { WM_ERASEBKGND, sent },
4231 static const struct message WmParentPaint[] = {
4232 { WM_PAINT, sent|parent },
4237 static const struct message WmParentPaintNc[] = {
4238 { WM_PAINT, sent|parent },
4240 { WM_NCPAINT, sent|beginpaint },
4241 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4242 { WM_ERASEBKGND, sent|beginpaint },
4246 static const struct message WmChildPaintNc[] = {
4248 { WM_NCPAINT, sent|beginpaint },
4249 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4250 { WM_ERASEBKGND, sent|beginpaint },
4254 static const struct message WmParentErasePaint[] = {
4255 { WM_PAINT, sent|parent },
4256 { WM_NCPAINT, sent|parent|beginpaint },
4257 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4258 { WM_ERASEBKGND, sent|parent|beginpaint },
4260 { WM_NCPAINT, sent|beginpaint },
4261 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4262 { WM_ERASEBKGND, sent|beginpaint },
4266 static const struct message WmParentOnlyNcPaint[] = {
4267 { WM_PAINT, sent|parent },
4268 { WM_NCPAINT, sent|parent|beginpaint },
4269 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4273 static const struct message WmSetParentStyle[] = {
4274 { WM_STYLECHANGING, sent|parent },
4275 { WM_STYLECHANGED, sent|parent },
4279 static void test_paint_messages(void)
4285 HWND hparent, hchild;
4286 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
4287 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
4288 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4289 100, 100, 200, 200, 0, 0, 0, NULL);
4290 ok (hwnd != 0, "Failed to create overlapped window\n");
4292 ShowWindow( hwnd, SW_SHOW );
4293 UpdateWindow( hwnd );
4296 check_update_rgn( hwnd, 0 );
4297 SetRectRgn( hrgn, 10, 10, 20, 20 );
4298 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4299 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4300 check_update_rgn( hwnd, hrgn );
4301 SetRectRgn( hrgn2, 20, 20, 30, 30 );
4302 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
4303 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4304 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
4305 check_update_rgn( hwnd, hrgn );
4306 /* validate everything */
4307 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4308 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4309 check_update_rgn( hwnd, 0 );
4311 /* test empty region */
4312 SetRectRgn( hrgn, 10, 10, 10, 15 );
4313 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4314 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4315 check_update_rgn( hwnd, 0 );
4316 /* test empty rect */
4317 SetRect( &rect, 10, 10, 10, 15 );
4318 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
4319 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4320 check_update_rgn( hwnd, 0 );
4322 /* flush pending messages */
4323 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4326 GetClientRect( hwnd, &rect );
4327 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
4328 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
4329 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4331 trace("testing InvalidateRect(0, NULL, FALSE)\n");
4332 SetRectEmpty( &rect );
4333 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
4334 check_update_rgn( hwnd, hrgn );
4335 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4336 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4337 ok_sequence( WmPaint, "Paint", FALSE );
4338 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4339 check_update_rgn( hwnd, 0 );
4341 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4342 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4344 trace("testing ValidateRect(0, NULL)\n");
4345 SetRectEmpty( &rect );
4346 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
4347 check_update_rgn( hwnd, hrgn );
4348 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4349 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4350 ok_sequence( WmPaint, "Paint", FALSE );
4351 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4352 check_update_rgn( hwnd, 0 );
4354 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4355 SetLastError(0xdeadbeef);
4356 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4357 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
4358 check_update_rgn( hwnd, 0 );
4359 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4360 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4362 trace("testing ValidateRgn(0, NULL)\n");
4363 SetLastError(0xdeadbeef);
4364 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
4365 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
4366 check_update_rgn( hwnd, 0 );
4367 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4368 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4370 /* now with frame */
4371 SetRectRgn( hrgn, -5, -5, 20, 20 );
4373 /* flush pending messages */
4374 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4377 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4378 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4380 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4381 check_update_rgn( hwnd, hrgn );
4384 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4385 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4388 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4389 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
4391 GetClientRect( hwnd, &rect );
4392 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
4393 check_update_rgn( hwnd, hrgn );
4396 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
4397 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4400 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
4401 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
4402 check_update_rgn( hwnd, 0 );
4405 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
4406 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
4407 check_update_rgn( hwnd, 0 );
4410 SetRectRgn( hrgn, 0, 0, 100, 100 );
4411 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4412 SetRectRgn( hrgn, 0, 0, 50, 100 );
4413 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
4414 SetRectRgn( hrgn, 50, 0, 100, 100 );
4415 check_update_rgn( hwnd, hrgn );
4416 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4417 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
4418 check_update_rgn( hwnd, 0 );
4421 SetRectRgn( hrgn, 0, 0, 100, 100 );
4422 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4423 SetRectRgn( hrgn, 0, 0, 100, 50 );
4424 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4425 ok_sequence( WmErase, "Erase", FALSE );
4426 SetRectRgn( hrgn, 0, 50, 100, 100 );
4427 check_update_rgn( hwnd, hrgn );
4430 SetRectRgn( hrgn, 0, 0, 100, 100 );
4431 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4432 SetRectRgn( hrgn, 0, 0, 50, 50 );
4433 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
4434 ok_sequence( WmPaint, "Paint", FALSE );
4437 SetRectRgn( hrgn, -4, -4, -2, -2 );
4438 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4439 SetRectRgn( hrgn, -200, -200, -198, -198 );
4440 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
4441 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4444 SetRectRgn( hrgn, -4, -4, -2, -2 );
4445 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4446 SetRectRgn( hrgn, -4, -4, -3, -3 );
4447 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
4448 SetRectRgn( hrgn, 0, 0, 1, 1 );
4449 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
4450 ok_sequence( WmPaint, "Paint", FALSE );
4453 SetRectRgn( hrgn, -4, -4, -1, -1 );
4454 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4455 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
4456 /* make sure no WM_PAINT was generated */
4457 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4458 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4461 SetRectRgn( hrgn, -4, -4, -1, -1 );
4462 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4463 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
4465 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
4467 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
4468 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
4469 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
4470 ret = GetUpdateRect( hwnd, &rect, FALSE );
4471 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
4472 /* this will send WM_NCPAINT and validate the non client area */
4473 ret = GetUpdateRect( hwnd, &rect, TRUE );
4474 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
4476 DispatchMessage( &msg );
4478 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
4480 DestroyWindow( hwnd );
4482 /* now test with a child window */
4484 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4485 100, 100, 200, 200, 0, 0, 0, NULL);
4486 ok (hparent != 0, "Failed to create parent window\n");
4488 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
4489 10, 10, 100, 100, hparent, 0, 0, NULL);
4490 ok (hchild != 0, "Failed to create child window\n");
4492 ShowWindow( hparent, SW_SHOW );
4493 UpdateWindow( hparent );
4494 UpdateWindow( hchild );
4497 log_all_parent_messages++;
4499 SetRect( &rect, 0, 0, 50, 50 );
4500 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4501 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4502 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
4504 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4506 MapWindowPoints( hchild, hparent, &pt, 1 );
4507 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
4508 check_update_rgn( hchild, hrgn );
4509 SetRectRgn( hrgn, 0, 0, 50, 50 );
4510 check_update_rgn( hparent, hrgn );
4511 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4512 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
4513 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4514 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4516 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4517 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
4519 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4520 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4521 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
4522 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4523 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4525 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
4526 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4527 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
4529 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4531 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4532 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4533 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
4535 /* flush all paint messages */
4536 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4539 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
4540 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4541 SetRectRgn( hrgn, 0, 0, 50, 50 );
4542 check_update_rgn( hparent, hrgn );
4543 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4544 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4545 SetRectRgn( hrgn, 0, 0, 50, 50 );
4546 check_update_rgn( hparent, hrgn );
4548 /* flush all paint messages */
4549 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4550 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4553 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
4554 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4555 SetRectRgn( hrgn, 0, 0, 50, 50 );
4556 check_update_rgn( hparent, hrgn );
4557 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4558 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4559 SetRectRgn( hrgn2, 10, 10, 50, 50 );
4560 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
4561 check_update_rgn( hparent, hrgn );
4562 /* flush all paint messages */
4563 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4566 /* same as above but parent gets completely validated */
4567 SetRect( &rect, 20, 20, 30, 30 );
4568 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4569 SetRectRgn( hrgn, 20, 20, 30, 30 );
4570 check_update_rgn( hparent, hrgn );
4571 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4572 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4573 check_update_rgn( hparent, 0 ); /* no update region */
4574 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4575 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
4577 /* make sure RDW_VALIDATE on child doesn't have the same effect */
4579 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4580 SetRectRgn( hrgn, 20, 20, 30, 30 );
4581 check_update_rgn( hparent, hrgn );
4582 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
4583 SetRectRgn( hrgn, 20, 20, 30, 30 );
4584 check_update_rgn( hparent, hrgn );
4586 /* same as above but normal WM_PAINT doesn't validate parent */
4588 SetRect( &rect, 20, 20, 30, 30 );
4589 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4590 SetRectRgn( hrgn, 20, 20, 30, 30 );
4591 check_update_rgn( hparent, hrgn );
4592 /* no WM_PAINT in child while parent still pending */
4593 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4594 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4595 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4596 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
4599 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4600 /* no WM_PAINT in child while parent still pending */
4601 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4602 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4603 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
4604 /* now that parent is valid child should get WM_PAINT */
4605 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4606 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4607 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4608 ok_sequence( WmEmptySeq, "No other message", FALSE );
4610 /* same thing with WS_CLIPCHILDREN in parent */
4612 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4613 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4614 /* changing style invalidates non client area, but we need to invalidate something else to see it */
4615 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
4616 ok_sequence( WmEmptySeq, "No message", FALSE );
4617 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
4618 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
4621 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
4622 SetRectRgn( hrgn, 20, 20, 30, 30 );
4623 check_update_rgn( hparent, hrgn );
4624 /* no WM_PAINT in child while parent still pending */
4625 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4626 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4627 /* WM_PAINT in parent first */
4628 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4629 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
4631 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
4633 SetRect( &rect, 0, 0, 30, 30 );
4634 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
4635 SetRectRgn( hrgn, 0, 0, 30, 30 );
4636 check_update_rgn( hparent, hrgn );
4637 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4638 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
4640 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4642 SetRect( &rect, -10, 0, 30, 30 );
4643 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4644 SetRect( &rect, 0, 0, 20, 20 );
4645 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4646 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4647 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
4649 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4651 SetRect( &rect, -10, 0, 30, 30 );
4652 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4653 SetRect( &rect, 0, 0, 100, 100 );
4654 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4655 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4656 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
4657 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4658 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
4660 /* test RDW_INTERNALPAINT behavior */
4663 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
4664 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4665 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4667 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
4668 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4669 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4671 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4672 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4673 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4675 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
4676 UpdateWindow( hparent );
4677 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4679 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
4680 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4681 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4682 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4683 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4684 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
4686 UpdateWindow( hparent );
4687 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4689 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
4690 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4691 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4692 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4693 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4694 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4696 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4697 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4698 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4699 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4700 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4702 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
4703 UpdateWindow( hparent );
4704 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4706 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
4707 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4708 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4709 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4710 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4711 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
4713 UpdateWindow( hparent );
4714 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4716 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
4717 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4718 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4719 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4720 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4721 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4723 log_all_parent_messages--;
4724 DestroyWindow( hparent );
4725 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
4727 DeleteObject( hrgn );
4728 DeleteObject( hrgn2 );
4737 static DWORD WINAPI thread_proc(void *param)
4740 struct wnd_event *wnd_event = (struct wnd_event *)param;
4742 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
4743 100, 100, 200, 200, 0, 0, 0, NULL);
4744 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
4746 SetEvent(wnd_event->event);
4748 while (GetMessage(&msg, 0, 0, 0))
4750 TranslateMessage(&msg);
4751 DispatchMessage(&msg);
4754 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
4759 static void test_interthread_messages(void)
4766 int len, expected_len;
4767 struct wnd_event wnd_event;
4770 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
4771 if (!wnd_event.event)
4773 trace("skipping interthread message test under win9x\n");
4777 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
4778 ok(hThread != NULL, "CreateThread failed, error %ld\n", GetLastError());
4780 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4782 CloseHandle(wnd_event.event);
4784 SetLastError(0xdeadbeef);
4785 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
4786 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %ld\n", GetLastError());
4788 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4789 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %ld\n", GetLastError());
4791 expected_len = lstrlenA("window caption text");
4792 memset(buf, 0, sizeof(buf));
4793 SetLastError(0xdeadbeef);
4794 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
4795 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %ld, len %d, expected len %d\n", GetLastError(), len, expected_len);
4796 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
4798 msg.hwnd = wnd_event.hwnd;
4799 msg.message = WM_GETTEXT;
4800 msg.wParam = sizeof(buf);
4801 msg.lParam = (LPARAM)buf;
4802 memset(buf, 0, sizeof(buf));
4803 SetLastError(0xdeadbeef);
4804 len = DispatchMessageA(&msg);
4805 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
4806 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %ld\n", len, GetLastError());
4808 /* the following test causes an exception in user.exe under win9x */
4809 msg.hwnd = wnd_event.hwnd;
4810 msg.message = WM_TIMER;
4812 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4813 SetLastError(0xdeadbeef);
4814 len = DispatchMessageA(&msg);
4815 ok(!len && GetLastError() == 0xdeadbeef,
4816 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len, GetLastError());
4818 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
4819 ok( ret, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
4821 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4822 CloseHandle(hThread);
4824 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
4828 static const struct message WmVkN[] = {
4829 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4830 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4831 { WM_CHAR, wparam|lparam, 'n', 1 },
4832 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
4833 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4834 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4837 static const struct message WmShiftVkN[] = {
4838 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4839 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4840 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4841 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4842 { WM_CHAR, wparam|lparam, 'N', 1 },
4843 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
4844 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4845 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4846 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4847 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4850 static const struct message WmCtrlVkN[] = {
4851 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4852 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4853 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4854 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4855 { WM_CHAR, wparam|lparam, 0x000e, 1 },
4856 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4857 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4858 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4859 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4860 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4863 static const struct message WmCtrlVkN_2[] = {
4864 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4865 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4866 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4867 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4868 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4869 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4870 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4871 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4874 static const struct message WmAltVkN[] = {
4875 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4876 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4877 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4878 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4879 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
4880 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
4881 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
4882 { HCBT_SYSCOMMAND, hook },
4883 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4884 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4885 { 0x00AE, sent|defwinproc|optional }, /* XP */
4886 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
4887 { WM_INITMENU, sent|defwinproc },
4888 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4889 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
4890 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4891 { WM_CAPTURECHANGED, sent|defwinproc },
4892 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
4893 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4894 { WM_EXITMENULOOP, sent|defwinproc },
4895 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
4896 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
4897 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4898 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4899 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4900 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4903 static const struct message WmAltVkN_2[] = {
4904 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4905 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4906 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4907 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
4908 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4909 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4910 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4911 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4914 static const struct message WmCtrlAltVkN[] = {
4915 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4916 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4917 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4918 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4919 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4920 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4921 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4922 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4923 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4924 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4925 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4926 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4929 static const struct message WmCtrlShiftVkN[] = {
4930 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4931 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4932 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4933 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4934 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4935 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
4936 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4937 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4938 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4939 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4940 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4941 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4944 static const struct message WmCtrlAltShiftVkN[] = {
4945 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4946 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4947 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4948 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4949 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
4950 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
4951 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4952 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
4953 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4954 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4955 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
4956 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
4957 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4958 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4959 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4960 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4963 static const struct message WmAltPressRelease[] = {
4964 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4965 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4966 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4967 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4968 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
4969 { HCBT_SYSCOMMAND, hook },
4970 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4971 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4972 { WM_INITMENU, sent|defwinproc },
4973 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4974 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
4975 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
4977 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4978 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
4979 { WM_CAPTURECHANGED, sent|defwinproc },
4980 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
4981 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4982 { WM_EXITMENULOOP, sent|defwinproc },
4983 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4984 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4987 static const struct message WmAltMouseButton[] = {
4988 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4989 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4990 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
4991 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
4992 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
4993 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
4994 { WM_LBUTTONUP, wparam, 0, 0 },
4995 { WM_LBUTTONUP, sent|wparam, 0, 0 },
4996 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4997 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5000 static const struct message WmF1Seq[] = {
5001 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
5002 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
5003 { 0x4d, wparam|lparam, 0, 0 },
5004 { 0x4d, sent|wparam|lparam, 0, 0 },
5005 { WM_HELP, sent|defwinproc },
5006 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
5007 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
5011 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
5015 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
5017 struct message log_msg;
5019 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
5021 /* ignore some unwanted messages */
5022 if (msg.message == WM_MOUSEMOVE ||
5023 msg.message == WM_GETICON ||
5024 msg.message == WM_DEVICECHANGE)
5027 log_msg.message = msg.message;
5028 log_msg.flags = wparam|lparam;
5029 log_msg.wParam = msg.wParam;
5030 log_msg.lParam = msg.lParam;
5031 add_message(&log_msg);
5033 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
5035 TranslateMessage(&msg);
5036 DispatchMessage(&msg);
5041 static void test_accelerators(void)
5046 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5047 100, 100, 200, 200, 0, 0, 0, NULL);
5054 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
5056 state = GetKeyState(VK_SHIFT);
5057 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
5058 state = GetKeyState(VK_CAPITAL);
5059 ok(state == 0, "wrong CapsLock state %04x\n", state);
5061 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
5062 assert(hAccel != 0);
5064 pump_msg_loop(hwnd, 0);
5067 trace("testing VK_N press/release\n");
5069 keybd_event('N', 0, 0, 0);
5070 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5071 pump_msg_loop(hwnd, hAccel);
5072 ok_sequence(WmVkN, "VK_N press/release", FALSE);
5074 trace("testing Shift+VK_N press/release\n");
5076 keybd_event(VK_SHIFT, 0, 0, 0);
5077 keybd_event('N', 0, 0, 0);
5078 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5079 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5080 pump_msg_loop(hwnd, hAccel);
5081 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
5083 trace("testing Ctrl+VK_N press/release\n");
5085 keybd_event(VK_CONTROL, 0, 0, 0);
5086 keybd_event('N', 0, 0, 0);
5087 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5088 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5089 pump_msg_loop(hwnd, hAccel);
5090 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
5092 trace("testing Alt+VK_N press/release\n");
5094 keybd_event(VK_MENU, 0, 0, 0);
5095 keybd_event('N', 0, 0, 0);
5096 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5097 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5098 pump_msg_loop(hwnd, hAccel);
5099 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
5101 trace("testing Ctrl+Alt+VK_N press/release 1\n");
5103 keybd_event(VK_CONTROL, 0, 0, 0);
5104 keybd_event(VK_MENU, 0, 0, 0);
5105 keybd_event('N', 0, 0, 0);
5106 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5107 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5108 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5109 pump_msg_loop(hwnd, hAccel);
5110 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
5112 ret = DestroyAcceleratorTable(hAccel);
5113 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
5115 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
5116 assert(hAccel != 0);
5118 trace("testing VK_N press/release\n");
5120 keybd_event('N', 0, 0, 0);
5121 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5122 pump_msg_loop(hwnd, hAccel);
5123 ok_sequence(WmVkN, "VK_N press/release", FALSE);
5125 trace("testing Shift+VK_N press/release\n");
5127 keybd_event(VK_SHIFT, 0, 0, 0);
5128 keybd_event('N', 0, 0, 0);
5129 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5130 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5131 pump_msg_loop(hwnd, hAccel);
5132 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
5134 trace("testing Ctrl+VK_N press/release 2\n");
5136 keybd_event(VK_CONTROL, 0, 0, 0);
5137 keybd_event('N', 0, 0, 0);
5138 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5139 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5140 pump_msg_loop(hwnd, hAccel);
5141 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
5143 trace("testing Alt+VK_N press/release 2\n");
5145 keybd_event(VK_MENU, 0, 0, 0);
5146 keybd_event('N', 0, 0, 0);
5147 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5148 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5149 pump_msg_loop(hwnd, hAccel);
5150 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
5152 trace("testing Ctrl+Alt+VK_N press/release 2\n");
5154 keybd_event(VK_CONTROL, 0, 0, 0);
5155 keybd_event(VK_MENU, 0, 0, 0);
5156 keybd_event('N', 0, 0, 0);
5157 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5158 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5159 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5160 pump_msg_loop(hwnd, hAccel);
5161 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
5163 trace("testing Ctrl+Shift+VK_N press/release\n");
5165 keybd_event(VK_CONTROL, 0, 0, 0);
5166 keybd_event(VK_SHIFT, 0, 0, 0);
5167 keybd_event('N', 0, 0, 0);
5168 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5169 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5170 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5171 pump_msg_loop(hwnd, hAccel);
5172 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
5174 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
5176 keybd_event(VK_CONTROL, 0, 0, 0);
5177 keybd_event(VK_MENU, 0, 0, 0);
5178 keybd_event(VK_SHIFT, 0, 0, 0);
5179 keybd_event('N', 0, 0, 0);
5180 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5181 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5182 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5183 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5184 pump_msg_loop(hwnd, hAccel);
5185 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
5187 ret = DestroyAcceleratorTable(hAccel);
5188 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
5190 trace("testing Alt press/release\n");
5192 keybd_event(VK_MENU, 0, 0, 0);
5193 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5194 keybd_event(VK_MENU, 0, 0, 0);
5195 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5196 pump_msg_loop(hwnd, 0);
5197 /* this test doesn't pass in Wine for managed windows */
5198 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
5200 trace("testing Alt+MouseButton press/release\n");
5201 /* first, move mouse pointer inside of the window client area */
5202 GetClientRect(hwnd, &rc);
5203 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
5204 rc.left += (rc.right - rc.left)/2;
5205 rc.top += (rc.bottom - rc.top)/2;
5206 SetCursorPos(rc.left, rc.top);
5208 pump_msg_loop(hwnd, 0);
5210 keybd_event(VK_MENU, 0, 0, 0);
5211 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
5212 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
5213 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5214 pump_msg_loop(hwnd, 0);
5215 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
5217 keybd_event(VK_F1, 0, 0, 0);
5218 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
5219 pump_msg_loop(hwnd, 0);
5220 ok_sequence(WmF1Seq, "F1 press/release", TRUE);
5222 DestroyWindow(hwnd);
5225 /************* window procedures ********************/
5227 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
5228 WPARAM wParam, LPARAM lParam)
5230 static long defwndproc_counter = 0;
5231 static long beginpaint_counter = 0;
5235 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5237 /* explicitly ignore WM_GETICON message */
5238 if (message == WM_GETICON) return 0;
5244 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
5245 ok((BOOL)wParam == !(style & WS_DISABLED),
5246 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
5250 case WM_CAPTURECHANGED:
5251 if (test_DestroyWindow_flag)
5253 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5254 if (style & WS_CHILD)
5255 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5256 else if (style & WS_POPUP)
5257 lParam = WND_POPUP_ID;
5259 lParam = WND_PARENT_ID;
5267 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
5268 capture = GetCapture();
5271 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
5272 trace("current capture %p, releasing...\n", capture);
5279 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
5280 if (test_DestroyWindow_flag)
5282 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5283 if (style & WS_CHILD)
5284 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5285 else if (style & WS_POPUP)
5286 lParam = WND_POPUP_ID;
5288 lParam = WND_PARENT_ID;
5292 /* test_accelerators() depends on this */
5299 case WM_DEVICECHANGE:
5302 case WM_WINDOWPOSCHANGING:
5303 case WM_WINDOWPOSCHANGED:
5305 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5307 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5308 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5309 winpos->hwnd, winpos->hwndInsertAfter,
5310 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5312 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5313 * in the high word for internal purposes
5315 wParam = winpos->flags & 0xffff;
5320 msg.message = message;
5321 msg.flags = sent|wparam|lparam;
5322 if (defwndproc_counter) msg.flags |= defwinproc;
5323 if (beginpaint_counter) msg.flags |= beginpaint;
5324 msg.wParam = wParam;
5325 msg.lParam = lParam;
5328 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
5330 HWND parent = GetParent(hwnd);
5332 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
5334 GetClientRect(parent, &rc);
5335 trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
5337 trace("ptReserved = (%ld,%ld)\n"
5338 "ptMaxSize = (%ld,%ld)\n"
5339 "ptMaxPosition = (%ld,%ld)\n"
5340 "ptMinTrackSize = (%ld,%ld)\n"
5341 "ptMaxTrackSize = (%ld,%ld)\n",
5342 minmax->ptReserved.x, minmax->ptReserved.y,
5343 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
5344 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
5345 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
5346 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
5348 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %ld != %ld\n",
5349 minmax->ptMaxSize.x, rc.right);
5350 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %ld != %ld\n",
5351 minmax->ptMaxSize.y, rc.bottom);
5354 if (message == WM_PAINT)
5357 beginpaint_counter++;
5358 BeginPaint( hwnd, &ps );
5359 beginpaint_counter--;
5360 EndPaint( hwnd, &ps );
5364 defwndproc_counter++;
5365 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
5366 : DefWindowProcA(hwnd, message, wParam, lParam);
5367 defwndproc_counter--;
5372 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5374 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
5377 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5379 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
5382 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5384 static long defwndproc_counter = 0;
5388 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5390 /* explicitly ignore WM_GETICON message */
5391 if (message == WM_GETICON) return 0;
5393 msg.message = message;
5394 msg.flags = sent|wparam|lparam;
5395 if (defwndproc_counter) msg.flags |= defwinproc;
5396 msg.wParam = wParam;
5397 msg.lParam = lParam;
5400 if (message == WM_CREATE)
5402 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
5403 SetWindowLongA(hwnd, GWL_STYLE, style);
5406 defwndproc_counter++;
5407 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5408 defwndproc_counter--;
5413 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5415 static long defwndproc_counter = 0;
5416 static long beginpaint_counter = 0;
5420 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5422 /* explicitly ignore WM_GETICON message */
5423 if (message == WM_GETICON) return 0;
5425 if (log_all_parent_messages ||
5426 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
5427 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
5428 message == WM_ENABLE || message == WM_ENTERIDLE ||
5429 message == WM_IME_SETCONTEXT)
5436 INT ret = GetClipBox((HDC)wParam, &rc);
5438 trace("WM_ERASEBKGND: GetClipBox()=%d, (%ld,%ld-%ld,%ld)\n",
5439 ret, rc.left, rc.top, rc.right, rc.bottom);
5443 case WM_WINDOWPOSCHANGING:
5444 case WM_WINDOWPOSCHANGED:
5446 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5448 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5449 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5450 winpos->hwnd, winpos->hwndInsertAfter,
5451 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5453 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5454 * in the high word for internal purposes
5456 wParam = winpos->flags & 0xffff;
5461 msg.message = message;
5462 msg.flags = sent|parent|wparam|lparam;
5463 if (defwndproc_counter) msg.flags |= defwinproc;
5464 if (beginpaint_counter) msg.flags |= beginpaint;
5465 msg.wParam = wParam;
5466 msg.lParam = lParam;
5470 if (message == WM_PAINT)
5473 beginpaint_counter++;
5474 BeginPaint( hwnd, &ps );
5475 beginpaint_counter--;
5476 EndPaint( hwnd, &ps );
5480 defwndproc_counter++;
5481 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5482 defwndproc_counter--;
5487 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5489 static long defwndproc_counter = 0;
5493 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5495 /* explicitly ignore WM_GETICON message */
5496 if (message == WM_GETICON) return 0;
5498 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
5499 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
5500 if (after_end_dialog)
5501 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
5503 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
5507 case WM_WINDOWPOSCHANGING:
5508 case WM_WINDOWPOSCHANGED:
5510 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5512 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5513 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5514 winpos->hwnd, winpos->hwndInsertAfter,
5515 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5517 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5518 * in the high word for internal purposes
5520 wParam = winpos->flags & 0xffff;
5525 msg.message = message;
5526 msg.flags = sent|wparam|lparam;
5527 if (defwndproc_counter) msg.flags |= defwinproc;
5528 msg.wParam = wParam;
5529 msg.lParam = lParam;
5532 defwndproc_counter++;
5533 ret = DefDlgProcA(hwnd, message, wParam, lParam);
5534 defwndproc_counter--;
5539 static BOOL RegisterWindowClasses(void)
5544 cls.lpfnWndProc = MsgCheckProcA;
5547 cls.hInstance = GetModuleHandleA(0);
5549 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
5550 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5551 cls.lpszMenuName = NULL;
5552 cls.lpszClassName = "TestWindowClass";
5553 if(!RegisterClassA(&cls)) return FALSE;
5555 cls.lpfnWndProc = PopupMsgCheckProcA;
5556 cls.lpszClassName = "TestPopupClass";
5557 if(!RegisterClassA(&cls)) return FALSE;
5559 cls.lpfnWndProc = ParentMsgCheckProcA;
5560 cls.lpszClassName = "TestParentClass";
5561 if(!RegisterClassA(&cls)) return FALSE;
5563 cls.lpfnWndProc = DefWindowProcA;
5564 cls.lpszClassName = "SimpleWindowClass";
5565 if(!RegisterClassA(&cls)) return FALSE;
5567 cls.style = CS_NOCLOSE;
5568 cls.lpszClassName = "NoCloseWindowClass";
5569 if(!RegisterClassA(&cls)) return FALSE;
5571 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
5573 cls.hInstance = GetModuleHandleA(0);
5574 cls.hbrBackground = 0;
5575 cls.lpfnWndProc = TestDlgProcA;
5576 cls.lpszClassName = "TestDialogClass";
5577 if(!RegisterClassA(&cls)) return FALSE;
5582 static HHOOK hCBT_hook;
5583 static DWORD cbt_hook_thread_id;
5585 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5587 static const char * const CBT_code_name[10] = {
5594 "HCBT_CLICKSKIPPED",
5598 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
5602 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
5604 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5606 if (nCode == HCBT_SYSCOMMAND)
5610 msg.message = nCode;
5611 msg.flags = hook|wparam|lparam;
5612 msg.wParam = wParam;
5613 msg.lParam = lParam;
5616 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5619 if (nCode == HCBT_DESTROYWND)
5621 if (test_DestroyWindow_flag)
5623 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
5624 if (style & WS_CHILD)
5625 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
5626 else if (style & WS_POPUP)
5627 lParam = WND_POPUP_ID;
5629 lParam = WND_PARENT_ID;
5633 /* Log also SetFocus(0) calls */
5634 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5636 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5638 if (!lstrcmpiA(buf, "TestWindowClass") ||
5639 !lstrcmpiA(buf, "TestParentClass") ||
5640 !lstrcmpiA(buf, "TestPopupClass") ||
5641 !lstrcmpiA(buf, "SimpleWindowClass") ||
5642 !lstrcmpiA(buf, "TestDialogClass") ||
5643 !lstrcmpiA(buf, "MDI_frame_class") ||
5644 !lstrcmpiA(buf, "MDI_client_class") ||
5645 !lstrcmpiA(buf, "MDI_child_class") ||
5646 !lstrcmpiA(buf, "my_button_class") ||
5647 !lstrcmpiA(buf, "my_edit_class") ||
5648 !lstrcmpiA(buf, "static") ||
5649 !lstrcmpiA(buf, "#32770"))
5653 msg.message = nCode;
5654 msg.flags = hook|wparam|lparam;
5655 msg.wParam = wParam;
5656 msg.lParam = lParam;
5660 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5663 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
5673 trace("WEH:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5674 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5676 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5678 /* ignore mouse cursor events */
5679 if (object_id == OBJID_CURSOR) return;
5681 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
5684 !lstrcmpiA(buf, "TestWindowClass") ||
5685 !lstrcmpiA(buf, "TestParentClass") ||
5686 !lstrcmpiA(buf, "TestPopupClass") ||
5687 !lstrcmpiA(buf, "SimpleWindowClass") ||
5688 !lstrcmpiA(buf, "TestDialogClass") ||
5689 !lstrcmpiA(buf, "MDI_frame_class") ||
5690 !lstrcmpiA(buf, "MDI_client_class") ||
5691 !lstrcmpiA(buf, "MDI_child_class") ||
5692 !lstrcmpiA(buf, "my_button_class") ||
5693 !lstrcmpiA(buf, "my_edit_class") ||
5694 !lstrcmpiA(buf, "static") ||
5695 !lstrcmpiA(buf, "#32770"))
5699 msg.message = event;
5700 msg.flags = winevent_hook|wparam|lparam;
5701 msg.wParam = object_id;
5702 msg.lParam = child_id;
5708 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
5709 static const WCHAR wszAnsi[] = {'U',0};
5711 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5715 case CB_FINDSTRINGEXACT:
5716 trace("String: %p\n", (LPCWSTR)lParam);
5717 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
5719 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
5723 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
5726 static const struct message WmGetTextLengthAfromW[] = {
5727 { WM_GETTEXTLENGTH, sent },
5728 { WM_GETTEXT, sent },
5732 static const WCHAR testWindowClassW[] =
5733 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
5735 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
5737 /* dummy window proc for WM_GETTEXTLENGTH test */
5738 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
5742 case WM_GETTEXTLENGTH:
5743 return lstrlenW(dummy_window_text) + 37; /* some random length */
5745 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
5746 return lstrlenW( (LPWSTR)lp );
5748 return DefWindowProcW( hwnd, msg, wp, lp );
5752 static void test_message_conversion(void)
5754 static const WCHAR wszMsgConversionClass[] =
5755 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
5759 WNDPROC wndproc, newproc;
5763 cls.lpfnWndProc = MsgConversionProcW;
5766 cls.hInstance = GetModuleHandleW(NULL);
5768 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
5769 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
5770 cls.lpszMenuName = NULL;
5771 cls.lpszClassName = wszMsgConversionClass;
5772 /* this call will fail on Win9x, but that doesn't matter as this test is
5773 * meaningless on those platforms */
5774 if(!RegisterClassW(&cls)) return;
5777 cls.lpfnWndProc = MsgCheckProcW;
5780 cls.hInstance = GetModuleHandleW(0);
5782 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
5783 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5784 cls.lpszMenuName = NULL;
5785 cls.lpszClassName = testWindowClassW;
5786 if(!RegisterClassW(&cls)) return;
5788 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
5789 100, 100, 200, 200, 0, 0, 0, NULL);
5790 ok(hwnd != NULL, "Window creation failed\n");
5794 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
5795 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5796 ok(lRes == 0, "String should have been converted\n");
5797 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5798 ok(lRes == 1, "String shouldn't have been converted\n");
5802 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
5803 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5804 ok(lRes == 1, "String shouldn't have been converted\n");
5805 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5806 ok(lRes == 1, "String shouldn't have been converted\n");
5808 /* Synchronous messages */
5810 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5811 ok(lRes == 0, "String should have been converted\n");
5812 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5813 ok(lRes == 1, "String shouldn't have been converted\n");
5815 /* Asynchronous messages */
5818 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5819 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5820 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5822 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5823 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5824 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5826 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5827 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5828 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5830 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5831 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5832 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5834 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5835 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5836 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5838 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5839 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5840 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5842 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5843 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5844 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5846 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5847 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5848 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5850 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
5852 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
5853 WS_OVERLAPPEDWINDOW,
5854 100, 100, 200, 200, 0, 0, 0, NULL);
5857 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
5858 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5859 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5860 "got bad length %ld\n", lRes );
5863 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
5864 hwnd, WM_GETTEXTLENGTH, 0, 0);
5865 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5866 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5867 "got bad length %ld\n", lRes );
5869 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
5870 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
5871 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5872 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5873 NULL, 0, NULL, NULL ),
5874 "got bad length %ld\n", lRes );
5876 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
5877 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5878 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5879 NULL, 0, NULL, NULL ),
5880 "got bad length %ld\n", lRes );
5882 ret = DestroyWindow(hwnd);
5883 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5893 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
5897 #define TIMER_ID 0x19
5899 static DWORD WINAPI timer_thread_proc(LPVOID x)
5901 struct timer_info *info = x;
5904 r = KillTimer(info->hWnd, 0x19);
5905 ok(r,"KillTimer failed in thread\n");
5906 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
5907 ok(r,"SetTimer failed in thread\n");
5908 ok(r==TIMER_ID,"SetTimer id different\n");
5909 r = SetEvent(info->handles[0]);
5910 ok(r,"SetEvent failed in thread\n");
5914 static void test_timers(void)
5916 struct timer_info info;
5919 info.hWnd = CreateWindow ("TestWindowClass", NULL,
5920 WS_OVERLAPPEDWINDOW ,
5921 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5924 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
5925 ok(info.id, "SetTimer failed\n");
5926 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
5927 info.handles[0] = CreateEvent(NULL,0,0,NULL);
5928 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
5930 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
5932 WaitForSingleObject(info.handles[1], INFINITE);
5934 CloseHandle(info.handles[0]);
5935 CloseHandle(info.handles[1]);
5937 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
5939 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
5942 /* Various win events with arbitrary parameters */
5943 static const struct message WmWinEventsSeq[] = {
5944 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5945 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5946 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5947 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5948 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5949 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5950 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5951 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5952 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5953 /* our win event hook ignores OBJID_CURSOR events */
5954 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
5955 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
5956 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
5957 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
5958 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
5959 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5960 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5961 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5962 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5963 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5964 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5965 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5966 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5967 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5970 static const struct message WmWinEventCaretSeq[] = {
5971 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5972 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5973 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
5974 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5977 static const struct message WmWinEventCaretSeq_2[] = {
5978 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5979 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5980 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5983 static const struct message WmWinEventAlertSeq[] = {
5984 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
5987 static const struct message WmWinEventAlertSeq_2[] = {
5988 /* create window in the thread proc */
5989 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
5990 /* our test event */
5991 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
5994 static const struct message WmGlobalHookSeq_1[] = {
5995 /* create window in the thread proc */
5996 { HCBT_CREATEWND, hook|lparam, 0, 2 },
5997 /* our test events */
5998 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
5999 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
6002 static const struct message WmGlobalHookSeq_2[] = {
6003 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
6004 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
6005 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
6006 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
6010 static const struct message WmMouseLLHookSeq[] = {
6011 { WM_MOUSEMOVE, hook },
6012 { WM_LBUTTONUP, hook },
6013 { WM_MOUSEMOVE, hook },
6017 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
6027 trace("WEH_2:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
6028 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
6030 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6032 if (!lstrcmpiA(buf, "TestWindowClass") ||
6033 !lstrcmpiA(buf, "static"))
6037 msg.message = event;
6038 msg.flags = winevent_hook|wparam|lparam;
6039 msg.wParam = object_id;
6040 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
6046 static HHOOK hCBT_global_hook;
6047 static DWORD cbt_global_hook_thread_id;
6049 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6054 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
6056 if (nCode == HCBT_SYSCOMMAND)
6060 msg.message = nCode;
6061 msg.flags = hook|wparam|lparam;
6062 msg.wParam = wParam;
6063 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
6066 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6068 /* WH_MOUSE_LL hook */
6069 if (nCode == HC_ACTION)
6072 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
6074 /* we can't test for real mouse events */
6075 if (mhll->flags & LLMHF_INJECTED)
6077 msg.message = wParam;
6081 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6084 /* Log also SetFocus(0) calls */
6085 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
6087 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6089 if (!lstrcmpiA(buf, "TestWindowClass") ||
6090 !lstrcmpiA(buf, "static"))
6094 msg.message = nCode;
6095 msg.flags = hook|wparam|lparam;
6096 msg.wParam = wParam;
6097 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
6101 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6104 static DWORD WINAPI win_event_global_thread_proc(void *param)
6108 HANDLE hevent = *(HANDLE *)param;
6109 HMODULE user32 = GetModuleHandleA("user32.dll");
6110 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
6112 assert(pNotifyWinEvent);
6114 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6116 trace("created thread window %p\n", hwnd);
6118 *(HWND *)param = hwnd;
6121 /* this event should be received only by our new hook proc,
6122 * an old one does not expect an event from another thread.
6124 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
6127 while (GetMessage(&msg, 0, 0, 0))
6129 TranslateMessage(&msg);
6130 DispatchMessage(&msg);
6135 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
6139 HANDLE hevent = *(HANDLE *)param;
6142 /* these events should be received only by our new hook proc,
6143 * an old one does not expect an event from another thread.
6146 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6148 trace("created thread window %p\n", hwnd);
6150 *(HWND *)param = hwnd;
6152 /* Windows doesn't like when a thread plays games with the focus,
6153 that leads to all kinds of misbehaviours and failures to activate
6154 a window. So, better keep next lines commented out.
6158 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6159 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6163 while (GetMessage(&msg, 0, 0, 0))
6165 TranslateMessage(&msg);
6166 DispatchMessage(&msg);
6171 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
6175 HANDLE hevent = *(HANDLE *)param;
6177 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6179 trace("created thread window %p\n", hwnd);
6181 *(HWND *)param = hwnd;
6185 /* Windows doesn't like when a thread plays games with the focus,
6186 * that leads to all kinds of misbehaviours and failures to activate
6187 * a window. So, better don't generate a mouse click message below.
6189 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
6190 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6191 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
6194 while (GetMessage(&msg, 0, 0, 0))
6196 TranslateMessage(&msg);
6197 DispatchMessage(&msg);
6202 static void test_winevents(void)
6208 HANDLE hthread, hevent;
6210 HWINEVENTHOOK hhook;
6211 const struct message *events = WmWinEventsSeq;
6212 HMODULE user32 = GetModuleHandleA("user32.dll");
6213 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6214 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6215 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
6217 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
6218 WS_OVERLAPPEDWINDOW,
6219 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
6223 /****** start of global hook test *************/
6224 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6225 assert(hCBT_global_hook);
6227 hevent = CreateEventA(NULL, 0, 0, NULL);
6229 hwnd2 = (HWND)hevent;
6231 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
6232 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6234 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6236 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
6239 /* this one should be received only by old hook proc */
6240 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6241 /* this one should be received only by old hook proc */
6242 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6244 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
6246 ret = UnhookWindowsHookEx(hCBT_global_hook);
6247 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
6249 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6250 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6251 CloseHandle(hthread);
6252 CloseHandle(hevent);
6253 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6254 /****** end of global hook test *************/
6256 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
6258 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6264 #if 0 /* this test doesn't pass under Win9x */
6265 /* win2k ignores events with hwnd == 0 */
6266 SetLastError(0xdeadbeef);
6267 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
6268 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
6269 GetLastError() == 0xdeadbeef, /* Win9x */
6270 "unexpected error %ld\n", GetLastError());
6271 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6274 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
6275 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
6277 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
6279 /****** start of event filtering test *************/
6280 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6281 EVENT_OBJECT_SHOW, /* 0x8002 */
6282 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
6283 GetModuleHandleA(0), win_event_global_hook_proc,
6284 GetCurrentProcessId(), 0,
6285 WINEVENT_INCONTEXT);
6286 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
6288 hevent = CreateEventA(NULL, 0, 0, NULL);
6290 hwnd2 = (HWND)hevent;
6292 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6293 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6295 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6297 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
6300 /* this one should be received only by old hook proc */
6301 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6302 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6303 /* this one should be received only by old hook proc */
6304 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6306 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
6308 ret = pUnhookWinEvent(hhook);
6309 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6311 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6312 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6313 CloseHandle(hthread);
6314 CloseHandle(hevent);
6315 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6316 /****** end of event filtering test *************/
6318 /****** start of out of context event test *************/
6319 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6320 EVENT_MIN, EVENT_MAX,
6321 0, win_event_global_hook_proc,
6322 GetCurrentProcessId(), 0,
6323 WINEVENT_OUTOFCONTEXT);
6324 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
6326 hevent = CreateEventA(NULL, 0, 0, NULL);
6328 hwnd2 = (HWND)hevent;
6332 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6333 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6335 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6337 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6338 /* process pending winevent messages */
6339 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6340 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
6343 /* this one should be received only by old hook proc */
6344 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6345 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6346 /* this one should be received only by old hook proc */
6347 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6349 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
6350 /* process pending winevent messages */
6351 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6352 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
6354 ret = pUnhookWinEvent(hhook);
6355 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6357 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6358 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6359 CloseHandle(hthread);
6360 CloseHandle(hevent);
6361 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6362 /****** end of out of context event test *************/
6364 /****** start of MOUSE_LL hook test *************/
6365 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6366 /* WH_MOUSE_LL is not supported on Win9x platforms */
6367 if (!hCBT_global_hook)
6369 trace("Skipping WH_MOUSE_LL test on this platform\n");
6370 goto skip_mouse_ll_hook_test;
6373 hevent = CreateEventA(NULL, 0, 0, NULL);
6375 hwnd2 = (HWND)hevent;
6377 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
6378 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6380 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
6381 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6383 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
6386 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
6387 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6388 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
6390 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
6392 ret = UnhookWindowsHookEx(hCBT_global_hook);
6393 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
6395 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6396 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6397 CloseHandle(hthread);
6398 CloseHandle(hevent);
6399 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6400 /****** end of MOUSE_LL hook test *************/
6401 skip_mouse_ll_hook_test:
6403 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6406 static void test_set_hook(void)
6410 HWINEVENTHOOK hwinevent_hook;
6411 HMODULE user32 = GetModuleHandleA("user32.dll");
6412 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6413 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6415 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
6416 ok(hhook != 0, "local hook does not require hModule set to 0\n");
6417 UnhookWindowsHookEx(hhook);
6419 #if 0 /* this test doesn't pass under Win9x: BUG! */
6420 SetLastError(0xdeadbeef);
6421 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
6422 ok(!hhook, "global hook requires hModule != 0\n");
6423 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %ld\n", GetLastError());
6426 SetLastError(0xdeadbeef);
6427 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
6428 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
6429 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
6430 GetLastError() == 0xdeadbeef, /* Win9x */
6431 "unexpected error %ld\n", GetLastError());
6433 SetLastError(0xdeadbeef);
6434 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
6435 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
6436 GetLastError() == 0xdeadbeef, /* Win9x */
6437 "unexpected error %ld\n", GetLastError());
6439 if (!pSetWinEventHook || !pUnhookWinEvent) return;
6441 /* even process local incontext hooks require hmodule */
6442 SetLastError(0xdeadbeef);
6443 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6444 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
6445 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
6446 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
6447 GetLastError() == 0xdeadbeef, /* Win9x */
6448 "unexpected error %ld\n", GetLastError());
6450 /* even thread local incontext hooks require hmodule */
6451 SetLastError(0xdeadbeef);
6452 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6453 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
6454 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
6455 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
6456 GetLastError() == 0xdeadbeef, /* Win9x */
6457 "unexpected error %ld\n", GetLastError());
6459 #if 0 /* these 3 tests don't pass under Win9x */
6460 SetLastError(0xdeadbeef);
6461 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
6462 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6463 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
6464 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
6466 SetLastError(0xdeadbeef);
6467 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
6468 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6469 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
6470 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
6472 SetLastError(0xdeadbeef);
6473 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6474 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
6475 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
6476 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %ld\n", GetLastError());
6479 SetLastError(0xdeadbeef);
6480 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
6481 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6482 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
6483 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
6484 ret = pUnhookWinEvent(hwinevent_hook);
6485 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6488 /* This call succeeds under win2k SP4, but fails under Wine.
6489 Does win2k test/use passed process id? */
6490 SetLastError(0xdeadbeef);
6491 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6492 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
6493 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
6494 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
6495 ret = pUnhookWinEvent(hwinevent_hook);
6496 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6499 SetLastError(0xdeadbeef);
6500 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
6501 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
6502 GetLastError() == 0xdeadbeef, /* Win9x */
6503 "unexpected error %ld\n", GetLastError());
6506 static const struct message ScrollWindowPaint1[] = {
6508 { WM_ERASEBKGND, sent|beginpaint },
6512 static const struct message ScrollWindowPaint2[] = {
6517 static void test_scrollwindowex(void)
6520 RECT rect={0,0,130,130};
6523 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
6524 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
6525 100, 100, 200, 200, 0, 0, 0, NULL);
6526 ok (hwnd != 0, "Failed to create overlapped window\n");
6527 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
6528 WS_VISIBLE|WS_CAPTION|WS_CHILD,
6529 10, 10, 150, 150, hwnd, 0, 0, NULL);
6530 ok (hchild != 0, "Failed to create child\n");
6535 /* scroll without the child window */
6536 trace("start scroll\n");
6537 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
6538 SW_ERASE|SW_INVALIDATE);
6539 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6540 trace("end scroll\n");
6542 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6543 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
6545 /* Now without the SW_ERASE flag */
6546 trace("start scroll\n");
6547 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
6548 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6549 trace("end scroll\n");
6551 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6552 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
6554 /* now scroll the child window as well */
6555 trace("start scroll\n");
6556 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
6557 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
6558 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
6559 /* windows sometimes a WM_MOVE */
6560 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6562 trace("end scroll\n");
6564 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6565 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
6567 /* now scroll with ScrollWindow() */
6568 trace("start scroll with ScrollWindow\n");
6569 ScrollWindow( hwnd, 5, 5, NULL, NULL);
6570 trace("end scroll\n");
6572 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6573 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
6575 ok(DestroyWindow(hchild), "failed to destroy window\n");
6576 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6580 static const struct message destroy_window_with_children[] = {
6581 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
6582 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
6583 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
6584 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
6585 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6586 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6587 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6588 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
6589 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
6590 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
6591 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
6592 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
6593 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
6594 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
6595 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
6596 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
6600 static void test_DestroyWindow(void)
6603 HWND parent, child1, child2, child3, child4, test;
6604 UINT child_id = WND_CHILD_ID + 1;
6606 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6607 100, 100, 200, 200, 0, 0, 0, NULL);
6608 assert(parent != 0);
6609 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6610 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
6611 assert(child1 != 0);
6612 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6613 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
6614 assert(child2 != 0);
6615 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6616 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
6617 assert(child3 != 0);
6618 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
6619 0, 0, 50, 50, parent, 0, 0, NULL);
6620 assert(child4 != 0);
6622 /* test owner/parent of child2 */
6623 test = GetParent(child2);
6624 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6625 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
6627 test = pGetAncestor(child2, GA_PARENT);
6628 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6630 test = GetWindow(child2, GW_OWNER);
6631 ok(!test, "wrong owner %p\n", test);
6633 test = SetParent(child2, parent);
6634 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
6636 /* test owner/parent of the parent */
6637 test = GetParent(parent);
6638 ok(!test, "wrong parent %p\n", test);
6640 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
6643 test = pGetAncestor(parent, GA_PARENT);
6644 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6646 test = GetWindow(parent, GW_OWNER);
6647 ok(!test, "wrong owner %p\n", test);
6649 /* test owner/parent of child1 */
6650 test = GetParent(child1);
6651 ok(test == parent, "wrong parent %p\n", test);
6652 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
6654 test = pGetAncestor(child1, GA_PARENT);
6655 ok(test == parent, "wrong parent %p\n", test);
6657 test = GetWindow(child1, GW_OWNER);
6658 ok(!test, "wrong owner %p\n", test);
6660 /* test owner/parent of child2 */
6661 test = GetParent(child2);
6662 ok(test == parent, "wrong parent %p\n", test);
6663 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
6665 test = pGetAncestor(child2, GA_PARENT);
6666 ok(test == parent, "wrong parent %p\n", test);
6668 test = GetWindow(child2, GW_OWNER);
6669 ok(!test, "wrong owner %p\n", test);
6671 /* test owner/parent of child3 */
6672 test = GetParent(child3);
6673 ok(test == child1, "wrong parent %p\n", test);
6674 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
6676 test = pGetAncestor(child3, GA_PARENT);
6677 ok(test == child1, "wrong parent %p\n", test);
6679 test = GetWindow(child3, GW_OWNER);
6680 ok(!test, "wrong owner %p\n", test);
6682 /* test owner/parent of child4 */
6683 test = GetParent(child4);
6684 ok(test == parent, "wrong parent %p\n", test);
6685 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
6687 test = pGetAncestor(child4, GA_PARENT);
6688 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6690 test = GetWindow(child4, GW_OWNER);
6691 ok(test == parent, "wrong owner %p\n", test);
6695 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
6696 parent, child1, child2, child3, child4);
6699 test = GetCapture();
6700 ok(test == child4, "wrong capture window %p\n", test);
6702 test_DestroyWindow_flag = TRUE;
6703 ret = DestroyWindow(parent);
6704 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
6705 test_DestroyWindow_flag = FALSE;
6706 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
6708 ok(!IsWindow(parent), "parent still exists\n");
6709 ok(!IsWindow(child1), "child1 still exists\n");
6710 ok(!IsWindow(child2), "child2 still exists\n");
6711 ok(!IsWindow(child3), "child3 still exists\n");
6712 ok(!IsWindow(child4), "child4 still exists\n");
6714 test = GetCapture();
6715 ok(!test, "wrong capture window %p\n", test);
6719 static const struct message WmDispatchPaint[] = {
6720 { WM_NCPAINT, sent },
6721 { WM_GETTEXT, sent|defwinproc|optional },
6722 { WM_GETTEXT, sent|defwinproc|optional },
6723 { WM_ERASEBKGND, sent },
6727 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6729 if (message == WM_PAINT) return 0;
6730 return MsgCheckProcA( hwnd, message, wParam, lParam );
6733 static void test_DispatchMessage(void)
6738 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6739 100, 100, 200, 200, 0, 0, 0, NULL);
6740 ShowWindow( hwnd, SW_SHOW );
6741 UpdateWindow( hwnd );
6742 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6744 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
6746 SetRect( &rect, -5, -5, 5, 5 );
6747 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6749 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6751 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6755 DispatchMessage( &msg );
6756 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
6757 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6758 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
6759 if (++count > 10) break;
6762 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
6764 trace("now without DispatchMessage\n");
6766 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6768 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6770 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6773 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
6775 /* this will send WM_NCCPAINT just like DispatchMessage does */
6776 GetUpdateRgn( hwnd, hrgn, TRUE );
6777 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6778 DeleteObject( hrgn );
6779 GetClientRect( hwnd, &rect );
6780 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
6781 ok( !count, "Got multiple WM_PAINTs\n" );
6782 if (++count > 10) break;
6785 DestroyWindow(hwnd);
6789 static const struct message WmUser[] = {
6801 static DWORD CALLBACK send_msg_thread( LPVOID arg )
6803 struct sendmsg_info *info = arg;
6804 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
6805 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %ld\n", GetLastError());
6809 static void wait_for_thread( HANDLE thread )
6811 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
6814 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
6818 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6820 if (message == WM_USER) Sleep(200);
6821 return MsgCheckProcA( hwnd, message, wParam, lParam );
6824 static void test_SendMessageTimeout(void)
6828 struct sendmsg_info info;
6831 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6832 100, 100, 200, 200, 0, 0, 0, NULL);
6833 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6836 info.timeout = 1000;
6837 info.ret = 0xdeadbeef;
6838 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6839 wait_for_thread( thread );
6840 CloseHandle( thread );
6841 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6842 ok_sequence( WmUser, "WmUser", FALSE );
6845 info.ret = 0xdeadbeef;
6846 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6847 Sleep(100); /* SendMessageTimeout should timeout here */
6848 wait_for_thread( thread );
6849 CloseHandle( thread );
6850 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6851 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6853 /* 0 means infinite timeout */
6855 info.ret = 0xdeadbeef;
6856 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6858 wait_for_thread( thread );
6859 CloseHandle( thread );
6860 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6861 ok_sequence( WmUser, "WmUser", FALSE );
6863 /* timeout is treated as signed despite the prototype */
6864 info.timeout = 0x7fffffff;
6865 info.ret = 0xdeadbeef;
6866 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6868 wait_for_thread( thread );
6869 CloseHandle( thread );
6870 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6871 ok_sequence( WmUser, "WmUser", FALSE );
6873 info.timeout = 0x80000000;
6874 info.ret = 0xdeadbeef;
6875 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6877 wait_for_thread( thread );
6878 CloseHandle( thread );
6879 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6880 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6882 /* now check for timeout during message processing */
6883 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
6885 info.ret = 0xdeadbeef;
6886 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6887 wait_for_thread( thread );
6888 CloseHandle( thread );
6889 /* we should timeout but still get the message */
6890 ok( info.ret == 0, "SendMessageTimeout failed\n" );
6891 ok_sequence( WmUser, "WmUser", FALSE );
6893 DestroyWindow( info.hwnd );
6897 /****************** edit message test *************************/
6898 #define ID_EDIT 0x1234
6899 static const struct message sl_edit_setfocus[] =
6901 { HCBT_SETFOCUS, hook },
6902 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
6903 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6904 { WM_SETFOCUS, sent|wparam, 0 },
6905 { WM_CTLCOLOREDIT, sent|parent },
6906 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6907 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6908 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6911 static const struct message ml_edit_setfocus[] =
6913 { HCBT_SETFOCUS, hook },
6914 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
6915 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6916 { WM_SETFOCUS, sent|wparam, 0 },
6917 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6918 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6919 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6920 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6923 static const struct message sl_edit_killfocus[] =
6925 { HCBT_SETFOCUS, hook },
6926 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6927 { WM_KILLFOCUS, sent|wparam, 0 },
6928 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6929 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6930 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
6931 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
6934 static const struct message sl_edit_lbutton_dblclk[] =
6936 { WM_LBUTTONDBLCLK, sent },
6937 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6940 static const struct message sl_edit_lbutton_down[] =
6942 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
6943 { HCBT_SETFOCUS, hook },
6944 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
6945 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6946 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
6947 { WM_CTLCOLOREDIT, sent|parent },
6948 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6949 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6950 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6951 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6952 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6953 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6954 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6955 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6958 static const struct message ml_edit_lbutton_down[] =
6960 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
6961 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6962 { HCBT_SETFOCUS, hook },
6963 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
6964 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6965 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
6966 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6967 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6968 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6971 static const struct message sl_edit_lbutton_up[] =
6973 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
6974 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6975 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6976 { WM_CAPTURECHANGED, sent|defwinproc },
6977 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6980 static const struct message ml_edit_lbutton_up[] =
6982 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
6983 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6984 { WM_CAPTURECHANGED, sent|defwinproc },
6988 static WNDPROC old_edit_proc;
6990 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6992 static long defwndproc_counter = 0;
6996 trace("edit: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
6998 /* explicitly ignore WM_GETICON message */
6999 if (message == WM_GETICON) return 0;
7001 msg.message = message;
7002 msg.flags = sent|wparam|lparam;
7003 if (defwndproc_counter) msg.flags |= defwinproc;
7004 msg.wParam = wParam;
7005 msg.lParam = lParam;
7008 defwndproc_counter++;
7009 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
7010 defwndproc_counter--;
7015 static void subclass_edit(void)
7019 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
7021 old_edit_proc = cls.lpfnWndProc;
7023 cls.hInstance = GetModuleHandle(0);
7024 cls.lpfnWndProc = edit_hook_proc;
7025 cls.lpszClassName = "my_edit_class";
7026 if (!RegisterClassA(&cls)) assert(0);
7029 static void test_edit_messages(void)
7035 log_all_parent_messages++;
7037 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
7038 100, 100, 200, 200, 0, 0, 0, NULL);
7039 ok (parent != 0, "Failed to create parent window\n");
7041 /* test single line edit */
7042 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
7043 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
7044 ok(hwnd != 0, "Failed to create edit window\n");
7046 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
7047 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08lx\n", dlg_code);
7049 ShowWindow(hwnd, SW_SHOW);
7055 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
7058 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
7064 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
7065 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
7071 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
7072 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
7074 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
7075 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
7077 DestroyWindow(hwnd);
7079 /* test multiline edit */
7080 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
7081 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
7082 ok(hwnd != 0, "Failed to create edit window\n");
7084 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
7085 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
7086 "wrong dlg_code %08lx\n", dlg_code);
7088 ShowWindow(hwnd, SW_SHOW);
7094 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
7097 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
7103 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
7104 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
7110 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
7111 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
7113 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
7114 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
7116 DestroyWindow(hwnd);
7117 DestroyWindow(parent);
7119 log_all_parent_messages--;
7122 /**************************** End of Edit test ******************************/
7124 static const struct message WmChar[] = {
7125 { WM_CHAR, sent|wparam, 'z' },
7129 static const struct message WmKeyDownUp[] = {
7130 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x00000001 },
7131 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
7135 static const struct message WmUserChar[] = {
7137 { WM_CHAR, sent|wparam, 'z' },
7141 #define EV_START_STOP 0
7142 #define EV_SENDMSG 1
7148 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
7151 static DWORD CALLBACK send_msg_thread_2(void *param)
7154 struct peekmsg_info *info = param;
7156 trace("thread: waiting for start\n");
7157 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
7158 trace("thread: looping\n");
7162 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
7166 case WAIT_OBJECT_0 + EV_START_STOP:
7167 trace("thread: exiting\n");
7170 case WAIT_OBJECT_0 + EV_SENDMSG:
7171 trace("thread: sending message\n");
7172 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
7173 SetEvent(info->hevent[EV_ACK]);
7177 trace("unexpected return: %04lx\n", ret);
7185 static void test_PeekMessage(void)
7190 UINT qs_all_input = QS_ALLINPUT;
7191 UINT qs_input = QS_INPUT;
7193 struct peekmsg_info info;
7195 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7196 100, 100, 200, 200, 0, 0, 0, NULL);
7198 ShowWindow(info.hwnd, SW_SHOW);
7199 UpdateWindow(info.hwnd);
7200 SetFocus(info.hwnd);
7202 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
7203 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
7204 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
7206 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
7209 trace("signalling to start looping\n");
7210 SetEvent(info.hevent[EV_START_STOP]);
7212 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7215 SetLastError(0xdeadbeef);
7216 qstatus = GetQueueStatus(qs_all_input);
7217 if (GetLastError() == ERROR_INVALID_FLAGS)
7219 trace("QS_RAWINPUT not supported on this platform\n");
7220 qs_all_input &= ~QS_RAWINPUT;
7221 qs_input &= ~QS_RAWINPUT;
7223 ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus);
7225 trace("signalling to send message\n");
7226 SetEvent(info.hevent[EV_SENDMSG]);
7227 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7229 /* pass invalid QS_xxxx flags */
7230 SetLastError(0xdeadbeef);
7231 qstatus = GetQueueStatus(0xffffffff);
7232 ok(qstatus == 0, "GetQueueStatus should fail: %08lx\n", qstatus);
7233 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %ld\n", GetLastError());
7235 qstatus = GetQueueStatus(qs_all_input);
7236 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
7237 "wrong qstatus %08lx\n", qstatus);
7239 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7240 ok_sequence(WmUser, "WmUser", FALSE);
7242 qstatus = GetQueueStatus(qs_all_input);
7243 ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus);
7245 keybd_event('N', 0, 0, 0);
7246 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7247 qstatus = GetQueueStatus(qs_all_input);
7248 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
7249 "wrong qstatus %08lx\n", qstatus);
7251 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7252 qstatus = GetQueueStatus(qs_all_input);
7253 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
7254 "wrong qstatus %08lx\n", qstatus);
7256 InvalidateRect(info.hwnd, NULL, FALSE);
7257 qstatus = GetQueueStatus(qs_all_input);
7258 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7259 "wrong qstatus %08lx\n", qstatus);
7261 trace("signalling to send message\n");
7262 SetEvent(info.hevent[EV_SENDMSG]);
7263 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7265 qstatus = GetQueueStatus(qs_all_input);
7266 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7267 "wrong qstatus %08lx\n", qstatus);
7268 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16))) DispatchMessageA(&msg);
7269 ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */
7271 qstatus = GetQueueStatus(qs_all_input);
7273 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7274 "wrong qstatus %08lx\n", qstatus);
7277 trace("signalling to send message\n");
7278 SetEvent(info.hevent[EV_SENDMSG]);
7279 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7281 qstatus = GetQueueStatus(qs_all_input);
7283 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7284 "wrong qstatus %08lx\n", qstatus);
7286 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg);
7287 ok_sequence(WmUser, "WmUser", FALSE);
7289 qstatus = GetQueueStatus(qs_all_input);
7291 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7292 "wrong qstatus %08lx\n", qstatus);
7295 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg);
7296 ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */
7298 qstatus = GetQueueStatus(qs_all_input);
7300 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
7301 "wrong qstatus %08lx\n", qstatus);
7304 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT)) DispatchMessageA(&msg);
7305 ok_sequence(WmPaint, "WmPaint", TRUE); /* todo_wine */
7307 qstatus = GetQueueStatus(qs_all_input);
7309 ok(qstatus == MAKELONG(0, QS_KEY),
7310 "wrong qstatus %08lx\n", qstatus);
7313 trace("signalling to send message\n");
7314 SetEvent(info.hevent[EV_SENDMSG]);
7315 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7317 qstatus = GetQueueStatus(qs_all_input);
7319 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
7320 "wrong qstatus %08lx\n", qstatus);
7323 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7325 qstatus = GetQueueStatus(qs_all_input);
7327 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7328 "wrong qstatus %08lx\n", qstatus);
7331 while (PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE)) DispatchMessage(&msg);
7332 ok_sequence(WmUserChar, "WmUserChar", FALSE);
7334 qstatus = GetQueueStatus(qs_all_input);
7336 ok(qstatus == MAKELONG(0, QS_KEY),
7337 "wrong qstatus %08lx\n", qstatus);
7340 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7342 qstatus = GetQueueStatus(qs_all_input);
7344 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
7345 "wrong qstatus %08lx\n", qstatus);
7348 trace("signalling to send message\n");
7349 SetEvent(info.hevent[EV_SENDMSG]);
7350 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7352 qstatus = GetQueueStatus(qs_all_input);
7354 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7355 "wrong qstatus %08lx\n", qstatus);
7358 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16))) DispatchMessage(&msg);
7359 ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */
7361 qstatus = GetQueueStatus(qs_all_input);
7363 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
7364 "wrong qstatus %08lx\n", qstatus);
7367 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16))) DispatchMessage(&msg);
7368 ok_sequence(WmKeyDownUp, "WmKeyDownUp", TRUE); /* todo_wine */
7370 qstatus = GetQueueStatus(qs_all_input);
7372 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7373 "wrong qstatus %08lx\n", qstatus);
7376 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE)) DispatchMessage(&msg);
7377 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7379 qstatus = GetQueueStatus(qs_all_input);
7381 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7382 "wrong qstatus %08lx\n", qstatus);
7385 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7386 ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */
7388 qstatus = GetQueueStatus(qs_all_input);
7390 "wrong qstatus %08lx\n", qstatus);
7392 /* test whether presence of the quit flag in the queue affects
7395 PostQuitMessage(0x1234abcd);
7397 qstatus = GetQueueStatus(qs_all_input);
7398 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
7399 "wrong qstatus %08lx\n", qstatus);
7401 PostMessageA(info.hwnd, WM_USER, 0, 0);
7403 qstatus = GetQueueStatus(qs_all_input);
7404 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
7405 "wrong qstatus %08lx\n", qstatus);
7408 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
7409 ok(ret && msg.message == WM_USER,
7410 "got %d and %x instead of TRUE and WM_USER\n", ret, msg.message);
7412 qstatus = GetQueueStatus(qs_all_input);
7413 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7414 "wrong qstatus %08lx\n", qstatus);
7417 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
7418 ok(ret && msg.message == WM_QUIT,
7419 "got %d and %x instead of TRUE and WM_QUIT\n", ret, msg.message);
7420 ok(msg.wParam == 0x1234abcd, "got wParam %x instead of 0x1234abcd\n", msg.wParam);
7421 ok(msg.lParam == 0, "got lParam %lx instead of 0\n", msg.lParam);
7423 qstatus = GetQueueStatus(qs_all_input);
7425 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7426 "wrong qstatus %08lx\n", qstatus);
7429 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
7431 "PeekMessageA should have returned FALSE instead of msg %x\n",
7434 qstatus = GetQueueStatus(qs_all_input);
7436 "wrong qstatus %08lx\n", qstatus);
7438 trace("signalling to exit\n");
7439 SetEvent(info.hevent[EV_START_STOP]);
7441 WaitForSingleObject(hthread, INFINITE);
7443 CloseHandle(hthread);
7444 CloseHandle(info.hevent[0]);
7445 CloseHandle(info.hevent[1]);
7446 CloseHandle(info.hevent[2]);
7448 DestroyWindow(info.hwnd);
7452 static void test_quit_message(void)
7457 /* test using PostQuitMessage */
7458 PostQuitMessage(0xbeef);
7460 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
7461 ok(ret, "PeekMessage failed with error %ld\n", GetLastError());
7462 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7463 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
7465 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
7466 ok(ret, "PostMessage failed with error %ld\n", GetLastError());
7468 ret = GetMessage(&msg, NULL, 0, 0);
7469 ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError());
7470 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
7472 /* note: WM_QUIT message received after WM_USER message */
7473 ret = GetMessage(&msg, NULL, 0, 0);
7474 ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError());
7475 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7476 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
7478 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
7479 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
7481 /* now test with PostThreadMessage - different behaviour! */
7482 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
7484 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
7485 ok(ret, "PeekMessage failed with error %ld\n", GetLastError());
7486 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7487 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
7489 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
7490 ok(ret, "PostMessage failed with error %ld\n", GetLastError());
7492 /* note: we receive the WM_QUIT message first this time */
7493 ret = GetMessage(&msg, NULL, 0, 0);
7494 ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError());
7495 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7496 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
7498 ret = GetMessage(&msg, NULL, 0, 0);
7499 ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError());
7500 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
7506 HMODULE user32 = GetModuleHandleA("user32.dll");
7507 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
7508 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
7509 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
7510 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
7512 if (!RegisterWindowClasses()) assert(0);
7514 if (pSetWinEventHook)
7516 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7517 GetModuleHandleA(0),
7520 GetCurrentThreadId(),
7521 WINEVENT_INCONTEXT);
7522 assert(hEvent_hook);
7524 if (pIsWinEventHookInstalled)
7527 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
7528 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
7532 cbt_hook_thread_id = GetCurrentThreadId();
7533 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
7538 /* Fix message sequences before removing 4 lines below */
7540 if (pUnhookWinEvent && hEvent_hook)
7542 ret = pUnhookWinEvent(hEvent_hook);
7543 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
7544 pUnhookWinEvent = 0;
7550 test_scrollwindowex();
7552 invisible_parent_tests();
7553 test_mdi_messages();
7554 test_button_messages();
7555 test_paint_messages();
7556 test_interthread_messages();
7557 test_message_conversion();
7558 test_accelerators();
7561 test_DestroyWindow();
7562 test_DispatchMessage();
7563 test_SendMessageTimeout();
7564 test_edit_messages();
7565 test_quit_message();
7567 UnhookWindowsHookEx(hCBT_hook);
7568 if (pUnhookWinEvent)
7570 ret = pUnhookWinEvent(hEvent_hook);
7571 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
7572 SetLastError(0xdeadbeef);
7573 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
7574 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7575 GetLastError() == 0xdeadbeef, /* Win9x */
7576 "unexpected error %ld\n", GetLastError());