2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #define _WIN32_WINNT 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 WND_PARENT_ID 1
44 #define WND_POPUP_ID 2
45 #define WND_CHILD_ID 3
47 static BOOL test_DestroyWindow_flag;
48 static HWINEVENTHOOK hEvent_hook;
50 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
53 FIXME: add tests for these
54 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
55 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
56 WS_THICKFRAME: thick border
57 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
58 WS_BORDER (default for overlapped windows): single black border
59 none (default for child (and popup?) windows): no border
76 UINT message; /* the WM_* code */
77 msg_flags_t flags; /* message props */
78 WPARAM wParam; /* expected value of wParam */
79 LPARAM lParam; /* expected value of lParam */
82 /* Empty message sequence */
83 static const struct message WmEmptySeq[] =
87 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
88 static const struct message WmCreateOverlappedSeq[] = {
89 { HCBT_CREATEWND, hook },
90 { WM_GETMINMAXINFO, sent },
91 { WM_NCCREATE, sent },
92 { WM_NCCALCSIZE, sent|wparam, 0 },
93 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
95 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
98 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
99 * for a not visible overlapped window.
101 static const struct message WmSWP_ShowOverlappedSeq[] = {
102 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
103 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
104 { WM_NCPAINT, sent|wparam|optional, 1 },
105 { WM_GETTEXT, sent|defwinproc|optional },
106 { WM_ERASEBKGND, sent|optional },
107 { HCBT_ACTIVATE, hook },
108 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
109 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
110 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
111 { WM_ACTIVATEAPP, sent|wparam, 1 },
112 { WM_NCACTIVATE, sent|wparam, 1 },
113 { WM_GETTEXT, sent|defwinproc|optional },
114 { WM_ACTIVATE, sent|wparam, 1 },
115 { HCBT_SETFOCUS, hook },
116 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
117 { WM_IME_NOTIFY, sent|defwinproc|optional },
118 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
119 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
120 { WM_NCPAINT, sent|wparam|optional, 1 },
121 { WM_GETTEXT, sent|defwinproc|optional },
122 { WM_ERASEBKGND, sent|optional },
123 /* Win9x adds SWP_NOZORDER below */
124 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
125 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
126 { WM_NCPAINT, sent|wparam|optional, 1 },
127 { WM_ERASEBKGND, sent|optional },
128 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
131 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
132 * for a visible overlapped window.
134 static const struct message WmSWP_HideOverlappedSeq[] = {
135 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
136 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
137 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
141 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
142 * for a visible overlapped window.
144 static const struct message WmSWP_ResizeSeq[] = {
145 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE },
146 { WM_GETMINMAXINFO, sent|defwinproc },
147 { WM_NCCALCSIZE, sent|wparam, TRUE },
148 { WM_NCPAINT, sent|optional },
149 { WM_GETTEXT, sent|defwinproc|optional },
150 { WM_ERASEBKGND, sent|optional },
151 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
152 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
153 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
154 { WM_NCPAINT, sent|optional },
155 { WM_GETTEXT, sent|defwinproc|optional },
156 { WM_ERASEBKGND, sent|optional },
157 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
158 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
162 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
163 * for a visible popup window.
165 static const struct message WmSWP_ResizePopupSeq[] = {
166 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE },
167 { WM_NCCALCSIZE, sent|wparam, TRUE },
168 { WM_NCPAINT, sent|optional },
169 { WM_GETTEXT, sent|defwinproc|optional },
170 { WM_ERASEBKGND, sent|optional },
171 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
172 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
173 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
174 { WM_NCPAINT, sent|optional },
175 { WM_GETTEXT, sent|defwinproc|optional },
176 { WM_ERASEBKGND, sent|optional },
177 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
181 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
182 * for a visible overlapped window.
184 static const struct message WmSWP_MoveSeq[] = {
185 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE },
186 { WM_NCPAINT, sent|optional },
187 { WM_GETTEXT, sent|defwinproc|optional },
188 { WM_ERASEBKGND, sent|optional },
189 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE },
190 { WM_MOVE, sent|defwinproc|wparam, 0 },
191 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
195 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
196 SWP_NOZORDER|SWP_FRAMECHANGED)
197 * for a visible overlapped window with WS_CLIPCHILDREN style set.
199 static const struct message WmSWP_FrameChanged_clip[] = {
200 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
201 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
202 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
203 { WM_GETTEXT, sent|parent|defwinproc|optional },
204 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
205 { WM_NCPAINT, sent }, /* wparam != 1 */
206 { WM_ERASEBKGND, sent },
207 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
208 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
212 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
213 SWP_NOZORDER|SWP_FRAMECHANGED)
214 * for a visible overlapped window.
216 static const struct message WmSWP_FrameChangedDeferErase[] = {
217 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
218 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
219 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
220 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
221 { WM_PAINT, sent|parent },
222 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
223 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
225 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
226 { WM_ERASEBKGND, sent|beginpaint },
230 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
231 SWP_NOZORDER|SWP_FRAMECHANGED)
232 * for a visible overlapped window without WS_CLIPCHILDREN style set.
234 static const struct message WmSWP_FrameChanged_noclip[] = {
235 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED },
236 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
237 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
238 { WM_GETTEXT, sent|parent|defwinproc|optional },
239 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
240 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
241 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
243 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
244 { WM_ERASEBKGND, sent|beginpaint },
248 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
249 static const struct message WmShowOverlappedSeq[] = {
250 { WM_SHOWWINDOW, sent|wparam, 1 },
251 { WM_NCPAINT, sent|wparam|optional, 1 },
252 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
253 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
254 { WM_NCPAINT, sent|wparam|optional, 1 },
255 { WM_GETTEXT, sent|defwinproc|optional },
256 { WM_ERASEBKGND, sent|optional },
257 { HCBT_ACTIVATE, hook },
258 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
259 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
260 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
261 { WM_ACTIVATEAPP, sent|wparam, 1 },
262 { WM_NCACTIVATE, sent|wparam, 1 },
263 { WM_GETTEXT, sent|defwinproc|optional },
264 { WM_ACTIVATE, sent|wparam, 1 },
265 { HCBT_SETFOCUS, hook },
266 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
267 { WM_IME_NOTIFY, sent|defwinproc|optional },
268 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
269 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
270 { WM_NCPAINT, sent|wparam|optional, 1 },
271 { WM_GETTEXT, sent|defwinproc|optional },
272 { WM_ERASEBKGND, sent|optional },
273 /* Win9x adds SWP_NOZORDER below */
274 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
275 { WM_NCCALCSIZE, sent|optional },
276 { WM_NCPAINT, sent|optional },
277 { WM_ERASEBKGND, sent|optional },
278 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
279 * messages. Does that mean that CreateWindow doesn't set initial
280 * window dimensions for overlapped windows?
287 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
288 static const struct message WmShowMaxOverlappedSeq[] = {
289 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
290 { WM_GETMINMAXINFO, sent },
291 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
292 { WM_GETMINMAXINFO, sent|defwinproc },
293 { WM_NCCALCSIZE, sent|wparam, TRUE },
294 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
295 { HCBT_ACTIVATE, hook },
296 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
297 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
298 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
299 { WM_ACTIVATEAPP, sent|wparam, 1 },
300 { WM_NCACTIVATE, sent|wparam, 1 },
301 { WM_GETTEXT, sent|defwinproc|optional },
302 { WM_ACTIVATE, sent|wparam, 1 },
303 { HCBT_SETFOCUS, hook },
304 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
305 { WM_IME_NOTIFY, sent|defwinproc|optional },
306 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
307 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
308 { WM_NCPAINT, sent|wparam|optional, 1 },
309 { WM_GETTEXT, sent|defwinproc|optional },
310 { WM_ERASEBKGND, sent|optional },
311 /* Win9x adds SWP_NOZORDER below */
312 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
313 { WM_MOVE, sent|defwinproc },
314 { WM_SIZE, sent|defwinproc },
315 { WM_NCCALCSIZE, sent|optional },
316 { WM_NCPAINT, sent|optional },
317 { WM_ERASEBKGND, sent|optional },
318 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
319 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
322 /* ShowWindow(SW_HIDE) for a visible overlapped window */
323 static const struct message WmHideOverlappedSeq[] = {
324 { WM_SHOWWINDOW, sent|wparam, 0 },
325 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
326 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
327 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
328 { WM_SIZE, sent|optional }, /* XP doesn't send it */
329 { WM_MOVE, sent|optional }, /* XP doesn't send it */
330 { WM_NCACTIVATE, sent|wparam, 0 },
331 { WM_ACTIVATE, sent|wparam, 0 },
332 { WM_ACTIVATEAPP, sent|wparam, 0 },
333 { WM_KILLFOCUS, sent|wparam, 0 },
334 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
335 { WM_IME_NOTIFY, sent|optional|defwinproc },
338 /* DestroyWindow for a visible overlapped window */
339 static const struct message WmDestroyOverlappedSeq[] = {
340 { HCBT_DESTROYWND, hook },
341 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
342 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
343 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
344 { WM_NCACTIVATE, sent|wparam, 0 },
345 { WM_ACTIVATE, sent|wparam, 0 },
346 { WM_ACTIVATEAPP, sent|wparam, 0 },
347 { WM_KILLFOCUS, sent|wparam, 0 },
348 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
349 { WM_IME_NOTIFY, sent|optional|defwinproc },
350 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
351 { WM_DESTROY, sent },
352 { WM_NCDESTROY, sent },
355 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
356 static const struct message WmCreateMaxPopupSeq[] = {
357 { HCBT_CREATEWND, hook },
358 { WM_NCCREATE, sent },
359 { WM_NCCALCSIZE, sent|wparam, 0 },
363 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
364 { WM_GETMINMAXINFO, sent },
365 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000*/ },
366 { WM_NCCALCSIZE, sent|wparam, TRUE },
367 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000*/ },
368 { WM_MOVE, sent|defwinproc },
369 { WM_SIZE, sent|defwinproc },
370 { WM_SHOWWINDOW, sent|wparam, 1 },
371 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
372 { HCBT_ACTIVATE, hook },
373 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
374 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
375 { WM_ACTIVATEAPP, sent|wparam, 1 },
376 { WM_NCACTIVATE, sent|wparam, 1 },
377 { WM_ACTIVATE, sent|wparam, 1 },
378 { HCBT_SETFOCUS, hook },
379 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
380 { WM_SYNCPAINT, sent|wparam|optional, 4 },
381 { WM_NCPAINT, sent|wparam|optional, 1 },
382 { WM_ERASEBKGND, sent|optional },
383 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE },
386 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
387 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
388 { HCBT_CREATEWND, hook },
389 { WM_NCCREATE, sent },
390 { WM_NCCALCSIZE, sent|wparam, 0 },
394 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
395 { WM_GETMINMAXINFO, sent },
396 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000*/ },
397 { WM_NCCALCSIZE, sent|wparam, TRUE },
398 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000*/ },
399 { WM_MOVE, sent|defwinproc },
400 { WM_SIZE, sent|defwinproc },
403 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
404 static const struct message WmShowMaxPopupResizedSeq[] = {
405 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
406 { WM_GETMINMAXINFO, sent },
407 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
408 { WM_NCCALCSIZE, sent|wparam, TRUE },
409 { HCBT_ACTIVATE, hook },
410 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
411 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
412 { WM_ACTIVATEAPP, sent|wparam, 1 },
413 { WM_NCACTIVATE, sent|wparam, 1 },
414 { WM_ACTIVATE, sent|wparam, 1 },
415 { HCBT_SETFOCUS, hook },
416 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
417 { WM_NCPAINT, sent|wparam|optional, 1 },
418 { WM_ERASEBKGND, sent|optional },
419 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOZORDER },
420 /* WinNT4.0 sends WM_MOVE */
421 { WM_MOVE, sent|defwinproc|optional },
422 { WM_SIZE, sent|defwinproc },
425 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
426 static const struct message WmShowMaxPopupSeq[] = {
427 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
428 { WM_GETMINMAXINFO, sent },
429 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
430 { WM_NCCALCSIZE, sent|wparam, TRUE },
431 { HCBT_ACTIVATE, hook },
432 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
433 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
434 { WM_ACTIVATEAPP, sent|wparam, 1 },
435 { WM_NCACTIVATE, sent|wparam, 1 },
436 { WM_ACTIVATE, sent|wparam, 1 },
437 { HCBT_SETFOCUS, hook },
438 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
439 { WM_SYNCPAINT, sent|wparam|optional, 4 },
440 { WM_NCPAINT, sent|wparam|optional, 1 },
441 { WM_ERASEBKGND, sent|optional },
442 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
445 /* CreateWindow(WS_VISIBLE) for popup window */
446 static const struct message WmCreatePopupSeq[] = {
447 { HCBT_CREATEWND, hook },
448 { WM_NCCREATE, sent },
449 { WM_NCCALCSIZE, sent|wparam, 0 },
453 { WM_SHOWWINDOW, sent|wparam, 1 },
454 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
455 { HCBT_ACTIVATE, hook },
456 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
457 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
458 { WM_NCPAINT, sent|wparam|optional, 1 },
459 { WM_ERASEBKGND, sent|optional },
460 { WM_ACTIVATEAPP, sent|wparam, 1 },
461 { WM_NCACTIVATE, sent|wparam, 1 },
462 { WM_ACTIVATE, sent|wparam, 1 },
463 { HCBT_SETFOCUS, hook },
464 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
465 { WM_SYNCPAINT, sent|wparam|optional, 4 },
466 { WM_NCPAINT, sent|wparam|optional, 1 },
467 { WM_ERASEBKGND, sent|optional },
468 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOSIZE },
471 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
472 static const struct message WmShowVisMaxPopupSeq[] = {
473 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
474 { WM_GETMINMAXINFO, sent },
475 { WM_GETTEXT, sent|optional },
476 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
477 { WM_NCCALCSIZE, sent|wparam, TRUE },
478 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
479 { WM_NCPAINT, sent|wparam|optional, 1 },
480 { WM_ERASEBKGND, sent|optional },
481 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOZORDER|0x8000 },
482 { WM_MOVE, sent|defwinproc },
483 { WM_SIZE, sent|defwinproc },
486 /* CreateWindow (for a child popup window, not initially visible) */
487 static const struct message WmCreateChildPopupSeq[] = {
488 { HCBT_CREATEWND, hook },
489 { WM_NCCREATE, sent },
490 { WM_NCCALCSIZE, sent|wparam, 0 },
492 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
497 /* CreateWindow (for a popup window, not initially visible,
498 * which sets WS_VISIBLE in WM_CREATE handler)
500 static const struct message WmCreateInvisiblePopupSeq[] = {
501 { HCBT_CREATEWND, hook },
502 { WM_NCCREATE, sent },
503 { WM_NCCALCSIZE, sent|wparam, 0 },
505 { WM_STYLECHANGING, sent },
506 { WM_STYLECHANGED, sent },
507 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
512 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
513 * for a popup window with WS_VISIBLE style set
515 static const struct message WmShowVisiblePopupSeq_2[] = {
516 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
519 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
520 * for a popup window with WS_VISIBLE style set
522 static const struct message WmShowVisiblePopupSeq_3[] = {
523 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
524 { HCBT_ACTIVATE, hook },
525 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
526 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
527 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
528 { WM_NCACTIVATE, sent|wparam, 1 },
529 { WM_ACTIVATE, sent|wparam, 1 },
530 { HCBT_SETFOCUS, hook },
531 { WM_KILLFOCUS, sent|parent },
532 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
533 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
534 { WM_IME_NOTIFY, sent|defwinproc|optional },
535 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
536 { WM_SETFOCUS, sent|defwinproc },
539 /* CreateWindow (for child window, not initially visible) */
540 static const struct message WmCreateChildSeq[] = {
541 { HCBT_CREATEWND, hook },
542 { WM_NCCREATE, sent },
543 /* child is inserted into parent's child list after WM_NCCREATE returns */
544 { WM_NCCALCSIZE, sent|wparam, 0 },
546 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
549 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
552 /* CreateWindow (for maximized child window, not initially visible) */
553 static const struct message WmCreateMaximizedChildSeq[] = {
554 { HCBT_CREATEWND, hook },
555 { WM_NCCREATE, sent },
556 { WM_NCCALCSIZE, sent|wparam, 0 },
558 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
561 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
562 { WM_GETMINMAXINFO, sent },
563 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
564 { WM_NCCALCSIZE, sent|wparam, 1 },
565 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
566 { WM_SIZE, sent|defwinproc },
567 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
568 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
571 /* CreateWindow (for a child window, initially visible) */
572 static const struct message WmCreateVisibleChildSeq[] = {
573 { HCBT_CREATEWND, hook },
574 { WM_NCCREATE, sent },
575 /* child is inserted into parent's child list after WM_NCCREATE returns */
576 { WM_NCCALCSIZE, sent|wparam, 0 },
577 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
579 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
582 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
583 { WM_SHOWWINDOW, sent|wparam, 1 },
584 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
585 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
586 { WM_ERASEBKGND, sent|parent|optional },
587 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
588 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
589 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
592 /* ShowWindow(SW_SHOW) for a not visible child window */
593 static const struct message WmShowChildSeq[] = {
594 { WM_SHOWWINDOW, sent|wparam, 1 },
595 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
596 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
597 { WM_ERASEBKGND, sent|parent|optional },
598 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
601 /* ShowWindow(SW_HIDE) for a visible child window */
602 static const struct message WmHideChildSeq[] = {
603 { WM_SHOWWINDOW, sent|wparam, 0 },
604 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
605 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
606 { WM_ERASEBKGND, sent|parent|optional },
607 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
610 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
611 * for a not visible child window
613 static const struct message WmShowChildSeq_2[] = {
614 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
615 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
616 { WM_CHILDACTIVATE, sent },
617 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
620 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
621 * for a not visible child window
623 static const struct message WmShowChildSeq_3[] = {
624 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
625 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
626 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
629 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
630 * for a visible child window with a caption
632 static const struct message WmShowChildSeq_4[] = {
633 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
634 { WM_CHILDACTIVATE, sent },
637 /* ShowWindow(SW_SHOW) for child with invisible parent */
638 static const struct message WmShowChildInvisibleParentSeq[] = {
639 { WM_SHOWWINDOW, sent|wparam, 1 },
642 /* ShowWindow(SW_HIDE) for child with invisible parent */
643 static const struct message WmHideChildInvisibleParentSeq[] = {
644 { WM_SHOWWINDOW, sent|wparam, 0 },
647 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
648 static const struct message WmShowChildInvisibleParentSeq_2[] = {
649 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
650 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
651 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
654 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
655 static const struct message WmHideChildInvisibleParentSeq_2[] = {
656 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
657 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
658 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
661 /* DestroyWindow for a visible child window */
662 static const struct message WmDestroyChildSeq[] = {
663 { HCBT_DESTROYWND, hook },
664 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
665 { WM_SHOWWINDOW, sent|wparam, 0 },
666 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
667 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
668 { WM_ERASEBKGND, sent|parent|optional },
669 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
670 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
671 { WM_KILLFOCUS, sent },
672 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
673 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
674 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
675 { WM_SETFOCUS, sent|parent },
676 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
677 { WM_DESTROY, sent },
678 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
679 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
680 { WM_NCDESTROY, sent },
683 /* DestroyWindow for a visible child window with invisible parent */
684 static const struct message WmDestroyInvisibleChildSeq[] = {
685 { HCBT_DESTROYWND, hook },
686 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
687 { WM_SHOWWINDOW, sent|wparam, 0 },
688 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
689 { WM_DESTROY, sent },
690 { WM_NCDESTROY, sent },
693 /* Moving the mouse in nonclient area */
694 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
695 { WM_NCHITTEST, sent },
696 { WM_SETCURSOR, sent },
697 { WM_NCMOUSEMOVE, posted },
700 /* Moving the mouse in client area */
701 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
702 { WM_NCHITTEST, sent },
703 { WM_SETCURSOR, sent },
704 { WM_MOUSEMOVE, posted },
707 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
708 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
709 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
710 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
711 { WM_GETMINMAXINFO, sent|defwinproc },
712 { WM_ENTERSIZEMOVE, sent|defwinproc },
713 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
714 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
715 { WM_MOVE, sent|defwinproc },
716 { WM_EXITSIZEMOVE, sent|defwinproc },
719 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
720 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
721 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
722 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
723 { WM_GETMINMAXINFO, sent|defwinproc },
724 { WM_ENTERSIZEMOVE, sent|defwinproc },
725 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
726 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
727 { WM_GETMINMAXINFO, sent|defwinproc },
728 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
729 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
730 { WM_GETTEXT, sent|defwinproc },
731 { WM_ERASEBKGND, sent|defwinproc },
732 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
733 { WM_MOVE, sent|defwinproc },
734 { WM_SIZE, sent|defwinproc },
735 { WM_EXITSIZEMOVE, sent|defwinproc },
738 /* Resizing child window with MoveWindow (32) */
739 static const struct message WmResizingChildWithMoveWindowSeq[] = {
740 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
741 { WM_NCCALCSIZE, sent|wparam, 1 },
742 { WM_ERASEBKGND, sent|optional },
743 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
744 { WM_MOVE, sent|defwinproc },
745 { WM_SIZE, sent|defwinproc },
746 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
749 /* Clicking on inactive button */
750 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
751 { WM_NCHITTEST, sent },
752 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
753 { WM_MOUSEACTIVATE, sent },
754 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
755 { WM_SETCURSOR, sent },
756 { WM_SETCURSOR, sent|parent|defwinproc },
757 { WM_LBUTTONDOWN, posted },
758 { WM_KILLFOCUS, posted|parent },
759 { WM_SETFOCUS, posted },
760 { WM_CTLCOLORBTN, posted|parent },
761 { BM_SETSTATE, posted },
762 { WM_CTLCOLORBTN, posted|parent },
763 { WM_LBUTTONUP, posted },
764 { BM_SETSTATE, posted },
765 { WM_CTLCOLORBTN, posted|parent },
766 { WM_COMMAND, posted|parent },
769 /* Reparenting a button (16/32) */
770 /* The last child (button) reparented gets topmost for its new parent. */
771 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
772 { WM_SHOWWINDOW, sent|wparam, 0 },
773 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
774 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
775 { WM_ERASEBKGND, sent|parent },
776 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
777 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOZORDER },
778 { WM_CHILDACTIVATE, sent },
779 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER },
780 { WM_MOVE, sent|defwinproc },
781 { WM_SHOWWINDOW, sent|wparam, 1 },
784 /* Creation of a custom dialog (32) */
785 static const struct message WmCreateCustomDialogSeq[] = {
786 { HCBT_CREATEWND, hook },
787 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
788 { WM_GETMINMAXINFO, sent },
789 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
790 { WM_NCCREATE, sent },
791 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
792 { WM_NCCALCSIZE, sent|wparam, 0 },
793 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
794 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
796 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
797 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
798 { WM_SHOWWINDOW, sent|wparam, 1 },
799 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
800 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
801 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
802 { HCBT_ACTIVATE, hook },
803 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
805 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
807 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
808 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
810 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
812 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
813 { WM_NCACTIVATE, sent|wparam, 1 },
814 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
815 { WM_GETTEXT, sent|optional|defwinproc },
816 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
817 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
818 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
819 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
820 { WM_GETTEXT, sent|optional|defwinproc },
821 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
822 { WM_ACTIVATE, sent|wparam, 1 },
823 { WM_KILLFOCUS, sent|parent },
824 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
825 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
826 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
827 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
828 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
829 { WM_IME_NOTIFY, sent|optional|defwinproc },
830 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
831 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
832 { WM_SETFOCUS, sent },
833 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
834 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
835 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
836 { WM_NCPAINT, sent|wparam, 1 },
837 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
838 { WM_GETTEXT, sent|optional|defwinproc },
839 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
840 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
841 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
842 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
843 { WM_GETTEXT, sent|optional|defwinproc },
844 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
845 { WM_ERASEBKGND, sent },
846 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
847 { WM_CTLCOLORDLG, sent|defwinproc },
848 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
849 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
850 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
851 { WM_GETTEXT, sent|optional },
852 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
853 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
854 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
855 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
856 { WM_GETTEXT, sent|optional },
857 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
858 { WM_NCCALCSIZE, sent|optional },
859 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
860 { WM_NCPAINT, sent|optional },
861 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
862 { WM_GETTEXT, sent|optional|defwinproc },
863 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
864 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
865 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
866 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
867 { WM_GETTEXT, sent|optional|defwinproc },
868 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
869 { WM_ERASEBKGND, sent|optional },
870 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
871 { WM_CTLCOLORDLG, sent|optional|defwinproc },
872 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
873 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
875 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
879 /* Calling EndDialog for a custom dialog (32) */
880 static const struct message WmEndCustomDialogSeq[] = {
881 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
882 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
883 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
884 { WM_GETTEXT, sent|optional },
885 { HCBT_ACTIVATE, hook },
886 { WM_NCACTIVATE, sent|wparam, 0 },
887 { WM_GETTEXT, sent|optional|defwinproc },
888 { WM_GETTEXT, sent|optional|defwinproc },
889 { WM_ACTIVATE, sent|wparam, 0 },
890 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
891 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
892 { HCBT_SETFOCUS, hook },
893 { WM_KILLFOCUS, sent },
894 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
895 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
896 { WM_IME_NOTIFY, sent|optional },
897 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
898 { WM_SETFOCUS, sent|parent|defwinproc },
901 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
902 static const struct message WmShowCustomDialogSeq[] = {
903 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
904 { WM_SHOWWINDOW, sent|wparam, 1 },
905 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
906 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
907 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
908 { HCBT_ACTIVATE, hook },
909 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
911 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
912 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
914 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
915 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
916 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
917 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
918 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
919 { WM_NCACTIVATE, sent|wparam, 1 },
920 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
921 { WM_ACTIVATE, sent|wparam, 1 },
923 { WM_KILLFOCUS, sent|parent },
924 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
925 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
926 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
927 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
928 { WM_IME_NOTIFY, sent|optional|defwinproc },
929 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
930 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
931 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
932 { WM_SETFOCUS, sent },
933 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
934 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
935 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
936 { WM_NCPAINT, sent|wparam, 1 },
937 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
938 { WM_ERASEBKGND, sent },
939 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
940 { WM_CTLCOLORDLG, sent|defwinproc },
942 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
943 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
946 /* Creation and destruction of a modal dialog (32) */
947 static const struct message WmModalDialogSeq[] = {
948 { WM_CANCELMODE, sent|parent },
949 { HCBT_SETFOCUS, hook },
950 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
951 { WM_KILLFOCUS, sent|parent },
952 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
953 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
954 { WM_ENABLE, sent|parent|wparam, 0 },
955 { HCBT_CREATEWND, hook },
956 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
957 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
958 { WM_SETFONT, sent },
959 { WM_INITDIALOG, sent },
960 { WM_CHANGEUISTATE, sent|optional },
961 { WM_SHOWWINDOW, sent },
962 { HCBT_ACTIVATE, hook },
963 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
964 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
965 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
966 { WM_NCACTIVATE, sent|wparam, 1 },
967 { WM_GETTEXT, sent|optional },
968 { WM_ACTIVATE, sent|wparam, 1 },
969 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE },
970 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
971 { WM_NCPAINT, sent },
972 { WM_GETTEXT, sent|optional },
973 { WM_ERASEBKGND, sent },
974 { WM_CTLCOLORDLG, sent },
975 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
976 { WM_GETTEXT, sent|optional },
977 { WM_NCCALCSIZE, sent|optional },
978 { WM_NCPAINT, sent|optional },
979 { WM_GETTEXT, sent|optional },
980 { WM_ERASEBKGND, sent|optional },
981 { WM_CTLCOLORDLG, sent|optional },
982 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
983 { WM_PAINT, sent|optional },
984 { WM_CTLCOLORBTN, sent },
985 { WM_ENTERIDLE, sent|parent|optional },
986 { WM_ENTERIDLE, sent|parent|optional },
987 { WM_ENTERIDLE, sent|parent|optional },
988 { WM_ENTERIDLE, sent|parent|optional },
989 { WM_ENTERIDLE, sent|parent|optional },
990 { WM_ENTERIDLE, sent|parent|optional },
991 { WM_ENTERIDLE, sent|parent|optional },
992 { WM_ENTERIDLE, sent|parent|optional },
993 { WM_ENTERIDLE, sent|parent|optional },
994 { WM_ENTERIDLE, sent|parent|optional },
995 { WM_ENTERIDLE, sent|parent|optional },
996 { WM_ENTERIDLE, sent|parent|optional },
997 { WM_ENTERIDLE, sent|parent|optional },
998 { WM_ENTERIDLE, sent|parent|optional },
999 { WM_ENTERIDLE, sent|parent|optional },
1000 { WM_ENTERIDLE, sent|parent|optional },
1001 { WM_ENTERIDLE, sent|parent|optional },
1002 { WM_ENTERIDLE, sent|parent|optional },
1003 { WM_ENTERIDLE, sent|parent|optional },
1004 { WM_ENTERIDLE, sent|parent|optional },
1006 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1007 { WM_ENABLE, sent|parent|wparam, 1 },
1008 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE },
1009 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1010 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1011 { WM_GETTEXT, sent|optional },
1012 { HCBT_ACTIVATE, hook },
1013 { WM_NCACTIVATE, sent|wparam, 0 },
1014 { WM_GETTEXT, sent|optional },
1015 { WM_ACTIVATE, sent|wparam, 0 },
1016 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1017 { WM_WINDOWPOSCHANGING, sent|optional },
1018 { HCBT_SETFOCUS, hook },
1019 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1020 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1021 { WM_SETFOCUS, sent|parent|defwinproc },
1022 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1023 { HCBT_DESTROYWND, hook },
1024 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1025 { WM_DESTROY, sent },
1026 { WM_NCDESTROY, sent },
1029 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1030 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1031 /* (inside dialog proc, handling WM_INITDIALOG) */
1032 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1033 { WM_NCCALCSIZE, sent },
1034 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1035 { WM_GETTEXT, sent|defwinproc },
1036 { WM_ACTIVATE, sent|parent|wparam, 0 },
1037 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1038 { WM_WINDOWPOSCHANGING, sent|parent },
1039 { WM_NCACTIVATE, sent|wparam, 1 },
1040 { WM_ACTIVATE, sent|wparam, 1 },
1041 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1042 { WM_SIZE, sent|defwinproc },
1043 /* (setting focus) */
1044 { WM_SHOWWINDOW, sent|wparam, 1 },
1045 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1046 { WM_NCPAINT, sent },
1047 { WM_GETTEXT, sent|defwinproc },
1048 { WM_ERASEBKGND, sent },
1049 { WM_CTLCOLORDLG, sent|defwinproc },
1050 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1052 /* (bunch of WM_CTLCOLOR* for each control) */
1053 { WM_PAINT, sent|parent },
1054 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1055 { WM_SETCURSOR, sent|parent },
1058 /* SetMenu for NonVisible windows with size change*/
1059 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1060 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1061 { WM_NCCALCSIZE, sent|wparam, 1 },
1062 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1063 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW },
1064 { WM_MOVE, sent|defwinproc },
1065 { WM_SIZE, sent|defwinproc },
1066 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1067 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1068 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1069 { WM_GETTEXT, sent|optional },
1070 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1073 /* SetMenu for NonVisible windows with no size change */
1074 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1075 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1076 { WM_NCCALCSIZE, sent|wparam, 1 },
1077 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1078 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1081 /* SetMenu for Visible windows with size change */
1082 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1083 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1084 { WM_NCCALCSIZE, sent|wparam, 1 },
1085 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1086 { WM_NCPAINT, sent }, /* wparam != 1 */
1087 { WM_GETTEXT, sent|defwinproc|optional },
1088 { WM_ERASEBKGND, sent|optional },
1089 { WM_ACTIVATE, sent|optional },
1090 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1091 { WM_MOVE, sent|defwinproc },
1092 { WM_SIZE, sent|defwinproc },
1093 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1094 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1095 { WM_ERASEBKGND, sent|optional },
1096 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1097 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1100 /* SetMenu for Visible windows with no size change */
1101 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1102 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1103 { WM_NCCALCSIZE, sent|wparam, 1 },
1104 { WM_NCPAINT, sent }, /* wparam != 1 */
1105 { WM_GETTEXT, sent|defwinproc|optional },
1106 { WM_ERASEBKGND, sent|optional },
1107 { WM_ACTIVATE, sent|optional },
1108 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1109 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1112 /* DrawMenuBar for a visible window */
1113 static const struct message WmDrawMenuBarSeq[] =
1115 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1116 { WM_NCCALCSIZE, sent|wparam, 1 },
1117 { WM_NCPAINT, sent }, /* wparam != 1 */
1118 { WM_GETTEXT, sent|defwinproc|optional },
1119 { WM_ERASEBKGND, sent|optional },
1120 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1121 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1125 static const struct message WmSetRedrawFalseSeq[] =
1127 { WM_SETREDRAW, sent|wparam, 0 },
1131 static const struct message WmSetRedrawTrueSeq[] =
1133 { WM_SETREDRAW, sent|wparam, 1 },
1137 static const struct message WmEnableWindowSeq_1[] =
1139 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1140 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1141 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1145 static const struct message WmEnableWindowSeq_2[] =
1147 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1148 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1152 static const struct message WmGetScrollRangeSeq[] =
1154 { SBM_GETRANGE, sent },
1157 static const struct message WmGetScrollInfoSeq[] =
1159 { SBM_GETSCROLLINFO, sent },
1162 static const struct message WmSetScrollRangeSeq[] =
1164 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1165 sends SBM_SETSCROLLINFO.
1167 { SBM_SETSCROLLINFO, sent },
1170 /* SetScrollRange for a window without a non-client area */
1171 static const struct message WmSetScrollRangeHSeq_empty[] =
1173 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1176 static const struct message WmSetScrollRangeVSeq_empty[] =
1178 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1181 static const struct message WmSetScrollRangeHVSeq[] =
1183 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER },
1184 { WM_NCCALCSIZE, sent|wparam, 1 },
1185 { WM_GETTEXT, sent|defwinproc|optional },
1186 { WM_ERASEBKGND, sent|optional },
1187 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1188 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1189 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1192 /* SetScrollRange for a window with a non-client area */
1193 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1195 { WM_WINDOWPOSCHANGING, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER*/ },
1196 { WM_NCCALCSIZE, sent|wparam, 1 },
1197 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1198 { WM_NCPAINT, sent|optional },
1199 { WM_GETTEXT, sent|defwinproc|optional },
1200 { WM_GETTEXT, sent|defwinproc|optional },
1201 { WM_ERASEBKGND, sent|optional },
1202 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1203 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|0x1000*/ },
1204 { WM_SIZE, sent|defwinproc },
1205 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1206 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1207 { WM_GETTEXT, sent|optional },
1208 { WM_GETTEXT, sent|optional },
1209 { WM_GETTEXT, sent|optional },
1210 { WM_GETTEXT, sent|optional },
1213 /* test if we receive the right sequence of messages */
1214 /* after calling ShowWindow( SW_SHOWNA) */
1215 static const struct message WmSHOWNAChildInvisParInvis[] = {
1216 { WM_SHOWWINDOW, sent|wparam, 1 },
1219 static const struct message WmSHOWNAChildVisParInvis[] = {
1220 { WM_SHOWWINDOW, sent|wparam, 1 },
1223 static const struct message WmSHOWNAChildVisParVis[] = {
1224 { WM_SHOWWINDOW, sent|wparam, 1 },
1225 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER },
1228 static const struct message WmSHOWNAChildInvisParVis[] = {
1229 { WM_SHOWWINDOW, sent|wparam, 1 },
1230 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER},
1231 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1232 { WM_ERASEBKGND, sent|optional },
1233 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1236 static const struct message WmSHOWNATopVisible[] = {
1237 { WM_SHOWWINDOW, sent|wparam, 1 },
1238 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1241 static const struct message WmSHOWNATopInvisible[] = {
1242 { WM_SHOWWINDOW, sent|wparam, 1 },
1243 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1244 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1245 { WM_NCPAINT, sent|wparam, 1 },
1246 { WM_GETTEXT, sent|defwinproc|optional },
1247 { WM_ERASEBKGND, sent|optional },
1248 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1249 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1250 { WM_NCPAINT, sent|wparam|optional, 1 },
1251 { WM_ERASEBKGND, sent|optional },
1252 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1258 static int after_end_dialog;
1259 static int sequence_cnt, sequence_size;
1260 static struct message* sequence;
1261 static int log_all_parent_messages;
1263 static void add_message(const struct message *msg)
1268 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1270 if (sequence_cnt == sequence_size)
1273 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1277 sequence[sequence_cnt].message = msg->message;
1278 sequence[sequence_cnt].flags = msg->flags;
1279 sequence[sequence_cnt].wParam = msg->wParam;
1280 sequence[sequence_cnt].lParam = msg->lParam;
1285 /* try to make sure pending X events have been processed before continuing */
1286 static void flush_events(void)
1290 DWORD time = GetTickCount() + diff;
1294 MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT );
1295 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1296 diff = time - GetTickCount();
1300 static void flush_sequence(void)
1302 HeapFree(GetProcessHeap(), 0, sequence);
1304 sequence_cnt = sequence_size = 0;
1307 #define ok_sequence( exp, contx, todo) \
1308 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1311 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1312 const char *file, int line)
1314 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1315 const struct message *actual;
1318 add_message(&end_of_sequence);
1322 while (expected->message && actual->message)
1324 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1326 if (expected->message == actual->message)
1328 if (expected->flags & wparam)
1330 if (expected->wParam != actual->wParam && todo)
1334 ok_( file, line) (FALSE,
1335 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1336 context, expected->message, expected->wParam, actual->wParam);
1340 ok_( file, line) (expected->wParam == actual->wParam,
1341 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1342 context, expected->message, expected->wParam, actual->wParam);
1344 if (expected->flags & lparam)
1345 ok_( file, line) (expected->lParam == actual->lParam,
1346 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1347 context, expected->message, expected->lParam, actual->lParam);
1348 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1349 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1350 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1351 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1352 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1353 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1354 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1355 "%s: the msg 0x%04x should have been %s\n",
1356 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1357 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1358 "%s: the msg 0x%04x was expected in %s\n",
1359 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1360 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1361 "%s: the msg 0x%04x should have been sent by a hook\n",
1362 context, expected->message);
1363 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1364 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1365 context, expected->message);
1369 /* silently drop winevent messages if there is no support for them */
1370 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1376 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1377 context, expected->message, actual->message);
1384 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1385 context, expected->message, actual->message);
1391 /* skip all optional trailing messages */
1392 while (expected->message && ((expected->flags & optional) ||
1393 ((expected->flags & winevent_hook) && !hEvent_hook)))
1399 if (expected->message || actual->message) {
1401 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1402 context, expected->message, actual->message);
1408 if (expected->message || actual->message)
1409 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1410 context, expected->message, actual->message);
1412 if( todo && !failcount) /* succeeded yet marked todo */
1414 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1420 /******************************** MDI test **********************************/
1422 /* CreateWindow for MDI frame window, initially visible */
1423 static const struct message WmCreateMDIframeSeq[] = {
1424 { HCBT_CREATEWND, hook },
1425 { WM_GETMINMAXINFO, sent },
1426 { WM_NCCREATE, sent },
1427 { WM_NCCALCSIZE, sent|wparam, 0 },
1428 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1429 { WM_CREATE, sent },
1430 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1431 { WM_SHOWWINDOW, sent|wparam, 1 },
1432 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1433 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1434 { HCBT_ACTIVATE, hook },
1435 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1436 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1437 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1438 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* Win9x */
1439 { WM_ACTIVATEAPP, sent|wparam, 1 },
1440 { WM_NCACTIVATE, sent|wparam, 1 },
1441 { WM_GETTEXT, sent|defwinproc|optional },
1442 { WM_ACTIVATE, sent|wparam, 1 },
1443 { HCBT_SETFOCUS, hook },
1444 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1445 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1446 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1447 /* Win9x adds SWP_NOZORDER below */
1448 { WM_WINDOWPOSCHANGED, sent, /*|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ },
1449 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1450 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1455 /* DestroyWindow for MDI frame window, initially visible */
1456 static const struct message WmDestroyMDIframeSeq[] = {
1457 { HCBT_DESTROYWND, hook },
1458 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1459 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1460 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1461 { WM_NCACTIVATE, sent|wparam, 0 },
1462 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1463 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1464 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1465 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1466 { WM_DESTROY, sent },
1467 { WM_NCDESTROY, sent },
1470 /* CreateWindow for MDI client window, initially visible */
1471 static const struct message WmCreateMDIclientSeq[] = {
1472 { HCBT_CREATEWND, hook },
1473 { WM_NCCREATE, sent },
1474 { WM_NCCALCSIZE, sent|wparam, 0 },
1475 { WM_CREATE, sent },
1476 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1479 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1480 { WM_SHOWWINDOW, sent|wparam, 1 },
1481 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1482 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1483 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1486 /* DestroyWindow for MDI client window, initially visible */
1487 static const struct message WmDestroyMDIclientSeq[] = {
1488 { HCBT_DESTROYWND, hook },
1489 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1490 { WM_SHOWWINDOW, sent|wparam, 0 },
1491 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1492 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1493 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1494 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1495 { WM_DESTROY, sent },
1496 { WM_NCDESTROY, sent },
1499 /* CreateWindow for MDI child window, initially visible */
1500 static const struct message WmCreateMDIchildVisibleSeq[] = {
1501 { HCBT_CREATEWND, hook },
1502 { WM_NCCREATE, sent },
1503 { WM_NCCALCSIZE, sent|wparam, 0 },
1504 { WM_CREATE, sent },
1505 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1508 /* Win2k sends wparam set to
1509 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1510 * while Win9x doesn't bother to set child window id according to
1511 * CLIENTCREATESTRUCT.idFirstChild
1513 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1514 { WM_SHOWWINDOW, sent|wparam, 1 },
1515 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1516 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1517 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1518 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1519 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1520 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1521 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1523 /* Win9x: message sequence terminates here. */
1525 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1526 { HCBT_SETFOCUS, hook }, /* in MDI client */
1527 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1528 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1529 { WM_SETFOCUS, sent }, /* in MDI client */
1530 { HCBT_SETFOCUS, hook },
1531 { WM_KILLFOCUS, sent }, /* in MDI client */
1532 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1533 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1534 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1535 { WM_SETFOCUS, sent|defwinproc },
1536 { WM_MDIACTIVATE, sent|defwinproc },
1539 /* DestroyWindow for MDI child window, initially visible */
1540 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1541 { HCBT_DESTROYWND, hook },
1542 /* Win2k sends wparam set to
1543 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1544 * while Win9x doesn't bother to set child window id according to
1545 * CLIENTCREATESTRUCT.idFirstChild
1547 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1548 { WM_SHOWWINDOW, sent|wparam, 0 },
1549 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1550 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1551 { WM_ERASEBKGND, sent|parent|optional },
1552 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1554 /* { WM_DESTROY, sent }
1555 * Win9x: message sequence terminates here.
1558 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1559 { WM_KILLFOCUS, sent },
1560 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1561 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1562 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1563 { WM_SETFOCUS, sent }, /* in MDI client */
1565 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1566 { WM_KILLFOCUS, sent }, /* in MDI client */
1567 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1568 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1569 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1570 { WM_SETFOCUS, sent }, /* in MDI client */
1572 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1574 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1575 { WM_KILLFOCUS, sent },
1576 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1577 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1578 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1579 { WM_SETFOCUS, sent }, /* in MDI client */
1581 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1582 { WM_KILLFOCUS, sent }, /* in MDI client */
1583 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1584 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1585 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1586 { WM_SETFOCUS, sent }, /* in MDI client */
1588 { WM_DESTROY, sent },
1590 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1591 { WM_KILLFOCUS, sent },
1592 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1593 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1594 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1595 { WM_SETFOCUS, sent }, /* in MDI client */
1597 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1598 { WM_KILLFOCUS, sent }, /* in MDI client */
1599 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1600 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1601 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1602 { WM_SETFOCUS, sent }, /* in MDI client */
1604 { WM_NCDESTROY, sent },
1607 /* CreateWindow for MDI child window, initially invisible */
1608 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1609 { HCBT_CREATEWND, hook },
1610 { WM_NCCREATE, sent },
1611 { WM_NCCALCSIZE, sent|wparam, 0 },
1612 { WM_CREATE, sent },
1613 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1616 /* Win2k sends wparam set to
1617 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1618 * while Win9x doesn't bother to set child window id according to
1619 * CLIENTCREATESTRUCT.idFirstChild
1621 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1624 /* DestroyWindow for MDI child window, initially invisible */
1625 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1626 { HCBT_DESTROYWND, hook },
1627 /* Win2k sends wparam set to
1628 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1629 * while Win9x doesn't bother to set child window id according to
1630 * CLIENTCREATESTRUCT.idFirstChild
1632 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1633 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1634 { WM_DESTROY, sent },
1635 { WM_NCDESTROY, sent },
1638 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1639 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1640 { HCBT_CREATEWND, hook },
1641 { WM_NCCREATE, sent },
1642 { WM_NCCALCSIZE, sent|wparam, 0 },
1643 { WM_CREATE, sent },
1644 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1647 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1648 { WM_GETMINMAXINFO, sent },
1649 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1650 { WM_NCCALCSIZE, sent|wparam, 1 },
1651 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1652 { WM_SIZE, sent|defwinproc },
1654 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1655 { WM_NCCALCSIZE, sent|wparam, 1 },
1656 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1657 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1658 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1659 /* Win2k sends wparam set to
1660 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1661 * while Win9x doesn't bother to set child window id according to
1662 * CLIENTCREATESTRUCT.idFirstChild
1664 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1665 { WM_SHOWWINDOW, sent|wparam, 1 },
1666 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1667 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1668 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1669 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1670 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1671 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1672 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1674 /* Win9x: message sequence terminates here. */
1676 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1677 { HCBT_SETFOCUS, hook }, /* in MDI client */
1678 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1679 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1680 { WM_SETFOCUS, sent }, /* in MDI client */
1681 { HCBT_SETFOCUS, hook },
1682 { WM_KILLFOCUS, sent }, /* in MDI client */
1683 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1684 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1685 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1686 { WM_SETFOCUS, sent|defwinproc },
1687 { WM_MDIACTIVATE, sent|defwinproc },
1689 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1690 { WM_NCCALCSIZE, sent|wparam, 1 },
1691 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1692 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1695 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1696 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
1697 /* restore the 1st MDI child */
1698 { WM_SETREDRAW, sent|wparam, 0 },
1699 { HCBT_MINMAX, hook },
1700 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1701 { WM_NCCALCSIZE, sent|wparam, 1 },
1702 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1703 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1704 { WM_SIZE, sent|defwinproc },
1706 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1707 { WM_NCCALCSIZE, sent|wparam, 1 },
1708 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1709 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1710 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1711 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
1712 /* create the 2nd MDI child */
1713 { HCBT_CREATEWND, hook },
1714 { WM_NCCREATE, sent },
1715 { WM_NCCALCSIZE, sent|wparam, 0 },
1716 { WM_CREATE, sent },
1717 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1720 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1721 { WM_GETMINMAXINFO, sent },
1722 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1723 { WM_NCCALCSIZE, sent|wparam, 1 },
1724 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1725 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1726 { WM_SIZE, sent|defwinproc },
1728 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1729 { WM_NCCALCSIZE, sent|wparam, 1 },
1730 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1731 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1732 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1733 /* Win2k sends wparam set to
1734 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1735 * while Win9x doesn't bother to set child window id according to
1736 * CLIENTCREATESTRUCT.idFirstChild
1738 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1739 { WM_SHOWWINDOW, sent|wparam, 1 },
1740 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1741 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1742 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1743 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1744 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1745 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1747 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1748 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1750 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1752 /* Win9x: message sequence terminates here. */
1754 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1755 { HCBT_SETFOCUS, hook },
1756 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
1757 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
1758 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1759 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1760 { WM_SETFOCUS, sent }, /* in MDI client */
1761 { HCBT_SETFOCUS, hook },
1762 { WM_KILLFOCUS, sent }, /* in MDI client */
1763 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1764 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1765 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1766 { WM_SETFOCUS, sent|defwinproc },
1768 { WM_MDIACTIVATE, sent|defwinproc },
1770 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1771 { WM_NCCALCSIZE, sent|wparam, 1 },
1772 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1773 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1776 /* WM_MDICREATE MDI child window, initially visible and maximized */
1777 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
1778 { WM_MDICREATE, sent },
1779 { HCBT_CREATEWND, hook },
1780 { WM_NCCREATE, sent },
1781 { WM_NCCALCSIZE, sent|wparam, 0 },
1782 { WM_CREATE, sent },
1783 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1786 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1787 { WM_GETMINMAXINFO, sent },
1788 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1789 { WM_NCCALCSIZE, sent|wparam, 1 },
1790 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1791 { 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 */
1800 /* Win2k sends wparam set to
1801 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1802 * while Win9x doesn't bother to set child window id according to
1803 * CLIENTCREATESTRUCT.idFirstChild
1805 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1806 { WM_SHOWWINDOW, sent|wparam, 1 },
1807 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1809 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1811 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1812 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1813 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1815 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1816 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1818 /* Win9x: message sequence terminates here. */
1820 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1821 { HCBT_SETFOCUS, hook }, /* in MDI client */
1822 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1823 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1824 { WM_SETFOCUS, sent }, /* in MDI client */
1825 { HCBT_SETFOCUS, hook },
1826 { WM_KILLFOCUS, sent }, /* in MDI client */
1827 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1828 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1829 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1830 { WM_SETFOCUS, sent|defwinproc },
1832 { WM_MDIACTIVATE, sent|defwinproc },
1835 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1836 { WM_NCCALCSIZE, sent|wparam, 1 },
1837 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1838 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1841 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1842 { WM_NCCALCSIZE, sent|wparam, 1 },
1843 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1844 { WM_MOVE, sent|defwinproc },
1845 { WM_SIZE, sent|defwinproc },
1848 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1849 { WM_NCCALCSIZE, sent|wparam, 1 },
1850 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1854 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1855 { WM_NCCALCSIZE, sent|wparam, 1 },
1856 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1857 { WM_SIZE, sent|defwinproc },
1859 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1860 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1861 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
1862 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1863 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
1867 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
1868 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
1869 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
1870 { HCBT_SYSCOMMAND, hook },
1871 { WM_CLOSE, sent|defwinproc },
1872 { WM_MDIDESTROY, sent }, /* in MDI client */
1874 /* bring the 1st MDI child to top */
1875 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
1876 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
1878 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1880 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
1881 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1882 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1884 /* maximize the 1st MDI child */
1885 { HCBT_MINMAX, hook },
1886 { WM_GETMINMAXINFO, sent|defwinproc },
1887 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
1888 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1889 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
1890 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1891 { WM_SIZE, sent|defwinproc },
1893 /* restore the 2nd MDI child */
1894 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
1895 { HCBT_MINMAX, hook },
1896 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOZORDER|0x8000 },
1897 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1899 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1901 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1902 { WM_SIZE, sent|defwinproc },
1904 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1906 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
1908 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1909 { WM_NCCALCSIZE, sent|wparam, 1 },
1910 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1911 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1912 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1914 /* bring the 1st MDI child to top */
1915 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1916 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1917 { HCBT_SETFOCUS, hook },
1918 { WM_KILLFOCUS, sent|defwinproc },
1919 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
1920 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1921 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1922 { WM_SETFOCUS, sent }, /* in MDI client */
1923 { HCBT_SETFOCUS, hook },
1924 { WM_KILLFOCUS, sent }, /* in MDI client */
1925 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1926 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1927 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1928 { WM_SETFOCUS, sent|defwinproc },
1929 { WM_MDIACTIVATE, sent|defwinproc },
1930 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1932 /* apparently ShowWindow(SW_SHOW) on an MDI client */
1933 { WM_SHOWWINDOW, sent|wparam, 1 },
1934 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1935 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1936 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1937 { WM_MDIREFRESHMENU, sent },
1939 { HCBT_DESTROYWND, hook },
1940 /* Win2k sends wparam set to
1941 * MAKEWPARAM(WM_DESTROY, 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_DESTROY*/ }, /* in MDI client */
1946 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
1947 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1948 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1949 { WM_ERASEBKGND, sent|parent|optional },
1950 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1952 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1953 { WM_DESTROY, sent|defwinproc },
1954 { WM_NCDESTROY, sent|defwinproc },
1957 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
1958 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
1959 { WM_MDIDESTROY, sent }, /* in MDI client */
1960 { WM_SHOWWINDOW, sent|wparam, 0 },
1961 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1962 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1963 { WM_ERASEBKGND, sent|parent|optional },
1964 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1966 { HCBT_SETFOCUS, hook },
1967 { WM_KILLFOCUS, sent },
1968 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1969 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1970 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1971 { WM_SETFOCUS, sent }, /* in MDI client */
1972 { HCBT_SETFOCUS, hook },
1973 { WM_KILLFOCUS, sent }, /* in MDI client */
1974 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1975 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1976 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1977 { WM_SETFOCUS, sent },
1980 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1981 { WM_NCCALCSIZE, sent|wparam, 1 },
1982 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1983 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1986 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1987 { WM_NCCALCSIZE, sent|wparam, 1 },
1988 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1989 { WM_MOVE, sent|defwinproc },
1990 { WM_SIZE, sent|defwinproc },
1993 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1994 { WM_NCCALCSIZE, sent|wparam, 1 },
1995 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1999 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2000 { WM_NCCALCSIZE, sent|wparam, 1 },
2001 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2002 { WM_SIZE, sent|defwinproc },
2005 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2006 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2007 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2008 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2011 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2012 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2013 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2014 { WM_MOVE, sent|defwinproc },
2015 { WM_SIZE, sent|defwinproc },
2018 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2019 { WM_NCCALCSIZE, sent|wparam, 1 },
2020 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2024 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOZORDER },
2025 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2026 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2027 { WM_SIZE, sent|defwinproc },
2028 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2029 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2031 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2033 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2034 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2035 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2036 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2037 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2040 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2041 { WM_NCCALCSIZE, sent|wparam, 1 },
2042 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2043 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2045 { WM_NCACTIVATE, sent|wparam, 0 },
2046 { WM_MDIACTIVATE, sent },
2048 { HCBT_MINMAX, hook },
2049 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2050 { WM_NCCALCSIZE, sent|wparam, 1 },
2052 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2054 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2055 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE|0x8000 },
2056 { WM_SIZE, sent|defwinproc },
2059 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2060 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2061 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2062 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2065 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2066 { WM_NCCALCSIZE, sent|wparam, 1 },
2067 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2068 { WM_MOVE, sent|defwinproc },
2069 { WM_SIZE, sent|defwinproc },
2072 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2073 { WM_NCCALCSIZE, sent|wparam, 1 },
2074 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2076 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2077 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2078 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2079 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2080 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2082 { HCBT_SETFOCUS, hook },
2083 { WM_KILLFOCUS, sent },
2084 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2085 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2086 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2087 { WM_SETFOCUS, sent }, /* in MDI client */
2089 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2091 { HCBT_DESTROYWND, hook },
2092 /* Win2k sends wparam set to
2093 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2094 * while Win9x doesn't bother to set child window id according to
2095 * CLIENTCREATESTRUCT.idFirstChild
2097 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2099 { WM_SHOWWINDOW, sent|wparam, 0 },
2100 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2101 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2102 { WM_ERASEBKGND, sent|parent|optional },
2103 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2105 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2106 { WM_DESTROY, sent },
2107 { WM_NCDESTROY, sent },
2110 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2111 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2112 { HCBT_MINMAX, hook },
2113 { WM_GETMINMAXINFO, sent },
2114 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2115 { WM_NCCALCSIZE, sent|wparam, 1 },
2116 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2117 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2119 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2120 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2121 { HCBT_SETFOCUS, hook },
2122 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2123 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2124 { WM_SETFOCUS, sent }, /* in MDI client */
2125 { HCBT_SETFOCUS, hook },
2126 { WM_KILLFOCUS, sent }, /* in MDI client */
2127 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2128 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2129 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2130 { WM_SETFOCUS, sent|defwinproc },
2131 { WM_MDIACTIVATE, sent|defwinproc },
2132 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2133 { WM_SIZE, sent|defwinproc },
2135 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2136 { WM_NCCALCSIZE, sent|wparam, 1 },
2137 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2138 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2139 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2142 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2143 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2144 { HCBT_MINMAX, hook },
2145 { WM_GETMINMAXINFO, sent },
2146 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2147 { WM_NCCALCSIZE, sent|wparam, 1 },
2148 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2149 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2150 { WM_SIZE, sent|defwinproc },
2152 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2153 { WM_NCCALCSIZE, sent|wparam, 1 },
2154 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2155 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2156 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2159 /* ShowWindow(SW_RESTORE) for a visible MDI child window */
2160 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2161 { HCBT_MINMAX, hook },
2162 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2163 { WM_NCCALCSIZE, sent|wparam, 1 },
2164 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2165 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2166 { WM_SIZE, sent|defwinproc },
2168 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2169 { WM_NCCALCSIZE, sent|wparam, 1 },
2170 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2171 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2172 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2175 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2176 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2177 { HCBT_MINMAX, hook },
2178 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2179 { WM_NCCALCSIZE, sent|wparam, 1 },
2180 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2181 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2182 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2183 { WM_SIZE, sent|defwinproc },
2185 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2186 { WM_NCCALCSIZE, sent|wparam, 1 },
2187 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2188 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2189 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2193 static HWND mdi_client;
2194 static WNDPROC old_mdi_client_proc;
2196 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2200 /* do not log painting messages */
2201 if (message != WM_PAINT &&
2202 message != WM_ERASEBKGND &&
2203 message != WM_NCPAINT &&
2204 message != WM_NCHITTEST &&
2205 message != WM_GETTEXT &&
2206 message != WM_MDIGETACTIVE &&
2207 message != WM_GETICON &&
2208 message != WM_DEVICECHANGE)
2210 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2214 case WM_WINDOWPOSCHANGING:
2215 case WM_WINDOWPOSCHANGED:
2217 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2219 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2220 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2221 winpos->hwnd, winpos->hwndInsertAfter,
2222 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2224 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2225 * in the high word for internal purposes
2227 wParam = winpos->flags & 0xffff;
2232 msg.message = message;
2233 msg.flags = sent|wparam|lparam;
2234 msg.wParam = wParam;
2235 msg.lParam = lParam;
2239 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2242 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2244 static long defwndproc_counter = 0;
2248 /* do not log painting messages */
2249 if (message != WM_PAINT &&
2250 message != WM_ERASEBKGND &&
2251 message != WM_NCPAINT &&
2252 message != WM_NCHITTEST &&
2253 message != WM_GETTEXT &&
2254 message != WM_GETICON &&
2255 message != WM_DEVICECHANGE)
2257 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2261 case WM_WINDOWPOSCHANGING:
2262 case WM_WINDOWPOSCHANGED:
2264 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2266 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2267 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2268 winpos->hwnd, winpos->hwndInsertAfter,
2269 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2271 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2272 * in the high word for internal purposes
2274 wParam = winpos->flags & 0xffff;
2278 case WM_MDIACTIVATE:
2280 HWND active, client = GetParent(hwnd);
2282 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2284 if (hwnd == (HWND)lParam) /* if we are being activated */
2285 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2287 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2292 msg.message = message;
2293 msg.flags = sent|wparam|lparam;
2294 if (defwndproc_counter) msg.flags |= defwinproc;
2295 msg.wParam = wParam;
2296 msg.lParam = lParam;
2300 defwndproc_counter++;
2301 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2302 defwndproc_counter--;
2307 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2309 static long defwndproc_counter = 0;
2313 /* do not log painting messages */
2314 if (message != WM_PAINT &&
2315 message != WM_ERASEBKGND &&
2316 message != WM_NCPAINT &&
2317 message != WM_NCHITTEST &&
2318 message != WM_GETTEXT &&
2319 message != WM_GETICON &&
2320 message != WM_DEVICECHANGE)
2322 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2326 case WM_WINDOWPOSCHANGING:
2327 case WM_WINDOWPOSCHANGED:
2329 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2331 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2332 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2333 winpos->hwnd, winpos->hwndInsertAfter,
2334 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2336 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2337 * in the high word for internal purposes
2339 wParam = winpos->flags & 0xffff;
2344 msg.message = message;
2345 msg.flags = sent|wparam|lparam;
2346 if (defwndproc_counter) msg.flags |= defwinproc;
2347 msg.wParam = wParam;
2348 msg.lParam = lParam;
2352 defwndproc_counter++;
2353 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2354 defwndproc_counter--;
2359 static BOOL mdi_RegisterWindowClasses(void)
2364 cls.lpfnWndProc = mdi_frame_wnd_proc;
2367 cls.hInstance = GetModuleHandleA(0);
2369 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2370 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2371 cls.lpszMenuName = NULL;
2372 cls.lpszClassName = "MDI_frame_class";
2373 if (!RegisterClassA(&cls)) return FALSE;
2375 cls.lpfnWndProc = mdi_child_wnd_proc;
2376 cls.lpszClassName = "MDI_child_class";
2377 if (!RegisterClassA(&cls)) return FALSE;
2379 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2380 old_mdi_client_proc = cls.lpfnWndProc;
2381 cls.hInstance = GetModuleHandleA(0);
2382 cls.lpfnWndProc = mdi_client_hook_proc;
2383 cls.lpszClassName = "MDI_client_class";
2384 if (!RegisterClassA(&cls)) assert(0);
2389 static void test_mdi_messages(void)
2391 MDICREATESTRUCTA mdi_cs;
2392 CLIENTCREATESTRUCT client_cs;
2393 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2395 HMENU hMenu = CreateMenu();
2397 assert(mdi_RegisterWindowClasses());
2401 trace("creating MDI frame window\n");
2402 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2403 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2404 WS_MAXIMIZEBOX | WS_VISIBLE,
2405 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2406 GetDesktopWindow(), hMenu,
2407 GetModuleHandleA(0), NULL);
2409 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", TRUE);
2411 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2412 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2414 trace("creating MDI client window\n");
2415 client_cs.hWindowMenu = 0;
2416 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2417 mdi_client = CreateWindowExA(0, "MDI_client_class",
2419 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2421 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2423 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2425 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2426 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2428 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2429 ok(!active_child, "wrong active MDI child %p\n", active_child);
2430 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2435 trace("creating invisible MDI child window\n");
2436 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2438 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2439 mdi_client, 0, GetModuleHandleA(0), NULL);
2443 ShowWindow(mdi_child, SW_SHOWNORMAL);
2444 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
2446 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2447 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2449 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2450 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2452 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2453 ok(!active_child, "wrong active MDI child %p\n", active_child);
2454 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2456 ShowWindow(mdi_child, SW_HIDE);
2457 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
2460 ShowWindow(mdi_child, SW_SHOW);
2461 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
2463 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2464 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2466 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2467 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2469 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2470 ok(!active_child, "wrong active MDI child %p\n", active_child);
2471 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2473 DestroyWindow(mdi_child);
2476 trace("creating visible MDI child window\n");
2477 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2478 WS_CHILD | WS_VISIBLE,
2479 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2480 mdi_client, 0, GetModuleHandleA(0), NULL);
2482 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
2484 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2485 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2487 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2488 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2490 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2491 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2492 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2495 DestroyWindow(mdi_child);
2496 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2498 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2499 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2501 /* Win2k: MDI client still returns a just destroyed child as active
2502 * Win9x: MDI client returns 0
2504 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2505 ok(active_child == mdi_child || /* win2k */
2506 !active_child, /* win9x */
2507 "wrong active MDI child %p\n", active_child);
2508 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2512 trace("creating invisible MDI child window\n");
2513 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2515 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2516 mdi_client, 0, GetModuleHandleA(0), NULL);
2518 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
2520 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
2521 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
2523 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2524 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2526 /* Win2k: MDI client still returns a just destroyed child as active
2527 * Win9x: MDI client returns mdi_child2
2529 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2530 ok(active_child == mdi_child || /* win2k */
2531 active_child == mdi_child2, /* win9x */
2532 "wrong active MDI child %p\n", active_child);
2533 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2536 ShowWindow(mdi_child2, SW_MAXIMIZE);
2537 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", TRUE);
2539 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2540 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2542 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2543 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2544 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2547 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2548 ok(GetFocus() == mdi_child2 || /* win2k */
2549 GetFocus() == 0, /* win9x */
2550 "wrong focus window %p\n", GetFocus());
2555 ShowWindow(mdi_child2, SW_HIDE);
2556 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2558 ShowWindow(mdi_child2, SW_RESTORE);
2559 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", TRUE);
2562 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2563 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2565 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2566 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2567 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2573 ShowWindow(mdi_child2, SW_HIDE);
2574 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2576 ShowWindow(mdi_child2, SW_SHOW);
2577 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
2579 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2580 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2582 ShowWindow(mdi_child2, SW_MAXIMIZE);
2583 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", TRUE);
2585 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2586 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2588 ShowWindow(mdi_child2, SW_RESTORE);
2589 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):MDI child", TRUE);
2591 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2592 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2597 ShowWindow(mdi_child2, SW_HIDE);
2598 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2600 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2601 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2603 DestroyWindow(mdi_child2);
2604 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
2606 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2607 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2609 /* test for maximized MDI children */
2610 trace("creating maximized visible MDI child window 1\n");
2611 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2612 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2613 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2614 mdi_client, 0, GetModuleHandleA(0), NULL);
2616 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
2617 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2619 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2620 ok(GetFocus() == mdi_child || /* win2k */
2621 GetFocus() == 0, /* win9x */
2622 "wrong focus window %p\n", GetFocus());
2624 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2625 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2626 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2629 trace("creating maximized visible MDI child window 2\n");
2630 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2631 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2632 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2633 mdi_client, 0, GetModuleHandleA(0), NULL);
2635 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2636 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2637 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2639 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2640 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2642 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2643 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2644 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2647 trace("destroying maximized visible MDI child window 2\n");
2648 DestroyWindow(mdi_child2);
2649 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2651 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2653 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2654 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2656 /* Win2k: MDI client still returns a just destroyed child as active
2657 * Win9x: MDI client returns 0
2659 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2660 ok(active_child == mdi_child2 || /* win2k */
2661 !active_child, /* win9x */
2662 "wrong active MDI child %p\n", active_child);
2665 ShowWindow(mdi_child, SW_MAXIMIZE);
2666 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2669 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2670 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2672 trace("re-creating maximized visible MDI child window 2\n");
2673 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2674 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2675 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2676 mdi_client, 0, GetModuleHandleA(0), NULL);
2678 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2679 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2680 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2682 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2683 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2685 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2686 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2687 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2690 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
2691 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
2692 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
2694 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2695 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2696 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2698 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2699 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2700 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2703 DestroyWindow(mdi_child);
2704 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2706 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2707 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2709 /* Win2k: MDI client still returns a just destroyed child as active
2710 * Win9x: MDI client returns 0
2712 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2713 ok(active_child == mdi_child || /* win2k */
2714 !active_child, /* win9x */
2715 "wrong active MDI child %p\n", active_child);
2717 /* end of test for maximized MDI children */
2719 mdi_cs.szClass = "MDI_child_Class";
2720 mdi_cs.szTitle = "MDI child";
2721 mdi_cs.hOwner = GetModuleHandleA(0);
2724 mdi_cs.cx = CW_USEDEFAULT;
2725 mdi_cs.cy = CW_USEDEFAULT;
2726 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
2728 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
2729 ok(mdi_child != 0, "MDI child creation failed\n");
2730 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
2732 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
2734 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2735 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2737 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
2738 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2739 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2741 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2742 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2743 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2746 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
2747 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
2749 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
2750 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2751 ok(!active_child, "wrong active MDI child %p\n", active_child);
2756 DestroyWindow(mdi_client);
2757 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
2759 DestroyWindow(mdi_frame);
2760 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
2762 /************************* End of MDI test **********************************/
2764 static void test_WM_SETREDRAW(HWND hwnd)
2766 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
2770 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
2771 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
2773 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
2774 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
2777 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
2778 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
2780 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
2781 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
2783 /* restore original WS_VISIBLE state */
2784 SetWindowLongA(hwnd, GWL_STYLE, style);
2789 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2793 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2795 /* explicitly ignore WM_GETICON message */
2796 if (message == WM_GETICON) return 0;
2800 case WM_WINDOWPOSCHANGING:
2801 case WM_WINDOWPOSCHANGED:
2803 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2805 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2806 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2807 winpos->hwnd, winpos->hwndInsertAfter,
2808 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2810 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2811 * in the high word for internal purposes
2813 wParam = winpos->flags & 0xffff;
2818 msg.message = message;
2819 msg.flags = sent|wparam|lparam;
2820 msg.wParam = wParam;
2821 msg.lParam = lParam;
2824 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
2825 if (message == WM_TIMER) EndDialog( hwnd, 0 );
2829 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
2831 DWORD style, exstyle;
2835 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2836 style = GetWindowLongA(hwnd, GWL_STYLE);
2837 /* do not be confused by WS_DLGFRAME set */
2838 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
2840 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
2841 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
2843 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
2844 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
2845 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
2846 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
2848 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
2850 style = GetWindowLongA(hwnd, GWL_STYLE);
2851 if (set) ok(style & set, "style %08lx should be set\n", set);
2852 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
2854 /* a subsequent call should do nothing */
2855 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
2856 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
2857 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2861 trace("Ignore GetScrollRange error below if you are on Win9x\n");
2862 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
2863 ok( ret, "GetScrollRange(%d) error %ld\n", ctl, GetLastError());
2864 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2865 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
2866 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
2869 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
2871 DWORD style, exstyle;
2875 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2876 style = GetWindowLongA(hwnd, GWL_STYLE);
2877 /* do not be confused by WS_DLGFRAME set */
2878 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
2880 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
2881 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
2883 si.cbSize = sizeof(si);
2884 si.fMask = SIF_RANGE;
2887 SetScrollInfo(hwnd, ctl, &si, TRUE);
2888 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
2889 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
2891 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
2893 style = GetWindowLongA(hwnd, GWL_STYLE);
2894 if (set) ok(style & set, "style %08lx should be set\n", set);
2895 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
2897 /* a subsequent call should do nothing */
2898 SetScrollInfo(hwnd, ctl, &si, TRUE);
2899 if (style & WS_HSCROLL)
2900 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2901 else if (style & WS_VSCROLL)
2902 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2904 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2906 si.fMask = SIF_PAGE;
2908 SetScrollInfo(hwnd, ctl, &si, FALSE);
2909 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2913 SetScrollInfo(hwnd, ctl, &si, FALSE);
2914 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
2916 si.fMask = SIF_RANGE;
2917 si.nMin = 0xdeadbeef;
2918 si.nMax = 0xdeadbeef;
2919 ret = GetScrollInfo(hwnd, ctl, &si);
2920 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
2921 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2922 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
2923 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
2926 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
2927 static void test_scroll_messages(HWND hwnd)
2935 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
2936 ok( ret, "GetScrollRange error %ld\n", GetLastError());
2937 if (sequence->message != WmGetScrollRangeSeq[0].message)
2938 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
2939 /* values of min and max are undefined */
2942 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
2943 ok( ret, "SetScrollRange error %ld\n", GetLastError());
2944 if (sequence->message != WmSetScrollRangeSeq[0].message)
2945 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
2950 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
2951 ok( ret, "GetScrollRange error %ld\n", GetLastError());
2952 if (sequence->message != WmGetScrollRangeSeq[0].message)
2953 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
2954 /* values of min and max are undefined */
2957 si.cbSize = sizeof(si);
2958 si.fMask = SIF_RANGE;
2961 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
2962 if (sequence->message != WmSetScrollRangeSeq[0].message)
2963 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2966 si.fMask = SIF_PAGE;
2968 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
2969 if (sequence->message != WmSetScrollRangeSeq[0].message)
2970 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2975 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
2976 if (sequence->message != WmSetScrollRangeSeq[0].message)
2977 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2980 si.fMask = SIF_RANGE;
2981 si.nMin = 0xdeadbeef;
2982 si.nMax = 0xdeadbeef;
2983 ret = GetScrollInfo(hwnd, SB_CTL, &si);
2984 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
2985 if (sequence->message != WmGetScrollInfoSeq[0].message)
2986 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
2987 /* values of min and max are undefined */
2990 /* set WS_HSCROLL */
2991 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
2992 /* clear WS_HSCROLL */
2993 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
2995 /* set WS_HSCROLL */
2996 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
2997 /* clear WS_HSCROLL */
2998 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3000 /* set WS_VSCROLL */
3001 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3002 /* clear WS_VSCROLL */
3003 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3005 /* set WS_VSCROLL */
3006 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3007 /* clear WS_VSCROLL */
3008 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3011 static void test_showwindow(void)
3016 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3017 100, 100, 200, 200, 0, 0, 0, NULL);
3018 ok (hwnd != 0, "Failed to create overlapped window\n");
3019 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3020 0, 0, 10, 10, hwnd, 0, 0, NULL);
3021 ok (hchild != 0, "Failed to create child\n");
3024 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3025 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3026 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3027 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3030 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3031 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3032 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3033 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3035 /* back to invisible */
3036 ShowWindow(hchild, SW_HIDE);
3037 ShowWindow(hwnd, SW_HIDE);
3039 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3040 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3041 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3042 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3044 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3045 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3047 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3048 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3049 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3051 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3052 ShowWindow( hwnd, SW_SHOW);
3054 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3055 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3056 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3059 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3060 ShowWindow( hchild, SW_HIDE);
3062 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3063 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3064 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3068 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3069 DestroyWindow(hchild);
3070 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3072 DestroyWindow(hwnd);
3077 * 1. Create invisible maximized popup window.
3078 * 2. Move and resize it.
3079 * 3. Show it maximized.
3081 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3082 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3083 100, 100, 200, 200, 0, 0, 0, NULL);
3084 ok (hwnd != 0, "Failed to create popup window\n");
3085 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3088 GetWindowRect(hwnd, &rc);
3089 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3090 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3091 "Invalid maximized size before ShowWindow (%ld,%ld)-(%ld,%ld)\n",
3092 rc.left, rc.top, rc.right, rc.bottom);
3093 /* Reset window's size & position */
3094 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3097 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible popup window\n");
3098 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3099 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3102 GetWindowRect(hwnd, &rc);
3103 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3104 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3105 "Invalid maximized size after ShowWindow (%ld,%ld)-(%ld,%ld)\n",
3106 rc.left, rc.top, rc.right, rc.bottom);
3107 DestroyWindow(hwnd);
3111 * 1. Create invisible maximized popup window.
3112 * 2. Show it maximized.
3114 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3115 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3116 100, 100, 200, 200, 0, 0, 0, NULL);
3117 ok (hwnd != 0, "Failed to create popup window\n");
3118 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3121 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible popup window\n");
3122 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3123 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3125 DestroyWindow(hwnd);
3129 * 1. Create visible maximized popup window.
3131 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3132 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3133 100, 100, 200, 200, 0, 0, 0, NULL);
3134 ok (hwnd != 0, "Failed to create popup window\n");
3135 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3137 DestroyWindow(hwnd);
3141 * 1. Create visible popup window.
3144 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3145 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3146 100, 100, 200, 200, 0, 0, 0, NULL);
3147 ok (hwnd != 0, "Failed to create popup window\n");
3148 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", TRUE);
3151 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3152 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3153 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", TRUE);
3155 DestroyWindow(hwnd);
3159 static void test_sys_menu(HWND hwnd)
3164 /* test existing window without CS_NOCLOSE style */
3165 hmenu = GetSystemMenu(hwnd, FALSE);
3166 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
3168 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3169 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3170 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3172 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3173 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3175 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3176 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3177 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3179 EnableMenuItem(hmenu, SC_CLOSE, 0);
3180 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3182 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3183 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3184 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3186 /* test new window with CS_NOCLOSE style */
3187 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3188 100, 100, 200, 200, 0, 0, 0, NULL);
3189 ok (hwnd != 0, "Failed to create overlapped window\n");
3191 hmenu = GetSystemMenu(hwnd, FALSE);
3192 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
3194 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3195 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3197 DestroyWindow(hwnd);
3200 /* test if we receive the right sequence of messages */
3201 static void test_messages(void)
3203 HWND hwnd, hparent, hchild;
3204 HWND hchild2, hbutton;
3211 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3212 100, 100, 200, 200, 0, 0, 0, NULL);
3213 ok (hwnd != 0, "Failed to create overlapped window\n");
3214 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3216 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3217 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
3218 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
3220 /* test WM_SETREDRAW on a not visible top level window */
3221 test_WM_SETREDRAW(hwnd);
3223 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3224 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
3225 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
3227 ok(GetActiveWindow() == hwnd, "window should be active\n");
3228 ok(GetFocus() == hwnd, "window should have input focus\n");
3229 ShowWindow(hwnd, SW_HIDE);
3230 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
3232 ShowWindow(hwnd, SW_SHOW);
3233 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
3235 ShowWindow(hwnd, SW_HIDE);
3236 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
3238 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3239 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
3241 ShowWindow(hwnd, SW_RESTORE);
3242 /* FIXME: add ok_sequence() here */
3245 ShowWindow(hwnd, SW_SHOW);
3246 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
3248 ok(GetActiveWindow() == hwnd, "window should be active\n");
3249 ok(GetFocus() == hwnd, "window should have input focus\n");
3250 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3251 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
3252 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
3253 ok(GetActiveWindow() == hwnd, "window should still be active\n");
3255 /* test WM_SETREDRAW on a visible top level window */
3256 ShowWindow(hwnd, SW_SHOW);
3257 test_WM_SETREDRAW(hwnd);
3259 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
3260 test_scroll_messages(hwnd);
3262 /* test resizing and moving */
3263 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3264 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
3265 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE );
3266 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
3268 /* popups don't get WM_GETMINMAXINFO */
3269 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
3270 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3272 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3273 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
3275 test_sys_menu(hwnd);
3278 DestroyWindow(hwnd);
3279 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
3281 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3282 100, 100, 200, 200, 0, 0, 0, NULL);
3283 ok (hparent != 0, "Failed to create parent window\n");
3286 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
3287 0, 0, 10, 10, hparent, 0, 0, NULL);
3288 ok (hchild != 0, "Failed to create child window\n");
3289 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", TRUE);
3290 DestroyWindow(hchild);
3293 /* visible child window with a caption */
3294 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
3295 WS_CHILD | WS_VISIBLE | WS_CAPTION,
3296 0, 0, 10, 10, hparent, 0, 0, NULL);
3297 ok (hchild != 0, "Failed to create child window\n");
3298 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
3300 trace("testing scroll APIs on a visible child window %p\n", hchild);
3301 test_scroll_messages(hchild);
3303 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3304 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
3306 DestroyWindow(hchild);
3309 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3310 0, 0, 10, 10, hparent, 0, 0, NULL);
3311 ok (hchild != 0, "Failed to create child window\n");
3312 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3314 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
3315 100, 100, 50, 50, hparent, 0, 0, NULL);
3316 ok (hchild2 != 0, "Failed to create child2 window\n");
3319 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
3320 0, 100, 50, 50, hchild, 0, 0, NULL);
3321 ok (hbutton != 0, "Failed to create button window\n");
3323 /* test WM_SETREDRAW on a not visible child window */
3324 test_WM_SETREDRAW(hchild);
3326 ShowWindow(hchild, SW_SHOW);
3327 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3329 ShowWindow(hchild, SW_HIDE);
3330 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
3332 ShowWindow(hchild, SW_SHOW);
3333 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3335 /* test WM_SETREDRAW on a visible child window */
3336 test_WM_SETREDRAW(hchild);
3338 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
3339 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
3341 ShowWindow(hchild, SW_HIDE);
3343 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3344 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
3346 ShowWindow(hchild, SW_HIDE);
3348 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3349 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
3351 /* DestroyWindow sequence below expects that a child has focus */
3355 DestroyWindow(hchild);
3356 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
3357 DestroyWindow(hchild2);
3358 DestroyWindow(hbutton);
3361 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
3362 0, 0, 100, 100, hparent, 0, 0, NULL);
3363 ok (hchild != 0, "Failed to create child popup window\n");
3364 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
3365 DestroyWindow(hchild);
3367 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3369 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
3370 0, 0, 100, 100, hparent, 0, 0, NULL);
3371 ok (hchild != 0, "Failed to create popup window\n");
3372 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3373 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3374 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3376 ShowWindow(hchild, SW_SHOW);
3377 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3379 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3380 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3382 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3383 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
3384 DestroyWindow(hchild);
3386 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3387 * changes nothing in message sequences.
3390 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
3391 0, 0, 100, 100, hparent, 0, 0, NULL);
3392 ok (hchild != 0, "Failed to create popup window\n");
3393 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3394 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3395 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3397 ShowWindow(hchild, SW_SHOW);
3398 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3400 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3401 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3402 DestroyWindow(hchild);
3405 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
3406 0, 0, 100, 100, hparent, 0, 0, NULL);
3407 ok(hwnd != 0, "Failed to create custom dialog window\n");
3408 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
3411 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3412 test_scroll_messages(hwnd);
3416 after_end_dialog = 1;
3417 EndDialog( hwnd, 0 );
3418 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
3420 DestroyWindow(hwnd);
3421 after_end_dialog = 0;
3423 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
3424 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
3425 ok(hwnd != 0, "Failed to create custom dialog window\n");
3427 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
3428 ShowWindow(hwnd, SW_SHOW);
3429 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
3430 DestroyWindow(hwnd);
3433 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
3434 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
3436 /* test showing child with hidden parent */
3437 ShowWindow( hparent, SW_HIDE );
3440 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3441 0, 0, 10, 10, hparent, 0, 0, NULL);
3442 ok (hchild != 0, "Failed to create child window\n");
3443 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3445 ShowWindow( hchild, SW_SHOW );
3446 ok_sequence(WmShowChildInvisibleParentSeq, "ShowWindow:show child with invisible parent", FALSE);
3447 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3448 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3450 ShowWindow( hchild, SW_HIDE );
3451 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
3452 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
3453 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3455 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3456 ok_sequence(WmShowChildInvisibleParentSeq_2, "SetWindowPos:show child with invisible parent", FALSE);
3457 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3458 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3460 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3461 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
3462 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
3463 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3465 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3467 DestroyWindow(hchild);
3468 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
3470 DestroyWindow(hparent);
3473 /* Message sequence for SetMenu */
3474 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
3475 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
3477 hmenu = CreateMenu();
3478 ok (hmenu != 0, "Failed to create menu\n");
3479 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
3480 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3481 100, 100, 200, 200, 0, hmenu, 0, NULL);
3482 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3483 ok (SetMenu(hwnd, 0), "SetMenu\n");
3484 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
3485 ok (SetMenu(hwnd, 0), "SetMenu\n");
3486 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
3487 ShowWindow(hwnd, SW_SHOW);
3488 UpdateWindow( hwnd );
3489 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3491 ok (SetMenu(hwnd, 0), "SetMenu\n");
3492 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
3493 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
3494 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
3496 UpdateWindow( hwnd );
3497 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3499 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
3500 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3501 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
3503 DestroyWindow(hwnd);
3506 /* Message sequence for EnableWindow */
3507 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3508 100, 100, 200, 200, 0, 0, 0, NULL);
3509 ok (hparent != 0, "Failed to create parent window\n");
3510 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
3511 0, 0, 10, 10, hparent, 0, 0, NULL);
3512 ok (hchild != 0, "Failed to create child window\n");
3517 EnableWindow(hparent, FALSE);
3518 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
3520 EnableWindow(hparent, TRUE);
3521 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
3523 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3526 /* MsgWaitForMultipleObjects test */
3527 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3528 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3530 PostMessageA(hparent, WM_USER, 0, 0);
3532 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3533 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %lx\n", ret);
3535 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3536 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3538 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3539 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3540 /* end of MsgWaitForMultipleObjects test */
3542 /* the following test causes an exception in user.exe under win9x */
3543 if (!PostMessageW( hparent, WM_USER, 0, 0 )) return;
3544 PostMessageW( hparent, WM_USER+1, 0, 0 );
3545 /* PeekMessage(NULL) fails, but still removes the message */
3546 SetLastError(0xdeadbeef);
3547 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
3548 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
3549 GetLastError() == 0xdeadbeef, /* NT4 */
3550 "last error is %ld\n", GetLastError() );
3551 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
3552 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
3554 DestroyWindow(hchild);
3555 DestroyWindow(hparent);
3561 /****************** button message test *************************/
3562 static const struct message WmSetFocusButtonSeq[] =
3564 { HCBT_SETFOCUS, hook },
3565 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3566 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3567 { WM_SETFOCUS, sent|wparam, 0 },
3568 { WM_CTLCOLORBTN, sent|defwinproc },
3571 static const struct message WmKillFocusButtonSeq[] =
3573 { HCBT_SETFOCUS, hook },
3574 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3575 { WM_KILLFOCUS, sent|wparam, 0 },
3576 { WM_CTLCOLORBTN, sent|defwinproc },
3577 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3580 static const struct message WmSetFocusStaticSeq[] =
3582 { HCBT_SETFOCUS, hook },
3583 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3584 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3585 { WM_SETFOCUS, sent|wparam, 0 },
3586 { WM_CTLCOLORSTATIC, sent|defwinproc },
3589 static const struct message WmKillFocusStaticSeq[] =
3591 { HCBT_SETFOCUS, hook },
3592 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3593 { WM_KILLFOCUS, sent|wparam, 0 },
3594 { WM_CTLCOLORSTATIC, sent|defwinproc },
3595 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3598 static const struct message WmLButtonDownSeq[] =
3600 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
3601 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
3602 { HCBT_SETFOCUS, hook },
3603 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3604 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3605 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
3606 { WM_CTLCOLORBTN, sent|defwinproc },
3607 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
3608 { WM_CTLCOLORBTN, sent|defwinproc },
3609 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3612 static const struct message WmLButtonUpSeq[] =
3614 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
3615 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
3616 { WM_CTLCOLORBTN, sent|defwinproc },
3617 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3618 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
3619 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
3623 static WNDPROC old_button_proc;
3625 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3627 static long defwndproc_counter = 0;
3631 trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3633 /* explicitly ignore WM_GETICON message */
3634 if (message == WM_GETICON) return 0;
3636 msg.message = message;
3637 msg.flags = sent|wparam|lparam;
3638 if (defwndproc_counter) msg.flags |= defwinproc;
3639 msg.wParam = wParam;
3640 msg.lParam = lParam;
3643 if (message == BM_SETSTATE)
3644 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
3646 defwndproc_counter++;
3647 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
3648 defwndproc_counter--;
3653 static void subclass_button(void)
3657 if (!GetClassInfoA(0, "button", &cls)) assert(0);
3659 old_button_proc = cls.lpfnWndProc;
3661 cls.hInstance = GetModuleHandle(0);
3662 cls.lpfnWndProc = button_hook_proc;
3663 cls.lpszClassName = "my_button_class";
3664 if (!RegisterClassA(&cls)) assert(0);
3667 static void test_button_messages(void)
3673 const struct message *setfocus;
3674 const struct message *killfocus;
3676 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
3677 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3678 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
3679 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3680 { BS_CHECKBOX, DLGC_BUTTON,
3681 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3682 { BS_AUTOCHECKBOX, DLGC_BUTTON,
3683 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3684 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
3685 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3686 { BS_3STATE, DLGC_BUTTON,
3687 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3688 { BS_AUTO3STATE, DLGC_BUTTON,
3689 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3690 { BS_GROUPBOX, DLGC_STATIC,
3691 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3692 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
3693 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3694 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
3695 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3696 { BS_OWNERDRAW, DLGC_BUTTON,
3697 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
3705 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
3707 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
3708 0, 0, 50, 14, 0, 0, 0, NULL);
3709 ok(hwnd != 0, "Failed to create button window\n");
3711 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
3712 ok(dlg_code == button[i].dlg_code, "%d: wrong dlg_code %08lx\n", i, dlg_code);
3714 ShowWindow(hwnd, SW_SHOW);
3719 trace("button style %08lx\n", button[i].style);
3721 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
3724 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
3726 DestroyWindow(hwnd);
3729 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
3730 0, 0, 50, 14, 0, 0, 0, NULL);
3731 ok(hwnd != 0, "Failed to create button window\n");
3736 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
3737 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
3739 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
3740 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
3741 DestroyWindow(hwnd);
3744 /************* painting message test ********************/
3746 void dump_region(HRGN hrgn)
3749 RGNDATA *data = NULL;
3754 printf( "null region\n" );
3757 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
3758 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
3759 GetRegionData( hrgn, size, data );
3760 printf("%ld rects:", data->rdh.nCount );
3761 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
3762 printf( " (%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
3764 HeapFree( GetProcessHeap(), 0, data );
3767 static void check_update_rgn( HWND hwnd, HRGN hrgn )
3771 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
3772 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
3774 ret = GetUpdateRgn( hwnd, update, FALSE );
3775 ok( ret != ERROR, "GetUpdateRgn failed\n" );
3776 if (ret == NULLREGION)
3778 ok( !hrgn, "Update region shouldn't be empty\n" );
3782 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
3784 ok( 0, "Regions are different\n" );
3785 if (winetest_debug > 0)
3787 printf( "Update region: " );
3788 dump_region( update );
3789 printf( "Wanted region: " );
3790 dump_region( hrgn );
3794 GetRgnBox( update, &r1 );
3795 GetUpdateRect( hwnd, &r2, FALSE );
3796 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
3797 "Rectangles are different: %ld,%ld-%ld,%ld / %ld,%ld-%ld,%ld\n",
3798 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
3800 DeleteObject( tmp );
3801 DeleteObject( update );
3804 static const struct message WmInvalidateRgn[] = {
3805 { WM_NCPAINT, sent },
3806 { WM_GETTEXT, sent|defwinproc|optional },
3810 static const struct message WmGetUpdateRect[] = {
3811 { WM_NCPAINT, sent },
3812 { WM_GETTEXT, sent|defwinproc|optional },
3817 static const struct message WmInvalidateFull[] = {
3818 { WM_NCPAINT, sent|wparam, 1 },
3819 { WM_GETTEXT, sent|defwinproc|optional },
3823 static const struct message WmInvalidateErase[] = {
3824 { WM_NCPAINT, sent|wparam, 1 },
3825 { WM_GETTEXT, sent|defwinproc|optional },
3826 { WM_ERASEBKGND, sent },
3830 static const struct message WmInvalidatePaint[] = {
3832 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
3833 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3837 static const struct message WmInvalidateErasePaint[] = {
3839 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
3840 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3841 { WM_ERASEBKGND, sent|beginpaint },
3845 static const struct message WmInvalidateErasePaint2[] = {
3847 { WM_NCPAINT, sent|beginpaint },
3848 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3849 { WM_ERASEBKGND, sent|beginpaint },
3853 static const struct message WmErase[] = {
3854 { WM_ERASEBKGND, sent },
3858 static const struct message WmPaint[] = {
3863 static const struct message WmParentOnlyPaint[] = {
3864 { WM_PAINT, sent|parent },
3868 static const struct message WmInvalidateParent[] = {
3869 { WM_NCPAINT, sent|parent },
3870 { WM_GETTEXT, sent|defwinproc|parent|optional },
3871 { WM_ERASEBKGND, sent|parent },
3875 static const struct message WmInvalidateParentChild[] = {
3876 { WM_NCPAINT, sent|parent },
3877 { WM_GETTEXT, sent|defwinproc|parent|optional },
3878 { WM_ERASEBKGND, sent|parent },
3879 { WM_NCPAINT, sent },
3880 { WM_GETTEXT, sent|defwinproc|optional },
3881 { WM_ERASEBKGND, sent },
3885 static const struct message WmInvalidateParentChild2[] = {
3886 { WM_ERASEBKGND, sent|parent },
3887 { WM_NCPAINT, sent },
3888 { WM_GETTEXT, sent|defwinproc|optional },
3889 { WM_ERASEBKGND, sent },
3893 static const struct message WmParentPaint[] = {
3894 { WM_PAINT, sent|parent },
3899 static const struct message WmParentPaintNc[] = {
3900 { WM_PAINT, sent|parent },
3902 { WM_NCPAINT, sent|beginpaint },
3903 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3904 { WM_ERASEBKGND, sent|beginpaint },
3908 static const struct message WmChildPaintNc[] = {
3910 { WM_NCPAINT, sent|beginpaint },
3911 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3912 { WM_ERASEBKGND, sent|beginpaint },
3916 static const struct message WmParentErasePaint[] = {
3917 { WM_PAINT, sent|parent },
3918 { WM_NCPAINT, sent|parent|beginpaint },
3919 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
3920 { WM_ERASEBKGND, sent|parent|beginpaint },
3922 { WM_NCPAINT, sent|beginpaint },
3923 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3924 { WM_ERASEBKGND, sent|beginpaint },
3928 static const struct message WmParentOnlyNcPaint[] = {
3929 { WM_PAINT, sent|parent },
3930 { WM_NCPAINT, sent|parent|beginpaint },
3931 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
3935 static const struct message WmSetParentStyle[] = {
3936 { WM_STYLECHANGING, sent|parent },
3937 { WM_STYLECHANGED, sent|parent },
3941 static void test_paint_messages(void)
3947 HWND hparent, hchild;
3948 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
3949 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
3950 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3951 100, 100, 200, 200, 0, 0, 0, NULL);
3952 ok (hwnd != 0, "Failed to create overlapped window\n");
3954 ShowWindow( hwnd, SW_SHOW );
3955 UpdateWindow( hwnd );
3958 check_update_rgn( hwnd, 0 );
3959 SetRectRgn( hrgn, 10, 10, 20, 20 );
3960 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
3961 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
3962 check_update_rgn( hwnd, hrgn );
3963 SetRectRgn( hrgn2, 20, 20, 30, 30 );
3964 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
3965 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
3966 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
3967 check_update_rgn( hwnd, hrgn );
3968 /* validate everything */
3969 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
3970 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
3971 check_update_rgn( hwnd, 0 );
3973 /* test empty region */
3974 SetRectRgn( hrgn, 10, 10, 10, 15 );
3975 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
3976 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
3977 check_update_rgn( hwnd, 0 );
3978 /* test empty rect */
3979 SetRect( &rect, 10, 10, 10, 15 );
3980 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
3981 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
3982 check_update_rgn( hwnd, 0 );
3984 /* flush pending messages */
3985 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3988 GetClientRect( hwnd, &rect );
3989 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
3990 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
3991 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
3993 trace("testing InvalidateRect(0, NULL, FALSE)\n");
3994 SetRectEmpty( &rect );
3995 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
3996 check_update_rgn( hwnd, hrgn );
3997 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
3998 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3999 ok_sequence( WmPaint, "Paint", FALSE );
4000 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4001 check_update_rgn( hwnd, 0 );
4003 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4004 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4006 trace("testing ValidateRect(0, NULL)\n");
4007 SetRectEmpty( &rect );
4008 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
4009 check_update_rgn( hwnd, hrgn );
4010 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4011 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4012 ok_sequence( WmPaint, "Paint", FALSE );
4013 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4014 check_update_rgn( hwnd, 0 );
4016 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4017 SetLastError(0xdeadbeef);
4018 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4019 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
4020 check_update_rgn( hwnd, 0 );
4021 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4022 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4024 trace("testing ValidateRgn(0, NULL)\n");
4025 SetLastError(0xdeadbeef);
4026 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
4027 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
4028 check_update_rgn( hwnd, 0 );
4029 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4030 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4032 /* now with frame */
4033 SetRectRgn( hrgn, -5, -5, 20, 20 );
4035 /* flush pending messages */
4036 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4039 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4040 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4042 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4043 check_update_rgn( hwnd, hrgn );
4046 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4047 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4050 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4051 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
4053 GetClientRect( hwnd, &rect );
4054 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
4055 check_update_rgn( hwnd, hrgn );
4058 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
4059 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4062 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
4063 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
4064 check_update_rgn( hwnd, 0 );
4067 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
4068 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
4069 check_update_rgn( hwnd, 0 );
4072 SetRectRgn( hrgn, 0, 0, 100, 100 );
4073 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4074 SetRectRgn( hrgn, 0, 0, 50, 100 );
4075 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
4076 SetRectRgn( hrgn, 50, 0, 100, 100 );
4077 check_update_rgn( hwnd, hrgn );
4078 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4079 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
4080 check_update_rgn( hwnd, 0 );
4083 SetRectRgn( hrgn, 0, 0, 100, 100 );
4084 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4085 SetRectRgn( hrgn, 0, 0, 100, 50 );
4086 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4087 ok_sequence( WmErase, "Erase", FALSE );
4088 SetRectRgn( hrgn, 0, 50, 100, 100 );
4089 check_update_rgn( hwnd, hrgn );
4092 SetRectRgn( hrgn, 0, 0, 100, 100 );
4093 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4094 SetRectRgn( hrgn, 0, 0, 50, 50 );
4095 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
4096 ok_sequence( WmPaint, "Paint", FALSE );
4099 SetRectRgn( hrgn, -4, -4, -2, -2 );
4100 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4101 SetRectRgn( hrgn, -200, -200, -198, -198 );
4102 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
4103 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4106 SetRectRgn( hrgn, -4, -4, -2, -2 );
4107 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4108 SetRectRgn( hrgn, -4, -4, -3, -3 );
4109 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
4110 SetRectRgn( hrgn, 0, 0, 1, 1 );
4111 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
4112 ok_sequence( WmPaint, "Paint", FALSE );
4115 SetRectRgn( hrgn, -4, -4, -1, -1 );
4116 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4117 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
4118 /* make sure no WM_PAINT was generated */
4119 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4120 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4123 SetRectRgn( hrgn, -4, -4, -1, -1 );
4124 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4125 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
4127 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
4129 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
4130 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
4131 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
4132 ret = GetUpdateRect( hwnd, &rect, FALSE );
4133 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
4134 /* this will send WM_NCPAINT and validate the non client area */
4135 ret = GetUpdateRect( hwnd, &rect, TRUE );
4136 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
4138 DispatchMessage( &msg );
4140 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
4142 DestroyWindow( hwnd );
4144 /* now test with a child window */
4146 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4147 100, 100, 200, 200, 0, 0, 0, NULL);
4148 ok (hparent != 0, "Failed to create parent window\n");
4150 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
4151 10, 10, 100, 100, hparent, 0, 0, NULL);
4152 ok (hchild != 0, "Failed to create child window\n");
4154 ShowWindow( hparent, SW_SHOW );
4155 UpdateWindow( hparent );
4156 UpdateWindow( hchild );
4159 log_all_parent_messages++;
4161 SetRect( &rect, 0, 0, 50, 50 );
4162 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4163 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4164 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
4166 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4168 MapWindowPoints( hchild, hparent, &pt, 1 );
4169 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
4170 check_update_rgn( hchild, hrgn );
4171 SetRectRgn( hrgn, 0, 0, 50, 50 );
4172 check_update_rgn( hparent, hrgn );
4173 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4174 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
4175 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4176 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4178 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4179 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
4181 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4182 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4183 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
4184 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4185 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4187 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
4188 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4189 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
4191 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4193 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4194 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4195 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
4197 /* flush all paint messages */
4198 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4201 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
4202 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4203 SetRectRgn( hrgn, 0, 0, 50, 50 );
4204 check_update_rgn( hparent, hrgn );
4205 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4206 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4207 SetRectRgn( hrgn, 0, 0, 50, 50 );
4208 check_update_rgn( hparent, hrgn );
4210 /* flush all paint messages */
4211 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4212 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4215 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
4216 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4217 SetRectRgn( hrgn, 0, 0, 50, 50 );
4218 check_update_rgn( hparent, hrgn );
4219 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4220 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4221 SetRectRgn( hrgn2, 10, 10, 50, 50 );
4222 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
4223 check_update_rgn( hparent, hrgn );
4224 /* flush all paint messages */
4225 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4228 /* same as above but parent gets completely validated */
4229 SetRect( &rect, 20, 20, 30, 30 );
4230 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4231 SetRectRgn( hrgn, 20, 20, 30, 30 );
4232 check_update_rgn( hparent, hrgn );
4233 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4234 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4235 check_update_rgn( hparent, 0 ); /* no update region */
4236 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4237 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
4239 /* make sure RDW_VALIDATE on child doesn't have the same effect */
4241 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4242 SetRectRgn( hrgn, 20, 20, 30, 30 );
4243 check_update_rgn( hparent, hrgn );
4244 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
4245 SetRectRgn( hrgn, 20, 20, 30, 30 );
4246 check_update_rgn( hparent, hrgn );
4248 /* same as above but normal WM_PAINT doesn't validate parent */
4250 SetRect( &rect, 20, 20, 30, 30 );
4251 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4252 SetRectRgn( hrgn, 20, 20, 30, 30 );
4253 check_update_rgn( hparent, hrgn );
4254 /* no WM_PAINT in child while parent still pending */
4255 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4256 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4257 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4258 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
4261 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4262 /* no WM_PAINT in child while parent still pending */
4263 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4264 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4265 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
4266 /* now that parent is valid child should get WM_PAINT */
4267 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4268 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4269 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4270 ok_sequence( WmEmptySeq, "No other message", FALSE );
4272 /* same thing with WS_CLIPCHILDREN in parent */
4274 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4275 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4276 /* changing style invalidates non client area, but we need to invalidate something else to see it */
4277 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
4278 ok_sequence( WmEmptySeq, "No message", FALSE );
4279 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
4280 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
4283 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
4284 SetRectRgn( hrgn, 20, 20, 30, 30 );
4285 check_update_rgn( hparent, hrgn );
4286 /* no WM_PAINT in child while parent still pending */
4287 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4288 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4289 /* WM_PAINT in parent first */
4290 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4291 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
4293 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
4295 SetRect( &rect, 0, 0, 30, 30 );
4296 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
4297 SetRectRgn( hrgn, 0, 0, 30, 30 );
4298 check_update_rgn( hparent, hrgn );
4299 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4300 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
4302 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4304 SetRect( &rect, -10, 0, 30, 30 );
4305 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4306 SetRect( &rect, 0, 0, 20, 20 );
4307 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4308 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4309 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
4311 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4313 SetRect( &rect, -10, 0, 30, 30 );
4314 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4315 SetRect( &rect, 0, 0, 100, 100 );
4316 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4317 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4318 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
4319 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4320 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
4322 /* test RDW_INTERNALPAINT behavior */
4325 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
4326 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4327 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4329 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
4330 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4331 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4333 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4334 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4335 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4337 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
4338 UpdateWindow( hparent );
4339 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4341 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
4342 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4343 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4344 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4345 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4346 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
4348 UpdateWindow( hparent );
4349 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4351 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
4352 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4353 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4354 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4355 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4356 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4358 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4359 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4360 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4361 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4362 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4364 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
4365 UpdateWindow( hparent );
4366 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4368 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
4369 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4370 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4371 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4372 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4373 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
4375 UpdateWindow( hparent );
4376 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4378 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
4379 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4380 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4381 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4382 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4383 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4385 log_all_parent_messages--;
4386 DestroyWindow( hparent );
4387 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
4389 DeleteObject( hrgn );
4390 DeleteObject( hrgn2 );
4399 static DWORD WINAPI thread_proc(void *param)
4402 struct wnd_event *wnd_event = (struct wnd_event *)param;
4404 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
4405 100, 100, 200, 200, 0, 0, 0, NULL);
4406 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
4408 SetEvent(wnd_event->event);
4410 while (GetMessage(&msg, 0, 0, 0))
4412 TranslateMessage(&msg);
4413 DispatchMessage(&msg);
4416 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
4421 static void test_interthread_messages(void)
4428 int len, expected_len;
4429 struct wnd_event wnd_event;
4432 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
4433 if (!wnd_event.event)
4435 trace("skipping interthread message test under win9x\n");
4439 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
4440 ok(hThread != NULL, "CreateThread failed, error %ld\n", GetLastError());
4442 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4444 CloseHandle(wnd_event.event);
4446 SetLastError(0xdeadbeef);
4447 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
4448 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %ld\n", GetLastError());
4450 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4451 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %ld\n", GetLastError());
4453 expected_len = lstrlenA("window caption text");
4454 memset(buf, 0, sizeof(buf));
4455 SetLastError(0xdeadbeef);
4456 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
4457 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %ld, len %d, expected len %d\n", GetLastError(), len, expected_len);
4458 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
4460 msg.hwnd = wnd_event.hwnd;
4461 msg.message = WM_GETTEXT;
4462 msg.wParam = sizeof(buf);
4463 msg.lParam = (LPARAM)buf;
4464 memset(buf, 0, sizeof(buf));
4465 SetLastError(0xdeadbeef);
4466 len = DispatchMessageA(&msg);
4467 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
4468 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %ld\n", len, GetLastError());
4470 /* the following test causes an exception in user.exe under win9x */
4471 msg.hwnd = wnd_event.hwnd;
4472 msg.message = WM_TIMER;
4474 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4475 SetLastError(0xdeadbeef);
4476 len = DispatchMessageA(&msg);
4477 ok(!len && GetLastError() == 0xdeadbeef,
4478 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len, GetLastError());
4480 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
4481 ok( ret, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
4483 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4484 CloseHandle(hThread);
4486 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
4490 static const struct message WmVkN[] = {
4491 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4492 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4493 { WM_CHAR, wparam|lparam, 'n', 1 },
4494 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
4495 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4496 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4499 static const struct message WmShiftVkN[] = {
4500 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4501 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4502 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4503 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4504 { WM_CHAR, wparam|lparam, 'N', 1 },
4505 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
4506 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4507 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4508 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4509 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4512 static const struct message WmCtrlVkN[] = {
4513 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4514 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4515 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4516 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4517 { WM_CHAR, wparam|lparam, 0x000e, 1 },
4518 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4519 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4520 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4521 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4522 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4525 static const struct message WmCtrlVkN_2[] = {
4526 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4527 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4528 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4529 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4530 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4531 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4532 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4533 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4536 static const struct message WmAltVkN[] = {
4537 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4538 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4539 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4540 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4541 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
4542 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
4543 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
4544 { HCBT_SYSCOMMAND, hook },
4545 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4546 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4547 { 0x00AE, sent|defwinproc|optional }, /* XP */
4548 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
4549 { WM_INITMENU, sent|defwinproc },
4550 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4551 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
4552 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4553 { WM_CAPTURECHANGED, sent|defwinproc },
4554 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
4555 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4556 { WM_EXITMENULOOP, sent|defwinproc },
4557 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
4558 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
4559 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4560 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4561 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4562 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4565 static const struct message WmAltVkN_2[] = {
4566 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4567 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4568 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4569 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
4570 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4571 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4572 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4573 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4576 static const struct message WmCtrlAltVkN[] = {
4577 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4578 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4579 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4580 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4581 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4582 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4583 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4584 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4585 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4586 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4587 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4588 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4591 static const struct message WmCtrlShiftVkN[] = {
4592 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4593 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4594 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4595 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4596 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4597 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
4598 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4599 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4600 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4601 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4602 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4603 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4606 static const struct message WmCtrlAltShiftVkN[] = {
4607 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4608 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4609 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4610 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4611 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
4612 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
4613 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4614 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
4615 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4616 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4617 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
4618 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
4619 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4620 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4621 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4622 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4625 static const struct message WmAltPressRelease[] = {
4626 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4627 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4628 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4629 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4630 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
4631 { HCBT_SYSCOMMAND, hook },
4632 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4633 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4634 { WM_INITMENU, sent|defwinproc },
4635 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4636 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
4637 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
4639 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4640 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
4641 { WM_CAPTURECHANGED, sent|defwinproc },
4642 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
4643 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4644 { WM_EXITMENULOOP, sent|defwinproc },
4645 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4646 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4649 static const struct message WmAltMouseButton[] = {
4650 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4651 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4652 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
4653 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
4654 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
4655 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
4656 { WM_LBUTTONUP, wparam, 0, 0 },
4657 { WM_LBUTTONUP, sent|wparam, 0, 0 },
4658 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4659 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4662 static const struct message WmF1Seq[] = {
4663 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
4664 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
4665 { 0x4d, wparam|lparam, 0, 0 },
4666 { 0x4d, sent|wparam|lparam, 0, 0 },
4667 { WM_HELP, sent|defwinproc },
4668 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
4669 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
4673 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
4677 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
4679 struct message log_msg;
4681 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
4683 /* ignore some unwanted messages */
4684 if (msg.message == WM_MOUSEMOVE ||
4685 msg.message == WM_GETICON ||
4686 msg.message == WM_DEVICECHANGE)
4689 log_msg.message = msg.message;
4690 log_msg.flags = wparam|lparam;
4691 log_msg.wParam = msg.wParam;
4692 log_msg.lParam = msg.lParam;
4693 add_message(&log_msg);
4695 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
4697 TranslateMessage(&msg);
4698 DispatchMessage(&msg);
4703 static void test_accelerators(void)
4708 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4709 100, 100, 200, 200, 0, 0, 0, NULL);
4716 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4718 state = GetKeyState(VK_SHIFT);
4719 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
4720 state = GetKeyState(VK_CAPITAL);
4721 ok(state == 0, "wrong CapsLock state %04x\n", state);
4723 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
4724 assert(hAccel != 0);
4726 pump_msg_loop(hwnd, 0);
4729 trace("testing VK_N press/release\n");
4731 keybd_event('N', 0, 0, 0);
4732 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4733 pump_msg_loop(hwnd, hAccel);
4734 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4736 trace("testing Shift+VK_N press/release\n");
4738 keybd_event(VK_SHIFT, 0, 0, 0);
4739 keybd_event('N', 0, 0, 0);
4740 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4741 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4742 pump_msg_loop(hwnd, hAccel);
4743 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4745 trace("testing Ctrl+VK_N press/release\n");
4747 keybd_event(VK_CONTROL, 0, 0, 0);
4748 keybd_event('N', 0, 0, 0);
4749 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4750 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4751 pump_msg_loop(hwnd, hAccel);
4752 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
4754 trace("testing Alt+VK_N press/release\n");
4756 keybd_event(VK_MENU, 0, 0, 0);
4757 keybd_event('N', 0, 0, 0);
4758 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4759 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4760 pump_msg_loop(hwnd, hAccel);
4761 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
4763 trace("testing Ctrl+Alt+VK_N press/release 1\n");
4765 keybd_event(VK_CONTROL, 0, 0, 0);
4766 keybd_event(VK_MENU, 0, 0, 0);
4767 keybd_event('N', 0, 0, 0);
4768 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4769 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4770 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4771 pump_msg_loop(hwnd, hAccel);
4772 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
4774 ret = DestroyAcceleratorTable(hAccel);
4775 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4777 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
4778 assert(hAccel != 0);
4780 trace("testing VK_N press/release\n");
4782 keybd_event('N', 0, 0, 0);
4783 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4784 pump_msg_loop(hwnd, hAccel);
4785 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4787 trace("testing Shift+VK_N press/release\n");
4789 keybd_event(VK_SHIFT, 0, 0, 0);
4790 keybd_event('N', 0, 0, 0);
4791 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4792 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4793 pump_msg_loop(hwnd, hAccel);
4794 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4796 trace("testing Ctrl+VK_N press/release 2\n");
4798 keybd_event(VK_CONTROL, 0, 0, 0);
4799 keybd_event('N', 0, 0, 0);
4800 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4801 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4802 pump_msg_loop(hwnd, hAccel);
4803 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
4805 trace("testing Alt+VK_N press/release 2\n");
4807 keybd_event(VK_MENU, 0, 0, 0);
4808 keybd_event('N', 0, 0, 0);
4809 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4810 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4811 pump_msg_loop(hwnd, hAccel);
4812 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
4814 trace("testing Ctrl+Alt+VK_N press/release 2\n");
4816 keybd_event(VK_CONTROL, 0, 0, 0);
4817 keybd_event(VK_MENU, 0, 0, 0);
4818 keybd_event('N', 0, 0, 0);
4819 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4820 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4821 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4822 pump_msg_loop(hwnd, hAccel);
4823 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
4825 trace("testing Ctrl+Shift+VK_N press/release\n");
4827 keybd_event(VK_CONTROL, 0, 0, 0);
4828 keybd_event(VK_SHIFT, 0, 0, 0);
4829 keybd_event('N', 0, 0, 0);
4830 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4831 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4832 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4833 pump_msg_loop(hwnd, hAccel);
4834 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
4836 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
4838 keybd_event(VK_CONTROL, 0, 0, 0);
4839 keybd_event(VK_MENU, 0, 0, 0);
4840 keybd_event(VK_SHIFT, 0, 0, 0);
4841 keybd_event('N', 0, 0, 0);
4842 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4843 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4844 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4845 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4846 pump_msg_loop(hwnd, hAccel);
4847 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
4849 ret = DestroyAcceleratorTable(hAccel);
4850 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4852 trace("testing Alt press/release\n");
4854 keybd_event(VK_MENU, 0, 0, 0);
4855 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4856 keybd_event(VK_MENU, 0, 0, 0);
4857 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4858 pump_msg_loop(hwnd, 0);
4859 /* this test doesn't pass in Wine for managed windows */
4860 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
4862 trace("testing Alt+MouseButton press/release\n");
4863 /* first, move mouse pointer inside of the window client area */
4864 GetClientRect(hwnd, &rc);
4865 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
4866 rc.left += (rc.right - rc.left)/2;
4867 rc.top += (rc.bottom - rc.top)/2;
4868 SetCursorPos(rc.left, rc.top);
4870 pump_msg_loop(hwnd, 0);
4872 keybd_event(VK_MENU, 0, 0, 0);
4873 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4874 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4875 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4876 pump_msg_loop(hwnd, 0);
4877 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
4879 keybd_event(VK_F1, 0, 0, 0);
4880 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
4881 pump_msg_loop(hwnd, 0);
4882 ok_sequence(WmF1Seq, "F1 press/release", TRUE);
4884 DestroyWindow(hwnd);
4887 /************* window procedures ********************/
4889 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
4890 WPARAM wParam, LPARAM lParam)
4892 static long defwndproc_counter = 0;
4893 static long beginpaint_counter = 0;
4897 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4899 /* explicitly ignore WM_GETICON message */
4900 if (message == WM_GETICON) return 0;
4906 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
4907 ok((BOOL)wParam == !(style & WS_DISABLED),
4908 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
4912 case WM_CAPTURECHANGED:
4913 if (test_DestroyWindow_flag)
4915 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
4916 if (style & WS_CHILD)
4917 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
4918 else if (style & WS_POPUP)
4919 lParam = WND_POPUP_ID;
4921 lParam = WND_PARENT_ID;
4929 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
4930 capture = GetCapture();
4933 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
4934 trace("current capture %p, releasing...\n", capture);
4941 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
4942 if (test_DestroyWindow_flag)
4944 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
4945 if (style & WS_CHILD)
4946 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
4947 else if (style & WS_POPUP)
4948 lParam = WND_POPUP_ID;
4950 lParam = WND_PARENT_ID;
4954 /* test_accelerators() depends on this */
4961 case WM_DEVICECHANGE:
4964 case WM_WINDOWPOSCHANGING:
4965 case WM_WINDOWPOSCHANGED:
4967 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4969 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
4970 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
4971 winpos->hwnd, winpos->hwndInsertAfter,
4972 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
4974 /* Log only documented flags, win2k uses 0x1000 and 0x2000
4975 * in the high word for internal purposes
4977 wParam = winpos->flags & 0xffff;
4982 msg.message = message;
4983 msg.flags = sent|wparam|lparam;
4984 if (defwndproc_counter) msg.flags |= defwinproc;
4985 if (beginpaint_counter) msg.flags |= beginpaint;
4986 msg.wParam = wParam;
4987 msg.lParam = lParam;
4990 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
4992 HWND parent = GetParent(hwnd);
4994 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
4996 GetClientRect(parent, &rc);
4997 trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
4999 trace("ptReserved = (%ld,%ld)\n"
5000 "ptMaxSize = (%ld,%ld)\n"
5001 "ptMaxPosition = (%ld,%ld)\n"
5002 "ptMinTrackSize = (%ld,%ld)\n"
5003 "ptMaxTrackSize = (%ld,%ld)\n",
5004 minmax->ptReserved.x, minmax->ptReserved.y,
5005 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
5006 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
5007 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
5008 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
5010 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %ld != %ld\n",
5011 minmax->ptMaxSize.x, rc.right);
5012 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %ld != %ld\n",
5013 minmax->ptMaxSize.y, rc.bottom);
5016 if (message == WM_PAINT)
5019 beginpaint_counter++;
5020 BeginPaint( hwnd, &ps );
5021 beginpaint_counter--;
5022 EndPaint( hwnd, &ps );
5026 defwndproc_counter++;
5027 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
5028 : DefWindowProcA(hwnd, message, wParam, lParam);
5029 defwndproc_counter--;
5034 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5036 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
5039 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5041 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
5044 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5046 static long defwndproc_counter = 0;
5050 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5052 /* explicitly ignore WM_GETICON message */
5053 if (message == WM_GETICON) return 0;
5055 msg.message = message;
5056 msg.flags = sent|wparam|lparam;
5057 if (defwndproc_counter) msg.flags |= defwinproc;
5058 msg.wParam = wParam;
5059 msg.lParam = lParam;
5062 if (message == WM_CREATE)
5064 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
5065 SetWindowLongA(hwnd, GWL_STYLE, style);
5068 defwndproc_counter++;
5069 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5070 defwndproc_counter--;
5075 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5077 static long defwndproc_counter = 0;
5078 static long beginpaint_counter = 0;
5082 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5084 /* explicitly ignore WM_GETICON message */
5085 if (message == WM_GETICON) return 0;
5087 if (log_all_parent_messages ||
5088 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
5089 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
5090 message == WM_ENABLE || message == WM_ENTERIDLE ||
5091 message == WM_IME_SETCONTEXT)
5098 INT ret = GetClipBox((HDC)wParam, &rc);
5100 trace("WM_ERASEBKGND: GetClipBox()=%d, (%ld,%ld-%ld,%ld)\n",
5101 ret, rc.left, rc.top, rc.right, rc.bottom);
5105 case WM_WINDOWPOSCHANGING:
5106 case WM_WINDOWPOSCHANGED:
5108 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5110 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5111 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5112 winpos->hwnd, winpos->hwndInsertAfter,
5113 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5115 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5116 * in the high word for internal purposes
5118 wParam = winpos->flags & 0xffff;
5123 msg.message = message;
5124 msg.flags = sent|parent|wparam|lparam;
5125 if (defwndproc_counter) msg.flags |= defwinproc;
5126 if (beginpaint_counter) msg.flags |= beginpaint;
5127 msg.wParam = wParam;
5128 msg.lParam = lParam;
5132 if (message == WM_PAINT)
5135 beginpaint_counter++;
5136 BeginPaint( hwnd, &ps );
5137 beginpaint_counter--;
5138 EndPaint( hwnd, &ps );
5142 defwndproc_counter++;
5143 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5144 defwndproc_counter--;
5149 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5151 static long defwndproc_counter = 0;
5155 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5157 /* explicitly ignore WM_GETICON message */
5158 if (message == WM_GETICON) return 0;
5160 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
5161 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
5162 if (after_end_dialog)
5163 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
5165 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
5169 case WM_WINDOWPOSCHANGING:
5170 case WM_WINDOWPOSCHANGED:
5172 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5174 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5175 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5176 winpos->hwnd, winpos->hwndInsertAfter,
5177 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5179 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5180 * in the high word for internal purposes
5182 wParam = winpos->flags & 0xffff;
5187 msg.message = message;
5188 msg.flags = sent|wparam|lparam;
5189 if (defwndproc_counter) msg.flags |= defwinproc;
5190 msg.wParam = wParam;
5191 msg.lParam = lParam;
5194 defwndproc_counter++;
5195 ret = DefDlgProcA(hwnd, message, wParam, lParam);
5196 defwndproc_counter--;
5201 static BOOL RegisterWindowClasses(void)
5206 cls.lpfnWndProc = MsgCheckProcA;
5209 cls.hInstance = GetModuleHandleA(0);
5211 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
5212 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5213 cls.lpszMenuName = NULL;
5214 cls.lpszClassName = "TestWindowClass";
5215 if(!RegisterClassA(&cls)) return FALSE;
5217 cls.lpfnWndProc = PopupMsgCheckProcA;
5218 cls.lpszClassName = "TestPopupClass";
5219 if(!RegisterClassA(&cls)) return FALSE;
5221 cls.lpfnWndProc = ParentMsgCheckProcA;
5222 cls.lpszClassName = "TestParentClass";
5223 if(!RegisterClassA(&cls)) return FALSE;
5225 cls.lpfnWndProc = DefWindowProcA;
5226 cls.lpszClassName = "SimpleWindowClass";
5227 if(!RegisterClassA(&cls)) return FALSE;
5229 cls.style = CS_NOCLOSE;
5230 cls.lpszClassName = "NoCloseWindowClass";
5231 if(!RegisterClassA(&cls)) return FALSE;
5233 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
5235 cls.hInstance = GetModuleHandleA(0);
5236 cls.hbrBackground = 0;
5237 cls.lpfnWndProc = TestDlgProcA;
5238 cls.lpszClassName = "TestDialogClass";
5239 if(!RegisterClassA(&cls)) return FALSE;
5244 static HHOOK hCBT_hook;
5245 static DWORD cbt_hook_thread_id;
5247 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5249 static const char *CBT_code_name[10] = {
5256 "HCBT_CLICKSKIPPED",
5260 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
5264 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
5266 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5268 if (nCode == HCBT_SYSCOMMAND)
5272 msg.message = nCode;
5273 msg.flags = hook|wparam|lparam;
5274 msg.wParam = wParam;
5275 msg.lParam = lParam;
5278 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5281 if (nCode == HCBT_DESTROYWND)
5283 if (test_DestroyWindow_flag)
5285 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
5286 if (style & WS_CHILD)
5287 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
5288 else if (style & WS_POPUP)
5289 lParam = WND_POPUP_ID;
5291 lParam = WND_PARENT_ID;
5295 /* Log also SetFocus(0) calls */
5296 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5298 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5300 if (!lstrcmpiA(buf, "TestWindowClass") ||
5301 !lstrcmpiA(buf, "TestParentClass") ||
5302 !lstrcmpiA(buf, "TestPopupClass") ||
5303 !lstrcmpiA(buf, "SimpleWindowClass") ||
5304 !lstrcmpiA(buf, "TestDialogClass") ||
5305 !lstrcmpiA(buf, "MDI_frame_class") ||
5306 !lstrcmpiA(buf, "MDI_client_class") ||
5307 !lstrcmpiA(buf, "MDI_child_class") ||
5308 !lstrcmpiA(buf, "my_button_class") ||
5309 !lstrcmpiA(buf, "my_edit_class") ||
5310 !lstrcmpiA(buf, "static") ||
5311 !lstrcmpiA(buf, "#32770"))
5315 msg.message = nCode;
5316 msg.flags = hook|wparam|lparam;
5317 msg.wParam = wParam;
5318 msg.lParam = lParam;
5322 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5325 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
5335 trace("WEH:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5336 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5338 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5340 /* ignore mouse cursor events */
5341 if (object_id == OBJID_CURSOR) return;
5343 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
5346 !lstrcmpiA(buf, "TestWindowClass") ||
5347 !lstrcmpiA(buf, "TestParentClass") ||
5348 !lstrcmpiA(buf, "TestPopupClass") ||
5349 !lstrcmpiA(buf, "SimpleWindowClass") ||
5350 !lstrcmpiA(buf, "TestDialogClass") ||
5351 !lstrcmpiA(buf, "MDI_frame_class") ||
5352 !lstrcmpiA(buf, "MDI_client_class") ||
5353 !lstrcmpiA(buf, "MDI_child_class") ||
5354 !lstrcmpiA(buf, "my_button_class") ||
5355 !lstrcmpiA(buf, "my_edit_class") ||
5356 !lstrcmpiA(buf, "static") ||
5357 !lstrcmpiA(buf, "#32770"))
5361 msg.message = event;
5362 msg.flags = winevent_hook|wparam|lparam;
5363 msg.wParam = object_id;
5364 msg.lParam = child_id;
5370 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
5371 static const WCHAR wszAnsi[] = {'U',0};
5373 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5377 case CB_FINDSTRINGEXACT:
5378 trace("String: %p\n", (LPCWSTR)lParam);
5379 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
5381 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
5385 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
5388 static const struct message WmGetTextLengthAfromW[] = {
5389 { WM_GETTEXTLENGTH, sent },
5390 { WM_GETTEXT, sent },
5394 static const WCHAR testWindowClassW[] =
5395 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
5397 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
5399 /* dummy window proc for WM_GETTEXTLENGTH test */
5400 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
5404 case WM_GETTEXTLENGTH:
5405 return lstrlenW(dummy_window_text) + 37; /* some random length */
5407 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
5408 return lstrlenW( (LPWSTR)lp );
5410 return DefWindowProcW( hwnd, msg, wp, lp );
5414 static void test_message_conversion(void)
5416 static const WCHAR wszMsgConversionClass[] =
5417 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
5421 WNDPROC wndproc, newproc;
5425 cls.lpfnWndProc = MsgConversionProcW;
5428 cls.hInstance = GetModuleHandleW(NULL);
5430 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
5431 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
5432 cls.lpszMenuName = NULL;
5433 cls.lpszClassName = wszMsgConversionClass;
5434 /* this call will fail on Win9x, but that doesn't matter as this test is
5435 * meaningless on those platforms */
5436 if(!RegisterClassW(&cls)) return;
5439 cls.lpfnWndProc = MsgCheckProcW;
5442 cls.hInstance = GetModuleHandleW(0);
5444 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
5445 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5446 cls.lpszMenuName = NULL;
5447 cls.lpszClassName = testWindowClassW;
5448 if(!RegisterClassW(&cls)) return;
5450 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
5451 100, 100, 200, 200, 0, 0, 0, NULL);
5452 ok(hwnd != NULL, "Window creation failed\n");
5456 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
5457 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5458 ok(lRes == 0, "String should have been converted\n");
5459 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5460 ok(lRes == 1, "String shouldn't have been converted\n");
5464 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
5465 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5466 ok(lRes == 1, "String shouldn't have been converted\n");
5467 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5468 ok(lRes == 1, "String shouldn't have been converted\n");
5470 /* Synchronous messages */
5472 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5473 ok(lRes == 0, "String should have been converted\n");
5474 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5475 ok(lRes == 1, "String shouldn't have been converted\n");
5477 /* Asynchronous messages */
5480 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5481 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5482 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5484 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5485 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5486 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5488 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5489 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5490 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5492 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5493 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5494 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5496 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5497 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5498 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5500 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5501 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5502 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5504 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5505 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5506 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5508 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5509 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5510 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5512 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
5514 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
5515 WS_OVERLAPPEDWINDOW,
5516 100, 100, 200, 200, 0, 0, 0, NULL);
5519 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
5520 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5521 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5522 "got bad length %ld\n", lRes );
5525 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
5526 hwnd, WM_GETTEXTLENGTH, 0, 0);
5527 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5528 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5529 "got bad length %ld\n", lRes );
5531 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
5532 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
5533 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5534 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5535 NULL, 0, NULL, NULL ),
5536 "got bad length %ld\n", lRes );
5538 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
5539 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5540 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5541 NULL, 0, NULL, NULL ),
5542 "got bad length %ld\n", lRes );
5544 ret = DestroyWindow(hwnd);
5545 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5555 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
5559 #define TIMER_ID 0x19
5561 static DWORD WINAPI timer_thread_proc(LPVOID x)
5563 struct timer_info *info = x;
5566 r = KillTimer(info->hWnd, 0x19);
5567 ok(r,"KillTimer failed in thread\n");
5568 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
5569 ok(r,"SetTimer failed in thread\n");
5570 ok(r==TIMER_ID,"SetTimer id different\n");
5571 r = SetEvent(info->handles[0]);
5572 ok(r,"SetEvent failed in thread\n");
5576 static void test_timers(void)
5578 struct timer_info info;
5581 info.hWnd = CreateWindow ("TestWindowClass", NULL,
5582 WS_OVERLAPPEDWINDOW ,
5583 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5586 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
5587 ok(info.id, "SetTimer failed\n");
5588 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
5589 info.handles[0] = CreateEvent(NULL,0,0,NULL);
5590 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
5592 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
5594 WaitForSingleObject(info.handles[1], INFINITE);
5596 CloseHandle(info.handles[0]);
5597 CloseHandle(info.handles[1]);
5599 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
5601 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
5604 /* Various win events with arbitrary parameters */
5605 static const struct message WmWinEventsSeq[] = {
5606 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5607 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5608 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5609 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5610 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5611 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5612 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5613 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5614 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5615 /* our win event hook ignores OBJID_CURSOR events */
5616 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
5617 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
5618 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
5619 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
5620 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
5621 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5622 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5623 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5624 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5625 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5626 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5627 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5628 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5629 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5632 static const struct message WmWinEventCaretSeq[] = {
5633 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5634 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5635 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
5636 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5639 static const struct message WmWinEventCaretSeq_2[] = {
5640 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5641 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5642 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5645 static const struct message WmWinEventAlertSeq[] = {
5646 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
5649 static const struct message WmWinEventAlertSeq_2[] = {
5650 /* create window in the thread proc */
5651 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
5652 /* our test event */
5653 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
5656 static const struct message WmGlobalHookSeq_1[] = {
5657 /* create window in the thread proc */
5658 { HCBT_CREATEWND, hook|lparam, 0, 2 },
5659 /* our test events */
5660 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
5661 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
5664 static const struct message WmGlobalHookSeq_2[] = {
5665 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
5666 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
5667 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
5668 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
5672 static const struct message WmMouseLLHookSeq[] = {
5673 { WM_MOUSEMOVE, hook },
5674 { WM_LBUTTONDOWN, hook },
5675 { WM_LBUTTONUP, hook },
5679 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
5689 trace("WEH_2:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5690 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5692 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5694 if (!lstrcmpiA(buf, "TestWindowClass") ||
5695 !lstrcmpiA(buf, "static"))
5699 msg.message = event;
5700 msg.flags = winevent_hook|wparam|lparam;
5701 msg.wParam = object_id;
5702 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
5708 static HHOOK hCBT_global_hook;
5709 static DWORD cbt_global_hook_thread_id;
5711 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5716 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
5718 if (nCode == HCBT_SYSCOMMAND)
5722 msg.message = nCode;
5723 msg.flags = hook|wparam|lparam;
5724 msg.wParam = wParam;
5725 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5728 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5730 /* WH_MOUSE_LL hook */
5731 if (nCode == HC_ACTION)
5734 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
5736 /* we can't test for real mouse events */
5737 if (mhll->flags & LLMHF_INJECTED)
5739 msg.message = wParam;
5743 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5746 /* Log also SetFocus(0) calls */
5747 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5749 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5751 if (!lstrcmpiA(buf, "TestWindowClass") ||
5752 !lstrcmpiA(buf, "static"))
5756 msg.message = nCode;
5757 msg.flags = hook|wparam|lparam;
5758 msg.wParam = wParam;
5759 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5763 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5766 static DWORD WINAPI win_event_global_thread_proc(void *param)
5770 HANDLE hevent = *(HANDLE *)param;
5771 HMODULE user32 = GetModuleHandleA("user32.dll");
5772 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5774 assert(pNotifyWinEvent);
5776 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5778 trace("created thread window %p\n", hwnd);
5780 *(HWND *)param = hwnd;
5783 /* this event should be received only by our new hook proc,
5784 * an old one does not expect an event from another thread.
5786 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
5789 while (GetMessage(&msg, 0, 0, 0))
5791 TranslateMessage(&msg);
5792 DispatchMessage(&msg);
5797 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
5801 HANDLE hevent = *(HANDLE *)param;
5804 /* these events should be received only by our new hook proc,
5805 * an old one does not expect an event from another thread.
5808 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5810 trace("created thread window %p\n", hwnd);
5812 *(HWND *)param = hwnd;
5814 /* Windows doesn't like when a thread plays games with the focus,
5815 that leads to all kinds of misbehaviours and failures to activate
5816 a window. So, better keep next lines commented out.
5820 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5821 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5825 while (GetMessage(&msg, 0, 0, 0))
5827 TranslateMessage(&msg);
5828 DispatchMessage(&msg);
5833 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
5837 HANDLE hevent = *(HANDLE *)param;
5839 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5841 trace("created thread window %p\n", hwnd);
5843 *(HWND *)param = hwnd;
5847 mouse_event(MOUSEEVENTF_MOVE, 100, 0, 0, 0);
5848 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
5849 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
5852 while (GetMessage(&msg, 0, 0, 0))
5854 TranslateMessage(&msg);
5855 DispatchMessage(&msg);
5860 static void test_winevents(void)
5866 HANDLE hthread, hevent;
5868 HWINEVENTHOOK hhook;
5869 const struct message *events = WmWinEventsSeq;
5870 HMODULE user32 = GetModuleHandleA("user32.dll");
5871 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
5872 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
5873 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5875 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
5876 WS_OVERLAPPEDWINDOW,
5877 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5881 /****** start of global hook test *************/
5882 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
5883 assert(hCBT_global_hook);
5885 hevent = CreateEventA(NULL, 0, 0, NULL);
5887 hwnd2 = (HWND)hevent;
5889 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
5890 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5892 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5894 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
5897 /* this one should be received only by old hook proc */
5898 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5899 /* this one should be received only by old hook proc */
5900 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5902 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
5904 ret = UnhookWindowsHookEx(hCBT_global_hook);
5905 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
5907 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5908 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5909 CloseHandle(hthread);
5910 CloseHandle(hevent);
5911 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5912 /****** end of global hook test *************/
5914 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
5916 ok(DestroyWindow(hwnd), "failed to destroy window\n");
5922 #if 0 /* this test doesn't pass under Win9x */
5923 /* win2k ignores events with hwnd == 0 */
5924 SetLastError(0xdeadbeef);
5925 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
5926 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
5927 GetLastError() == 0xdeadbeef, /* Win9x */
5928 "unexpected error %ld\n", GetLastError());
5929 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
5932 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
5933 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
5935 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
5937 /****** start of event filtering test *************/
5938 hhook = (HWINEVENTHOOK)pSetWinEventHook(
5939 EVENT_OBJECT_SHOW, /* 0x8002 */
5940 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
5941 GetModuleHandleA(0), win_event_global_hook_proc,
5942 GetCurrentProcessId(), 0,
5943 WINEVENT_INCONTEXT);
5944 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
5946 hevent = CreateEventA(NULL, 0, 0, NULL);
5948 hwnd2 = (HWND)hevent;
5950 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
5951 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5953 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5955 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
5958 /* this one should be received only by old hook proc */
5959 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
5960 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
5961 /* this one should be received only by old hook proc */
5962 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
5964 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
5966 ret = pUnhookWinEvent(hhook);
5967 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
5969 PostThreadMessageA(tid, WM_QUIT, 0, 0);
5970 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5971 CloseHandle(hthread);
5972 CloseHandle(hevent);
5973 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
5974 /****** end of event filtering test *************/
5976 /****** start of out of context event test *************/
5977 hhook = (HWINEVENTHOOK)pSetWinEventHook(
5978 EVENT_MIN, EVENT_MAX,
5979 0, win_event_global_hook_proc,
5980 GetCurrentProcessId(), 0,
5981 WINEVENT_OUTOFCONTEXT);
5982 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
5984 hevent = CreateEventA(NULL, 0, 0, NULL);
5986 hwnd2 = (HWND)hevent;
5990 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
5991 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
5993 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5995 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
5996 /* process pending winevent messages */
5997 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
5998 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
6001 /* this one should be received only by old hook proc */
6002 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6003 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6004 /* this one should be received only by old hook proc */
6005 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6007 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
6008 /* process pending winevent messages */
6009 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6010 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
6012 ret = pUnhookWinEvent(hhook);
6013 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6015 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6016 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6017 CloseHandle(hthread);
6018 CloseHandle(hevent);
6019 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6020 /****** end of out of context event test *************/
6022 /****** start of MOUSE_LL hook test *************/
6023 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6024 assert(hCBT_global_hook);
6026 hevent = CreateEventA(NULL, 0, 0, NULL);
6028 hwnd2 = (HWND)hevent;
6030 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
6031 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6033 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
6034 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6036 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
6039 mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0);
6040 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6041 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6043 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
6045 ret = UnhookWindowsHookEx(hCBT_global_hook);
6046 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
6048 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6049 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6050 CloseHandle(hthread);
6051 CloseHandle(hevent);
6052 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6053 /****** end of MOUSE_LL hook test *************/
6055 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6058 static void test_set_hook(void)
6062 HWINEVENTHOOK hwinevent_hook;
6063 HMODULE user32 = GetModuleHandleA("user32.dll");
6064 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6065 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6067 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
6068 ok(hhook != 0, "local hook does not require hModule set to 0\n");
6069 UnhookWindowsHookEx(hhook);
6071 #if 0 /* this test doesn't pass under Win9x: BUG! */
6072 SetLastError(0xdeadbeef);
6073 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
6074 ok(!hhook, "global hook requires hModule != 0\n");
6075 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %ld\n", GetLastError());
6078 SetLastError(0xdeadbeef);
6079 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
6080 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
6081 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
6082 GetLastError() == 0xdeadbeef, /* Win9x */
6083 "unexpected error %ld\n", GetLastError());
6085 SetLastError(0xdeadbeef);
6086 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
6087 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
6088 GetLastError() == 0xdeadbeef, /* Win9x */
6089 "unexpected error %ld\n", GetLastError());
6091 if (!pSetWinEventHook || !pUnhookWinEvent) return;
6093 /* even process local incontext hooks require hmodule */
6094 SetLastError(0xdeadbeef);
6095 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6096 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
6097 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
6098 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
6099 GetLastError() == 0xdeadbeef, /* Win9x */
6100 "unexpected error %ld\n", GetLastError());
6102 /* even thread local incontext hooks require hmodule */
6103 SetLastError(0xdeadbeef);
6104 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6105 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
6106 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
6107 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
6108 GetLastError() == 0xdeadbeef, /* Win9x */
6109 "unexpected error %ld\n", GetLastError());
6111 #if 0 /* these 3 tests don't pass under Win9x */
6112 SetLastError(0xdeadbeef);
6113 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
6114 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6115 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
6116 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
6118 SetLastError(0xdeadbeef);
6119 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
6120 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6121 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
6122 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
6124 SetLastError(0xdeadbeef);
6125 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6126 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
6127 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
6128 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %ld\n", GetLastError());
6131 SetLastError(0xdeadbeef);
6132 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
6133 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6134 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
6135 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
6136 ret = pUnhookWinEvent(hwinevent_hook);
6137 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6140 /* This call succeeds under win2k SP4, but fails under Wine.
6141 Does win2k test/use passed process id? */
6142 SetLastError(0xdeadbeef);
6143 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6144 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
6145 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
6146 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
6147 ret = pUnhookWinEvent(hwinevent_hook);
6148 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6151 SetLastError(0xdeadbeef);
6152 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
6153 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
6154 GetLastError() == 0xdeadbeef, /* Win9x */
6155 "unexpected error %ld\n", GetLastError());
6158 static const struct message ScrollWindowPaint1[] = {
6160 { WM_ERASEBKGND, sent|beginpaint },
6164 static const struct message ScrollWindowPaint2[] = {
6169 static void test_scrollwindowex(void)
6172 RECT rect={0,0,130,130};
6175 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
6176 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
6177 100, 100, 200, 200, 0, 0, 0, NULL);
6178 ok (hwnd != 0, "Failed to create overlapped window\n");
6179 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
6180 WS_VISIBLE|WS_CAPTION|WS_CHILD,
6181 10, 10, 150, 150, hwnd, 0, 0, NULL);
6182 ok (hchild != 0, "Failed to create child\n");
6187 /* scroll without the child window */
6188 trace("start scroll\n");
6189 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
6190 SW_ERASE|SW_INVALIDATE);
6191 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6192 trace("end scroll\n");
6194 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6195 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
6197 /* Now without the SW_ERASE flag */
6198 trace("start scroll\n");
6199 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
6200 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6201 trace("end scroll\n");
6203 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6204 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
6206 /* now scroll the child window as well */
6207 trace("start scroll\n");
6208 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
6209 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
6210 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
6211 /* windows sometimes a WM_MOVE */
6212 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6214 trace("end scroll\n");
6216 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6217 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
6219 /* now scroll with ScrollWindow() */
6220 trace("start scroll with ScrollWindow\n");
6221 ScrollWindow( hwnd, 5, 5, NULL, NULL);
6222 trace("end scroll\n");
6224 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6225 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
6227 ok(DestroyWindow(hchild), "failed to destroy window\n");
6228 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6232 static const struct message destroy_window_with_children[] = {
6233 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
6234 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
6235 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
6236 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
6237 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6238 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6239 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6240 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
6241 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
6242 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
6243 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
6244 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
6245 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
6246 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
6247 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
6248 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
6252 static void test_DestroyWindow(void)
6255 HWND parent, child1, child2, child3, child4, test;
6256 UINT child_id = WND_CHILD_ID + 1;
6258 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6259 100, 100, 200, 200, 0, 0, 0, NULL);
6260 assert(parent != 0);
6261 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6262 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
6263 assert(child1 != 0);
6264 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6265 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
6266 assert(child2 != 0);
6267 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6268 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
6269 assert(child3 != 0);
6270 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
6271 0, 0, 50, 50, parent, 0, 0, NULL);
6272 assert(child4 != 0);
6274 /* test owner/parent of child2 */
6275 test = GetParent(child2);
6276 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6277 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
6279 test = pGetAncestor(child2, GA_PARENT);
6280 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6282 test = GetWindow(child2, GW_OWNER);
6283 ok(!test, "wrong owner %p\n", test);
6285 test = SetParent(child2, parent);
6286 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
6288 /* test owner/parent of the parent */
6289 test = GetParent(parent);
6290 ok(!test, "wrong parent %p\n", test);
6292 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
6295 test = pGetAncestor(parent, GA_PARENT);
6296 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6298 test = GetWindow(parent, GW_OWNER);
6299 ok(!test, "wrong owner %p\n", test);
6301 /* test owner/parent of child1 */
6302 test = GetParent(child1);
6303 ok(test == parent, "wrong parent %p\n", test);
6304 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
6306 test = pGetAncestor(child1, GA_PARENT);
6307 ok(test == parent, "wrong parent %p\n", test);
6309 test = GetWindow(child1, GW_OWNER);
6310 ok(!test, "wrong owner %p\n", test);
6312 /* test owner/parent of child2 */
6313 test = GetParent(child2);
6314 ok(test == parent, "wrong parent %p\n", test);
6315 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
6317 test = pGetAncestor(child2, GA_PARENT);
6318 ok(test == parent, "wrong parent %p\n", test);
6320 test = GetWindow(child2, GW_OWNER);
6321 ok(!test, "wrong owner %p\n", test);
6323 /* test owner/parent of child3 */
6324 test = GetParent(child3);
6325 ok(test == child1, "wrong parent %p\n", test);
6326 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
6328 test = pGetAncestor(child3, GA_PARENT);
6329 ok(test == child1, "wrong parent %p\n", test);
6331 test = GetWindow(child3, GW_OWNER);
6332 ok(!test, "wrong owner %p\n", test);
6334 /* test owner/parent of child4 */
6335 test = GetParent(child4);
6336 ok(test == parent, "wrong parent %p\n", test);
6337 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
6339 test = pGetAncestor(child4, GA_PARENT);
6340 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6342 test = GetWindow(child4, GW_OWNER);
6343 ok(test == parent, "wrong owner %p\n", test);
6347 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
6348 parent, child1, child2, child3, child4);
6351 test = GetCapture();
6352 ok(test == child4, "wrong capture window %p\n", test);
6354 test_DestroyWindow_flag = TRUE;
6355 ret = DestroyWindow(parent);
6356 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
6357 test_DestroyWindow_flag = FALSE;
6358 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
6360 ok(!IsWindow(parent), "parent still exists\n");
6361 ok(!IsWindow(child1), "child1 still exists\n");
6362 ok(!IsWindow(child2), "child2 still exists\n");
6363 ok(!IsWindow(child3), "child3 still exists\n");
6364 ok(!IsWindow(child4), "child4 still exists\n");
6366 test = GetCapture();
6367 ok(!test, "wrong capture window %p\n", test);
6371 static const struct message WmDispatchPaint[] = {
6372 { WM_NCPAINT, sent },
6373 { WM_GETTEXT, sent|defwinproc|optional },
6374 { WM_GETTEXT, sent|defwinproc|optional },
6375 { WM_ERASEBKGND, sent },
6379 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6381 if (message == WM_PAINT) return 0;
6382 return MsgCheckProcA( hwnd, message, wParam, lParam );
6385 static void test_DispatchMessage(void)
6390 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6391 100, 100, 200, 200, 0, 0, 0, NULL);
6392 ShowWindow( hwnd, SW_SHOW );
6393 UpdateWindow( hwnd );
6394 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6396 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
6398 SetRect( &rect, -5, -5, 5, 5 );
6399 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6401 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6403 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6407 DispatchMessage( &msg );
6408 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
6409 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6410 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
6411 if (++count > 10) break;
6414 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
6416 trace("now without DispatchMessage\n");
6418 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6420 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6422 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6425 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
6427 /* this will send WM_NCCPAINT just like DispatchMessage does */
6428 GetUpdateRgn( hwnd, hrgn, TRUE );
6429 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6430 DeleteObject( hrgn );
6431 GetClientRect( hwnd, &rect );
6432 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
6433 ok( !count, "Got multiple WM_PAINTs\n" );
6434 if (++count > 10) break;
6437 DestroyWindow(hwnd);
6441 static const struct message WmUser[] = {
6453 static DWORD CALLBACK send_msg_thread( LPVOID arg )
6455 struct sendmsg_info *info = arg;
6456 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
6457 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %ld\n", GetLastError());
6461 static void wait_for_thread( HANDLE thread )
6463 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
6466 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
6470 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6472 if (message == WM_USER) Sleep(200);
6473 return MsgCheckProcA( hwnd, message, wParam, lParam );
6476 static void test_SendMessageTimeout(void)
6480 struct sendmsg_info info;
6483 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6484 100, 100, 200, 200, 0, 0, 0, NULL);
6485 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6488 info.timeout = 1000;
6489 info.ret = 0xdeadbeef;
6490 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6491 wait_for_thread( thread );
6492 CloseHandle( thread );
6493 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6494 ok_sequence( WmUser, "WmUser", FALSE );
6497 info.ret = 0xdeadbeef;
6498 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6499 Sleep(100); /* SendMessageTimeout should timeout here */
6500 wait_for_thread( thread );
6501 CloseHandle( thread );
6502 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6503 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6505 /* 0 means infinite timeout */
6507 info.ret = 0xdeadbeef;
6508 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6510 wait_for_thread( thread );
6511 CloseHandle( thread );
6512 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6513 ok_sequence( WmUser, "WmUser", FALSE );
6515 /* timeout is treated as signed despite the prototype */
6516 info.timeout = 0x7fffffff;
6517 info.ret = 0xdeadbeef;
6518 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6520 wait_for_thread( thread );
6521 CloseHandle( thread );
6522 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6523 ok_sequence( WmUser, "WmUser", FALSE );
6525 info.timeout = 0x80000000;
6526 info.ret = 0xdeadbeef;
6527 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6529 wait_for_thread( thread );
6530 CloseHandle( thread );
6531 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6532 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6534 /* now check for timeout during message processing */
6535 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
6537 info.ret = 0xdeadbeef;
6538 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6539 wait_for_thread( thread );
6540 CloseHandle( thread );
6541 /* we should timeout but still get the message */
6542 ok( info.ret == 0, "SendMessageTimeout failed\n" );
6543 ok_sequence( WmUser, "WmUser", FALSE );
6545 DestroyWindow( info.hwnd );
6549 /****************** edit message test *************************/
6550 #define ID_EDIT 0x1234
6551 static const struct message sl_edit_setfocus[] =
6553 { HCBT_SETFOCUS, hook },
6554 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
6555 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6556 { WM_SETFOCUS, sent|wparam, 0 },
6557 { WM_CTLCOLOREDIT, sent|parent },
6558 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6559 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6560 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6563 static const struct message ml_edit_setfocus[] =
6565 { HCBT_SETFOCUS, hook },
6566 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
6567 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6568 { WM_SETFOCUS, sent|wparam, 0 },
6569 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6570 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6571 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6572 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6575 static const struct message sl_edit_killfocus[] =
6577 { HCBT_SETFOCUS, hook },
6578 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6579 { WM_KILLFOCUS, sent|wparam, 0 },
6580 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6581 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6582 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
6583 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
6586 static const struct message sl_edit_lbutton_dblclk[] =
6588 { WM_LBUTTONDBLCLK, sent },
6589 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6592 static const struct message sl_edit_lbutton_down[] =
6594 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
6595 { HCBT_SETFOCUS, hook },
6596 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
6597 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6598 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
6599 { WM_CTLCOLOREDIT, sent|parent },
6600 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6601 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6602 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6603 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6604 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6605 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6606 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6607 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6610 static const struct message ml_edit_lbutton_down[] =
6612 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
6613 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6614 { HCBT_SETFOCUS, hook },
6615 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
6616 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6617 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
6618 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6619 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6620 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6623 static const struct message sl_edit_lbutton_up[] =
6625 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
6626 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6627 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6628 { WM_CAPTURECHANGED, sent|defwinproc },
6629 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6632 static const struct message ml_edit_lbutton_up[] =
6634 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
6635 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6636 { WM_CAPTURECHANGED, sent|defwinproc },
6640 static WNDPROC old_edit_proc;
6642 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6644 static long defwndproc_counter = 0;
6648 trace("edit: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
6650 /* explicitly ignore WM_GETICON message */
6651 if (message == WM_GETICON) return 0;
6653 msg.message = message;
6654 msg.flags = sent|wparam|lparam;
6655 if (defwndproc_counter) msg.flags |= defwinproc;
6656 msg.wParam = wParam;
6657 msg.lParam = lParam;
6660 defwndproc_counter++;
6661 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
6662 defwndproc_counter--;
6667 static void subclass_edit(void)
6671 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
6673 old_edit_proc = cls.lpfnWndProc;
6675 cls.hInstance = GetModuleHandle(0);
6676 cls.lpfnWndProc = edit_hook_proc;
6677 cls.lpszClassName = "my_edit_class";
6678 if (!RegisterClassA(&cls)) assert(0);
6681 static void test_edit_messages(void)
6687 log_all_parent_messages++;
6689 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6690 100, 100, 200, 200, 0, 0, 0, NULL);
6691 ok (parent != 0, "Failed to create parent window\n");
6693 /* test single line edit */
6694 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
6695 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
6696 ok(hwnd != 0, "Failed to create edit window\n");
6698 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
6699 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08lx\n", dlg_code);
6701 ShowWindow(hwnd, SW_SHOW);
6707 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
6710 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
6716 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
6717 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
6723 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
6724 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
6726 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
6727 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
6729 DestroyWindow(hwnd);
6731 /* test multiline edit */
6732 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
6733 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
6734 ok(hwnd != 0, "Failed to create edit window\n");
6736 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
6737 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
6738 "wrong dlg_code %08lx\n", dlg_code);
6740 ShowWindow(hwnd, SW_SHOW);
6746 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
6749 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
6755 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
6756 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
6762 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
6763 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
6765 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
6766 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
6768 DestroyWindow(hwnd);
6769 DestroyWindow(parent);
6771 log_all_parent_messages--;
6774 /**************************** End of Edit test ******************************/
6776 static const struct message WmChar[] = {
6777 { WM_CHAR, sent|wparam, 'z' },
6781 static const struct message WmKeyDownUp[] = {
6782 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x00000001 },
6783 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6787 static const struct message WmUserChar[] = {
6789 { WM_CHAR, sent|wparam, 'z' },
6793 #define EV_START_STOP 0
6794 #define EV_SENDMSG 1
6800 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
6803 static DWORD CALLBACK send_msg_thread_2(void *param)
6806 struct peekmsg_info *info = param;
6808 trace("thread: waiting for start\n");
6809 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
6810 trace("thread: looping\n");
6814 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
6818 case WAIT_OBJECT_0 + EV_START_STOP:
6819 trace("thread: exiting\n");
6822 case WAIT_OBJECT_0 + EV_SENDMSG:
6823 trace("thread: sending message\n");
6824 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
6825 SetEvent(info->hevent[EV_ACK]);
6829 trace("unexpected return: %04lx\n", ret);
6837 static void test_PeekMessage(void)
6842 UINT qs_all_input = QS_ALLINPUT;
6843 UINT qs_input = QS_INPUT;
6844 struct peekmsg_info info;
6846 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6847 100, 100, 200, 200, 0, 0, 0, NULL);
6848 ShowWindow(info.hwnd, SW_SHOW);
6849 UpdateWindow(info.hwnd);
6851 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
6852 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
6853 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
6855 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
6857 trace("signalling to start looping\n");
6858 SetEvent(info.hevent[EV_START_STOP]);
6860 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
6863 SetLastError(0xdeadbeef);
6864 qstatus = GetQueueStatus(qs_all_input);
6865 if (GetLastError() == ERROR_INVALID_FLAGS)
6867 trace("QS_RAWINPUT not supported on this platform\n");
6868 qs_all_input &= ~QS_RAWINPUT;
6869 qs_input &= ~QS_RAWINPUT;
6871 ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus);
6873 trace("signalling to send message\n");
6874 SetEvent(info.hevent[EV_SENDMSG]);
6875 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
6877 /* pass invalid QS_xxxx flags */
6878 SetLastError(0xdeadbeef);
6879 qstatus = GetQueueStatus(0xffffffff);
6880 ok(qstatus == 0, "GetQueueStatus should fail: %08lx\n", qstatus);
6881 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %ld\n", GetLastError());
6883 qstatus = GetQueueStatus(qs_all_input);
6884 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
6885 "wrong qstatus %08lx\n", qstatus);
6887 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
6888 ok_sequence(WmUser, "WmUser", FALSE);
6890 qstatus = GetQueueStatus(qs_all_input);
6891 ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus);
6893 keybd_event('N', 0, 0, 0);
6894 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6895 qstatus = GetQueueStatus(qs_all_input);
6896 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
6897 "wrong qstatus %08lx\n", qstatus);
6899 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
6900 qstatus = GetQueueStatus(qs_all_input);
6901 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
6902 "wrong qstatus %08lx\n", qstatus);
6904 InvalidateRect(info.hwnd, NULL, FALSE);
6905 qstatus = GetQueueStatus(qs_all_input);
6906 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
6907 "wrong qstatus %08lx\n", qstatus);
6909 trace("signalling to send message\n");
6910 SetEvent(info.hevent[EV_SENDMSG]);
6911 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
6913 qstatus = GetQueueStatus(qs_all_input);
6914 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
6915 "wrong qstatus %08lx\n", qstatus);
6916 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16))) DispatchMessageA(&msg);
6917 ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */
6919 qstatus = GetQueueStatus(qs_all_input);
6921 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
6922 "wrong qstatus %08lx\n", qstatus);
6925 trace("signalling to send message\n");
6926 SetEvent(info.hevent[EV_SENDMSG]);
6927 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
6929 qstatus = GetQueueStatus(qs_all_input);
6931 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
6932 "wrong qstatus %08lx\n", qstatus);
6934 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg);
6935 ok_sequence(WmUser, "WmUser", FALSE);
6937 qstatus = GetQueueStatus(qs_all_input);
6939 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
6940 "wrong qstatus %08lx\n", qstatus);
6943 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg);
6944 ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */
6946 qstatus = GetQueueStatus(qs_all_input);
6948 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
6949 "wrong qstatus %08lx\n", qstatus);
6952 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT)) DispatchMessageA(&msg);
6953 ok_sequence(WmPaint, "WmPaint", TRUE); /* todo_wine */
6955 qstatus = GetQueueStatus(qs_all_input);
6957 ok(qstatus == MAKELONG(0, QS_KEY),
6958 "wrong qstatus %08lx\n", qstatus);
6961 trace("signalling to send message\n");
6962 SetEvent(info.hevent[EV_SENDMSG]);
6963 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
6965 qstatus = GetQueueStatus(qs_all_input);
6967 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
6968 "wrong qstatus %08lx\n", qstatus);
6971 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
6973 qstatus = GetQueueStatus(qs_all_input);
6975 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
6976 "wrong qstatus %08lx\n", qstatus);
6979 while (PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE)) DispatchMessage(&msg);
6980 ok_sequence(WmUserChar, "WmUserChar", FALSE);
6982 qstatus = GetQueueStatus(qs_all_input);
6984 ok(qstatus == MAKELONG(0, QS_KEY),
6985 "wrong qstatus %08lx\n", qstatus);
6988 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
6990 qstatus = GetQueueStatus(qs_all_input);
6992 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
6993 "wrong qstatus %08lx\n", qstatus);
6996 trace("signalling to send message\n");
6997 SetEvent(info.hevent[EV_SENDMSG]);
6998 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7000 qstatus = GetQueueStatus(qs_all_input);
7002 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7003 "wrong qstatus %08lx\n", qstatus);
7006 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16))) DispatchMessage(&msg);
7007 ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */
7009 qstatus = GetQueueStatus(qs_all_input);
7011 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
7012 "wrong qstatus %08lx\n", qstatus);
7015 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16))) DispatchMessage(&msg);
7016 ok_sequence(WmKeyDownUp, "WmKeyDownUp", TRUE); /* todo_wine */
7018 qstatus = GetQueueStatus(qs_all_input);
7020 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7021 "wrong qstatus %08lx\n", qstatus);
7024 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE)) DispatchMessage(&msg);
7025 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7027 qstatus = GetQueueStatus(qs_all_input);
7029 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7030 "wrong qstatus %08lx\n", qstatus);
7033 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7034 ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */
7036 qstatus = GetQueueStatus(qs_all_input);
7038 "wrong qstatus %08lx\n", qstatus);
7040 trace("signalling to exit\n");
7041 SetEvent(info.hevent[EV_START_STOP]);
7043 WaitForSingleObject(hthread, INFINITE);
7045 CloseHandle(hthread);
7046 CloseHandle(info.hevent[0]);
7047 CloseHandle(info.hevent[1]);
7048 CloseHandle(info.hevent[2]);
7050 DestroyWindow(info.hwnd);
7054 static void test_quit_message(void)
7059 /* test using PostQuitMessage */
7060 PostQuitMessage(0xbeef);
7062 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
7063 ok(ret, "PeekMessage failed with error %ld\n", GetLastError());
7064 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7065 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
7067 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
7068 ok(ret, "PostMessage failed with error %ld\n", GetLastError());
7070 ret = GetMessage(&msg, NULL, 0, 0);
7071 ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError());
7072 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
7074 /* note: WM_QUIT message received after WM_USER message */
7075 ret = GetMessage(&msg, NULL, 0, 0);
7076 ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError());
7077 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7078 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
7080 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
7081 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
7083 /* now test with PostThreadMessage - different behaviour! */
7084 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
7086 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
7087 ok(ret, "PeekMessage failed with error %ld\n", GetLastError());
7088 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7089 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
7091 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
7092 ok(ret, "PostMessage failed with error %ld\n", GetLastError());
7094 /* note: we receive the WM_QUIT message first this time */
7095 ret = GetMessage(&msg, NULL, 0, 0);
7096 ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError());
7097 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7098 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
7100 ret = GetMessage(&msg, NULL, 0, 0);
7101 ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError());
7102 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
7108 HMODULE user32 = GetModuleHandleA("user32.dll");
7109 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
7110 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
7111 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
7112 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
7114 if (!RegisterWindowClasses()) assert(0);
7116 if (pSetWinEventHook)
7118 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7119 GetModuleHandleA(0),
7122 GetCurrentThreadId(),
7123 WINEVENT_INCONTEXT);
7124 assert(hEvent_hook);
7126 if (pIsWinEventHookInstalled)
7129 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
7130 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
7134 cbt_hook_thread_id = GetCurrentThreadId();
7135 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
7140 /* Fix message sequences before removing 4 lines below */
7142 ret = pUnhookWinEvent(hEvent_hook);
7143 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
7144 pUnhookWinEvent = 0;
7149 test_scrollwindowex();
7151 test_mdi_messages();
7152 test_button_messages();
7153 test_paint_messages();
7154 test_interthread_messages();
7155 test_message_conversion();
7156 test_accelerators();
7159 test_DestroyWindow();
7160 test_DispatchMessage();
7161 test_SendMessageTimeout();
7162 test_edit_messages();
7163 test_quit_message();
7165 UnhookWindowsHookEx(hCBT_hook);
7166 if (pUnhookWinEvent)
7168 ret = pUnhookWinEvent(hEvent_hook);
7169 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
7170 SetLastError(0xdeadbeef);
7171 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
7172 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7173 GetLastError() == 0xdeadbeef, /* Win9x */
7174 "unexpected error %ld\n", GetLastError());