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 /* ShowWindow(SW_SHOW) for MDI client window */
1487 static const struct message WmShowMDIclientSeq[] = {
1488 { WM_SHOWWINDOW, sent|wparam, 1 },
1489 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1490 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1491 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1494 /* ShowWindow(SW_HIDE) for MDI client window */
1495 static const struct message WmHideMDIclientSeq[] = {
1496 { WM_SHOWWINDOW, sent|wparam, 0 },
1497 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE },
1498 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1499 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1502 /* DestroyWindow for MDI client window, initially visible */
1503 static const struct message WmDestroyMDIclientSeq[] = {
1504 { HCBT_DESTROYWND, hook },
1505 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1506 { WM_SHOWWINDOW, sent|wparam, 0 },
1507 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1508 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1509 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1510 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1511 { WM_DESTROY, sent },
1512 { WM_NCDESTROY, sent },
1515 /* CreateWindow for MDI child window, initially visible */
1516 static const struct message WmCreateMDIchildVisibleSeq[] = {
1517 { HCBT_CREATEWND, hook },
1518 { WM_NCCREATE, sent },
1519 { WM_NCCALCSIZE, sent|wparam, 0 },
1520 { WM_CREATE, sent },
1521 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1524 /* Win2k sends wparam set to
1525 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1526 * while Win9x doesn't bother to set child window id according to
1527 * CLIENTCREATESTRUCT.idFirstChild
1529 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1530 { WM_SHOWWINDOW, sent|wparam, 1 },
1531 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1532 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1533 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1534 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1535 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1536 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1537 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1539 /* Win9x: message sequence terminates here. */
1541 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1542 { HCBT_SETFOCUS, hook }, /* in MDI client */
1543 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1544 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1545 { WM_SETFOCUS, sent }, /* in MDI client */
1546 { HCBT_SETFOCUS, hook },
1547 { WM_KILLFOCUS, sent }, /* in MDI client */
1548 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1549 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1550 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1551 { WM_SETFOCUS, sent|defwinproc },
1552 { WM_MDIACTIVATE, sent|defwinproc },
1555 /* CreateWindow for MDI child window with invisible parent */
1556 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1557 { HCBT_CREATEWND, hook },
1558 { WM_GETMINMAXINFO, sent },
1559 { WM_NCCREATE, sent },
1560 { WM_NCCALCSIZE, sent|wparam, 0 },
1561 { WM_CREATE, sent },
1562 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1565 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1566 { WM_SHOWWINDOW, sent|wparam, 1 },
1567 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1568 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1569 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1570 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1572 /* Win9x: message sequence terminates here. */
1574 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1575 { HCBT_SETFOCUS, hook }, /* in MDI client */
1576 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1577 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1578 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1579 { WM_SETFOCUS, sent }, /* in MDI client */
1580 { HCBT_SETFOCUS, hook },
1581 { WM_KILLFOCUS, sent }, /* in MDI client */
1582 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1583 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1584 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1585 { WM_SETFOCUS, sent|defwinproc },
1586 { WM_MDIACTIVATE, sent|defwinproc },
1589 /* DestroyWindow for MDI child window, initially visible */
1590 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1591 { HCBT_DESTROYWND, hook },
1592 /* Win2k sends wparam set to
1593 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1594 * while Win9x doesn't bother to set child window id according to
1595 * CLIENTCREATESTRUCT.idFirstChild
1597 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1598 { WM_SHOWWINDOW, sent|wparam, 0 },
1599 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1600 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1601 { WM_ERASEBKGND, sent|parent|optional },
1602 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1604 /* { WM_DESTROY, sent }
1605 * Win9x: message sequence terminates here.
1608 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1609 { WM_KILLFOCUS, sent },
1610 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1611 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1612 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1613 { WM_SETFOCUS, sent }, /* in MDI client */
1615 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1616 { WM_KILLFOCUS, sent }, /* in MDI client */
1617 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1618 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1619 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1620 { WM_SETFOCUS, sent }, /* in MDI client */
1622 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1624 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1625 { WM_KILLFOCUS, sent },
1626 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1627 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1628 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1629 { WM_SETFOCUS, sent }, /* in MDI client */
1631 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1632 { WM_KILLFOCUS, sent }, /* in MDI client */
1633 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1634 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1635 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1636 { WM_SETFOCUS, sent }, /* in MDI client */
1638 { WM_DESTROY, sent },
1640 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1641 { WM_KILLFOCUS, sent },
1642 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1643 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1644 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1645 { WM_SETFOCUS, sent }, /* in MDI client */
1647 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1648 { WM_KILLFOCUS, sent }, /* in MDI client */
1649 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1650 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1651 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1652 { WM_SETFOCUS, sent }, /* in MDI client */
1654 { WM_NCDESTROY, sent },
1657 /* CreateWindow for MDI child window, initially invisible */
1658 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1659 { HCBT_CREATEWND, hook },
1660 { WM_NCCREATE, sent },
1661 { WM_NCCALCSIZE, sent|wparam, 0 },
1662 { WM_CREATE, sent },
1663 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1666 /* Win2k sends wparam set to
1667 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1668 * while Win9x doesn't bother to set child window id according to
1669 * CLIENTCREATESTRUCT.idFirstChild
1671 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1674 /* DestroyWindow for MDI child window, initially invisible */
1675 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1676 { HCBT_DESTROYWND, hook },
1677 /* Win2k sends wparam set to
1678 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1679 * while Win9x doesn't bother to set child window id according to
1680 * CLIENTCREATESTRUCT.idFirstChild
1682 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1683 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1684 { WM_DESTROY, sent },
1685 { WM_NCDESTROY, sent },
1688 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1689 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1690 { HCBT_CREATEWND, hook },
1691 { WM_NCCREATE, sent },
1692 { WM_NCCALCSIZE, sent|wparam, 0 },
1693 { WM_CREATE, sent },
1694 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1697 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1698 { WM_GETMINMAXINFO, sent },
1699 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1700 { WM_NCCALCSIZE, sent|wparam, 1 },
1701 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1702 { WM_SIZE, sent|defwinproc },
1704 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1705 { WM_NCCALCSIZE, sent|wparam, 1 },
1706 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1707 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1708 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1709 /* Win2k sends wparam set to
1710 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1711 * while Win9x doesn't bother to set child window id according to
1712 * CLIENTCREATESTRUCT.idFirstChild
1714 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1715 { WM_SHOWWINDOW, sent|wparam, 1 },
1716 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1717 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1718 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1719 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1720 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1721 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1722 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1724 /* Win9x: message sequence terminates here. */
1726 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1727 { HCBT_SETFOCUS, hook }, /* in MDI client */
1728 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1729 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1730 { WM_SETFOCUS, sent }, /* in MDI client */
1731 { HCBT_SETFOCUS, hook },
1732 { WM_KILLFOCUS, sent }, /* in MDI client */
1733 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1734 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1735 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1736 { WM_SETFOCUS, sent|defwinproc },
1737 { WM_MDIACTIVATE, sent|defwinproc },
1739 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1740 { WM_NCCALCSIZE, sent|wparam, 1 },
1741 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1742 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1745 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1746 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
1747 /* restore the 1st MDI child */
1748 { WM_SETREDRAW, sent|wparam, 0 },
1749 { HCBT_MINMAX, hook },
1750 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1751 { WM_NCCALCSIZE, sent|wparam, 1 },
1752 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1753 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1754 { WM_SIZE, sent|defwinproc },
1756 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1757 { WM_NCCALCSIZE, sent|wparam, 1 },
1758 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1759 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1760 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1761 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
1762 /* create the 2nd MDI child */
1763 { HCBT_CREATEWND, hook },
1764 { WM_NCCREATE, sent },
1765 { WM_NCCALCSIZE, sent|wparam, 0 },
1766 { WM_CREATE, sent },
1767 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1770 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1771 { WM_GETMINMAXINFO, sent },
1772 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1773 { WM_NCCALCSIZE, sent|wparam, 1 },
1774 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1775 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1776 { WM_SIZE, sent|defwinproc },
1778 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1779 { WM_NCCALCSIZE, sent|wparam, 1 },
1780 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1781 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1782 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1783 /* Win2k sends wparam set to
1784 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1785 * while Win9x doesn't bother to set child window id according to
1786 * CLIENTCREATESTRUCT.idFirstChild
1788 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1789 { WM_SHOWWINDOW, sent|wparam, 1 },
1790 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1791 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1792 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1793 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1794 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1795 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1797 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1798 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1800 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1802 /* Win9x: message sequence terminates here. */
1804 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1805 { HCBT_SETFOCUS, hook },
1806 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
1807 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
1808 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1809 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1810 { WM_SETFOCUS, sent }, /* in MDI client */
1811 { HCBT_SETFOCUS, hook },
1812 { WM_KILLFOCUS, sent }, /* in MDI client */
1813 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1814 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1815 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1816 { WM_SETFOCUS, sent|defwinproc },
1818 { WM_MDIACTIVATE, sent|defwinproc },
1820 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1821 { WM_NCCALCSIZE, sent|wparam, 1 },
1822 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1823 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1826 /* WM_MDICREATE MDI child window, initially visible and maximized */
1827 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
1828 { WM_MDICREATE, sent },
1829 { HCBT_CREATEWND, hook },
1830 { WM_NCCREATE, sent },
1831 { WM_NCCALCSIZE, sent|wparam, 0 },
1832 { WM_CREATE, sent },
1833 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1836 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1837 { WM_GETMINMAXINFO, sent },
1838 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1839 { WM_NCCALCSIZE, sent|wparam, 1 },
1840 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1841 { WM_SIZE, sent|defwinproc },
1844 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1845 { WM_NCCALCSIZE, sent|wparam, 1 },
1846 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1847 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1848 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1850 /* Win2k sends wparam set to
1851 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1852 * while Win9x doesn't bother to set child window id according to
1853 * CLIENTCREATESTRUCT.idFirstChild
1855 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1856 { WM_SHOWWINDOW, sent|wparam, 1 },
1857 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1859 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1861 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1862 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1863 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1865 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1866 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1868 /* Win9x: message sequence terminates here. */
1870 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1871 { HCBT_SETFOCUS, hook }, /* in MDI client */
1872 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1873 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1874 { WM_SETFOCUS, sent }, /* in MDI client */
1875 { HCBT_SETFOCUS, hook },
1876 { WM_KILLFOCUS, sent }, /* in MDI client */
1877 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1878 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1879 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1880 { WM_SETFOCUS, sent|defwinproc },
1882 { WM_MDIACTIVATE, sent|defwinproc },
1885 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1886 { WM_NCCALCSIZE, sent|wparam, 1 },
1887 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1888 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1891 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1892 { WM_NCCALCSIZE, sent|wparam, 1 },
1893 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1894 { WM_MOVE, sent|defwinproc },
1895 { WM_SIZE, sent|defwinproc },
1898 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1899 { WM_NCCALCSIZE, sent|wparam, 1 },
1900 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1904 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
1905 { WM_NCCALCSIZE, sent|wparam, 1 },
1906 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
1907 { WM_SIZE, sent|defwinproc },
1909 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1910 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1911 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
1912 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1913 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
1917 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
1918 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
1919 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
1920 { HCBT_SYSCOMMAND, hook },
1921 { WM_CLOSE, sent|defwinproc },
1922 { WM_MDIDESTROY, sent }, /* in MDI client */
1924 /* bring the 1st MDI child to top */
1925 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
1926 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
1928 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1930 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
1931 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1932 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1934 /* maximize the 1st MDI child */
1935 { HCBT_MINMAX, hook },
1936 { WM_GETMINMAXINFO, sent|defwinproc },
1937 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
1938 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1939 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
1940 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1941 { WM_SIZE, sent|defwinproc },
1943 /* restore the 2nd MDI child */
1944 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
1945 { HCBT_MINMAX, hook },
1946 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOZORDER|0x8000 },
1947 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1949 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1951 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1952 { WM_SIZE, sent|defwinproc },
1954 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1956 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
1958 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1959 { WM_NCCALCSIZE, sent|wparam, 1 },
1960 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1961 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1962 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1964 /* bring the 1st MDI child to top */
1965 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1966 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1967 { HCBT_SETFOCUS, hook },
1968 { WM_KILLFOCUS, sent|defwinproc },
1969 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
1970 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1971 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1972 { WM_SETFOCUS, sent }, /* in MDI client */
1973 { HCBT_SETFOCUS, hook },
1974 { WM_KILLFOCUS, sent }, /* in MDI client */
1975 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1976 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1977 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1978 { WM_SETFOCUS, sent|defwinproc },
1979 { WM_MDIACTIVATE, sent|defwinproc },
1980 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1982 /* apparently ShowWindow(SW_SHOW) on an MDI client */
1983 { WM_SHOWWINDOW, sent|wparam, 1 },
1984 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1985 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1986 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1987 { WM_MDIREFRESHMENU, sent },
1989 { HCBT_DESTROYWND, hook },
1990 /* Win2k sends wparam set to
1991 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1992 * while Win9x doesn't bother to set child window id according to
1993 * CLIENTCREATESTRUCT.idFirstChild
1995 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1996 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
1997 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
1998 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1999 { WM_ERASEBKGND, sent|parent|optional },
2000 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2002 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2003 { WM_DESTROY, sent|defwinproc },
2004 { WM_NCDESTROY, sent|defwinproc },
2007 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2008 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2009 { WM_MDIDESTROY, sent }, /* in MDI client */
2010 { WM_SHOWWINDOW, sent|wparam, 0 },
2011 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2012 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2013 { WM_ERASEBKGND, sent|parent|optional },
2014 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2016 { HCBT_SETFOCUS, hook },
2017 { WM_KILLFOCUS, sent },
2018 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2019 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2020 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2021 { WM_SETFOCUS, sent }, /* in MDI client */
2022 { HCBT_SETFOCUS, hook },
2023 { WM_KILLFOCUS, sent }, /* in MDI client */
2024 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2025 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2026 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2027 { WM_SETFOCUS, sent },
2030 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2031 { WM_NCCALCSIZE, sent|wparam, 1 },
2032 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2033 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2036 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2037 { WM_NCCALCSIZE, sent|wparam, 1 },
2038 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2039 { WM_MOVE, sent|defwinproc },
2040 { WM_SIZE, sent|defwinproc },
2043 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2044 { WM_NCCALCSIZE, sent|wparam, 1 },
2045 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2049 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2050 { WM_NCCALCSIZE, sent|wparam, 1 },
2051 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2052 { WM_SIZE, sent|defwinproc },
2055 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2056 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2057 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2058 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2061 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2062 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2063 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2064 { WM_MOVE, sent|defwinproc },
2065 { WM_SIZE, sent|defwinproc },
2068 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2069 { WM_NCCALCSIZE, sent|wparam, 1 },
2070 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2074 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOZORDER },
2075 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2076 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2077 { WM_SIZE, sent|defwinproc },
2078 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2079 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2081 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2083 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2084 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2085 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2086 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2087 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2090 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2091 { WM_NCCALCSIZE, sent|wparam, 1 },
2092 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2093 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2095 { WM_NCACTIVATE, sent|wparam, 0 },
2096 { WM_MDIACTIVATE, sent },
2098 { HCBT_MINMAX, hook },
2099 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2100 { WM_NCCALCSIZE, sent|wparam, 1 },
2102 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2104 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2105 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE|0x8000 },
2106 { WM_SIZE, sent|defwinproc },
2109 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2110 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2111 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2112 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2115 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2116 { WM_NCCALCSIZE, sent|wparam, 1 },
2117 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2118 { WM_MOVE, sent|defwinproc },
2119 { WM_SIZE, sent|defwinproc },
2122 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2123 { WM_NCCALCSIZE, sent|wparam, 1 },
2124 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
2126 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2127 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2128 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2129 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2130 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2132 { HCBT_SETFOCUS, hook },
2133 { WM_KILLFOCUS, sent },
2134 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2135 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2136 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2137 { WM_SETFOCUS, sent }, /* in MDI client */
2139 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2141 { HCBT_DESTROYWND, hook },
2142 /* Win2k sends wparam set to
2143 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2144 * while Win9x doesn't bother to set child window id according to
2145 * CLIENTCREATESTRUCT.idFirstChild
2147 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2149 { WM_SHOWWINDOW, sent|wparam, 0 },
2150 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2151 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2152 { WM_ERASEBKGND, sent|parent|optional },
2153 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2155 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2156 { WM_DESTROY, sent },
2157 { WM_NCDESTROY, sent },
2160 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2161 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2162 { HCBT_MINMAX, hook },
2163 { WM_GETMINMAXINFO, sent },
2164 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2165 { WM_NCCALCSIZE, sent|wparam, 1 },
2166 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2167 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2169 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2170 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2171 { HCBT_SETFOCUS, hook },
2172 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2173 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2174 { WM_SETFOCUS, sent }, /* in MDI client */
2175 { HCBT_SETFOCUS, hook },
2176 { WM_KILLFOCUS, sent }, /* in MDI client */
2177 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2178 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2179 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2180 { WM_SETFOCUS, sent|defwinproc },
2181 { WM_MDIACTIVATE, sent|defwinproc },
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 */
2192 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2193 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2194 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2195 { HCBT_MINMAX, hook },
2196 { WM_GETMINMAXINFO, sent },
2197 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2198 { WM_GETMINMAXINFO, sent|defwinproc },
2199 { WM_NCCALCSIZE, sent|wparam, 1 },
2200 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2201 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2202 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOZORDER|0x8000 },
2203 { WM_MOVE, sent|defwinproc },
2204 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2206 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2207 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2208 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2210 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2211 { WM_NCCALCSIZE, sent|wparam, 1 },
2212 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2213 { WM_MOVE, sent|defwinproc },
2214 { WM_SIZE, sent|defwinproc },
2215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2217 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOZORDER },
2218 { WM_NCCALCSIZE, sent|wparam, 1 },
2219 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2222 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOZORDER },
2223 { WM_GETMINMAXINFO, sent|defwinproc },
2224 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2225 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2226 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2227 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2230 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2231 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2232 { HCBT_MINMAX, hook },
2233 { WM_GETMINMAXINFO, sent },
2234 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2235 { WM_NCCALCSIZE, sent|wparam, 1 },
2236 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2237 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2238 { WM_SIZE, sent|defwinproc },
2240 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2241 { WM_NCCALCSIZE, sent|wparam, 1 },
2242 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2243 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2244 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2247 /* ShowWindow(SW_RESTORE) for a visible MDI child window */
2248 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2249 { HCBT_MINMAX, hook },
2250 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2251 { WM_NCCALCSIZE, sent|wparam, 1 },
2252 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2253 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2254 { WM_SIZE, sent|defwinproc },
2256 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2257 { WM_NCCALCSIZE, sent|wparam, 1 },
2258 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2259 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2260 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2263 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2264 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2265 { HCBT_MINMAX, hook },
2266 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2267 { WM_NCCALCSIZE, sent|wparam, 1 },
2268 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2269 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2270 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2271 { WM_SIZE, sent|defwinproc },
2273 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER },
2274 { WM_NCCALCSIZE, sent|wparam, 1 },
2275 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2276 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2277 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2281 static HWND mdi_client;
2282 static WNDPROC old_mdi_client_proc;
2284 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2288 /* do not log painting messages */
2289 if (message != WM_PAINT &&
2290 message != WM_ERASEBKGND &&
2291 message != WM_NCPAINT &&
2292 message != WM_NCHITTEST &&
2293 message != WM_GETTEXT &&
2294 message != WM_MDIGETACTIVE &&
2295 message != WM_GETICON &&
2296 message != WM_DEVICECHANGE)
2298 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2302 case WM_WINDOWPOSCHANGING:
2303 case WM_WINDOWPOSCHANGED:
2305 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2307 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2308 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2309 winpos->hwnd, winpos->hwndInsertAfter,
2310 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2312 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2313 * in the high word for internal purposes
2315 wParam = winpos->flags & 0xffff;
2320 msg.message = message;
2321 msg.flags = sent|wparam|lparam;
2322 msg.wParam = wParam;
2323 msg.lParam = lParam;
2327 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2330 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2332 static long defwndproc_counter = 0;
2336 /* do not log painting messages */
2337 if (message != WM_PAINT &&
2338 message != WM_ERASEBKGND &&
2339 message != WM_NCPAINT &&
2340 message != WM_NCHITTEST &&
2341 message != WM_GETTEXT &&
2342 message != WM_GETICON &&
2343 message != WM_DEVICECHANGE)
2345 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2349 case WM_WINDOWPOSCHANGING:
2350 case WM_WINDOWPOSCHANGED:
2352 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2354 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2355 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2356 winpos->hwnd, winpos->hwndInsertAfter,
2357 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2359 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2360 * in the high word for internal purposes
2362 wParam = winpos->flags & 0xffff;
2366 case WM_MDIACTIVATE:
2368 HWND active, client = GetParent(hwnd);
2370 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2372 if (hwnd == (HWND)lParam) /* if we are being activated */
2373 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2375 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2380 msg.message = message;
2381 msg.flags = sent|wparam|lparam;
2382 if (defwndproc_counter) msg.flags |= defwinproc;
2383 msg.wParam = wParam;
2384 msg.lParam = lParam;
2388 defwndproc_counter++;
2389 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2390 defwndproc_counter--;
2395 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2397 static long defwndproc_counter = 0;
2401 /* do not log painting messages */
2402 if (message != WM_PAINT &&
2403 message != WM_ERASEBKGND &&
2404 message != WM_NCPAINT &&
2405 message != WM_NCHITTEST &&
2406 message != WM_GETTEXT &&
2407 message != WM_GETICON &&
2408 message != WM_DEVICECHANGE)
2410 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2414 case WM_WINDOWPOSCHANGING:
2415 case WM_WINDOWPOSCHANGED:
2417 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2419 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2420 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2421 winpos->hwnd, winpos->hwndInsertAfter,
2422 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2424 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2425 * in the high word for internal purposes
2427 wParam = winpos->flags & 0xffff;
2432 msg.message = message;
2433 msg.flags = sent|wparam|lparam;
2434 if (defwndproc_counter) msg.flags |= defwinproc;
2435 msg.wParam = wParam;
2436 msg.lParam = lParam;
2440 defwndproc_counter++;
2441 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2442 defwndproc_counter--;
2447 static BOOL mdi_RegisterWindowClasses(void)
2452 cls.lpfnWndProc = mdi_frame_wnd_proc;
2455 cls.hInstance = GetModuleHandleA(0);
2457 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2458 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2459 cls.lpszMenuName = NULL;
2460 cls.lpszClassName = "MDI_frame_class";
2461 if (!RegisterClassA(&cls)) return FALSE;
2463 cls.lpfnWndProc = mdi_child_wnd_proc;
2464 cls.lpszClassName = "MDI_child_class";
2465 if (!RegisterClassA(&cls)) return FALSE;
2467 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2468 old_mdi_client_proc = cls.lpfnWndProc;
2469 cls.hInstance = GetModuleHandleA(0);
2470 cls.lpfnWndProc = mdi_client_hook_proc;
2471 cls.lpszClassName = "MDI_client_class";
2472 if (!RegisterClassA(&cls)) assert(0);
2477 static void test_mdi_messages(void)
2479 MDICREATESTRUCTA mdi_cs;
2480 CLIENTCREATESTRUCT client_cs;
2481 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2483 HMENU hMenu = CreateMenu();
2485 assert(mdi_RegisterWindowClasses());
2489 trace("creating MDI frame window\n");
2490 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2491 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2492 WS_MAXIMIZEBOX | WS_VISIBLE,
2493 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2494 GetDesktopWindow(), hMenu,
2495 GetModuleHandleA(0), NULL);
2497 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", TRUE);
2499 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2500 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2502 trace("creating MDI client window\n");
2503 client_cs.hWindowMenu = 0;
2504 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2505 mdi_client = CreateWindowExA(0, "MDI_client_class",
2507 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2509 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2511 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2513 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2514 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2516 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2517 ok(!active_child, "wrong active MDI child %p\n", active_child);
2518 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2523 trace("creating invisible MDI child window\n");
2524 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2526 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2527 mdi_client, 0, GetModuleHandleA(0), NULL);
2531 ShowWindow(mdi_child, SW_SHOWNORMAL);
2532 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
2534 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2535 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2537 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2538 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2540 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2541 ok(!active_child, "wrong active MDI child %p\n", active_child);
2542 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2544 ShowWindow(mdi_child, SW_HIDE);
2545 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
2548 ShowWindow(mdi_child, SW_SHOW);
2549 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
2551 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2552 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2554 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2555 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2557 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2558 ok(!active_child, "wrong active MDI child %p\n", active_child);
2559 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2561 DestroyWindow(mdi_child);
2564 trace("creating visible MDI child window\n");
2565 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2566 WS_CHILD | WS_VISIBLE,
2567 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2568 mdi_client, 0, GetModuleHandleA(0), NULL);
2570 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
2572 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2573 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2575 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2576 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2578 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2579 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2580 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2583 DestroyWindow(mdi_child);
2584 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2586 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2587 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2589 /* Win2k: MDI client still returns a just destroyed child as active
2590 * Win9x: MDI client returns 0
2592 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2593 ok(active_child == mdi_child || /* win2k */
2594 !active_child, /* win9x */
2595 "wrong active MDI child %p\n", active_child);
2596 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2600 trace("creating invisible MDI child window\n");
2601 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2603 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2604 mdi_client, 0, GetModuleHandleA(0), NULL);
2606 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
2608 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
2609 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
2611 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2612 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2614 /* Win2k: MDI client still returns a just destroyed child as active
2615 * Win9x: MDI client returns mdi_child2
2617 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2618 ok(active_child == mdi_child || /* win2k */
2619 active_child == mdi_child2, /* win9x */
2620 "wrong active MDI child %p\n", active_child);
2621 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2624 ShowWindow(mdi_child2, SW_MAXIMIZE);
2625 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", TRUE);
2627 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2628 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2630 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2631 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2632 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2635 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2636 ok(GetFocus() == mdi_child2 || /* win2k */
2637 GetFocus() == 0, /* win9x */
2638 "wrong focus window %p\n", GetFocus());
2643 ShowWindow(mdi_child2, SW_HIDE);
2644 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2646 ShowWindow(mdi_child2, SW_RESTORE);
2647 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", TRUE);
2650 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2651 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2653 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2654 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2655 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2661 ShowWindow(mdi_child2, SW_HIDE);
2662 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2664 ShowWindow(mdi_child2, SW_SHOW);
2665 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
2667 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2668 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2670 ShowWindow(mdi_child2, SW_MAXIMIZE);
2671 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", TRUE);
2673 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2674 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2676 ShowWindow(mdi_child2, SW_RESTORE);
2677 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):MDI child", TRUE);
2679 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2680 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2685 ShowWindow(mdi_child2, SW_HIDE);
2686 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2688 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2689 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2691 DestroyWindow(mdi_child2);
2692 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
2694 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2695 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2697 /* test for maximized MDI children */
2698 trace("creating maximized visible MDI child window 1\n");
2699 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2700 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2701 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2702 mdi_client, 0, GetModuleHandleA(0), NULL);
2704 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
2705 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2707 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2708 ok(GetFocus() == mdi_child || /* win2k */
2709 GetFocus() == 0, /* win9x */
2710 "wrong focus window %p\n", GetFocus());
2712 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2713 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2714 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2717 trace("creating maximized visible MDI child window 2\n");
2718 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2719 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2720 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2721 mdi_client, 0, GetModuleHandleA(0), NULL);
2723 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2724 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2725 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2727 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2728 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2730 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2731 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2732 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2735 trace("destroying maximized visible MDI child window 2\n");
2736 DestroyWindow(mdi_child2);
2737 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2739 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2741 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2742 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2744 /* Win2k: MDI client still returns a just destroyed child as active
2745 * Win9x: MDI client returns 0
2747 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2748 ok(active_child == mdi_child2 || /* win2k */
2749 !active_child, /* win9x */
2750 "wrong active MDI child %p\n", active_child);
2753 ShowWindow(mdi_child, SW_MAXIMIZE);
2754 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2757 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2758 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2760 trace("re-creating maximized visible MDI child window 2\n");
2761 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2762 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2763 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2764 mdi_client, 0, GetModuleHandleA(0), NULL);
2766 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2767 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2768 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2770 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2771 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2773 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2774 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2775 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2778 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
2779 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
2780 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
2782 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2783 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2784 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2786 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2787 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2788 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2791 DestroyWindow(mdi_child);
2792 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2794 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2795 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2797 /* Win2k: MDI client still returns a just destroyed child as active
2798 * Win9x: MDI client returns 0
2800 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2801 ok(active_child == mdi_child || /* win2k */
2802 !active_child, /* win9x */
2803 "wrong active MDI child %p\n", active_child);
2805 /* end of test for maximized MDI children */
2807 mdi_cs.szClass = "MDI_child_Class";
2808 mdi_cs.szTitle = "MDI child";
2809 mdi_cs.hOwner = GetModuleHandleA(0);
2812 mdi_cs.cx = CW_USEDEFAULT;
2813 mdi_cs.cy = CW_USEDEFAULT;
2814 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
2816 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
2817 ok(mdi_child != 0, "MDI child creation failed\n");
2818 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
2820 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
2822 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2823 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2825 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
2826 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2827 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2829 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2830 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2831 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2834 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
2835 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
2837 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
2838 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2839 ok(!active_child, "wrong active MDI child %p\n", active_child);
2844 DestroyWindow(mdi_client);
2845 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
2847 /* test maximization of MDI child with invisible parent */
2848 client_cs.hWindowMenu = 0;
2849 mdi_client = CreateWindow("MDI_client_class",
2851 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
2853 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2854 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
2856 ShowWindow(mdi_client, SW_HIDE);
2857 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
2859 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2860 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
2862 mdi_client, 0, GetModuleHandleA(0), NULL);
2863 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
2865 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
2866 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
2867 zoomed = IsZoomed(mdi_child);
2868 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2870 ShowWindow(mdi_client, SW_SHOW);
2871 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
2873 DestroyWindow(mdi_child);
2874 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
2876 DestroyWindow(mdi_client);
2877 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
2878 /* end of test for maximization of MDI child with invisible parent */
2880 DestroyWindow(mdi_frame);
2881 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
2883 /************************* End of MDI test **********************************/
2885 static void test_WM_SETREDRAW(HWND hwnd)
2887 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
2891 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
2892 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
2894 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
2895 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
2898 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
2899 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
2901 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
2902 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
2904 /* restore original WS_VISIBLE state */
2905 SetWindowLongA(hwnd, GWL_STYLE, style);
2910 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2914 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2916 /* explicitly ignore WM_GETICON message */
2917 if (message == WM_GETICON) return 0;
2921 case WM_WINDOWPOSCHANGING:
2922 case WM_WINDOWPOSCHANGED:
2924 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2926 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2927 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2928 winpos->hwnd, winpos->hwndInsertAfter,
2929 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2931 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2932 * in the high word for internal purposes
2934 wParam = winpos->flags & 0xffff;
2939 msg.message = message;
2940 msg.flags = sent|wparam|lparam;
2941 msg.wParam = wParam;
2942 msg.lParam = lParam;
2945 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
2946 if (message == WM_TIMER) EndDialog( hwnd, 0 );
2950 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
2952 DWORD style, exstyle;
2956 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2957 style = GetWindowLongA(hwnd, GWL_STYLE);
2958 /* do not be confused by WS_DLGFRAME set */
2959 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
2961 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
2962 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
2964 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
2965 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
2966 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
2967 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
2969 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
2971 style = GetWindowLongA(hwnd, GWL_STYLE);
2972 if (set) ok(style & set, "style %08lx should be set\n", set);
2973 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
2975 /* a subsequent call should do nothing */
2976 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
2977 ok( ret, "SetScrollRange(%d) error %ld\n", ctl, GetLastError());
2978 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2982 trace("Ignore GetScrollRange error below if you are on Win9x\n");
2983 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
2984 ok( ret, "GetScrollRange(%d) error %ld\n", ctl, GetLastError());
2985 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
2986 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
2987 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
2990 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
2992 DWORD style, exstyle;
2996 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
2997 style = GetWindowLongA(hwnd, GWL_STYLE);
2998 /* do not be confused by WS_DLGFRAME set */
2999 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3001 if (clear) ok(style & clear, "style %08lx should be set\n", clear);
3002 if (set) ok(!(style & set), "style %08lx should not be set\n", set);
3004 si.cbSize = sizeof(si);
3005 si.fMask = SIF_RANGE;
3008 SetScrollInfo(hwnd, ctl, &si, TRUE);
3009 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3010 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3012 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3014 style = GetWindowLongA(hwnd, GWL_STYLE);
3015 if (set) ok(style & set, "style %08lx should be set\n", set);
3016 if (clear) ok(!(style & clear), "style %08lx should not be set\n", clear);
3018 /* a subsequent call should do nothing */
3019 SetScrollInfo(hwnd, ctl, &si, TRUE);
3020 if (style & WS_HSCROLL)
3021 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3022 else if (style & WS_VSCROLL)
3023 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3025 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3027 si.fMask = SIF_PAGE;
3029 SetScrollInfo(hwnd, ctl, &si, FALSE);
3030 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3034 SetScrollInfo(hwnd, ctl, &si, FALSE);
3035 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3037 si.fMask = SIF_RANGE;
3038 si.nMin = 0xdeadbeef;
3039 si.nMax = 0xdeadbeef;
3040 ret = GetScrollInfo(hwnd, ctl, &si);
3041 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
3042 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3043 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3044 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3047 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3048 static void test_scroll_messages(HWND hwnd)
3056 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3057 ok( ret, "GetScrollRange error %ld\n", GetLastError());
3058 if (sequence->message != WmGetScrollRangeSeq[0].message)
3059 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3060 /* values of min and max are undefined */
3063 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3064 ok( ret, "SetScrollRange error %ld\n", GetLastError());
3065 if (sequence->message != WmSetScrollRangeSeq[0].message)
3066 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3071 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3072 ok( ret, "GetScrollRange error %ld\n", GetLastError());
3073 if (sequence->message != WmGetScrollRangeSeq[0].message)
3074 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3075 /* values of min and max are undefined */
3078 si.cbSize = sizeof(si);
3079 si.fMask = SIF_RANGE;
3082 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3083 if (sequence->message != WmSetScrollRangeSeq[0].message)
3084 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3087 si.fMask = SIF_PAGE;
3089 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3090 if (sequence->message != WmSetScrollRangeSeq[0].message)
3091 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3096 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3097 if (sequence->message != WmSetScrollRangeSeq[0].message)
3098 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3101 si.fMask = SIF_RANGE;
3102 si.nMin = 0xdeadbeef;
3103 si.nMax = 0xdeadbeef;
3104 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3105 ok( ret, "GetScrollInfo error %ld\n", GetLastError());
3106 if (sequence->message != WmGetScrollInfoSeq[0].message)
3107 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3108 /* values of min and max are undefined */
3111 /* set WS_HSCROLL */
3112 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3113 /* clear WS_HSCROLL */
3114 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3116 /* set WS_HSCROLL */
3117 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3118 /* clear WS_HSCROLL */
3119 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3121 /* set WS_VSCROLL */
3122 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3123 /* clear WS_VSCROLL */
3124 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3126 /* set WS_VSCROLL */
3127 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3128 /* clear WS_VSCROLL */
3129 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3132 static void test_showwindow(void)
3137 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3138 100, 100, 200, 200, 0, 0, 0, NULL);
3139 ok (hwnd != 0, "Failed to create overlapped window\n");
3140 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3141 0, 0, 10, 10, hwnd, 0, 0, NULL);
3142 ok (hchild != 0, "Failed to create child\n");
3145 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3146 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3147 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3148 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3151 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3152 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3153 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3154 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3156 /* back to invisible */
3157 ShowWindow(hchild, SW_HIDE);
3158 ShowWindow(hwnd, SW_HIDE);
3160 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3161 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3162 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3163 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3165 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3166 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3168 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3169 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3170 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3172 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3173 ShowWindow( hwnd, SW_SHOW);
3175 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3176 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3177 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3180 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3181 ShowWindow( hchild, SW_HIDE);
3183 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3184 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3185 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3189 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3190 DestroyWindow(hchild);
3191 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3193 DestroyWindow(hwnd);
3198 * 1. Create invisible maximized popup window.
3199 * 2. Move and resize it.
3200 * 3. Show it maximized.
3202 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3203 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3204 100, 100, 200, 200, 0, 0, 0, NULL);
3205 ok (hwnd != 0, "Failed to create popup window\n");
3206 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3209 GetWindowRect(hwnd, &rc);
3210 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3211 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3212 "Invalid maximized size before ShowWindow (%ld,%ld)-(%ld,%ld)\n",
3213 rc.left, rc.top, rc.right, rc.bottom);
3214 /* Reset window's size & position */
3215 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3218 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible popup window\n");
3219 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3220 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3223 GetWindowRect(hwnd, &rc);
3224 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3225 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3226 "Invalid maximized size after ShowWindow (%ld,%ld)-(%ld,%ld)\n",
3227 rc.left, rc.top, rc.right, rc.bottom);
3228 DestroyWindow(hwnd);
3232 * 1. Create invisible maximized popup window.
3233 * 2. Show it maximized.
3235 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3236 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3237 100, 100, 200, 200, 0, 0, 0, NULL);
3238 ok (hwnd != 0, "Failed to create popup window\n");
3239 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3242 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible popup window\n");
3243 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3244 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3246 DestroyWindow(hwnd);
3250 * 1. Create visible maximized popup window.
3252 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3253 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3254 100, 100, 200, 200, 0, 0, 0, NULL);
3255 ok (hwnd != 0, "Failed to create popup window\n");
3256 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3258 DestroyWindow(hwnd);
3262 * 1. Create visible popup window.
3265 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3266 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3267 100, 100, 200, 200, 0, 0, 0, NULL);
3268 ok (hwnd != 0, "Failed to create popup window\n");
3269 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", TRUE);
3272 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3273 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3274 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", TRUE);
3276 DestroyWindow(hwnd);
3280 static void test_sys_menu(HWND hwnd)
3285 /* test existing window without CS_NOCLOSE style */
3286 hmenu = GetSystemMenu(hwnd, FALSE);
3287 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
3289 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3290 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3291 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3293 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3294 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3296 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3297 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3298 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3300 EnableMenuItem(hmenu, SC_CLOSE, 0);
3301 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3303 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3304 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3305 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3307 /* test new window with CS_NOCLOSE style */
3308 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3309 100, 100, 200, 200, 0, 0, 0, NULL);
3310 ok (hwnd != 0, "Failed to create overlapped window\n");
3312 hmenu = GetSystemMenu(hwnd, FALSE);
3313 ok(hmenu != 0, "GetSystemMenu error %ld\n", GetLastError());
3315 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3316 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3318 DestroyWindow(hwnd);
3321 /* test if we receive the right sequence of messages */
3322 static void test_messages(void)
3324 HWND hwnd, hparent, hchild;
3325 HWND hchild2, hbutton;
3332 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3333 100, 100, 200, 200, 0, 0, 0, NULL);
3334 ok (hwnd != 0, "Failed to create overlapped window\n");
3335 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3337 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3338 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
3339 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
3341 /* test WM_SETREDRAW on a not visible top level window */
3342 test_WM_SETREDRAW(hwnd);
3344 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3345 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
3346 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
3348 ok(GetActiveWindow() == hwnd, "window should be active\n");
3349 ok(GetFocus() == hwnd, "window should have input focus\n");
3350 ShowWindow(hwnd, SW_HIDE);
3351 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
3353 ShowWindow(hwnd, SW_SHOW);
3354 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
3356 ShowWindow(hwnd, SW_HIDE);
3357 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
3359 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3360 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
3362 ShowWindow(hwnd, SW_RESTORE);
3363 /* FIXME: add ok_sequence() here */
3366 ShowWindow(hwnd, SW_SHOW);
3367 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
3369 ok(GetActiveWindow() == hwnd, "window should be active\n");
3370 ok(GetFocus() == hwnd, "window should have input focus\n");
3371 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3372 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
3373 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
3374 ok(GetActiveWindow() == hwnd, "window should still be active\n");
3376 /* test WM_SETREDRAW on a visible top level window */
3377 ShowWindow(hwnd, SW_SHOW);
3378 test_WM_SETREDRAW(hwnd);
3380 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
3381 test_scroll_messages(hwnd);
3383 /* test resizing and moving */
3384 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3385 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
3386 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE );
3387 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
3389 /* popups don't get WM_GETMINMAXINFO */
3390 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
3391 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3393 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE );
3394 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
3396 test_sys_menu(hwnd);
3399 DestroyWindow(hwnd);
3400 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
3402 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3403 100, 100, 200, 200, 0, 0, 0, NULL);
3404 ok (hparent != 0, "Failed to create parent window\n");
3407 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
3408 0, 0, 10, 10, hparent, 0, 0, NULL);
3409 ok (hchild != 0, "Failed to create child window\n");
3410 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", TRUE);
3411 DestroyWindow(hchild);
3414 /* visible child window with a caption */
3415 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
3416 WS_CHILD | WS_VISIBLE | WS_CAPTION,
3417 0, 0, 10, 10, hparent, 0, 0, NULL);
3418 ok (hchild != 0, "Failed to create child window\n");
3419 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
3421 trace("testing scroll APIs on a visible child window %p\n", hchild);
3422 test_scroll_messages(hchild);
3424 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3425 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
3427 DestroyWindow(hchild);
3430 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3431 0, 0, 10, 10, hparent, 0, 0, NULL);
3432 ok (hchild != 0, "Failed to create child window\n");
3433 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3435 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
3436 100, 100, 50, 50, hparent, 0, 0, NULL);
3437 ok (hchild2 != 0, "Failed to create child2 window\n");
3440 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
3441 0, 100, 50, 50, hchild, 0, 0, NULL);
3442 ok (hbutton != 0, "Failed to create button window\n");
3444 /* test WM_SETREDRAW on a not visible child window */
3445 test_WM_SETREDRAW(hchild);
3447 ShowWindow(hchild, SW_SHOW);
3448 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3450 ShowWindow(hchild, SW_HIDE);
3451 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
3453 ShowWindow(hchild, SW_SHOW);
3454 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3456 /* test WM_SETREDRAW on a visible child window */
3457 test_WM_SETREDRAW(hchild);
3459 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
3460 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
3462 ShowWindow(hchild, SW_HIDE);
3464 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3465 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
3467 ShowWindow(hchild, SW_HIDE);
3469 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3470 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
3472 /* DestroyWindow sequence below expects that a child has focus */
3476 DestroyWindow(hchild);
3477 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
3478 DestroyWindow(hchild2);
3479 DestroyWindow(hbutton);
3482 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
3483 0, 0, 100, 100, hparent, 0, 0, NULL);
3484 ok (hchild != 0, "Failed to create child popup window\n");
3485 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
3486 DestroyWindow(hchild);
3488 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3490 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
3491 0, 0, 100, 100, hparent, 0, 0, NULL);
3492 ok (hchild != 0, "Failed to create popup window\n");
3493 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3494 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3495 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3497 ShowWindow(hchild, SW_SHOW);
3498 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3500 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3501 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3503 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3504 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
3505 DestroyWindow(hchild);
3507 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3508 * changes nothing in message sequences.
3511 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
3512 0, 0, 100, 100, hparent, 0, 0, NULL);
3513 ok (hchild != 0, "Failed to create popup window\n");
3514 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3515 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3516 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3518 ShowWindow(hchild, SW_SHOW);
3519 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3521 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3522 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3523 DestroyWindow(hchild);
3526 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
3527 0, 0, 100, 100, hparent, 0, 0, NULL);
3528 ok(hwnd != 0, "Failed to create custom dialog window\n");
3529 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
3532 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3533 test_scroll_messages(hwnd);
3537 after_end_dialog = 1;
3538 EndDialog( hwnd, 0 );
3539 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
3541 DestroyWindow(hwnd);
3542 after_end_dialog = 0;
3544 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
3545 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
3546 ok(hwnd != 0, "Failed to create custom dialog window\n");
3548 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
3549 ShowWindow(hwnd, SW_SHOW);
3550 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
3551 DestroyWindow(hwnd);
3554 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
3555 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
3557 /* test showing child with hidden parent */
3558 ShowWindow( hparent, SW_HIDE );
3561 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3562 0, 0, 10, 10, hparent, 0, 0, NULL);
3563 ok (hchild != 0, "Failed to create child window\n");
3564 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3566 ShowWindow( hchild, SW_SHOW );
3567 ok_sequence(WmShowChildInvisibleParentSeq, "ShowWindow:show child with invisible parent", FALSE);
3568 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3569 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3571 ShowWindow( hchild, SW_HIDE );
3572 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
3573 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
3574 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3576 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3577 ok_sequence(WmShowChildInvisibleParentSeq_2, "SetWindowPos:show child with invisible parent", FALSE);
3578 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3579 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3581 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3582 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
3583 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
3584 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
3586 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3588 DestroyWindow(hchild);
3589 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
3591 DestroyWindow(hparent);
3594 /* Message sequence for SetMenu */
3595 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
3596 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
3598 hmenu = CreateMenu();
3599 ok (hmenu != 0, "Failed to create menu\n");
3600 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
3601 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3602 100, 100, 200, 200, 0, hmenu, 0, NULL);
3603 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3604 ok (SetMenu(hwnd, 0), "SetMenu\n");
3605 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
3606 ok (SetMenu(hwnd, 0), "SetMenu\n");
3607 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
3608 ShowWindow(hwnd, SW_SHOW);
3609 UpdateWindow( hwnd );
3610 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3612 ok (SetMenu(hwnd, 0), "SetMenu\n");
3613 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
3614 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
3615 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
3617 UpdateWindow( hwnd );
3618 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3620 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
3621 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3622 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
3624 DestroyWindow(hwnd);
3627 /* Message sequence for EnableWindow */
3628 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3629 100, 100, 200, 200, 0, 0, 0, NULL);
3630 ok (hparent != 0, "Failed to create parent window\n");
3631 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
3632 0, 0, 10, 10, hparent, 0, 0, NULL);
3633 ok (hchild != 0, "Failed to create child window\n");
3638 EnableWindow(hparent, FALSE);
3639 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
3641 EnableWindow(hparent, TRUE);
3642 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
3644 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3647 /* MsgWaitForMultipleObjects test */
3648 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3649 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3651 PostMessageA(hparent, WM_USER, 0, 0);
3653 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3654 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %lx\n", ret);
3656 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3657 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3659 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3660 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %lx\n", ret);
3661 /* end of MsgWaitForMultipleObjects test */
3663 /* the following test causes an exception in user.exe under win9x */
3664 if (!PostMessageW( hparent, WM_USER, 0, 0 )) return;
3665 PostMessageW( hparent, WM_USER+1, 0, 0 );
3666 /* PeekMessage(NULL) fails, but still removes the message */
3667 SetLastError(0xdeadbeef);
3668 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
3669 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
3670 GetLastError() == 0xdeadbeef, /* NT4 */
3671 "last error is %ld\n", GetLastError() );
3672 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
3673 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
3675 DestroyWindow(hchild);
3676 DestroyWindow(hparent);
3682 /****************** button message test *************************/
3683 static const struct message WmSetFocusButtonSeq[] =
3685 { HCBT_SETFOCUS, hook },
3686 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3687 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3688 { WM_SETFOCUS, sent|wparam, 0 },
3689 { WM_CTLCOLORBTN, sent|defwinproc },
3692 static const struct message WmKillFocusButtonSeq[] =
3694 { HCBT_SETFOCUS, hook },
3695 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3696 { WM_KILLFOCUS, sent|wparam, 0 },
3697 { WM_CTLCOLORBTN, sent|defwinproc },
3698 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3701 static const struct message WmSetFocusStaticSeq[] =
3703 { HCBT_SETFOCUS, hook },
3704 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3705 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3706 { WM_SETFOCUS, sent|wparam, 0 },
3707 { WM_CTLCOLORSTATIC, sent|defwinproc },
3710 static const struct message WmKillFocusStaticSeq[] =
3712 { HCBT_SETFOCUS, hook },
3713 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3714 { WM_KILLFOCUS, sent|wparam, 0 },
3715 { WM_CTLCOLORSTATIC, sent|defwinproc },
3716 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
3719 static const struct message WmLButtonDownSeq[] =
3721 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
3722 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
3723 { HCBT_SETFOCUS, hook },
3724 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3725 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3726 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
3727 { WM_CTLCOLORBTN, sent|defwinproc },
3728 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
3729 { WM_CTLCOLORBTN, sent|defwinproc },
3730 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3733 static const struct message WmLButtonUpSeq[] =
3735 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
3736 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
3737 { WM_CTLCOLORBTN, sent|defwinproc },
3738 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3739 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
3740 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
3744 static WNDPROC old_button_proc;
3746 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3748 static long defwndproc_counter = 0;
3752 trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3754 /* explicitly ignore WM_GETICON message */
3755 if (message == WM_GETICON) return 0;
3757 msg.message = message;
3758 msg.flags = sent|wparam|lparam;
3759 if (defwndproc_counter) msg.flags |= defwinproc;
3760 msg.wParam = wParam;
3761 msg.lParam = lParam;
3764 if (message == BM_SETSTATE)
3765 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
3767 defwndproc_counter++;
3768 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
3769 defwndproc_counter--;
3774 static void subclass_button(void)
3778 if (!GetClassInfoA(0, "button", &cls)) assert(0);
3780 old_button_proc = cls.lpfnWndProc;
3782 cls.hInstance = GetModuleHandle(0);
3783 cls.lpfnWndProc = button_hook_proc;
3784 cls.lpszClassName = "my_button_class";
3785 if (!RegisterClassA(&cls)) assert(0);
3788 static void test_button_messages(void)
3794 const struct message *setfocus;
3795 const struct message *killfocus;
3797 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
3798 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3799 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
3800 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3801 { BS_CHECKBOX, DLGC_BUTTON,
3802 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3803 { BS_AUTOCHECKBOX, DLGC_BUTTON,
3804 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3805 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
3806 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3807 { BS_3STATE, DLGC_BUTTON,
3808 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3809 { BS_AUTO3STATE, DLGC_BUTTON,
3810 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3811 { BS_GROUPBOX, DLGC_STATIC,
3812 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3813 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
3814 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
3815 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
3816 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
3817 { BS_OWNERDRAW, DLGC_BUTTON,
3818 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
3826 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
3828 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
3829 0, 0, 50, 14, 0, 0, 0, NULL);
3830 ok(hwnd != 0, "Failed to create button window\n");
3832 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
3833 ok(dlg_code == button[i].dlg_code, "%d: wrong dlg_code %08lx\n", i, dlg_code);
3835 ShowWindow(hwnd, SW_SHOW);
3840 trace("button style %08lx\n", button[i].style);
3842 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
3845 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
3847 DestroyWindow(hwnd);
3850 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
3851 0, 0, 50, 14, 0, 0, 0, NULL);
3852 ok(hwnd != 0, "Failed to create button window\n");
3857 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
3858 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
3860 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
3861 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
3862 DestroyWindow(hwnd);
3865 /************* painting message test ********************/
3867 void dump_region(HRGN hrgn)
3870 RGNDATA *data = NULL;
3875 printf( "null region\n" );
3878 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
3879 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
3880 GetRegionData( hrgn, size, data );
3881 printf("%ld rects:", data->rdh.nCount );
3882 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
3883 printf( " (%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
3885 HeapFree( GetProcessHeap(), 0, data );
3888 static void check_update_rgn( HWND hwnd, HRGN hrgn )
3892 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
3893 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
3895 ret = GetUpdateRgn( hwnd, update, FALSE );
3896 ok( ret != ERROR, "GetUpdateRgn failed\n" );
3897 if (ret == NULLREGION)
3899 ok( !hrgn, "Update region shouldn't be empty\n" );
3903 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
3905 ok( 0, "Regions are different\n" );
3906 if (winetest_debug > 0)
3908 printf( "Update region: " );
3909 dump_region( update );
3910 printf( "Wanted region: " );
3911 dump_region( hrgn );
3915 GetRgnBox( update, &r1 );
3916 GetUpdateRect( hwnd, &r2, FALSE );
3917 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
3918 "Rectangles are different: %ld,%ld-%ld,%ld / %ld,%ld-%ld,%ld\n",
3919 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
3921 DeleteObject( tmp );
3922 DeleteObject( update );
3925 static const struct message WmInvalidateRgn[] = {
3926 { WM_NCPAINT, sent },
3927 { WM_GETTEXT, sent|defwinproc|optional },
3931 static const struct message WmGetUpdateRect[] = {
3932 { WM_NCPAINT, sent },
3933 { WM_GETTEXT, sent|defwinproc|optional },
3938 static const struct message WmInvalidateFull[] = {
3939 { WM_NCPAINT, sent|wparam, 1 },
3940 { WM_GETTEXT, sent|defwinproc|optional },
3944 static const struct message WmInvalidateErase[] = {
3945 { WM_NCPAINT, sent|wparam, 1 },
3946 { WM_GETTEXT, sent|defwinproc|optional },
3947 { WM_ERASEBKGND, sent },
3951 static const struct message WmInvalidatePaint[] = {
3953 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
3954 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3958 static const struct message WmInvalidateErasePaint[] = {
3960 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
3961 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3962 { WM_ERASEBKGND, sent|beginpaint },
3966 static const struct message WmInvalidateErasePaint2[] = {
3968 { WM_NCPAINT, sent|beginpaint },
3969 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
3970 { WM_ERASEBKGND, sent|beginpaint },
3974 static const struct message WmErase[] = {
3975 { WM_ERASEBKGND, sent },
3979 static const struct message WmPaint[] = {
3984 static const struct message WmParentOnlyPaint[] = {
3985 { WM_PAINT, sent|parent },
3989 static const struct message WmInvalidateParent[] = {
3990 { WM_NCPAINT, sent|parent },
3991 { WM_GETTEXT, sent|defwinproc|parent|optional },
3992 { WM_ERASEBKGND, sent|parent },
3996 static const struct message WmInvalidateParentChild[] = {
3997 { WM_NCPAINT, sent|parent },
3998 { WM_GETTEXT, sent|defwinproc|parent|optional },
3999 { WM_ERASEBKGND, sent|parent },
4000 { WM_NCPAINT, sent },
4001 { WM_GETTEXT, sent|defwinproc|optional },
4002 { WM_ERASEBKGND, sent },
4006 static const struct message WmInvalidateParentChild2[] = {
4007 { WM_ERASEBKGND, sent|parent },
4008 { WM_NCPAINT, sent },
4009 { WM_GETTEXT, sent|defwinproc|optional },
4010 { WM_ERASEBKGND, sent },
4014 static const struct message WmParentPaint[] = {
4015 { WM_PAINT, sent|parent },
4020 static const struct message WmParentPaintNc[] = {
4021 { WM_PAINT, sent|parent },
4023 { WM_NCPAINT, sent|beginpaint },
4024 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4025 { WM_ERASEBKGND, sent|beginpaint },
4029 static const struct message WmChildPaintNc[] = {
4031 { WM_NCPAINT, sent|beginpaint },
4032 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4033 { WM_ERASEBKGND, sent|beginpaint },
4037 static const struct message WmParentErasePaint[] = {
4038 { WM_PAINT, sent|parent },
4039 { WM_NCPAINT, sent|parent|beginpaint },
4040 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4041 { WM_ERASEBKGND, sent|parent|beginpaint },
4043 { WM_NCPAINT, sent|beginpaint },
4044 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4045 { WM_ERASEBKGND, sent|beginpaint },
4049 static const struct message WmParentOnlyNcPaint[] = {
4050 { WM_PAINT, sent|parent },
4051 { WM_NCPAINT, sent|parent|beginpaint },
4052 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4056 static const struct message WmSetParentStyle[] = {
4057 { WM_STYLECHANGING, sent|parent },
4058 { WM_STYLECHANGED, sent|parent },
4062 static void test_paint_messages(void)
4068 HWND hparent, hchild;
4069 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
4070 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
4071 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4072 100, 100, 200, 200, 0, 0, 0, NULL);
4073 ok (hwnd != 0, "Failed to create overlapped window\n");
4075 ShowWindow( hwnd, SW_SHOW );
4076 UpdateWindow( hwnd );
4079 check_update_rgn( hwnd, 0 );
4080 SetRectRgn( hrgn, 10, 10, 20, 20 );
4081 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4082 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4083 check_update_rgn( hwnd, hrgn );
4084 SetRectRgn( hrgn2, 20, 20, 30, 30 );
4085 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
4086 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4087 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
4088 check_update_rgn( hwnd, hrgn );
4089 /* validate everything */
4090 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4091 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4092 check_update_rgn( hwnd, 0 );
4094 /* test empty region */
4095 SetRectRgn( hrgn, 10, 10, 10, 15 );
4096 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4097 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4098 check_update_rgn( hwnd, 0 );
4099 /* test empty rect */
4100 SetRect( &rect, 10, 10, 10, 15 );
4101 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
4102 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4103 check_update_rgn( hwnd, 0 );
4105 /* flush pending messages */
4106 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4109 GetClientRect( hwnd, &rect );
4110 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
4111 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
4112 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4114 trace("testing InvalidateRect(0, NULL, FALSE)\n");
4115 SetRectEmpty( &rect );
4116 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
4117 check_update_rgn( hwnd, hrgn );
4118 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4119 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4120 ok_sequence( WmPaint, "Paint", FALSE );
4121 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4122 check_update_rgn( hwnd, 0 );
4124 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4125 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4127 trace("testing ValidateRect(0, NULL)\n");
4128 SetRectEmpty( &rect );
4129 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
4130 check_update_rgn( hwnd, hrgn );
4131 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4132 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4133 ok_sequence( WmPaint, "Paint", FALSE );
4134 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4135 check_update_rgn( hwnd, 0 );
4137 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4138 SetLastError(0xdeadbeef);
4139 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4140 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
4141 check_update_rgn( hwnd, 0 );
4142 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4143 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4145 trace("testing ValidateRgn(0, NULL)\n");
4146 SetLastError(0xdeadbeef);
4147 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
4148 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %ld\n", GetLastError());
4149 check_update_rgn( hwnd, 0 );
4150 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4151 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4153 /* now with frame */
4154 SetRectRgn( hrgn, -5, -5, 20, 20 );
4156 /* flush pending messages */
4157 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4160 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4161 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4163 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4164 check_update_rgn( hwnd, hrgn );
4167 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4168 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4171 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4172 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
4174 GetClientRect( hwnd, &rect );
4175 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
4176 check_update_rgn( hwnd, hrgn );
4179 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
4180 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4183 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
4184 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
4185 check_update_rgn( hwnd, 0 );
4188 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
4189 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
4190 check_update_rgn( hwnd, 0 );
4193 SetRectRgn( hrgn, 0, 0, 100, 100 );
4194 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4195 SetRectRgn( hrgn, 0, 0, 50, 100 );
4196 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
4197 SetRectRgn( hrgn, 50, 0, 100, 100 );
4198 check_update_rgn( hwnd, hrgn );
4199 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4200 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
4201 check_update_rgn( hwnd, 0 );
4204 SetRectRgn( hrgn, 0, 0, 100, 100 );
4205 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4206 SetRectRgn( hrgn, 0, 0, 100, 50 );
4207 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4208 ok_sequence( WmErase, "Erase", FALSE );
4209 SetRectRgn( hrgn, 0, 50, 100, 100 );
4210 check_update_rgn( hwnd, hrgn );
4213 SetRectRgn( hrgn, 0, 0, 100, 100 );
4214 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4215 SetRectRgn( hrgn, 0, 0, 50, 50 );
4216 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
4217 ok_sequence( WmPaint, "Paint", FALSE );
4220 SetRectRgn( hrgn, -4, -4, -2, -2 );
4221 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4222 SetRectRgn( hrgn, -200, -200, -198, -198 );
4223 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
4224 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4227 SetRectRgn( hrgn, -4, -4, -2, -2 );
4228 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4229 SetRectRgn( hrgn, -4, -4, -3, -3 );
4230 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
4231 SetRectRgn( hrgn, 0, 0, 1, 1 );
4232 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
4233 ok_sequence( WmPaint, "Paint", FALSE );
4236 SetRectRgn( hrgn, -4, -4, -1, -1 );
4237 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4238 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
4239 /* make sure no WM_PAINT was generated */
4240 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4241 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4244 SetRectRgn( hrgn, -4, -4, -1, -1 );
4245 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4246 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
4248 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
4250 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
4251 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
4252 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
4253 ret = GetUpdateRect( hwnd, &rect, FALSE );
4254 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
4255 /* this will send WM_NCPAINT and validate the non client area */
4256 ret = GetUpdateRect( hwnd, &rect, TRUE );
4257 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
4259 DispatchMessage( &msg );
4261 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
4263 DestroyWindow( hwnd );
4265 /* now test with a child window */
4267 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4268 100, 100, 200, 200, 0, 0, 0, NULL);
4269 ok (hparent != 0, "Failed to create parent window\n");
4271 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
4272 10, 10, 100, 100, hparent, 0, 0, NULL);
4273 ok (hchild != 0, "Failed to create child window\n");
4275 ShowWindow( hparent, SW_SHOW );
4276 UpdateWindow( hparent );
4277 UpdateWindow( hchild );
4280 log_all_parent_messages++;
4282 SetRect( &rect, 0, 0, 50, 50 );
4283 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4284 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4285 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
4287 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4289 MapWindowPoints( hchild, hparent, &pt, 1 );
4290 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
4291 check_update_rgn( hchild, hrgn );
4292 SetRectRgn( hrgn, 0, 0, 50, 50 );
4293 check_update_rgn( hparent, hrgn );
4294 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4295 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
4296 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4297 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4299 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4300 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
4302 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4303 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4304 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
4305 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4306 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4308 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
4309 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4310 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
4312 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4314 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4315 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4316 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
4318 /* flush all paint messages */
4319 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4322 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
4323 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4324 SetRectRgn( hrgn, 0, 0, 50, 50 );
4325 check_update_rgn( hparent, hrgn );
4326 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4327 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4328 SetRectRgn( hrgn, 0, 0, 50, 50 );
4329 check_update_rgn( hparent, hrgn );
4331 /* flush all paint messages */
4332 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4333 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4336 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
4337 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4338 SetRectRgn( hrgn, 0, 0, 50, 50 );
4339 check_update_rgn( hparent, hrgn );
4340 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4341 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4342 SetRectRgn( hrgn2, 10, 10, 50, 50 );
4343 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
4344 check_update_rgn( hparent, hrgn );
4345 /* flush all paint messages */
4346 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4349 /* same as above but parent gets completely validated */
4350 SetRect( &rect, 20, 20, 30, 30 );
4351 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4352 SetRectRgn( hrgn, 20, 20, 30, 30 );
4353 check_update_rgn( hparent, hrgn );
4354 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4355 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4356 check_update_rgn( hparent, 0 ); /* no update region */
4357 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4358 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
4360 /* make sure RDW_VALIDATE on child doesn't have the same effect */
4362 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4363 SetRectRgn( hrgn, 20, 20, 30, 30 );
4364 check_update_rgn( hparent, hrgn );
4365 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
4366 SetRectRgn( hrgn, 20, 20, 30, 30 );
4367 check_update_rgn( hparent, hrgn );
4369 /* same as above but normal WM_PAINT doesn't validate parent */
4371 SetRect( &rect, 20, 20, 30, 30 );
4372 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4373 SetRectRgn( hrgn, 20, 20, 30, 30 );
4374 check_update_rgn( hparent, hrgn );
4375 /* no WM_PAINT in child while parent still pending */
4376 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4377 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4378 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4379 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
4382 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4383 /* no WM_PAINT in child while parent still pending */
4384 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4385 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4386 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
4387 /* now that parent is valid child should get WM_PAINT */
4388 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4389 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4390 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4391 ok_sequence( WmEmptySeq, "No other message", FALSE );
4393 /* same thing with WS_CLIPCHILDREN in parent */
4395 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4396 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4397 /* changing style invalidates non client area, but we need to invalidate something else to see it */
4398 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
4399 ok_sequence( WmEmptySeq, "No message", FALSE );
4400 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
4401 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
4404 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
4405 SetRectRgn( hrgn, 20, 20, 30, 30 );
4406 check_update_rgn( hparent, hrgn );
4407 /* no WM_PAINT in child while parent still pending */
4408 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4409 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
4410 /* WM_PAINT in parent first */
4411 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4412 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
4414 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
4416 SetRect( &rect, 0, 0, 30, 30 );
4417 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
4418 SetRectRgn( hrgn, 0, 0, 30, 30 );
4419 check_update_rgn( hparent, hrgn );
4420 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4421 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
4423 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4425 SetRect( &rect, -10, 0, 30, 30 );
4426 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4427 SetRect( &rect, 0, 0, 20, 20 );
4428 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4429 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4430 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
4432 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
4434 SetRect( &rect, -10, 0, 30, 30 );
4435 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
4436 SetRect( &rect, 0, 0, 100, 100 );
4437 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
4438 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
4439 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
4440 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4441 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
4443 /* test RDW_INTERNALPAINT behavior */
4446 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
4447 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4448 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4450 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
4451 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4452 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4454 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4455 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4456 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
4458 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
4459 UpdateWindow( hparent );
4460 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4462 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
4463 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4464 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4465 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4466 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4467 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
4469 UpdateWindow( hparent );
4470 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4472 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
4473 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4474 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4475 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4476 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4477 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4479 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4480 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
4481 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
4482 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4483 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
4485 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
4486 UpdateWindow( hparent );
4487 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4489 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
4490 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4491 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
4492 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4493 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4494 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
4496 UpdateWindow( hparent );
4497 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4499 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
4500 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4501 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
4502 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
4503 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4504 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
4506 log_all_parent_messages--;
4507 DestroyWindow( hparent );
4508 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
4510 DeleteObject( hrgn );
4511 DeleteObject( hrgn2 );
4520 static DWORD WINAPI thread_proc(void *param)
4523 struct wnd_event *wnd_event = (struct wnd_event *)param;
4525 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
4526 100, 100, 200, 200, 0, 0, 0, NULL);
4527 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
4529 SetEvent(wnd_event->event);
4531 while (GetMessage(&msg, 0, 0, 0))
4533 TranslateMessage(&msg);
4534 DispatchMessage(&msg);
4537 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
4542 static void test_interthread_messages(void)
4549 int len, expected_len;
4550 struct wnd_event wnd_event;
4553 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
4554 if (!wnd_event.event)
4556 trace("skipping interthread message test under win9x\n");
4560 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
4561 ok(hThread != NULL, "CreateThread failed, error %ld\n", GetLastError());
4563 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4565 CloseHandle(wnd_event.event);
4567 SetLastError(0xdeadbeef);
4568 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
4569 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %ld\n", GetLastError());
4571 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4572 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %ld\n", GetLastError());
4574 expected_len = lstrlenA("window caption text");
4575 memset(buf, 0, sizeof(buf));
4576 SetLastError(0xdeadbeef);
4577 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
4578 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %ld, len %d, expected len %d\n", GetLastError(), len, expected_len);
4579 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
4581 msg.hwnd = wnd_event.hwnd;
4582 msg.message = WM_GETTEXT;
4583 msg.wParam = sizeof(buf);
4584 msg.lParam = (LPARAM)buf;
4585 memset(buf, 0, sizeof(buf));
4586 SetLastError(0xdeadbeef);
4587 len = DispatchMessageA(&msg);
4588 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
4589 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %ld\n", len, GetLastError());
4591 /* the following test causes an exception in user.exe under win9x */
4592 msg.hwnd = wnd_event.hwnd;
4593 msg.message = WM_TIMER;
4595 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
4596 SetLastError(0xdeadbeef);
4597 len = DispatchMessageA(&msg);
4598 ok(!len && GetLastError() == 0xdeadbeef,
4599 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %ld\n", len, GetLastError());
4601 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
4602 ok( ret, "PostMessageA(WM_QUIT) error %ld\n", GetLastError());
4604 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
4605 CloseHandle(hThread);
4607 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
4611 static const struct message WmVkN[] = {
4612 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4613 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4614 { WM_CHAR, wparam|lparam, 'n', 1 },
4615 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
4616 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4617 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4620 static const struct message WmShiftVkN[] = {
4621 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4622 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4623 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4624 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4625 { WM_CHAR, wparam|lparam, 'N', 1 },
4626 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
4627 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4628 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4629 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4630 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4633 static const struct message WmCtrlVkN[] = {
4634 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4635 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4636 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4637 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
4638 { WM_CHAR, wparam|lparam, 0x000e, 1 },
4639 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4640 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4641 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4642 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4643 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4646 static const struct message WmCtrlVkN_2[] = {
4647 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4648 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4649 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4650 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
4651 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4652 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4653 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4654 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4657 static const struct message WmAltVkN[] = {
4658 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4659 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4660 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4661 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4662 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
4663 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
4664 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
4665 { HCBT_SYSCOMMAND, hook },
4666 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4667 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4668 { 0x00AE, sent|defwinproc|optional }, /* XP */
4669 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
4670 { WM_INITMENU, sent|defwinproc },
4671 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4672 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
4673 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4674 { WM_CAPTURECHANGED, sent|defwinproc },
4675 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
4676 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4677 { WM_EXITMENULOOP, sent|defwinproc },
4678 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
4679 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
4680 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4681 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4682 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4683 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4686 static const struct message WmAltVkN_2[] = {
4687 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4688 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4689 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
4690 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
4691 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
4692 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4693 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4694 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4697 static const struct message WmCtrlAltVkN[] = {
4698 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4699 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4700 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4701 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4702 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4703 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
4704 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4705 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4706 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4707 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4708 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4709 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4712 static const struct message WmCtrlShiftVkN[] = {
4713 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4714 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4715 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
4716 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
4717 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
4718 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
4719 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
4720 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
4721 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
4722 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
4723 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4724 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4727 static const struct message WmCtrlAltShiftVkN[] = {
4728 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
4729 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
4730 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4731 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4732 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
4733 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
4734 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
4735 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
4736 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
4737 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
4738 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
4739 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
4740 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4741 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4742 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
4743 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
4746 static const struct message WmAltPressRelease[] = {
4747 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4748 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4749 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4750 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4751 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
4752 { HCBT_SYSCOMMAND, hook },
4753 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
4754 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4755 { WM_INITMENU, sent|defwinproc },
4756 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4757 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
4758 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
4760 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4761 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
4762 { WM_CAPTURECHANGED, sent|defwinproc },
4763 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
4764 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
4765 { WM_EXITMENULOOP, sent|defwinproc },
4766 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4767 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4770 static const struct message WmAltMouseButton[] = {
4771 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
4772 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
4773 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
4774 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
4775 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
4776 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
4777 { WM_LBUTTONUP, wparam, 0, 0 },
4778 { WM_LBUTTONUP, sent|wparam, 0, 0 },
4779 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
4780 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
4783 static const struct message WmF1Seq[] = {
4784 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
4785 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
4786 { 0x4d, wparam|lparam, 0, 0 },
4787 { 0x4d, sent|wparam|lparam, 0, 0 },
4788 { WM_HELP, sent|defwinproc },
4789 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
4790 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
4794 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
4798 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
4800 struct message log_msg;
4802 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
4804 /* ignore some unwanted messages */
4805 if (msg.message == WM_MOUSEMOVE ||
4806 msg.message == WM_GETICON ||
4807 msg.message == WM_DEVICECHANGE)
4810 log_msg.message = msg.message;
4811 log_msg.flags = wparam|lparam;
4812 log_msg.wParam = msg.wParam;
4813 log_msg.lParam = msg.lParam;
4814 add_message(&log_msg);
4816 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
4818 TranslateMessage(&msg);
4819 DispatchMessage(&msg);
4824 static void test_accelerators(void)
4829 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4830 100, 100, 200, 200, 0, 0, 0, NULL);
4837 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
4839 state = GetKeyState(VK_SHIFT);
4840 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
4841 state = GetKeyState(VK_CAPITAL);
4842 ok(state == 0, "wrong CapsLock state %04x\n", state);
4844 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
4845 assert(hAccel != 0);
4847 pump_msg_loop(hwnd, 0);
4850 trace("testing VK_N press/release\n");
4852 keybd_event('N', 0, 0, 0);
4853 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4854 pump_msg_loop(hwnd, hAccel);
4855 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4857 trace("testing Shift+VK_N press/release\n");
4859 keybd_event(VK_SHIFT, 0, 0, 0);
4860 keybd_event('N', 0, 0, 0);
4861 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4862 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4863 pump_msg_loop(hwnd, hAccel);
4864 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4866 trace("testing Ctrl+VK_N press/release\n");
4868 keybd_event(VK_CONTROL, 0, 0, 0);
4869 keybd_event('N', 0, 0, 0);
4870 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4871 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4872 pump_msg_loop(hwnd, hAccel);
4873 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
4875 trace("testing Alt+VK_N press/release\n");
4877 keybd_event(VK_MENU, 0, 0, 0);
4878 keybd_event('N', 0, 0, 0);
4879 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4880 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4881 pump_msg_loop(hwnd, hAccel);
4882 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
4884 trace("testing Ctrl+Alt+VK_N press/release 1\n");
4886 keybd_event(VK_CONTROL, 0, 0, 0);
4887 keybd_event(VK_MENU, 0, 0, 0);
4888 keybd_event('N', 0, 0, 0);
4889 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4890 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4891 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4892 pump_msg_loop(hwnd, hAccel);
4893 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
4895 ret = DestroyAcceleratorTable(hAccel);
4896 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4898 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
4899 assert(hAccel != 0);
4901 trace("testing VK_N press/release\n");
4903 keybd_event('N', 0, 0, 0);
4904 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4905 pump_msg_loop(hwnd, hAccel);
4906 ok_sequence(WmVkN, "VK_N press/release", FALSE);
4908 trace("testing Shift+VK_N press/release\n");
4910 keybd_event(VK_SHIFT, 0, 0, 0);
4911 keybd_event('N', 0, 0, 0);
4912 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4913 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4914 pump_msg_loop(hwnd, hAccel);
4915 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
4917 trace("testing Ctrl+VK_N press/release 2\n");
4919 keybd_event(VK_CONTROL, 0, 0, 0);
4920 keybd_event('N', 0, 0, 0);
4921 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4922 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4923 pump_msg_loop(hwnd, hAccel);
4924 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
4926 trace("testing Alt+VK_N press/release 2\n");
4928 keybd_event(VK_MENU, 0, 0, 0);
4929 keybd_event('N', 0, 0, 0);
4930 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4931 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4932 pump_msg_loop(hwnd, hAccel);
4933 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
4935 trace("testing Ctrl+Alt+VK_N press/release 2\n");
4937 keybd_event(VK_CONTROL, 0, 0, 0);
4938 keybd_event(VK_MENU, 0, 0, 0);
4939 keybd_event('N', 0, 0, 0);
4940 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4941 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4942 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4943 pump_msg_loop(hwnd, hAccel);
4944 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
4946 trace("testing Ctrl+Shift+VK_N press/release\n");
4948 keybd_event(VK_CONTROL, 0, 0, 0);
4949 keybd_event(VK_SHIFT, 0, 0, 0);
4950 keybd_event('N', 0, 0, 0);
4951 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4952 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4953 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4954 pump_msg_loop(hwnd, hAccel);
4955 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
4957 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
4959 keybd_event(VK_CONTROL, 0, 0, 0);
4960 keybd_event(VK_MENU, 0, 0, 0);
4961 keybd_event(VK_SHIFT, 0, 0, 0);
4962 keybd_event('N', 0, 0, 0);
4963 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
4964 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
4965 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4966 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
4967 pump_msg_loop(hwnd, hAccel);
4968 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
4970 ret = DestroyAcceleratorTable(hAccel);
4971 ok( ret, "DestroyAcceleratorTable error %ld\n", GetLastError());
4973 trace("testing Alt press/release\n");
4975 keybd_event(VK_MENU, 0, 0, 0);
4976 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4977 keybd_event(VK_MENU, 0, 0, 0);
4978 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4979 pump_msg_loop(hwnd, 0);
4980 /* this test doesn't pass in Wine for managed windows */
4981 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
4983 trace("testing Alt+MouseButton press/release\n");
4984 /* first, move mouse pointer inside of the window client area */
4985 GetClientRect(hwnd, &rc);
4986 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
4987 rc.left += (rc.right - rc.left)/2;
4988 rc.top += (rc.bottom - rc.top)/2;
4989 SetCursorPos(rc.left, rc.top);
4991 pump_msg_loop(hwnd, 0);
4993 keybd_event(VK_MENU, 0, 0, 0);
4994 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
4995 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
4996 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
4997 pump_msg_loop(hwnd, 0);
4998 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
5000 keybd_event(VK_F1, 0, 0, 0);
5001 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
5002 pump_msg_loop(hwnd, 0);
5003 ok_sequence(WmF1Seq, "F1 press/release", TRUE);
5005 DestroyWindow(hwnd);
5008 /************* window procedures ********************/
5010 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
5011 WPARAM wParam, LPARAM lParam)
5013 static long defwndproc_counter = 0;
5014 static long beginpaint_counter = 0;
5018 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5020 /* explicitly ignore WM_GETICON message */
5021 if (message == WM_GETICON) return 0;
5027 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
5028 ok((BOOL)wParam == !(style & WS_DISABLED),
5029 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
5033 case WM_CAPTURECHANGED:
5034 if (test_DestroyWindow_flag)
5036 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5037 if (style & WS_CHILD)
5038 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5039 else if (style & WS_POPUP)
5040 lParam = WND_POPUP_ID;
5042 lParam = WND_PARENT_ID;
5050 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
5051 capture = GetCapture();
5054 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
5055 trace("current capture %p, releasing...\n", capture);
5062 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
5063 if (test_DestroyWindow_flag)
5065 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5066 if (style & WS_CHILD)
5067 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5068 else if (style & WS_POPUP)
5069 lParam = WND_POPUP_ID;
5071 lParam = WND_PARENT_ID;
5075 /* test_accelerators() depends on this */
5082 case WM_DEVICECHANGE:
5085 case WM_WINDOWPOSCHANGING:
5086 case WM_WINDOWPOSCHANGED:
5088 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5090 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5091 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5092 winpos->hwnd, winpos->hwndInsertAfter,
5093 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5095 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5096 * in the high word for internal purposes
5098 wParam = winpos->flags & 0xffff;
5103 msg.message = message;
5104 msg.flags = sent|wparam|lparam;
5105 if (defwndproc_counter) msg.flags |= defwinproc;
5106 if (beginpaint_counter) msg.flags |= beginpaint;
5107 msg.wParam = wParam;
5108 msg.lParam = lParam;
5111 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
5113 HWND parent = GetParent(hwnd);
5115 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
5117 GetClientRect(parent, &rc);
5118 trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
5120 trace("ptReserved = (%ld,%ld)\n"
5121 "ptMaxSize = (%ld,%ld)\n"
5122 "ptMaxPosition = (%ld,%ld)\n"
5123 "ptMinTrackSize = (%ld,%ld)\n"
5124 "ptMaxTrackSize = (%ld,%ld)\n",
5125 minmax->ptReserved.x, minmax->ptReserved.y,
5126 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
5127 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
5128 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
5129 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
5131 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %ld != %ld\n",
5132 minmax->ptMaxSize.x, rc.right);
5133 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %ld != %ld\n",
5134 minmax->ptMaxSize.y, rc.bottom);
5137 if (message == WM_PAINT)
5140 beginpaint_counter++;
5141 BeginPaint( hwnd, &ps );
5142 beginpaint_counter--;
5143 EndPaint( hwnd, &ps );
5147 defwndproc_counter++;
5148 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
5149 : DefWindowProcA(hwnd, message, wParam, lParam);
5150 defwndproc_counter--;
5155 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5157 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
5160 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5162 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
5165 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5167 static long defwndproc_counter = 0;
5171 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5173 /* explicitly ignore WM_GETICON message */
5174 if (message == WM_GETICON) return 0;
5176 msg.message = message;
5177 msg.flags = sent|wparam|lparam;
5178 if (defwndproc_counter) msg.flags |= defwinproc;
5179 msg.wParam = wParam;
5180 msg.lParam = lParam;
5183 if (message == WM_CREATE)
5185 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
5186 SetWindowLongA(hwnd, GWL_STYLE, style);
5189 defwndproc_counter++;
5190 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5191 defwndproc_counter--;
5196 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5198 static long defwndproc_counter = 0;
5199 static long beginpaint_counter = 0;
5203 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5205 /* explicitly ignore WM_GETICON message */
5206 if (message == WM_GETICON) return 0;
5208 if (log_all_parent_messages ||
5209 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
5210 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
5211 message == WM_ENABLE || message == WM_ENTERIDLE ||
5212 message == WM_IME_SETCONTEXT)
5219 INT ret = GetClipBox((HDC)wParam, &rc);
5221 trace("WM_ERASEBKGND: GetClipBox()=%d, (%ld,%ld-%ld,%ld)\n",
5222 ret, rc.left, rc.top, rc.right, rc.bottom);
5226 case WM_WINDOWPOSCHANGING:
5227 case WM_WINDOWPOSCHANGED:
5229 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5231 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5232 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5233 winpos->hwnd, winpos->hwndInsertAfter,
5234 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5236 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5237 * in the high word for internal purposes
5239 wParam = winpos->flags & 0xffff;
5244 msg.message = message;
5245 msg.flags = sent|parent|wparam|lparam;
5246 if (defwndproc_counter) msg.flags |= defwinproc;
5247 if (beginpaint_counter) msg.flags |= beginpaint;
5248 msg.wParam = wParam;
5249 msg.lParam = lParam;
5253 if (message == WM_PAINT)
5256 beginpaint_counter++;
5257 BeginPaint( hwnd, &ps );
5258 beginpaint_counter--;
5259 EndPaint( hwnd, &ps );
5263 defwndproc_counter++;
5264 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5265 defwndproc_counter--;
5270 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5272 static long defwndproc_counter = 0;
5276 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5278 /* explicitly ignore WM_GETICON message */
5279 if (message == WM_GETICON) return 0;
5281 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
5282 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
5283 if (after_end_dialog)
5284 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
5286 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
5290 case WM_WINDOWPOSCHANGING:
5291 case WM_WINDOWPOSCHANGED:
5293 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5295 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5296 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5297 winpos->hwnd, winpos->hwndInsertAfter,
5298 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5300 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5301 * in the high word for internal purposes
5303 wParam = winpos->flags & 0xffff;
5308 msg.message = message;
5309 msg.flags = sent|wparam|lparam;
5310 if (defwndproc_counter) msg.flags |= defwinproc;
5311 msg.wParam = wParam;
5312 msg.lParam = lParam;
5315 defwndproc_counter++;
5316 ret = DefDlgProcA(hwnd, message, wParam, lParam);
5317 defwndproc_counter--;
5322 static BOOL RegisterWindowClasses(void)
5327 cls.lpfnWndProc = MsgCheckProcA;
5330 cls.hInstance = GetModuleHandleA(0);
5332 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
5333 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5334 cls.lpszMenuName = NULL;
5335 cls.lpszClassName = "TestWindowClass";
5336 if(!RegisterClassA(&cls)) return FALSE;
5338 cls.lpfnWndProc = PopupMsgCheckProcA;
5339 cls.lpszClassName = "TestPopupClass";
5340 if(!RegisterClassA(&cls)) return FALSE;
5342 cls.lpfnWndProc = ParentMsgCheckProcA;
5343 cls.lpszClassName = "TestParentClass";
5344 if(!RegisterClassA(&cls)) return FALSE;
5346 cls.lpfnWndProc = DefWindowProcA;
5347 cls.lpszClassName = "SimpleWindowClass";
5348 if(!RegisterClassA(&cls)) return FALSE;
5350 cls.style = CS_NOCLOSE;
5351 cls.lpszClassName = "NoCloseWindowClass";
5352 if(!RegisterClassA(&cls)) return FALSE;
5354 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
5356 cls.hInstance = GetModuleHandleA(0);
5357 cls.hbrBackground = 0;
5358 cls.lpfnWndProc = TestDlgProcA;
5359 cls.lpszClassName = "TestDialogClass";
5360 if(!RegisterClassA(&cls)) return FALSE;
5365 static HHOOK hCBT_hook;
5366 static DWORD cbt_hook_thread_id;
5368 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5370 static const char *CBT_code_name[10] = {
5377 "HCBT_CLICKSKIPPED",
5381 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
5385 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
5387 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5389 if (nCode == HCBT_SYSCOMMAND)
5393 msg.message = nCode;
5394 msg.flags = hook|wparam|lparam;
5395 msg.wParam = wParam;
5396 msg.lParam = lParam;
5399 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5402 if (nCode == HCBT_DESTROYWND)
5404 if (test_DestroyWindow_flag)
5406 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
5407 if (style & WS_CHILD)
5408 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
5409 else if (style & WS_POPUP)
5410 lParam = WND_POPUP_ID;
5412 lParam = WND_PARENT_ID;
5416 /* Log also SetFocus(0) calls */
5417 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5419 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5421 if (!lstrcmpiA(buf, "TestWindowClass") ||
5422 !lstrcmpiA(buf, "TestParentClass") ||
5423 !lstrcmpiA(buf, "TestPopupClass") ||
5424 !lstrcmpiA(buf, "SimpleWindowClass") ||
5425 !lstrcmpiA(buf, "TestDialogClass") ||
5426 !lstrcmpiA(buf, "MDI_frame_class") ||
5427 !lstrcmpiA(buf, "MDI_client_class") ||
5428 !lstrcmpiA(buf, "MDI_child_class") ||
5429 !lstrcmpiA(buf, "my_button_class") ||
5430 !lstrcmpiA(buf, "my_edit_class") ||
5431 !lstrcmpiA(buf, "static") ||
5432 !lstrcmpiA(buf, "#32770"))
5436 msg.message = nCode;
5437 msg.flags = hook|wparam|lparam;
5438 msg.wParam = wParam;
5439 msg.lParam = lParam;
5443 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
5446 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
5456 trace("WEH:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5457 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5459 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
5461 /* ignore mouse cursor events */
5462 if (object_id == OBJID_CURSOR) return;
5464 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
5467 !lstrcmpiA(buf, "TestWindowClass") ||
5468 !lstrcmpiA(buf, "TestParentClass") ||
5469 !lstrcmpiA(buf, "TestPopupClass") ||
5470 !lstrcmpiA(buf, "SimpleWindowClass") ||
5471 !lstrcmpiA(buf, "TestDialogClass") ||
5472 !lstrcmpiA(buf, "MDI_frame_class") ||
5473 !lstrcmpiA(buf, "MDI_client_class") ||
5474 !lstrcmpiA(buf, "MDI_child_class") ||
5475 !lstrcmpiA(buf, "my_button_class") ||
5476 !lstrcmpiA(buf, "my_edit_class") ||
5477 !lstrcmpiA(buf, "static") ||
5478 !lstrcmpiA(buf, "#32770"))
5482 msg.message = event;
5483 msg.flags = winevent_hook|wparam|lparam;
5484 msg.wParam = object_id;
5485 msg.lParam = child_id;
5491 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
5492 static const WCHAR wszAnsi[] = {'U',0};
5494 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5498 case CB_FINDSTRINGEXACT:
5499 trace("String: %p\n", (LPCWSTR)lParam);
5500 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
5502 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
5506 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
5509 static const struct message WmGetTextLengthAfromW[] = {
5510 { WM_GETTEXTLENGTH, sent },
5511 { WM_GETTEXT, sent },
5515 static const WCHAR testWindowClassW[] =
5516 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
5518 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
5520 /* dummy window proc for WM_GETTEXTLENGTH test */
5521 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
5525 case WM_GETTEXTLENGTH:
5526 return lstrlenW(dummy_window_text) + 37; /* some random length */
5528 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
5529 return lstrlenW( (LPWSTR)lp );
5531 return DefWindowProcW( hwnd, msg, wp, lp );
5535 static void test_message_conversion(void)
5537 static const WCHAR wszMsgConversionClass[] =
5538 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
5542 WNDPROC wndproc, newproc;
5546 cls.lpfnWndProc = MsgConversionProcW;
5549 cls.hInstance = GetModuleHandleW(NULL);
5551 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
5552 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
5553 cls.lpszMenuName = NULL;
5554 cls.lpszClassName = wszMsgConversionClass;
5555 /* this call will fail on Win9x, but that doesn't matter as this test is
5556 * meaningless on those platforms */
5557 if(!RegisterClassW(&cls)) return;
5560 cls.lpfnWndProc = MsgCheckProcW;
5563 cls.hInstance = GetModuleHandleW(0);
5565 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
5566 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
5567 cls.lpszMenuName = NULL;
5568 cls.lpszClassName = testWindowClassW;
5569 if(!RegisterClassW(&cls)) return;
5571 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
5572 100, 100, 200, 200, 0, 0, 0, NULL);
5573 ok(hwnd != NULL, "Window creation failed\n");
5577 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
5578 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5579 ok(lRes == 0, "String should have been converted\n");
5580 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5581 ok(lRes == 1, "String shouldn't have been converted\n");
5585 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
5586 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5587 ok(lRes == 1, "String shouldn't have been converted\n");
5588 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5589 ok(lRes == 1, "String shouldn't have been converted\n");
5591 /* Synchronous messages */
5593 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5594 ok(lRes == 0, "String should have been converted\n");
5595 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5596 ok(lRes == 1, "String shouldn't have been converted\n");
5598 /* Asynchronous messages */
5601 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5602 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5603 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5605 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5606 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5607 "PostMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5609 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5610 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5611 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5613 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5614 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5615 "PosThreadtMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5617 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5618 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5619 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5621 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
5622 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5623 "SendNotifyMessage on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5625 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5626 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5627 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5629 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
5630 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
5631 "SendMessageCallback on sync only message returned %ld, last error %ld\n", lRes, GetLastError());
5633 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
5635 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
5636 WS_OVERLAPPEDWINDOW,
5637 100, 100, 200, 200, 0, 0, 0, NULL);
5640 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
5641 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5642 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5643 "got bad length %ld\n", lRes );
5646 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
5647 hwnd, WM_GETTEXTLENGTH, 0, 0);
5648 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
5649 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
5650 "got bad length %ld\n", lRes );
5652 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
5653 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
5654 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5655 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5656 NULL, 0, NULL, NULL ),
5657 "got bad length %ld\n", lRes );
5659 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
5660 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
5661 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
5662 NULL, 0, NULL, NULL ),
5663 "got bad length %ld\n", lRes );
5665 ret = DestroyWindow(hwnd);
5666 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
5676 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
5680 #define TIMER_ID 0x19
5682 static DWORD WINAPI timer_thread_proc(LPVOID x)
5684 struct timer_info *info = x;
5687 r = KillTimer(info->hWnd, 0x19);
5688 ok(r,"KillTimer failed in thread\n");
5689 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
5690 ok(r,"SetTimer failed in thread\n");
5691 ok(r==TIMER_ID,"SetTimer id different\n");
5692 r = SetEvent(info->handles[0]);
5693 ok(r,"SetEvent failed in thread\n");
5697 static void test_timers(void)
5699 struct timer_info info;
5702 info.hWnd = CreateWindow ("TestWindowClass", NULL,
5703 WS_OVERLAPPEDWINDOW ,
5704 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5707 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
5708 ok(info.id, "SetTimer failed\n");
5709 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
5710 info.handles[0] = CreateEvent(NULL,0,0,NULL);
5711 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
5713 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
5715 WaitForSingleObject(info.handles[1], INFINITE);
5717 CloseHandle(info.handles[0]);
5718 CloseHandle(info.handles[1]);
5720 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
5722 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
5725 /* Various win events with arbitrary parameters */
5726 static const struct message WmWinEventsSeq[] = {
5727 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5728 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5729 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5730 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5731 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5732 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5733 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5734 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5735 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5736 /* our win event hook ignores OBJID_CURSOR events */
5737 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
5738 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
5739 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
5740 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
5741 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
5742 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
5743 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5744 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
5745 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
5746 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
5747 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
5748 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
5749 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
5750 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
5753 static const struct message WmWinEventCaretSeq[] = {
5754 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5755 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5756 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
5757 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
5760 static const struct message WmWinEventCaretSeq_2[] = {
5761 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5762 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5763 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
5766 static const struct message WmWinEventAlertSeq[] = {
5767 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
5770 static const struct message WmWinEventAlertSeq_2[] = {
5771 /* create window in the thread proc */
5772 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
5773 /* our test event */
5774 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
5777 static const struct message WmGlobalHookSeq_1[] = {
5778 /* create window in the thread proc */
5779 { HCBT_CREATEWND, hook|lparam, 0, 2 },
5780 /* our test events */
5781 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
5782 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
5785 static const struct message WmGlobalHookSeq_2[] = {
5786 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
5787 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
5788 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
5789 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
5793 static const struct message WmMouseLLHookSeq[] = {
5794 { WM_MOUSEMOVE, hook },
5795 { WM_LBUTTONDOWN, hook },
5796 { WM_LBUTTONUP, hook },
5800 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
5810 trace("WEH_2:%p,event %08lx,hwnd %p,obj %08lx,id %08lx,thread %08lx,time %08lx\n",
5811 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
5813 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5815 if (!lstrcmpiA(buf, "TestWindowClass") ||
5816 !lstrcmpiA(buf, "static"))
5820 msg.message = event;
5821 msg.flags = winevent_hook|wparam|lparam;
5822 msg.wParam = object_id;
5823 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
5829 static HHOOK hCBT_global_hook;
5830 static DWORD cbt_global_hook_thread_id;
5832 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
5837 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
5839 if (nCode == HCBT_SYSCOMMAND)
5843 msg.message = nCode;
5844 msg.flags = hook|wparam|lparam;
5845 msg.wParam = wParam;
5846 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5849 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5851 /* WH_MOUSE_LL hook */
5852 if (nCode == HC_ACTION)
5855 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
5857 /* we can't test for real mouse events */
5858 if (mhll->flags & LLMHF_INJECTED)
5860 msg.message = wParam;
5864 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5867 /* Log also SetFocus(0) calls */
5868 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
5870 if (GetClassNameA(hwnd, buf, sizeof(buf)))
5872 if (!lstrcmpiA(buf, "TestWindowClass") ||
5873 !lstrcmpiA(buf, "static"))
5877 msg.message = nCode;
5878 msg.flags = hook|wparam|lparam;
5879 msg.wParam = wParam;
5880 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
5884 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
5887 static DWORD WINAPI win_event_global_thread_proc(void *param)
5891 HANDLE hevent = *(HANDLE *)param;
5892 HMODULE user32 = GetModuleHandleA("user32.dll");
5893 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5895 assert(pNotifyWinEvent);
5897 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5899 trace("created thread window %p\n", hwnd);
5901 *(HWND *)param = hwnd;
5904 /* this event should be received only by our new hook proc,
5905 * an old one does not expect an event from another thread.
5907 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
5910 while (GetMessage(&msg, 0, 0, 0))
5912 TranslateMessage(&msg);
5913 DispatchMessage(&msg);
5918 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
5922 HANDLE hevent = *(HANDLE *)param;
5925 /* these events should be received only by our new hook proc,
5926 * an old one does not expect an event from another thread.
5929 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5931 trace("created thread window %p\n", hwnd);
5933 *(HWND *)param = hwnd;
5935 /* Windows doesn't like when a thread plays games with the focus,
5936 that leads to all kinds of misbehaviours and failures to activate
5937 a window. So, better keep next lines commented out.
5941 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
5942 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
5946 while (GetMessage(&msg, 0, 0, 0))
5948 TranslateMessage(&msg);
5949 DispatchMessage(&msg);
5954 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
5958 HANDLE hevent = *(HANDLE *)param;
5960 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
5962 trace("created thread window %p\n", hwnd);
5964 *(HWND *)param = hwnd;
5968 mouse_event(MOUSEEVENTF_MOVE, 100, 0, 0, 0);
5969 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
5970 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
5973 while (GetMessage(&msg, 0, 0, 0))
5975 TranslateMessage(&msg);
5976 DispatchMessage(&msg);
5981 static void test_winevents(void)
5987 HANDLE hthread, hevent;
5989 HWINEVENTHOOK hhook;
5990 const struct message *events = WmWinEventsSeq;
5991 HMODULE user32 = GetModuleHandleA("user32.dll");
5992 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
5993 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
5994 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
5996 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
5997 WS_OVERLAPPEDWINDOW,
5998 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
6002 /****** start of global hook test *************/
6003 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6004 assert(hCBT_global_hook);
6006 hevent = CreateEventA(NULL, 0, 0, NULL);
6008 hwnd2 = (HWND)hevent;
6010 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
6011 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6013 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6015 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
6018 /* this one should be received only by old hook proc */
6019 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6020 /* this one should be received only by old hook proc */
6021 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6023 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
6025 ret = UnhookWindowsHookEx(hCBT_global_hook);
6026 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
6028 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6029 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6030 CloseHandle(hthread);
6031 CloseHandle(hevent);
6032 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6033 /****** end of global hook test *************/
6035 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
6037 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6043 #if 0 /* this test doesn't pass under Win9x */
6044 /* win2k ignores events with hwnd == 0 */
6045 SetLastError(0xdeadbeef);
6046 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
6047 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
6048 GetLastError() == 0xdeadbeef, /* Win9x */
6049 "unexpected error %ld\n", GetLastError());
6050 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6053 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
6054 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
6056 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
6058 /****** start of event filtering test *************/
6059 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6060 EVENT_OBJECT_SHOW, /* 0x8002 */
6061 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
6062 GetModuleHandleA(0), win_event_global_hook_proc,
6063 GetCurrentProcessId(), 0,
6064 WINEVENT_INCONTEXT);
6065 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
6067 hevent = CreateEventA(NULL, 0, 0, NULL);
6069 hwnd2 = (HWND)hevent;
6071 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6072 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6074 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6076 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
6079 /* this one should be received only by old hook proc */
6080 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6081 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6082 /* this one should be received only by old hook proc */
6083 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6085 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
6087 ret = pUnhookWinEvent(hhook);
6088 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6090 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6091 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6092 CloseHandle(hthread);
6093 CloseHandle(hevent);
6094 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6095 /****** end of event filtering test *************/
6097 /****** start of out of context event test *************/
6098 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6099 EVENT_MIN, EVENT_MAX,
6100 0, win_event_global_hook_proc,
6101 GetCurrentProcessId(), 0,
6102 WINEVENT_OUTOFCONTEXT);
6103 ok(hhook != 0, "SetWinEventHook error %ld\n", GetLastError());
6105 hevent = CreateEventA(NULL, 0, 0, NULL);
6107 hwnd2 = (HWND)hevent;
6111 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6112 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6114 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6116 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6117 /* process pending winevent messages */
6118 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6119 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
6122 /* this one should be received only by old hook proc */
6123 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6124 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6125 /* this one should be received only by old hook proc */
6126 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6128 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
6129 /* process pending winevent messages */
6130 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6131 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
6133 ret = pUnhookWinEvent(hhook);
6134 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6136 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6137 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6138 CloseHandle(hthread);
6139 CloseHandle(hevent);
6140 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6141 /****** end of out of context event test *************/
6143 /****** start of MOUSE_LL hook test *************/
6144 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6145 assert(hCBT_global_hook);
6147 hevent = CreateEventA(NULL, 0, 0, NULL);
6149 hwnd2 = (HWND)hevent;
6151 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
6152 ok(hthread != NULL, "CreateThread failed, error %ld\n", GetLastError());
6154 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
6155 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6157 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
6160 mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0);
6161 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6162 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6164 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
6166 ret = UnhookWindowsHookEx(hCBT_global_hook);
6167 ok( ret, "UnhookWindowsHookEx error %ld\n", GetLastError());
6169 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6170 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6171 CloseHandle(hthread);
6172 CloseHandle(hevent);
6173 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6174 /****** end of MOUSE_LL hook test *************/
6176 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6179 static void test_set_hook(void)
6183 HWINEVENTHOOK hwinevent_hook;
6184 HMODULE user32 = GetModuleHandleA("user32.dll");
6185 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6186 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6188 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
6189 ok(hhook != 0, "local hook does not require hModule set to 0\n");
6190 UnhookWindowsHookEx(hhook);
6192 #if 0 /* this test doesn't pass under Win9x: BUG! */
6193 SetLastError(0xdeadbeef);
6194 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
6195 ok(!hhook, "global hook requires hModule != 0\n");
6196 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %ld\n", GetLastError());
6199 SetLastError(0xdeadbeef);
6200 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
6201 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
6202 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
6203 GetLastError() == 0xdeadbeef, /* Win9x */
6204 "unexpected error %ld\n", GetLastError());
6206 SetLastError(0xdeadbeef);
6207 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
6208 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
6209 GetLastError() == 0xdeadbeef, /* Win9x */
6210 "unexpected error %ld\n", GetLastError());
6212 if (!pSetWinEventHook || !pUnhookWinEvent) return;
6214 /* even process local incontext hooks require hmodule */
6215 SetLastError(0xdeadbeef);
6216 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6217 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
6218 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
6219 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
6220 GetLastError() == 0xdeadbeef, /* Win9x */
6221 "unexpected error %ld\n", GetLastError());
6223 /* even thread local incontext hooks require hmodule */
6224 SetLastError(0xdeadbeef);
6225 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6226 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
6227 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
6228 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
6229 GetLastError() == 0xdeadbeef, /* Win9x */
6230 "unexpected error %ld\n", GetLastError());
6232 #if 0 /* these 3 tests don't pass under Win9x */
6233 SetLastError(0xdeadbeef);
6234 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
6235 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6236 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
6237 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
6239 SetLastError(0xdeadbeef);
6240 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
6241 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6242 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
6243 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %ld\n", GetLastError());
6245 SetLastError(0xdeadbeef);
6246 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6247 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
6248 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
6249 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %ld\n", GetLastError());
6252 SetLastError(0xdeadbeef);
6253 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
6254 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
6255 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
6256 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
6257 ret = pUnhookWinEvent(hwinevent_hook);
6258 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6261 /* This call succeeds under win2k SP4, but fails under Wine.
6262 Does win2k test/use passed process id? */
6263 SetLastError(0xdeadbeef);
6264 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
6265 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
6266 ok(hwinevent_hook != 0, "SetWinEventHook error %ld\n", GetLastError());
6267 ok(GetLastError() == 0xdeadbeef, "unexpected error %ld\n", GetLastError());
6268 ret = pUnhookWinEvent(hwinevent_hook);
6269 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
6272 SetLastError(0xdeadbeef);
6273 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
6274 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
6275 GetLastError() == 0xdeadbeef, /* Win9x */
6276 "unexpected error %ld\n", GetLastError());
6279 static const struct message ScrollWindowPaint1[] = {
6281 { WM_ERASEBKGND, sent|beginpaint },
6285 static const struct message ScrollWindowPaint2[] = {
6290 static void test_scrollwindowex(void)
6293 RECT rect={0,0,130,130};
6296 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
6297 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
6298 100, 100, 200, 200, 0, 0, 0, NULL);
6299 ok (hwnd != 0, "Failed to create overlapped window\n");
6300 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
6301 WS_VISIBLE|WS_CAPTION|WS_CHILD,
6302 10, 10, 150, 150, hwnd, 0, 0, NULL);
6303 ok (hchild != 0, "Failed to create child\n");
6308 /* scroll without the child window */
6309 trace("start scroll\n");
6310 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
6311 SW_ERASE|SW_INVALIDATE);
6312 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6313 trace("end scroll\n");
6315 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6316 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
6318 /* Now without the SW_ERASE flag */
6319 trace("start scroll\n");
6320 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
6321 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6322 trace("end scroll\n");
6324 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6325 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
6327 /* now scroll the child window as well */
6328 trace("start scroll\n");
6329 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
6330 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
6331 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
6332 /* windows sometimes a WM_MOVE */
6333 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
6335 trace("end scroll\n");
6337 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6338 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
6340 /* now scroll with ScrollWindow() */
6341 trace("start scroll with ScrollWindow\n");
6342 ScrollWindow( hwnd, 5, 5, NULL, NULL);
6343 trace("end scroll\n");
6345 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6346 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
6348 ok(DestroyWindow(hchild), "failed to destroy window\n");
6349 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6353 static const struct message destroy_window_with_children[] = {
6354 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
6355 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
6356 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
6357 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
6358 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6359 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6360 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
6361 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
6362 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
6363 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
6364 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
6365 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
6366 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
6367 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
6368 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
6369 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
6373 static void test_DestroyWindow(void)
6376 HWND parent, child1, child2, child3, child4, test;
6377 UINT child_id = WND_CHILD_ID + 1;
6379 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6380 100, 100, 200, 200, 0, 0, 0, NULL);
6381 assert(parent != 0);
6382 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6383 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
6384 assert(child1 != 0);
6385 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6386 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
6387 assert(child2 != 0);
6388 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
6389 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
6390 assert(child3 != 0);
6391 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
6392 0, 0, 50, 50, parent, 0, 0, NULL);
6393 assert(child4 != 0);
6395 /* test owner/parent of child2 */
6396 test = GetParent(child2);
6397 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6398 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
6400 test = pGetAncestor(child2, GA_PARENT);
6401 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6403 test = GetWindow(child2, GW_OWNER);
6404 ok(!test, "wrong owner %p\n", test);
6406 test = SetParent(child2, parent);
6407 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
6409 /* test owner/parent of the parent */
6410 test = GetParent(parent);
6411 ok(!test, "wrong parent %p\n", test);
6413 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
6416 test = pGetAncestor(parent, GA_PARENT);
6417 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6419 test = GetWindow(parent, GW_OWNER);
6420 ok(!test, "wrong owner %p\n", test);
6422 /* test owner/parent of child1 */
6423 test = GetParent(child1);
6424 ok(test == parent, "wrong parent %p\n", test);
6425 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
6427 test = pGetAncestor(child1, GA_PARENT);
6428 ok(test == parent, "wrong parent %p\n", test);
6430 test = GetWindow(child1, GW_OWNER);
6431 ok(!test, "wrong owner %p\n", test);
6433 /* test owner/parent of child2 */
6434 test = GetParent(child2);
6435 ok(test == parent, "wrong parent %p\n", test);
6436 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
6438 test = pGetAncestor(child2, GA_PARENT);
6439 ok(test == parent, "wrong parent %p\n", test);
6441 test = GetWindow(child2, GW_OWNER);
6442 ok(!test, "wrong owner %p\n", test);
6444 /* test owner/parent of child3 */
6445 test = GetParent(child3);
6446 ok(test == child1, "wrong parent %p\n", test);
6447 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
6449 test = pGetAncestor(child3, GA_PARENT);
6450 ok(test == child1, "wrong parent %p\n", test);
6452 test = GetWindow(child3, GW_OWNER);
6453 ok(!test, "wrong owner %p\n", test);
6455 /* test owner/parent of child4 */
6456 test = GetParent(child4);
6457 ok(test == parent, "wrong parent %p\n", test);
6458 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
6460 test = pGetAncestor(child4, GA_PARENT);
6461 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
6463 test = GetWindow(child4, GW_OWNER);
6464 ok(test == parent, "wrong owner %p\n", test);
6468 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
6469 parent, child1, child2, child3, child4);
6472 test = GetCapture();
6473 ok(test == child4, "wrong capture window %p\n", test);
6475 test_DestroyWindow_flag = TRUE;
6476 ret = DestroyWindow(parent);
6477 ok( ret, "DestroyWindow() error %ld\n", GetLastError());
6478 test_DestroyWindow_flag = FALSE;
6479 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
6481 ok(!IsWindow(parent), "parent still exists\n");
6482 ok(!IsWindow(child1), "child1 still exists\n");
6483 ok(!IsWindow(child2), "child2 still exists\n");
6484 ok(!IsWindow(child3), "child3 still exists\n");
6485 ok(!IsWindow(child4), "child4 still exists\n");
6487 test = GetCapture();
6488 ok(!test, "wrong capture window %p\n", test);
6492 static const struct message WmDispatchPaint[] = {
6493 { WM_NCPAINT, sent },
6494 { WM_GETTEXT, sent|defwinproc|optional },
6495 { WM_GETTEXT, sent|defwinproc|optional },
6496 { WM_ERASEBKGND, sent },
6500 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6502 if (message == WM_PAINT) return 0;
6503 return MsgCheckProcA( hwnd, message, wParam, lParam );
6506 static void test_DispatchMessage(void)
6511 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6512 100, 100, 200, 200, 0, 0, 0, NULL);
6513 ShowWindow( hwnd, SW_SHOW );
6514 UpdateWindow( hwnd );
6515 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6517 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
6519 SetRect( &rect, -5, -5, 5, 5 );
6520 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6522 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6524 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6528 DispatchMessage( &msg );
6529 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
6530 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6531 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
6532 if (++count > 10) break;
6535 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
6537 trace("now without DispatchMessage\n");
6539 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
6541 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6543 if (msg.message != WM_PAINT) DispatchMessage( &msg );
6546 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
6548 /* this will send WM_NCCPAINT just like DispatchMessage does */
6549 GetUpdateRgn( hwnd, hrgn, TRUE );
6550 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
6551 DeleteObject( hrgn );
6552 GetClientRect( hwnd, &rect );
6553 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
6554 ok( !count, "Got multiple WM_PAINTs\n" );
6555 if (++count > 10) break;
6558 DestroyWindow(hwnd);
6562 static const struct message WmUser[] = {
6574 static DWORD CALLBACK send_msg_thread( LPVOID arg )
6576 struct sendmsg_info *info = arg;
6577 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
6578 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %ld\n", GetLastError());
6582 static void wait_for_thread( HANDLE thread )
6584 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
6587 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
6591 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6593 if (message == WM_USER) Sleep(200);
6594 return MsgCheckProcA( hwnd, message, wParam, lParam );
6597 static void test_SendMessageTimeout(void)
6601 struct sendmsg_info info;
6604 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6605 100, 100, 200, 200, 0, 0, 0, NULL);
6606 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6609 info.timeout = 1000;
6610 info.ret = 0xdeadbeef;
6611 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6612 wait_for_thread( thread );
6613 CloseHandle( thread );
6614 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6615 ok_sequence( WmUser, "WmUser", FALSE );
6618 info.ret = 0xdeadbeef;
6619 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6620 Sleep(100); /* SendMessageTimeout should timeout here */
6621 wait_for_thread( thread );
6622 CloseHandle( thread );
6623 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6624 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6626 /* 0 means infinite timeout */
6628 info.ret = 0xdeadbeef;
6629 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6631 wait_for_thread( thread );
6632 CloseHandle( thread );
6633 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6634 ok_sequence( WmUser, "WmUser", FALSE );
6636 /* timeout is treated as signed despite the prototype */
6637 info.timeout = 0x7fffffff;
6638 info.ret = 0xdeadbeef;
6639 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6641 wait_for_thread( thread );
6642 CloseHandle( thread );
6643 ok( info.ret == 1, "SendMessageTimeout failed\n" );
6644 ok_sequence( WmUser, "WmUser", FALSE );
6646 info.timeout = 0x80000000;
6647 info.ret = 0xdeadbeef;
6648 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6650 wait_for_thread( thread );
6651 CloseHandle( thread );
6652 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
6653 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6655 /* now check for timeout during message processing */
6656 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
6658 info.ret = 0xdeadbeef;
6659 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
6660 wait_for_thread( thread );
6661 CloseHandle( thread );
6662 /* we should timeout but still get the message */
6663 ok( info.ret == 0, "SendMessageTimeout failed\n" );
6664 ok_sequence( WmUser, "WmUser", FALSE );
6666 DestroyWindow( info.hwnd );
6670 /****************** edit message test *************************/
6671 #define ID_EDIT 0x1234
6672 static const struct message sl_edit_setfocus[] =
6674 { HCBT_SETFOCUS, hook },
6675 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
6676 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6677 { WM_SETFOCUS, sent|wparam, 0 },
6678 { WM_CTLCOLOREDIT, sent|parent },
6679 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6680 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6681 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6684 static const struct message ml_edit_setfocus[] =
6686 { HCBT_SETFOCUS, hook },
6687 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
6688 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6689 { WM_SETFOCUS, sent|wparam, 0 },
6690 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6691 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6692 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6693 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6696 static const struct message sl_edit_killfocus[] =
6698 { HCBT_SETFOCUS, hook },
6699 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6700 { WM_KILLFOCUS, sent|wparam, 0 },
6701 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6702 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6703 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
6704 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
6707 static const struct message sl_edit_lbutton_dblclk[] =
6709 { WM_LBUTTONDBLCLK, sent },
6710 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6713 static const struct message sl_edit_lbutton_down[] =
6715 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
6716 { HCBT_SETFOCUS, hook },
6717 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
6718 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6719 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
6720 { WM_CTLCOLOREDIT, sent|parent },
6721 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6722 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6723 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6724 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6725 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6726 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6727 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6728 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6731 static const struct message ml_edit_lbutton_down[] =
6733 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
6734 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6735 { HCBT_SETFOCUS, hook },
6736 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
6737 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
6738 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
6739 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6740 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6741 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
6744 static const struct message sl_edit_lbutton_up[] =
6746 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
6747 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6748 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6749 { WM_CAPTURECHANGED, sent|defwinproc },
6750 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
6753 static const struct message ml_edit_lbutton_up[] =
6755 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
6756 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6757 { WM_CAPTURECHANGED, sent|defwinproc },
6761 static WNDPROC old_edit_proc;
6763 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6765 static long defwndproc_counter = 0;
6769 trace("edit: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
6771 /* explicitly ignore WM_GETICON message */
6772 if (message == WM_GETICON) return 0;
6774 msg.message = message;
6775 msg.flags = sent|wparam|lparam;
6776 if (defwndproc_counter) msg.flags |= defwinproc;
6777 msg.wParam = wParam;
6778 msg.lParam = lParam;
6781 defwndproc_counter++;
6782 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
6783 defwndproc_counter--;
6788 static void subclass_edit(void)
6792 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
6794 old_edit_proc = cls.lpfnWndProc;
6796 cls.hInstance = GetModuleHandle(0);
6797 cls.lpfnWndProc = edit_hook_proc;
6798 cls.lpszClassName = "my_edit_class";
6799 if (!RegisterClassA(&cls)) assert(0);
6802 static void test_edit_messages(void)
6808 log_all_parent_messages++;
6810 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6811 100, 100, 200, 200, 0, 0, 0, NULL);
6812 ok (parent != 0, "Failed to create parent window\n");
6814 /* test single line edit */
6815 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
6816 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
6817 ok(hwnd != 0, "Failed to create edit window\n");
6819 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
6820 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08lx\n", dlg_code);
6822 ShowWindow(hwnd, SW_SHOW);
6828 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
6831 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
6837 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
6838 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
6844 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
6845 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
6847 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
6848 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
6850 DestroyWindow(hwnd);
6852 /* test multiline edit */
6853 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
6854 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
6855 ok(hwnd != 0, "Failed to create edit window\n");
6857 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
6858 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
6859 "wrong dlg_code %08lx\n", dlg_code);
6861 ShowWindow(hwnd, SW_SHOW);
6867 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
6870 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
6876 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
6877 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
6883 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
6884 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
6886 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
6887 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
6889 DestroyWindow(hwnd);
6890 DestroyWindow(parent);
6892 log_all_parent_messages--;
6895 /**************************** End of Edit test ******************************/
6897 static const struct message WmChar[] = {
6898 { WM_CHAR, sent|wparam, 'z' },
6902 static const struct message WmKeyDownUp[] = {
6903 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x00000001 },
6904 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6908 static const struct message WmUserChar[] = {
6910 { WM_CHAR, sent|wparam, 'z' },
6914 #define EV_START_STOP 0
6915 #define EV_SENDMSG 1
6921 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
6924 static DWORD CALLBACK send_msg_thread_2(void *param)
6927 struct peekmsg_info *info = param;
6929 trace("thread: waiting for start\n");
6930 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
6931 trace("thread: looping\n");
6935 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
6939 case WAIT_OBJECT_0 + EV_START_STOP:
6940 trace("thread: exiting\n");
6943 case WAIT_OBJECT_0 + EV_SENDMSG:
6944 trace("thread: sending message\n");
6945 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
6946 SetEvent(info->hevent[EV_ACK]);
6950 trace("unexpected return: %04lx\n", ret);
6958 static void test_PeekMessage(void)
6963 UINT qs_all_input = QS_ALLINPUT;
6964 UINT qs_input = QS_INPUT;
6965 struct peekmsg_info info;
6967 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
6968 100, 100, 200, 200, 0, 0, 0, NULL);
6969 ShowWindow(info.hwnd, SW_SHOW);
6970 UpdateWindow(info.hwnd);
6972 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
6973 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
6974 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
6976 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
6978 trace("signalling to start looping\n");
6979 SetEvent(info.hevent[EV_START_STOP]);
6981 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
6984 SetLastError(0xdeadbeef);
6985 qstatus = GetQueueStatus(qs_all_input);
6986 if (GetLastError() == ERROR_INVALID_FLAGS)
6988 trace("QS_RAWINPUT not supported on this platform\n");
6989 qs_all_input &= ~QS_RAWINPUT;
6990 qs_input &= ~QS_RAWINPUT;
6992 ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus);
6994 trace("signalling to send message\n");
6995 SetEvent(info.hevent[EV_SENDMSG]);
6996 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
6998 /* pass invalid QS_xxxx flags */
6999 SetLastError(0xdeadbeef);
7000 qstatus = GetQueueStatus(0xffffffff);
7001 ok(qstatus == 0, "GetQueueStatus should fail: %08lx\n", qstatus);
7002 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %ld\n", GetLastError());
7004 qstatus = GetQueueStatus(qs_all_input);
7005 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
7006 "wrong qstatus %08lx\n", qstatus);
7008 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7009 ok_sequence(WmUser, "WmUser", FALSE);
7011 qstatus = GetQueueStatus(qs_all_input);
7012 ok(qstatus == 0, "wrong qstatus %08lx\n", qstatus);
7014 keybd_event('N', 0, 0, 0);
7015 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7016 qstatus = GetQueueStatus(qs_all_input);
7017 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
7018 "wrong qstatus %08lx\n", qstatus);
7020 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7021 qstatus = GetQueueStatus(qs_all_input);
7022 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
7023 "wrong qstatus %08lx\n", qstatus);
7025 InvalidateRect(info.hwnd, NULL, FALSE);
7026 qstatus = GetQueueStatus(qs_all_input);
7027 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7028 "wrong qstatus %08lx\n", qstatus);
7030 trace("signalling to send message\n");
7031 SetEvent(info.hevent[EV_SENDMSG]);
7032 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7034 qstatus = GetQueueStatus(qs_all_input);
7035 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7036 "wrong qstatus %08lx\n", qstatus);
7037 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16))) DispatchMessageA(&msg);
7038 ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */
7040 qstatus = GetQueueStatus(qs_all_input);
7042 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7043 "wrong qstatus %08lx\n", qstatus);
7046 trace("signalling to send message\n");
7047 SetEvent(info.hevent[EV_SENDMSG]);
7048 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7050 qstatus = GetQueueStatus(qs_all_input);
7052 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7053 "wrong qstatus %08lx\n", qstatus);
7055 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg);
7056 ok_sequence(WmUser, "WmUser", FALSE);
7058 qstatus = GetQueueStatus(qs_all_input);
7060 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7061 "wrong qstatus %08lx\n", qstatus);
7064 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE)) DispatchMessageA(&msg);
7065 ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */
7067 qstatus = GetQueueStatus(qs_all_input);
7069 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
7070 "wrong qstatus %08lx\n", qstatus);
7073 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT)) DispatchMessageA(&msg);
7074 ok_sequence(WmPaint, "WmPaint", TRUE); /* todo_wine */
7076 qstatus = GetQueueStatus(qs_all_input);
7078 ok(qstatus == MAKELONG(0, QS_KEY),
7079 "wrong qstatus %08lx\n", qstatus);
7082 trace("signalling to send message\n");
7083 SetEvent(info.hevent[EV_SENDMSG]);
7084 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7086 qstatus = GetQueueStatus(qs_all_input);
7088 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
7089 "wrong qstatus %08lx\n", qstatus);
7092 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7094 qstatus = GetQueueStatus(qs_all_input);
7096 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7097 "wrong qstatus %08lx\n", qstatus);
7100 while (PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE)) DispatchMessage(&msg);
7101 ok_sequence(WmUserChar, "WmUserChar", FALSE);
7103 qstatus = GetQueueStatus(qs_all_input);
7105 ok(qstatus == MAKELONG(0, QS_KEY),
7106 "wrong qstatus %08lx\n", qstatus);
7109 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7111 qstatus = GetQueueStatus(qs_all_input);
7113 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
7114 "wrong qstatus %08lx\n", qstatus);
7117 trace("signalling to send message\n");
7118 SetEvent(info.hevent[EV_SENDMSG]);
7119 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7121 qstatus = GetQueueStatus(qs_all_input);
7123 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7124 "wrong qstatus %08lx\n", qstatus);
7127 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16))) DispatchMessage(&msg);
7128 ok_sequence(WmUser, "WmUser", TRUE); /* todo_wine */
7130 qstatus = GetQueueStatus(qs_all_input);
7132 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
7133 "wrong qstatus %08lx\n", qstatus);
7136 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16))) DispatchMessage(&msg);
7137 ok_sequence(WmKeyDownUp, "WmKeyDownUp", TRUE); /* todo_wine */
7139 qstatus = GetQueueStatus(qs_all_input);
7141 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7142 "wrong qstatus %08lx\n", qstatus);
7145 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE)) DispatchMessage(&msg);
7146 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7148 qstatus = GetQueueStatus(qs_all_input);
7150 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
7151 "wrong qstatus %08lx\n", qstatus);
7154 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7155 ok_sequence(WmChar, "WmChar", TRUE); /* todo_wine */
7157 qstatus = GetQueueStatus(qs_all_input);
7159 "wrong qstatus %08lx\n", qstatus);
7161 trace("signalling to exit\n");
7162 SetEvent(info.hevent[EV_START_STOP]);
7164 WaitForSingleObject(hthread, INFINITE);
7166 CloseHandle(hthread);
7167 CloseHandle(info.hevent[0]);
7168 CloseHandle(info.hevent[1]);
7169 CloseHandle(info.hevent[2]);
7171 DestroyWindow(info.hwnd);
7175 static void test_quit_message(void)
7180 /* test using PostQuitMessage */
7181 PostQuitMessage(0xbeef);
7183 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
7184 ok(ret, "PeekMessage failed with error %ld\n", GetLastError());
7185 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7186 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
7188 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
7189 ok(ret, "PostMessage failed with error %ld\n", GetLastError());
7191 ret = GetMessage(&msg, NULL, 0, 0);
7192 ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError());
7193 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
7195 /* note: WM_QUIT message received after WM_USER message */
7196 ret = GetMessage(&msg, NULL, 0, 0);
7197 ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError());
7198 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7199 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
7201 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
7202 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
7204 /* now test with PostThreadMessage - different behaviour! */
7205 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
7207 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
7208 ok(ret, "PeekMessage failed with error %ld\n", GetLastError());
7209 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7210 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
7212 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
7213 ok(ret, "PostMessage failed with error %ld\n", GetLastError());
7215 /* note: we receive the WM_QUIT message first this time */
7216 ret = GetMessage(&msg, NULL, 0, 0);
7217 ok(!ret, "GetMessage return %d with error %ld instead of FALSE\n", ret, GetLastError());
7218 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
7219 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
7221 ret = GetMessage(&msg, NULL, 0, 0);
7222 ok(ret > 0, "GetMessage failed with error %ld\n", GetLastError());
7223 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
7229 HMODULE user32 = GetModuleHandleA("user32.dll");
7230 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
7231 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
7232 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
7233 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
7235 if (!RegisterWindowClasses()) assert(0);
7237 if (pSetWinEventHook)
7239 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7240 GetModuleHandleA(0),
7243 GetCurrentThreadId(),
7244 WINEVENT_INCONTEXT);
7245 assert(hEvent_hook);
7247 if (pIsWinEventHookInstalled)
7250 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
7251 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
7255 cbt_hook_thread_id = GetCurrentThreadId();
7256 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
7261 /* Fix message sequences before removing 4 lines below */
7263 ret = pUnhookWinEvent(hEvent_hook);
7264 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
7265 pUnhookWinEvent = 0;
7270 test_scrollwindowex();
7272 test_mdi_messages();
7273 test_button_messages();
7274 test_paint_messages();
7275 test_interthread_messages();
7276 test_message_conversion();
7277 test_accelerators();
7280 test_DestroyWindow();
7281 test_DispatchMessage();
7282 test_SendMessageTimeout();
7283 test_edit_messages();
7284 test_quit_message();
7286 UnhookWindowsHookEx(hCBT_hook);
7287 if (pUnhookWinEvent)
7289 ret = pUnhookWinEvent(hEvent_hook);
7290 ok( ret, "UnhookWinEvent error %ld\n", GetLastError());
7291 SetLastError(0xdeadbeef);
7292 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
7293 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7294 GetLastError() == 0xdeadbeef, /* Win9x */
7295 "unexpected error %ld\n", GetLastError());