2 * Unit tests for window message handling
4 * Copyright 1999 Ove Kaaven
5 * Copyright 2003 Dimitrie O. Paun
6 * Copyright 2004, 2005 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define _WIN32_WINNT 0x0501 /* For WM_CHANGEUISTATE,QS_RAWINPUT */
35 #include "wine/test.h"
37 #define MDI_FIRST_CHILD_ID 2004
39 /* undocumented SWP flags - from SDK 3.1 */
40 #define SWP_NOCLIENTSIZE 0x0800
41 #define SWP_NOCLIENTMOVE 0x1000
43 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
46 #define WM_SYSTIMER 0x0118
49 #define WND_PARENT_ID 1
50 #define WND_POPUP_ID 2
51 #define WND_CHILD_ID 3
53 static BOOL test_DestroyWindow_flag;
54 static HWINEVENTHOOK hEvent_hook;
56 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
58 static void dump_winpos_flags(UINT flags);
61 FIXME: add tests for these
62 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
63 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
64 WS_THICKFRAME: thick border
65 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
66 WS_BORDER (default for overlapped windows): single black border
67 none (default for child (and popup?) windows): no border
84 UINT message; /* the WM_* code */
85 msg_flags_t flags; /* message props */
86 WPARAM wParam; /* expected value of wParam */
87 LPARAM lParam; /* expected value of lParam */
90 /* Empty message sequence */
91 static const struct message WmEmptySeq[] =
95 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
96 static const struct message WmCreateOverlappedSeq[] = {
97 { HCBT_CREATEWND, hook },
98 { WM_GETMINMAXINFO, sent },
99 { WM_NCCREATE, sent },
100 { WM_NCCALCSIZE, sent|wparam, 0 },
101 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
103 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
106 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
107 * for a not visible overlapped window.
109 static const struct message WmSWP_ShowOverlappedSeq[] = {
110 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
111 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
112 { WM_NCPAINT, sent|wparam|optional, 1 },
113 { WM_GETTEXT, sent|defwinproc|optional },
114 { WM_ERASEBKGND, sent|optional },
115 { HCBT_ACTIVATE, hook },
116 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
117 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
118 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
119 { WM_ACTIVATEAPP, sent|wparam, 1 },
120 { WM_NCACTIVATE, sent|wparam, 1 },
121 { WM_GETTEXT, sent|defwinproc|optional },
122 { WM_ACTIVATE, sent|wparam, 1 },
123 { HCBT_SETFOCUS, hook },
124 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
125 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
126 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
127 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
128 { WM_NCPAINT, sent|wparam|optional, 1 },
129 { WM_GETTEXT, sent|defwinproc|optional },
130 { WM_ERASEBKGND, sent|optional },
131 /* Win9x adds SWP_NOZORDER below */
132 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
133 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
134 { WM_NCPAINT, sent|wparam|optional, 1 },
135 { WM_ERASEBKGND, sent|optional },
136 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
139 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
140 * for a visible overlapped window.
142 static const struct message WmSWP_HideOverlappedSeq[] = {
143 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
144 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
145 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
149 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
150 * for a visible overlapped window.
152 static const struct message WmSWP_ResizeSeq[] = {
153 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
154 { WM_GETMINMAXINFO, sent|defwinproc },
155 { WM_NCCALCSIZE, sent|wparam, TRUE },
156 { WM_NCPAINT, sent|optional },
157 { WM_GETTEXT, sent|defwinproc|optional },
158 { WM_ERASEBKGND, sent|optional },
159 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
160 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
161 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
162 { WM_NCPAINT, sent|optional },
163 { WM_GETTEXT, sent|defwinproc|optional },
164 { WM_ERASEBKGND, sent|optional },
165 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
166 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
170 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
171 * for a visible popup window.
173 static const struct message WmSWP_ResizePopupSeq[] = {
174 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
175 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
176 { WM_NCCALCSIZE, sent|wparam, TRUE },
177 { WM_NCPAINT, sent|optional },
178 { WM_GETTEXT, sent|defwinproc|optional },
179 { WM_ERASEBKGND, sent|optional },
180 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
181 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
182 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
183 { WM_NCPAINT, sent|optional },
184 { WM_GETTEXT, sent|defwinproc|optional },
185 { WM_ERASEBKGND, sent|optional },
186 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
190 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
191 * for a visible overlapped window.
193 static const struct message WmSWP_MoveSeq[] = {
194 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
195 { WM_NCPAINT, sent|optional },
196 { WM_GETTEXT, sent|defwinproc|optional },
197 { WM_ERASEBKGND, sent|optional },
198 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
199 { WM_MOVE, sent|defwinproc|wparam, 0 },
200 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
204 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
205 SWP_NOZORDER|SWP_FRAMECHANGED)
206 * for a visible overlapped window with WS_CLIPCHILDREN style set.
208 static const struct message WmSWP_FrameChanged_clip[] = {
209 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
210 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
211 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
212 { WM_GETTEXT, sent|parent|defwinproc|optional },
213 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
214 { WM_NCPAINT, sent }, /* wparam != 1 */
215 { WM_ERASEBKGND, sent },
216 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
217 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
221 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
222 SWP_NOZORDER|SWP_FRAMECHANGED)
223 * for a visible overlapped window.
225 static const struct message WmSWP_FrameChangedDeferErase[] = {
226 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
227 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
228 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
229 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
230 { WM_PAINT, sent|parent },
231 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
232 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
234 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
235 { WM_ERASEBKGND, sent|beginpaint },
239 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
240 SWP_NOZORDER|SWP_FRAMECHANGED)
241 * for a visible overlapped window without WS_CLIPCHILDREN style set.
243 static const struct message WmSWP_FrameChanged_noclip[] = {
244 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
245 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
246 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
247 { WM_GETTEXT, sent|parent|defwinproc|optional },
248 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
249 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
250 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
252 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
253 { WM_ERASEBKGND, sent|beginpaint },
257 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
258 static const struct message WmShowOverlappedSeq[] = {
259 { WM_SHOWWINDOW, sent|wparam, 1 },
260 { WM_NCPAINT, sent|wparam|optional, 1 },
261 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
262 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
263 { WM_NCPAINT, sent|wparam|optional, 1 },
264 { WM_GETTEXT, sent|defwinproc|optional },
265 { WM_ERASEBKGND, sent|optional },
266 { HCBT_ACTIVATE, hook },
267 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
268 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
269 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
270 { WM_NCPAINT, sent|wparam|optional, 1 },
271 { WM_ACTIVATEAPP, sent|wparam, 1 },
272 { WM_NCACTIVATE, sent|wparam, 1 },
273 { WM_GETTEXT, sent|defwinproc|optional },
274 { WM_ACTIVATE, sent|wparam, 1 },
275 { HCBT_SETFOCUS, hook },
276 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
277 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
278 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
279 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
280 { WM_NCPAINT, sent|wparam|optional, 1 },
281 { WM_GETTEXT, sent|defwinproc|optional },
282 { WM_ERASEBKGND, sent|optional },
283 /* Win9x adds SWP_NOZORDER below */
284 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
285 { WM_NCCALCSIZE, sent|optional },
286 { WM_NCPAINT, sent|optional },
287 { WM_ERASEBKGND, sent|optional },
288 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
289 * messages. Does that mean that CreateWindow doesn't set initial
290 * window dimensions for overlapped windows?
297 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
298 static const struct message WmShowMaxOverlappedSeq[] = {
299 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
300 { WM_GETMINMAXINFO, sent },
301 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
302 { WM_GETMINMAXINFO, sent|defwinproc },
303 { WM_NCCALCSIZE, sent|wparam, TRUE },
304 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
305 { HCBT_ACTIVATE, hook },
306 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
307 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
308 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
309 { WM_ACTIVATEAPP, sent|wparam, 1 },
310 { WM_NCACTIVATE, sent|wparam, 1 },
311 { WM_GETTEXT, sent|defwinproc|optional },
312 { WM_ACTIVATE, sent|wparam, 1 },
313 { HCBT_SETFOCUS, hook },
314 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
315 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
316 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
317 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
318 { WM_NCPAINT, sent|wparam|optional, 1 },
319 { WM_GETTEXT, sent|defwinproc|optional },
320 { WM_ERASEBKGND, sent|optional },
321 /* Win9x adds SWP_NOZORDER below */
322 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
323 { WM_MOVE, sent|defwinproc },
324 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
325 { WM_NCCALCSIZE, sent|optional },
326 { WM_NCPAINT, sent|optional },
327 { WM_ERASEBKGND, sent|optional },
328 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
329 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
332 /* ShowWindow(SW_HIDE) for a visible overlapped window */
333 static const struct message WmHideOverlappedSeq[] = {
334 { WM_SHOWWINDOW, sent|wparam, 0 },
335 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
336 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
337 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
338 { WM_SIZE, sent|optional }, /* XP doesn't send it */
339 { WM_MOVE, sent|optional }, /* XP doesn't send it */
340 { WM_NCACTIVATE, sent|wparam, 0 },
341 { WM_ACTIVATE, sent|wparam, 0 },
342 { WM_ACTIVATEAPP, sent|wparam, 0 },
343 { WM_KILLFOCUS, sent|wparam, 0 },
344 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
345 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
348 /* DestroyWindow for a visible overlapped window */
349 static const struct message WmDestroyOverlappedSeq[] = {
350 { HCBT_DESTROYWND, hook },
351 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
352 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
353 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
354 { WM_NCACTIVATE, sent|wparam, 0 },
355 { WM_ACTIVATE, sent|wparam, 0 },
356 { WM_ACTIVATEAPP, sent|wparam, 0 },
357 { WM_KILLFOCUS, sent|wparam, 0 },
358 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
359 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
360 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
361 { WM_DESTROY, sent },
362 { WM_NCDESTROY, sent },
365 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
366 static const struct message WmCreateMaxPopupSeq[] = {
367 { HCBT_CREATEWND, hook },
368 { WM_NCCREATE, sent },
369 { WM_NCCALCSIZE, sent|wparam, 0 },
371 { WM_SIZE, sent|wparam, SIZE_RESTORED },
373 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
374 { WM_GETMINMAXINFO, sent },
375 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
376 { WM_NCCALCSIZE, sent|wparam, TRUE },
377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
378 { WM_MOVE, sent|defwinproc },
379 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
380 { WM_SHOWWINDOW, sent|wparam, 1 },
381 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
382 { HCBT_ACTIVATE, hook },
383 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
384 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
385 { WM_ACTIVATEAPP, sent|wparam, 1 },
386 { WM_NCACTIVATE, sent|wparam, 1 },
387 { WM_ACTIVATE, sent|wparam, 1 },
388 { HCBT_SETFOCUS, hook },
389 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
390 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
391 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
392 { WM_SYNCPAINT, sent|wparam|optional, 4 },
393 { WM_NCPAINT, sent|wparam|optional, 1 },
394 { WM_ERASEBKGND, sent|optional },
395 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
398 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
399 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
400 { HCBT_CREATEWND, hook },
401 { WM_NCCREATE, sent },
402 { WM_NCCALCSIZE, sent|wparam, 0 },
404 { WM_SIZE, sent|wparam, SIZE_RESTORED },
406 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
407 { WM_GETMINMAXINFO, sent },
408 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
409 { WM_NCCALCSIZE, sent|wparam, TRUE },
410 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
411 { WM_MOVE, sent|defwinproc },
412 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
415 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
416 static const struct message WmShowMaxPopupResizedSeq[] = {
417 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
418 { WM_GETMINMAXINFO, sent },
419 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
420 { WM_NCCALCSIZE, sent|wparam, TRUE },
421 { HCBT_ACTIVATE, hook },
422 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
423 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
424 { WM_ACTIVATEAPP, sent|wparam, 1 },
425 { WM_NCACTIVATE, sent|wparam, 1 },
426 { WM_ACTIVATE, sent|wparam, 1 },
427 { HCBT_SETFOCUS, hook },
428 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
429 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
430 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
431 { WM_NCPAINT, sent|wparam|optional, 1 },
432 { WM_ERASEBKGND, sent|optional },
433 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE },
434 /* WinNT4.0 sends WM_MOVE */
435 { WM_MOVE, sent|defwinproc|optional },
436 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
439 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
440 static const struct message WmShowMaxPopupSeq[] = {
441 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
442 { WM_GETMINMAXINFO, sent },
443 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
444 { WM_NCCALCSIZE, sent|wparam, TRUE },
445 { HCBT_ACTIVATE, hook },
446 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
447 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
448 { WM_ACTIVATEAPP, sent|wparam, 1 },
449 { WM_NCACTIVATE, sent|wparam, 1 },
450 { WM_ACTIVATE, sent|wparam, 1 },
451 { HCBT_SETFOCUS, hook },
452 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
453 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
454 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
455 { WM_SYNCPAINT, sent|wparam|optional, 4 },
456 { WM_NCPAINT, sent|wparam|optional, 1 },
457 { WM_ERASEBKGND, sent|optional },
458 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
461 /* CreateWindow(WS_VISIBLE) for popup window */
462 static const struct message WmCreatePopupSeq[] = {
463 { HCBT_CREATEWND, hook },
464 { WM_NCCREATE, sent },
465 { WM_NCCALCSIZE, sent|wparam, 0 },
467 { WM_SIZE, sent|wparam, SIZE_RESTORED },
469 { WM_SHOWWINDOW, sent|wparam, 1 },
470 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
471 { HCBT_ACTIVATE, hook },
472 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
473 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
474 { WM_NCPAINT, sent|wparam|optional, 1 },
475 { WM_ERASEBKGND, sent|optional },
476 { WM_ACTIVATEAPP, sent|wparam, 1 },
477 { WM_NCACTIVATE, sent|wparam, 1 },
478 { WM_ACTIVATE, sent|wparam, 1 },
479 { HCBT_SETFOCUS, hook },
480 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
481 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
482 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
483 { WM_SYNCPAINT, sent|wparam|optional, 4 },
484 { WM_NCPAINT, sent|wparam|optional, 1 },
485 { WM_ERASEBKGND, sent|optional },
486 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
489 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
490 static const struct message WmShowVisMaxPopupSeq[] = {
491 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
492 { WM_GETMINMAXINFO, sent },
493 { WM_GETTEXT, sent|optional },
494 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
495 { WM_NCCALCSIZE, sent|wparam, TRUE },
496 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
497 { WM_NCPAINT, sent|wparam|optional, 1 },
498 { WM_ERASEBKGND, sent|optional },
499 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
500 { WM_MOVE, sent|defwinproc },
501 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
504 /* CreateWindow (for a child popup window, not initially visible) */
505 static const struct message WmCreateChildPopupSeq[] = {
506 { HCBT_CREATEWND, hook },
507 { WM_NCCREATE, sent },
508 { WM_NCCALCSIZE, sent|wparam, 0 },
510 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
511 { WM_SIZE, sent|wparam, SIZE_RESTORED },
515 /* CreateWindow (for a popup window, not initially visible,
516 * which sets WS_VISIBLE in WM_CREATE handler)
518 static const struct message WmCreateInvisiblePopupSeq[] = {
519 { HCBT_CREATEWND, hook },
520 { WM_NCCREATE, sent },
521 { WM_NCCALCSIZE, sent|wparam, 0 },
523 { WM_STYLECHANGING, sent },
524 { WM_STYLECHANGED, sent },
525 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
526 { WM_SIZE, sent|wparam, SIZE_RESTORED },
530 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
531 * for a popup window with WS_VISIBLE style set
533 static const struct message WmShowVisiblePopupSeq_2[] = {
534 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
537 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
538 * for a popup window with WS_VISIBLE style set
540 static const struct message WmShowVisiblePopupSeq_3[] = {
541 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
542 { HCBT_ACTIVATE, hook },
543 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
544 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
545 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
546 { WM_NCACTIVATE, sent|wparam, 1 },
547 { WM_ACTIVATE, sent|wparam, 1 },
548 { HCBT_SETFOCUS, hook },
549 { WM_KILLFOCUS, sent|parent },
550 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
551 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
552 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
553 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
554 { WM_SETFOCUS, sent|defwinproc },
557 /* CreateWindow (for child window, not initially visible) */
558 static const struct message WmCreateChildSeq[] = {
559 { HCBT_CREATEWND, hook },
560 { WM_NCCREATE, sent },
561 /* child is inserted into parent's child list after WM_NCCREATE returns */
562 { WM_NCCALCSIZE, sent|wparam, 0 },
564 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
565 { WM_SIZE, sent|wparam, SIZE_RESTORED },
567 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
570 /* CreateWindow (for maximized child window, not initially visible) */
571 static const struct message WmCreateMaximizedChildSeq[] = {
572 { HCBT_CREATEWND, hook },
573 { WM_NCCREATE, sent },
574 { WM_NCCALCSIZE, sent|wparam, 0 },
576 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
577 { WM_SIZE, sent|wparam, SIZE_RESTORED },
579 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
580 { WM_GETMINMAXINFO, sent },
581 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
582 { WM_NCCALCSIZE, sent|wparam, 1 },
583 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
584 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
585 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
586 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
589 /* CreateWindow (for a child window, initially visible) */
590 static const struct message WmCreateVisibleChildSeq[] = {
591 { HCBT_CREATEWND, hook },
592 { WM_NCCREATE, sent },
593 /* child is inserted into parent's child list after WM_NCCREATE returns */
594 { WM_NCCALCSIZE, sent|wparam, 0 },
595 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
597 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
598 { WM_SIZE, sent|wparam, SIZE_RESTORED },
600 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
601 { WM_SHOWWINDOW, sent|wparam, 1 },
602 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
603 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
604 { WM_ERASEBKGND, sent|parent|optional },
605 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
606 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
607 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
610 /* ShowWindow(SW_SHOW) for a not visible child window */
611 static const struct message WmShowChildSeq[] = {
612 { WM_SHOWWINDOW, sent|wparam, 1 },
613 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
614 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
615 { WM_ERASEBKGND, sent|parent|optional },
616 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
619 /* ShowWindow(SW_HIDE) for a visible child window */
620 static const struct message WmHideChildSeq[] = {
621 { WM_SHOWWINDOW, sent|wparam, 0 },
622 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
623 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
624 { WM_ERASEBKGND, sent|parent|optional },
625 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
628 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
629 * for a not visible child window
631 static const struct message WmShowChildSeq_2[] = {
632 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
633 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
634 { WM_CHILDACTIVATE, sent },
635 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
638 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
639 * for a not visible child window
641 static const struct message WmShowChildSeq_3[] = {
642 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
643 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
644 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
647 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
648 * for a visible child window with a caption
650 static const struct message WmShowChildSeq_4[] = {
651 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
652 { WM_CHILDACTIVATE, sent },
655 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
656 static const struct message WmShowChildInvisibleParentSeq_1[] = {
657 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
658 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
659 { WM_NCCALCSIZE, sent|wparam, 1 },
660 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
661 { WM_MOVE, sent|defwinproc },
662 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
663 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
664 /* FIXME: Wine creates an icon/title window while Windows doesn't */
665 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
666 { WM_GETTEXT, sent|optional },
669 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
670 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
671 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
674 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
675 static const struct message WmShowChildInvisibleParentSeq_2[] = {
676 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
677 { WM_GETMINMAXINFO, sent },
678 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
679 { WM_NCCALCSIZE, sent|wparam, 1 },
680 { WM_CHILDACTIVATE, sent },
681 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|0x8000 },
682 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
683 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
686 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
687 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
688 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
691 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
692 static const struct message WmShowChildInvisibleParentSeq_3[] = {
693 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
694 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
695 { WM_NCCALCSIZE, sent|wparam, 1 },
696 { WM_CHILDACTIVATE, sent },
697 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
698 { WM_MOVE, sent|defwinproc },
699 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
700 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
701 /* FIXME: Wine creates an icon/title window while Windows doesn't */
702 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
703 { WM_GETTEXT, sent|optional },
706 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
707 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
708 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
711 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
712 static const struct message WmShowChildInvisibleParentSeq_4[] = {
713 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
714 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
715 { WM_NCCALCSIZE, sent|wparam, 1 },
716 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|0x8000 },
717 { WM_MOVE, sent|defwinproc },
718 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
719 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
720 /* FIXME: Wine creates an icon/title window while Windows doesn't */
721 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
722 { WM_GETTEXT, sent|optional },
725 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
726 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
727 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
730 /* ShowWindow(SW_SHOW) for child with invisible parent */
731 static const struct message WmShowChildInvisibleParentSeq_5[] = {
732 { WM_SHOWWINDOW, sent|wparam, 1 },
735 /* ShowWindow(SW_HIDE) for child with invisible parent */
736 static const struct message WmHideChildInvisibleParentSeq[] = {
737 { WM_SHOWWINDOW, sent|wparam, 0 },
740 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
741 static const struct message WmShowChildInvisibleParentSeq_6[] = {
742 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
743 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
744 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
747 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
748 static const struct message WmHideChildInvisibleParentSeq_2[] = {
749 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
750 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
751 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
754 /* DestroyWindow for a visible child window */
755 static const struct message WmDestroyChildSeq[] = {
756 { HCBT_DESTROYWND, hook },
757 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
758 { WM_SHOWWINDOW, sent|wparam, 0 },
759 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
760 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
761 { WM_ERASEBKGND, sent|parent|optional },
762 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
763 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
764 { WM_KILLFOCUS, sent },
765 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
766 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
767 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
768 { WM_SETFOCUS, sent|parent },
769 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
770 { WM_DESTROY, sent },
771 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
772 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
773 { WM_NCDESTROY, sent },
776 /* DestroyWindow for a visible child window with invisible parent */
777 static const struct message WmDestroyInvisibleChildSeq[] = {
778 { HCBT_DESTROYWND, hook },
779 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
780 { WM_SHOWWINDOW, sent|wparam, 0 },
781 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
782 { WM_DESTROY, sent },
783 { WM_NCDESTROY, sent },
786 /* Moving the mouse in nonclient area */
787 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
788 { WM_NCHITTEST, sent },
789 { WM_SETCURSOR, sent },
790 { WM_NCMOUSEMOVE, posted },
793 /* Moving the mouse in client area */
794 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
795 { WM_NCHITTEST, sent },
796 { WM_SETCURSOR, sent },
797 { WM_MOUSEMOVE, posted },
800 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
801 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
802 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
803 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
804 { WM_GETMINMAXINFO, sent|defwinproc },
805 { WM_ENTERSIZEMOVE, sent|defwinproc },
806 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
807 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
808 { WM_MOVE, sent|defwinproc },
809 { WM_EXITSIZEMOVE, sent|defwinproc },
812 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
813 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
814 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
815 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
816 { WM_GETMINMAXINFO, sent|defwinproc },
817 { WM_ENTERSIZEMOVE, sent|defwinproc },
818 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
819 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
820 { WM_GETMINMAXINFO, sent|defwinproc },
821 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
822 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
823 { WM_GETTEXT, sent|defwinproc },
824 { WM_ERASEBKGND, sent|defwinproc },
825 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
826 { WM_MOVE, sent|defwinproc },
827 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
828 { WM_EXITSIZEMOVE, sent|defwinproc },
831 /* Resizing child window with MoveWindow (32) */
832 static const struct message WmResizingChildWithMoveWindowSeq[] = {
833 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
834 { WM_NCCALCSIZE, sent|wparam, 1 },
835 { WM_ERASEBKGND, sent|optional },
836 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
837 { WM_MOVE, sent|defwinproc },
838 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
839 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
842 /* Clicking on inactive button */
843 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
844 { WM_NCHITTEST, sent },
845 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
846 { WM_MOUSEACTIVATE, sent },
847 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
848 { WM_SETCURSOR, sent },
849 { WM_SETCURSOR, sent|parent|defwinproc },
850 { WM_LBUTTONDOWN, posted },
851 { WM_KILLFOCUS, posted|parent },
852 { WM_SETFOCUS, posted },
853 { WM_CTLCOLORBTN, posted|parent },
854 { BM_SETSTATE, posted },
855 { WM_CTLCOLORBTN, posted|parent },
856 { WM_LBUTTONUP, posted },
857 { BM_SETSTATE, posted },
858 { WM_CTLCOLORBTN, posted|parent },
859 { WM_COMMAND, posted|parent },
862 /* Reparenting a button (16/32) */
863 /* The last child (button) reparented gets topmost for its new parent. */
864 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
865 { WM_SHOWWINDOW, sent|wparam, 0 },
866 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
867 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
868 { WM_ERASEBKGND, sent|parent },
869 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
870 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
871 { WM_CHILDACTIVATE, sent },
872 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
873 { WM_MOVE, sent|defwinproc },
874 { WM_SHOWWINDOW, sent|wparam, 1 },
877 /* Creation of a custom dialog (32) */
878 static const struct message WmCreateCustomDialogSeq[] = {
879 { HCBT_CREATEWND, hook },
880 { WM_GETMINMAXINFO, sent },
881 { WM_NCCREATE, sent },
882 { WM_NCCALCSIZE, sent|wparam, 0 },
883 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
885 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
886 { WM_SHOWWINDOW, sent|wparam, 1 },
887 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
888 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
889 { HCBT_ACTIVATE, hook },
890 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
893 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
895 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
897 { WM_NCACTIVATE, sent|wparam, 1 },
898 { WM_GETTEXT, sent|optional|defwinproc },
899 { WM_GETTEXT, sent|optional|defwinproc },
900 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
901 { WM_ACTIVATE, sent|wparam, 1 },
902 { WM_KILLFOCUS, sent|parent },
903 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
904 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
905 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
906 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
907 { WM_SETFOCUS, sent },
908 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
909 { WM_NCPAINT, sent|wparam, 1 },
910 { WM_GETTEXT, sent|optional|defwinproc },
911 { WM_GETTEXT, sent|optional|defwinproc },
912 { WM_ERASEBKGND, sent },
913 { WM_CTLCOLORDLG, sent|defwinproc },
914 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
915 { WM_GETTEXT, sent|optional },
916 { WM_GETTEXT, sent|optional },
917 { WM_NCCALCSIZE, sent|optional },
918 { WM_NCPAINT, sent|optional },
919 { WM_GETTEXT, sent|optional|defwinproc },
920 { WM_GETTEXT, sent|optional|defwinproc },
921 { WM_ERASEBKGND, sent|optional },
922 { WM_CTLCOLORDLG, sent|optional|defwinproc },
923 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
924 { WM_SIZE, sent|wparam, SIZE_RESTORED },
928 /* Calling EndDialog for a custom dialog (32) */
929 static const struct message WmEndCustomDialogSeq[] = {
930 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
931 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
932 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
933 { WM_GETTEXT, sent|optional },
934 { HCBT_ACTIVATE, hook },
935 { WM_NCACTIVATE, sent|wparam, 0 },
936 { WM_GETTEXT, sent|optional|defwinproc },
937 { WM_GETTEXT, sent|optional|defwinproc },
938 { WM_ACTIVATE, sent|wparam, 0 },
939 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
940 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
941 { HCBT_SETFOCUS, hook },
942 { WM_KILLFOCUS, sent },
943 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
944 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
945 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
946 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
947 { WM_SETFOCUS, sent|parent|defwinproc },
950 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
951 static const struct message WmShowCustomDialogSeq[] = {
952 { WM_SHOWWINDOW, sent|wparam, 1 },
953 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
954 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
955 { HCBT_ACTIVATE, hook },
956 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
958 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
960 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
961 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
962 { WM_NCACTIVATE, sent|wparam, 1 },
963 { WM_ACTIVATE, sent|wparam, 1 },
965 { WM_KILLFOCUS, sent|parent },
966 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
967 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
968 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
969 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
970 { WM_SETFOCUS, sent },
971 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
972 { WM_NCPAINT, sent|wparam, 1 },
973 { WM_ERASEBKGND, sent },
974 { WM_CTLCOLORDLG, sent|defwinproc },
975 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
978 /* Creation and destruction of a modal dialog (32) */
979 static const struct message WmModalDialogSeq[] = {
980 { WM_CANCELMODE, sent|parent },
981 { HCBT_SETFOCUS, hook },
982 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
983 { WM_KILLFOCUS, sent|parent },
984 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
985 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
986 { WM_ENABLE, sent|parent|wparam, 0 },
987 { HCBT_CREATEWND, hook },
988 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
989 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
990 { WM_SETFONT, sent },
991 { WM_INITDIALOG, sent },
992 { WM_CHANGEUISTATE, sent|optional },
993 { WM_UPDATEUISTATE, sent|optional },
994 { WM_SHOWWINDOW, sent },
995 { HCBT_ACTIVATE, hook },
996 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
997 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
998 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
999 { WM_NCACTIVATE, sent|wparam, 1 },
1000 { WM_GETTEXT, sent|optional },
1001 { WM_ACTIVATE, sent|wparam, 1 },
1002 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1003 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1004 { WM_NCPAINT, sent },
1005 { WM_GETTEXT, sent|optional },
1006 { WM_ERASEBKGND, sent },
1007 { WM_CTLCOLORDLG, sent },
1008 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1009 { WM_GETTEXT, sent|optional },
1010 { WM_NCCALCSIZE, sent|optional },
1011 { WM_NCPAINT, sent|optional },
1012 { WM_GETTEXT, sent|optional },
1013 { WM_ERASEBKGND, sent|optional },
1014 { WM_CTLCOLORDLG, sent|optional },
1015 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1016 { WM_PAINT, sent|optional },
1017 { WM_CTLCOLORBTN, sent },
1018 { WM_ENTERIDLE, sent|parent|optional },
1019 { WM_ENTERIDLE, sent|parent|optional },
1020 { WM_ENTERIDLE, sent|parent|optional },
1021 { WM_ENTERIDLE, sent|parent|optional },
1022 { WM_ENTERIDLE, sent|parent|optional },
1023 { WM_ENTERIDLE, sent|parent|optional },
1024 { WM_ENTERIDLE, sent|parent|optional },
1025 { WM_ENTERIDLE, sent|parent|optional },
1026 { WM_ENTERIDLE, sent|parent|optional },
1027 { WM_ENTERIDLE, sent|parent|optional },
1028 { WM_ENTERIDLE, sent|parent|optional },
1029 { WM_ENTERIDLE, sent|parent|optional },
1030 { WM_ENTERIDLE, sent|parent|optional },
1031 { WM_ENTERIDLE, sent|parent|optional },
1032 { WM_ENTERIDLE, sent|parent|optional },
1033 { WM_ENTERIDLE, sent|parent|optional },
1034 { WM_ENTERIDLE, sent|parent|optional },
1035 { WM_ENTERIDLE, sent|parent|optional },
1036 { WM_ENTERIDLE, sent|parent|optional },
1037 { WM_ENTERIDLE, sent|parent|optional },
1039 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1040 { WM_ENABLE, sent|parent|wparam, 1 },
1041 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1042 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1043 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1044 { WM_GETTEXT, sent|optional },
1045 { HCBT_ACTIVATE, hook },
1046 { WM_NCACTIVATE, sent|wparam, 0 },
1047 { WM_GETTEXT, sent|optional },
1048 { WM_ACTIVATE, sent|wparam, 0 },
1049 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1050 { WM_WINDOWPOSCHANGING, sent|optional },
1051 { HCBT_SETFOCUS, hook },
1052 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1053 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1054 { WM_SETFOCUS, sent|parent|defwinproc },
1055 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1056 { HCBT_DESTROYWND, hook },
1057 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1058 { WM_DESTROY, sent },
1059 { WM_NCDESTROY, sent },
1062 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1063 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1064 /* (inside dialog proc, handling WM_INITDIALOG) */
1065 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1066 { WM_NCCALCSIZE, sent },
1067 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1068 { WM_GETTEXT, sent|defwinproc },
1069 { WM_ACTIVATE, sent|parent|wparam, 0 },
1070 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1071 { WM_WINDOWPOSCHANGING, sent|parent },
1072 { WM_NCACTIVATE, sent|wparam, 1 },
1073 { WM_ACTIVATE, sent|wparam, 1 },
1074 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1075 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1076 /* (setting focus) */
1077 { WM_SHOWWINDOW, sent|wparam, 1 },
1078 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1079 { WM_NCPAINT, sent },
1080 { WM_GETTEXT, sent|defwinproc },
1081 { WM_ERASEBKGND, sent },
1082 { WM_CTLCOLORDLG, sent|defwinproc },
1083 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1085 /* (bunch of WM_CTLCOLOR* for each control) */
1086 { WM_PAINT, sent|parent },
1087 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1088 { WM_SETCURSOR, sent|parent },
1091 /* SetMenu for NonVisible windows with size change*/
1092 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1093 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1094 { WM_NCCALCSIZE, sent|wparam, 1 },
1095 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1096 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1097 { WM_MOVE, sent|defwinproc },
1098 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1099 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1100 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1101 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1102 { WM_GETTEXT, sent|optional },
1103 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1106 /* SetMenu for NonVisible windows with no size change */
1107 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1108 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1109 { WM_NCCALCSIZE, sent|wparam, 1 },
1110 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1111 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1114 /* SetMenu for Visible windows with size change */
1115 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1116 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1117 { WM_NCCALCSIZE, sent|wparam, 1 },
1118 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1119 { WM_NCPAINT, sent }, /* wparam != 1 */
1120 { WM_GETTEXT, sent|defwinproc|optional },
1121 { WM_ERASEBKGND, sent|optional },
1122 { WM_ACTIVATE, sent|optional },
1123 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1124 { WM_MOVE, sent|defwinproc },
1125 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1126 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1127 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1128 { WM_ERASEBKGND, sent|optional },
1129 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1130 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1133 /* SetMenu for Visible windows with no size change */
1134 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1135 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1136 { WM_NCCALCSIZE, sent|wparam, 1 },
1137 { WM_NCPAINT, sent }, /* wparam != 1 */
1138 { WM_GETTEXT, sent|defwinproc|optional },
1139 { WM_ERASEBKGND, sent|optional },
1140 { WM_ACTIVATE, sent|optional },
1141 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1142 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1145 /* DrawMenuBar for a visible window */
1146 static const struct message WmDrawMenuBarSeq[] =
1148 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1149 { WM_NCCALCSIZE, sent|wparam, 1 },
1150 { WM_NCPAINT, sent }, /* wparam != 1 */
1151 { WM_GETTEXT, sent|defwinproc|optional },
1152 { WM_ERASEBKGND, sent|optional },
1153 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1154 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1158 static const struct message WmSetRedrawFalseSeq[] =
1160 { WM_SETREDRAW, sent|wparam, 0 },
1164 static const struct message WmSetRedrawTrueSeq[] =
1166 { WM_SETREDRAW, sent|wparam, 1 },
1170 static const struct message WmEnableWindowSeq_1[] =
1172 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1173 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1174 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1178 static const struct message WmEnableWindowSeq_2[] =
1180 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1181 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1185 static const struct message WmGetScrollRangeSeq[] =
1187 { SBM_GETRANGE, sent },
1190 static const struct message WmGetScrollInfoSeq[] =
1192 { SBM_GETSCROLLINFO, sent },
1195 static const struct message WmSetScrollRangeSeq[] =
1197 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1198 sends SBM_SETSCROLLINFO.
1200 { SBM_SETSCROLLINFO, sent },
1203 /* SetScrollRange for a window without a non-client area */
1204 static const struct message WmSetScrollRangeHSeq_empty[] =
1206 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1209 static const struct message WmSetScrollRangeVSeq_empty[] =
1211 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1214 static const struct message WmSetScrollRangeHVSeq[] =
1216 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1217 { WM_NCCALCSIZE, sent|wparam, 1 },
1218 { WM_GETTEXT, sent|defwinproc|optional },
1219 { WM_ERASEBKGND, sent|optional },
1220 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1221 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1222 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1225 /* SetScrollRange for a window with a non-client area */
1226 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1228 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1229 { WM_NCCALCSIZE, sent|wparam, 1 },
1230 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1231 { WM_NCPAINT, sent|optional },
1232 { WM_GETTEXT, sent|defwinproc|optional },
1233 { WM_GETTEXT, sent|defwinproc|optional },
1234 { WM_ERASEBKGND, sent|optional },
1235 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1236 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1237 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1238 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1239 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1240 { WM_GETTEXT, sent|optional },
1241 { WM_GETTEXT, sent|optional },
1242 { WM_GETTEXT, sent|optional },
1243 { WM_GETTEXT, sent|optional },
1246 /* test if we receive the right sequence of messages */
1247 /* after calling ShowWindow( SW_SHOWNA) */
1248 static const struct message WmSHOWNAChildInvisParInvis[] = {
1249 { WM_SHOWWINDOW, sent|wparam, 1 },
1252 static const struct message WmSHOWNAChildVisParInvis[] = {
1253 { WM_SHOWWINDOW, sent|wparam, 1 },
1256 static const struct message WmSHOWNAChildVisParVis[] = {
1257 { WM_SHOWWINDOW, sent|wparam, 1 },
1258 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1261 static const struct message WmSHOWNAChildInvisParVis[] = {
1262 { WM_SHOWWINDOW, sent|wparam, 1 },
1263 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1264 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1265 { WM_ERASEBKGND, sent|optional },
1266 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1269 static const struct message WmSHOWNATopVisible[] = {
1270 { WM_SHOWWINDOW, sent|wparam, 1 },
1271 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1274 static const struct message WmSHOWNATopInvisible[] = {
1275 { WM_SHOWWINDOW, sent|wparam, 1 },
1276 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1277 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1278 { WM_NCPAINT, sent|wparam, 1 },
1279 { WM_GETTEXT, sent|defwinproc|optional },
1280 { WM_ERASEBKGND, sent|optional },
1281 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1282 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1283 { WM_NCPAINT, sent|wparam|optional, 1 },
1284 { WM_ERASEBKGND, sent|optional },
1285 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1286 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1291 static int after_end_dialog, test_def_id;
1292 static int sequence_cnt, sequence_size;
1293 static struct message* sequence;
1294 static int log_all_parent_messages;
1296 static void add_message(const struct message *msg)
1301 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof (struct message) );
1303 if (sequence_cnt == sequence_size)
1306 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof (struct message) );
1310 sequence[sequence_cnt].message = msg->message;
1311 sequence[sequence_cnt].flags = msg->flags;
1312 sequence[sequence_cnt].wParam = msg->wParam;
1313 sequence[sequence_cnt].lParam = msg->lParam;
1318 /* try to make sure pending X events have been processed before continuing */
1319 static void flush_events(void)
1323 DWORD time = GetTickCount() + diff;
1327 MsgWaitForMultipleObjects( 0, NULL, FALSE, diff, QS_ALLINPUT );
1328 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1329 diff = time - GetTickCount();
1333 static void flush_sequence(void)
1335 HeapFree(GetProcessHeap(), 0, sequence);
1337 sequence_cnt = sequence_size = 0;
1340 #define ok_sequence( exp, contx, todo) \
1341 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1344 static void ok_sequence_(const struct message *expected, const char *context, int todo,
1345 const char *file, int line)
1347 static const struct message end_of_sequence = { 0, 0, 0, 0 };
1348 const struct message *actual;
1351 add_message(&end_of_sequence);
1355 while (expected->message && actual->message)
1357 trace_( file, line)("expected %04x - actual %04x\n", expected->message, actual->message);
1359 if (expected->message == actual->message)
1361 if (expected->flags & wparam)
1363 if (expected->wParam != actual->wParam && todo)
1367 ok_( file, line) (FALSE,
1368 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1369 context, expected->message, expected->wParam, actual->wParam);
1373 ok_( file, line) (expected->wParam == actual->wParam,
1374 "%s: in msg 0x%04x expecting wParam 0x%x got 0x%x\n",
1375 context, expected->message, expected->wParam, actual->wParam);
1377 if (expected->flags & lparam)
1379 if (expected->lParam != actual->lParam && todo)
1383 ok_( file, line) (FALSE,
1384 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1385 context, expected->message, expected->lParam, actual->lParam);
1389 ok_( file, line) (expected->lParam == actual->lParam,
1390 "%s: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1391 context, expected->message, expected->lParam, actual->lParam);
1393 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1397 ok_( file, line) (FALSE,
1398 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1399 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1403 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1404 "%s: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1405 context, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1406 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1407 "%s: the msg 0x%04x should %shave been sent by BeginPaint\n",
1408 context, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1409 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1410 "%s: the msg 0x%04x should have been %s\n",
1411 context, expected->message, (expected->flags & posted) ? "posted" : "sent");
1412 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1413 "%s: the msg 0x%04x was expected in %s\n",
1414 context, expected->message, (expected->flags & parent) ? "parent" : "child");
1415 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
1416 "%s: the msg 0x%04x should have been sent by a hook\n",
1417 context, expected->message);
1418 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
1419 "%s: the msg 0x%04x should have been sent by a winevent hook\n",
1420 context, expected->message);
1424 /* silently drop winevent messages if there is no support for them */
1425 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1431 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1432 context, expected->message, actual->message);
1439 ok_( file, line) (FALSE, "%s: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
1440 context, expected->message, actual->message);
1446 /* skip all optional trailing messages */
1447 while (expected->message && ((expected->flags & optional) ||
1448 ((expected->flags & winevent_hook) && !hEvent_hook)))
1454 if (expected->message || actual->message) {
1456 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1457 context, expected->message, actual->message);
1463 if (expected->message || actual->message)
1464 ok_( file, line) (FALSE, "%s: the msg sequence is not complete: expected %04x - actual %04x\n",
1465 context, expected->message, actual->message);
1467 if( todo && !failcount) /* succeeded yet marked todo */
1469 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
1475 /******************************** MDI test **********************************/
1477 /* CreateWindow for MDI frame window, initially visible */
1478 static const struct message WmCreateMDIframeSeq[] = {
1479 { HCBT_CREATEWND, hook },
1480 { WM_GETMINMAXINFO, sent },
1481 { WM_NCCREATE, sent },
1482 { WM_NCCALCSIZE, sent|wparam, 0 },
1483 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1484 { WM_CREATE, sent },
1485 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1486 { WM_SHOWWINDOW, sent|wparam, 1 },
1487 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1488 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1489 { HCBT_ACTIVATE, hook },
1490 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1491 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1492 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
1493 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
1494 { WM_NCACTIVATE, sent|wparam, 1 },
1495 { WM_GETTEXT, sent|defwinproc|optional },
1496 { WM_ACTIVATE, sent|wparam, 1 },
1497 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
1498 { HCBT_SETFOCUS, hook },
1499 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1500 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1501 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1502 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
1503 /* Win9x adds SWP_NOZORDER below */
1504 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1505 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
1506 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1507 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1511 /* DestroyWindow for MDI frame window, initially visible */
1512 static const struct message WmDestroyMDIframeSeq[] = {
1513 { HCBT_DESTROYWND, hook },
1514 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1515 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1516 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1517 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1518 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
1519 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
1520 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
1521 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
1522 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1523 { WM_DESTROY, sent },
1524 { WM_NCDESTROY, sent },
1527 /* CreateWindow for MDI client window, initially visible */
1528 static const struct message WmCreateMDIclientSeq[] = {
1529 { HCBT_CREATEWND, hook },
1530 { WM_NCCREATE, sent },
1531 { WM_NCCALCSIZE, sent|wparam, 0 },
1532 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1533 { WM_CREATE, sent },
1534 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1535 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1536 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1538 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
1539 { WM_SHOWWINDOW, sent|wparam, 1 },
1540 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1541 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1545 /* ShowWindow(SW_SHOW) for MDI client window */
1546 static const struct message WmShowMDIclientSeq[] = {
1547 { WM_SHOWWINDOW, sent|wparam, 1 },
1548 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1549 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1550 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1553 /* ShowWindow(SW_HIDE) for MDI client window */
1554 static const struct message WmHideMDIclientSeq[] = {
1555 { WM_SHOWWINDOW, sent|wparam, 0 },
1556 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1557 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
1558 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
1559 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1562 /* DestroyWindow for MDI client window, initially visible */
1563 static const struct message WmDestroyMDIclientSeq[] = {
1564 { HCBT_DESTROYWND, hook },
1565 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
1566 { WM_SHOWWINDOW, sent|wparam, 0 },
1567 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1568 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1569 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1570 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1571 { WM_DESTROY, sent },
1572 { WM_NCDESTROY, sent },
1575 /* CreateWindow for MDI child window, initially visible */
1576 static const struct message WmCreateMDIchildVisibleSeq[] = {
1577 { HCBT_CREATEWND, hook },
1578 { WM_NCCREATE, sent },
1579 { WM_NCCALCSIZE, sent|wparam, 0 },
1580 { WM_CREATE, sent },
1581 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1582 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1584 /* Win2k sends wparam set to
1585 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1586 * while Win9x doesn't bother to set child window id according to
1587 * CLIENTCREATESTRUCT.idFirstChild
1589 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1590 { WM_SHOWWINDOW, sent|wparam, 1 },
1591 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1592 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1593 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1594 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1595 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1596 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1597 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1599 /* Win9x: message sequence terminates here. */
1601 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1602 { HCBT_SETFOCUS, hook }, /* in MDI client */
1603 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1604 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1605 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1606 { WM_SETFOCUS, sent }, /* in MDI client */
1607 { HCBT_SETFOCUS, hook },
1608 { WM_KILLFOCUS, sent }, /* in MDI client */
1609 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1610 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1611 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1612 { WM_SETFOCUS, sent|defwinproc },
1613 { WM_MDIACTIVATE, sent|defwinproc },
1616 /* CreateWindow for MDI child window with invisible parent */
1617 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
1618 { HCBT_CREATEWND, hook },
1619 { WM_GETMINMAXINFO, sent },
1620 { WM_NCCREATE, sent },
1621 { WM_NCCALCSIZE, sent|wparam, 0 },
1622 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
1623 { WM_CREATE, sent },
1624 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1625 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1627 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1628 { WM_SHOWWINDOW, sent|wparam, 1 },
1629 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
1630 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1631 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1632 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1634 /* Win9x: message sequence terminates here. */
1636 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1637 { HCBT_SETFOCUS, hook }, /* in MDI client */
1638 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1639 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1640 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1641 { WM_SETFOCUS, sent }, /* in MDI client */
1642 { HCBT_SETFOCUS, hook },
1643 { WM_KILLFOCUS, sent }, /* in MDI client */
1644 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1645 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1646 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1647 { WM_SETFOCUS, sent|defwinproc },
1648 { WM_MDIACTIVATE, sent|defwinproc },
1651 /* DestroyWindow for MDI child window, initially visible */
1652 static const struct message WmDestroyMDIchildVisibleSeq[] = {
1653 { HCBT_DESTROYWND, hook },
1654 /* Win2k sends wparam set to
1655 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1656 * while Win9x doesn't bother to set child window id according to
1657 * CLIENTCREATESTRUCT.idFirstChild
1659 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1660 { WM_SHOWWINDOW, sent|wparam, 0 },
1661 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1662 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1663 { WM_ERASEBKGND, sent|parent|optional },
1664 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1666 /* { WM_DESTROY, sent }
1667 * Win9x: message sequence terminates here.
1670 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1671 { WM_KILLFOCUS, sent },
1672 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1673 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1674 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1675 { WM_SETFOCUS, sent }, /* in MDI client */
1677 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1678 { WM_KILLFOCUS, sent }, /* in MDI client */
1679 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1680 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1681 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1682 { WM_SETFOCUS, sent }, /* in MDI client */
1684 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1686 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1687 { WM_KILLFOCUS, sent },
1688 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1689 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1690 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1691 { WM_SETFOCUS, sent }, /* in MDI client */
1693 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1694 { WM_KILLFOCUS, sent }, /* in MDI client */
1695 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1696 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1697 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1698 { WM_SETFOCUS, sent }, /* in MDI client */
1700 { WM_DESTROY, sent },
1702 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
1703 { WM_KILLFOCUS, sent },
1704 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1705 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1706 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1707 { WM_SETFOCUS, sent }, /* in MDI client */
1709 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
1710 { WM_KILLFOCUS, sent }, /* in MDI client */
1711 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1712 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1713 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1714 { WM_SETFOCUS, sent }, /* in MDI client */
1716 { WM_NCDESTROY, sent },
1719 /* CreateWindow for MDI child window, initially invisible */
1720 static const struct message WmCreateMDIchildInvisibleSeq[] = {
1721 { HCBT_CREATEWND, hook },
1722 { WM_NCCREATE, sent },
1723 { WM_NCCALCSIZE, sent|wparam, 0 },
1724 { WM_CREATE, sent },
1725 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1726 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1728 /* Win2k sends wparam set to
1729 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1730 * while Win9x doesn't bother to set child window id according to
1731 * CLIENTCREATESTRUCT.idFirstChild
1733 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1736 /* DestroyWindow for MDI child window, initially invisible */
1737 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
1738 { HCBT_DESTROYWND, hook },
1739 /* Win2k sends wparam set to
1740 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
1741 * while Win9x doesn't bother to set child window id according to
1742 * CLIENTCREATESTRUCT.idFirstChild
1744 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
1745 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1746 { WM_DESTROY, sent },
1747 { WM_NCDESTROY, sent },
1748 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
1749 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
1752 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
1753 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
1754 { HCBT_CREATEWND, hook },
1755 { WM_NCCREATE, sent },
1756 { WM_NCCALCSIZE, sent|wparam, 0 },
1757 { WM_CREATE, sent },
1758 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1759 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1761 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1762 { WM_GETMINMAXINFO, sent },
1763 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1764 { WM_NCCALCSIZE, sent|wparam, 1 },
1765 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1766 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1768 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1769 { WM_NCCALCSIZE, sent|wparam, 1 },
1770 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1771 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1772 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1773 /* Win2k sends wparam set to
1774 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1775 * while Win9x doesn't bother to set child window id according to
1776 * CLIENTCREATESTRUCT.idFirstChild
1778 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1779 { WM_SHOWWINDOW, sent|wparam, 1 },
1780 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1781 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1782 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1783 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1784 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1785 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1786 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1788 /* Win9x: message sequence terminates here. */
1790 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1791 { HCBT_SETFOCUS, hook }, /* in MDI client */
1792 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1793 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
1794 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1795 { WM_SETFOCUS, sent }, /* in MDI client */
1796 { HCBT_SETFOCUS, hook },
1797 { WM_KILLFOCUS, sent }, /* in MDI client */
1798 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1799 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1800 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1801 { WM_SETFOCUS, sent|defwinproc },
1802 { WM_MDIACTIVATE, sent|defwinproc },
1804 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1805 { WM_NCCALCSIZE, sent|wparam, 1 },
1806 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1807 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1810 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
1811 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
1812 /* restore the 1st MDI child */
1813 { WM_SETREDRAW, sent|wparam, 0 },
1814 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
1815 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
1816 { WM_NCCALCSIZE, sent|wparam, 1 },
1817 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1818 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1819 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1821 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1822 { WM_NCCALCSIZE, sent|wparam, 1 },
1823 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1824 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1825 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1826 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
1827 /* create the 2nd MDI child */
1828 { HCBT_CREATEWND, hook },
1829 { WM_NCCREATE, sent },
1830 { WM_NCCALCSIZE, sent|wparam, 0 },
1831 { WM_CREATE, sent },
1832 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1833 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1835 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1836 { WM_GETMINMAXINFO, sent },
1837 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1838 { WM_NCCALCSIZE, sent|wparam, 1 },
1839 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1840 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1841 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1843 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1844 { WM_NCCALCSIZE, sent|wparam, 1 },
1845 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1846 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1847 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1848 /* Win2k sends wparam set to
1849 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1850 * while Win9x doesn't bother to set child window id according to
1851 * CLIENTCREATESTRUCT.idFirstChild
1853 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1854 { WM_SHOWWINDOW, sent|wparam, 1 },
1855 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1856 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1857 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1858 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1859 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1860 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1862 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
1863 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
1865 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1867 /* Win9x: message sequence terminates here. */
1869 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1870 { HCBT_SETFOCUS, hook },
1871 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
1872 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
1873 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1874 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1875 { WM_SETFOCUS, sent }, /* in MDI client */
1876 { HCBT_SETFOCUS, hook },
1877 { WM_KILLFOCUS, sent }, /* in MDI client */
1878 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1879 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1880 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1881 { WM_SETFOCUS, sent|defwinproc },
1883 { WM_MDIACTIVATE, sent|defwinproc },
1885 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1886 { WM_NCCALCSIZE, sent|wparam, 1 },
1887 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1888 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1891 /* WM_MDICREATE MDI child window, initially visible and maximized */
1892 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
1893 { WM_MDICREATE, sent },
1894 { HCBT_CREATEWND, hook },
1895 { WM_NCCREATE, sent },
1896 { WM_NCCALCSIZE, sent|wparam, 0 },
1897 { WM_CREATE, sent },
1898 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1899 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1901 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1902 { WM_GETMINMAXINFO, sent },
1903 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1904 { WM_NCCALCSIZE, sent|wparam, 1 },
1905 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
1906 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1909 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1910 { WM_NCCALCSIZE, sent|wparam, 1 },
1911 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1912 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1913 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1915 /* Win2k sends wparam set to
1916 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
1917 * while Win9x doesn't bother to set child window id according to
1918 * CLIENTCREATESTRUCT.idFirstChild
1920 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
1921 { WM_SHOWWINDOW, sent|wparam, 1 },
1922 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1924 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1926 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1927 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
1928 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1930 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
1931 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1933 /* Win9x: message sequence terminates here. */
1935 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
1936 { WM_SETFOCUS, sent|optional }, /* in MDI client */
1937 { HCBT_SETFOCUS, hook }, /* in MDI client */
1938 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
1939 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1940 { WM_SETFOCUS, sent|optional }, /* in MDI client */
1941 { HCBT_SETFOCUS, hook|optional },
1942 { WM_KILLFOCUS, sent }, /* in MDI client */
1943 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
1944 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
1945 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1946 { WM_SETFOCUS, sent|defwinproc },
1948 { WM_MDIACTIVATE, sent|defwinproc },
1951 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1952 { WM_NCCALCSIZE, sent|wparam, 1 },
1953 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1954 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1957 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1958 { WM_NCCALCSIZE, sent|wparam, 1 },
1959 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1960 { WM_MOVE, sent|defwinproc },
1961 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1964 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1965 { WM_NCCALCSIZE, sent|wparam, 1 },
1966 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
1967 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1970 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1971 { WM_NCCALCSIZE, sent|wparam, 1 },
1972 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
1973 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1975 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
1976 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
1977 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
1978 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
1979 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
1983 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
1984 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
1985 { HCBT_CREATEWND, hook },
1986 { WM_GETMINMAXINFO, sent },
1987 { WM_NCCREATE, sent },
1988 { WM_NCCALCSIZE, sent|wparam, 0 },
1989 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1990 { WM_CREATE, sent },
1991 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1992 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1994 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1995 { WM_GETMINMAXINFO, sent },
1996 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|0x8000 },
1997 { WM_GETMINMAXINFO, sent|defwinproc },
1998 { WM_NCCALCSIZE, sent|wparam, 1 },
1999 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|0x8000 },
2000 { WM_MOVE, sent|defwinproc },
2001 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2003 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2004 { WM_NCCALCSIZE, sent|wparam, 1 },
2005 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2006 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2007 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2008 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2009 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2010 /* Win2k sends wparam set to
2011 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2012 * while Win9x doesn't bother to set child window id according to
2013 * CLIENTCREATESTRUCT.idFirstChild
2015 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2018 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2019 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2020 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2021 { HCBT_SYSCOMMAND, hook },
2022 { WM_CLOSE, sent|defwinproc },
2023 { WM_MDIDESTROY, sent }, /* in MDI client */
2025 /* bring the 1st MDI child to top */
2026 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2027 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2029 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2031 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2032 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2033 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2035 /* maximize the 1st MDI child */
2036 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2037 { WM_GETMINMAXINFO, sent|defwinproc },
2038 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|0x8000 },
2039 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2040 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2041 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2042 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2044 /* restore the 2nd MDI child */
2045 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2046 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2047 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2048 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2050 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2052 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2053 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2055 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2057 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2059 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2060 { WM_NCCALCSIZE, sent|wparam, 1 },
2061 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2062 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2063 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2065 /* bring the 1st MDI child to top */
2066 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2067 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2068 { HCBT_SETFOCUS, hook },
2069 { WM_KILLFOCUS, sent|defwinproc },
2070 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2071 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2072 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2073 { WM_SETFOCUS, sent }, /* in MDI client */
2074 { HCBT_SETFOCUS, hook },
2075 { WM_KILLFOCUS, sent }, /* in MDI client */
2076 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2077 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2078 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2079 { WM_SETFOCUS, sent|defwinproc },
2080 { WM_MDIACTIVATE, sent|defwinproc },
2081 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2083 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2084 { WM_SHOWWINDOW, sent|wparam, 1 },
2085 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2086 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2087 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2088 { WM_MDIREFRESHMENU, sent },
2090 { HCBT_DESTROYWND, hook },
2091 /* Win2k sends wparam set to
2092 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2093 * while Win9x doesn't bother to set child window id according to
2094 * CLIENTCREATESTRUCT.idFirstChild
2096 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2097 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2098 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2099 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2100 { WM_ERASEBKGND, sent|parent|optional },
2101 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2103 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2104 { WM_DESTROY, sent|defwinproc },
2105 { WM_NCDESTROY, sent|defwinproc },
2108 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2109 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2110 { WM_MDIDESTROY, sent }, /* in MDI client */
2111 { WM_SHOWWINDOW, sent|wparam, 0 },
2112 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2113 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2114 { WM_ERASEBKGND, sent|parent|optional },
2115 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2117 { HCBT_SETFOCUS, hook },
2118 { WM_KILLFOCUS, sent },
2119 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2120 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2121 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2122 { WM_SETFOCUS, sent }, /* in MDI client */
2123 { HCBT_SETFOCUS, hook },
2124 { WM_KILLFOCUS, sent }, /* in MDI client */
2125 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2126 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2127 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2128 { WM_SETFOCUS, sent },
2131 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2132 { WM_NCCALCSIZE, sent|wparam, 1 },
2133 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2134 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2137 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2138 { WM_NCCALCSIZE, sent|wparam, 1 },
2139 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2140 { WM_MOVE, sent|defwinproc },
2141 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2144 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2145 { WM_NCCALCSIZE, sent|wparam, 1 },
2146 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2147 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2150 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2151 { WM_NCCALCSIZE, sent|wparam, 1 },
2152 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2153 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2156 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2157 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2158 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2159 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2162 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2163 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2164 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2165 { WM_MOVE, sent|defwinproc },
2166 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2169 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2170 { WM_NCCALCSIZE, sent|wparam, 1 },
2171 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2172 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2175 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2176 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2177 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2178 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2179 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2180 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2182 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2184 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2185 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2186 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2187 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2188 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2191 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2192 { WM_NCCALCSIZE, sent|wparam, 1 },
2193 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2194 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2196 { WM_NCACTIVATE, sent|wparam, 0 },
2197 { WM_MDIACTIVATE, sent },
2199 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2200 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|0x8000 },
2201 { WM_NCCALCSIZE, sent|wparam, 1 },
2203 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2205 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2206 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|0x8000 },
2207 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2210 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2211 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2212 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2213 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2216 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2217 { WM_NCCALCSIZE, sent|wparam, 1 },
2218 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2219 { WM_MOVE, sent|defwinproc },
2220 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2223 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2224 { WM_NCCALCSIZE, sent|wparam, 1 },
2225 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2226 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2227 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2228 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2229 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2230 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2231 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2233 { HCBT_SETFOCUS, hook },
2234 { WM_KILLFOCUS, sent },
2235 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2236 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2237 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2238 { WM_SETFOCUS, sent }, /* in MDI client */
2240 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2242 { HCBT_DESTROYWND, hook },
2243 /* Win2k sends wparam set to
2244 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2245 * while Win9x doesn't bother to set child window id according to
2246 * CLIENTCREATESTRUCT.idFirstChild
2248 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2250 { WM_SHOWWINDOW, sent|wparam, 0 },
2251 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2252 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2253 { WM_ERASEBKGND, sent|parent|optional },
2254 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2256 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2257 { WM_DESTROY, sent },
2258 { WM_NCDESTROY, sent },
2261 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2262 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2263 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2264 { WM_GETMINMAXINFO, sent },
2265 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2266 { WM_NCCALCSIZE, sent|wparam, 1 },
2267 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2268 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2270 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2271 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2272 { HCBT_SETFOCUS, hook },
2273 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2274 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2275 { WM_SETFOCUS, sent }, /* in MDI client */
2276 { HCBT_SETFOCUS, hook },
2277 { WM_KILLFOCUS, sent }, /* in MDI client */
2278 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2279 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2280 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2281 { WM_SETFOCUS, sent|defwinproc },
2282 { WM_MDIACTIVATE, sent|defwinproc },
2283 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2284 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2286 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2287 { WM_NCCALCSIZE, sent|wparam, 1 },
2288 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2289 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2290 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2293 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2294 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2295 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2296 { WM_GETMINMAXINFO, sent },
2297 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2298 { WM_GETMINMAXINFO, sent|defwinproc },
2299 { WM_NCCALCSIZE, sent|wparam, 1 },
2300 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2301 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2303 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2304 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2305 { HCBT_SETFOCUS, hook },
2306 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2307 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2308 { WM_SETFOCUS, sent }, /* in MDI client */
2309 { HCBT_SETFOCUS, hook },
2310 { WM_KILLFOCUS, sent }, /* in MDI client */
2311 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2312 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2313 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2314 { WM_SETFOCUS, sent|defwinproc },
2315 { WM_MDIACTIVATE, sent|defwinproc },
2316 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2317 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2320 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2321 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2322 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2323 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2324 { WM_GETMINMAXINFO, sent },
2325 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2326 { WM_GETMINMAXINFO, sent|defwinproc },
2327 { WM_NCCALCSIZE, sent|wparam, 1 },
2328 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2329 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2330 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|0x8000 },
2331 { WM_MOVE, sent|defwinproc },
2332 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2334 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2335 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2336 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2337 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2338 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2339 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2341 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2342 { WM_NCCALCSIZE, sent|wparam, 1 },
2343 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2344 { WM_MOVE, sent|defwinproc },
2345 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2346 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
2348 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2349 { WM_NCCALCSIZE, sent|wparam, 1 },
2350 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2351 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2353 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2354 { WM_GETMINMAXINFO, sent|defwinproc },
2355 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2356 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2357 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2358 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
2359 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2360 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2361 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2362 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2364 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2365 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2366 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
2367 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2370 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
2371 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
2372 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2373 { WM_GETMINMAXINFO, sent },
2374 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2375 { WM_NCCALCSIZE, sent|wparam, 1 },
2376 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2377 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2378 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2380 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2381 { WM_NCCALCSIZE, sent|wparam, 1 },
2382 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2383 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2384 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2387 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
2388 static const struct message WmRestoreMDIchildVisibleSeq[] = {
2389 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2390 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
2391 { WM_NCCALCSIZE, sent|wparam, 1 },
2392 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2393 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2394 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2396 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2397 { WM_NCCALCSIZE, sent|wparam, 1 },
2398 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2399 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2400 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2403 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
2404 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
2405 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2406 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
2407 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
2408 { WM_NCCALCSIZE, sent|wparam, 1 },
2409 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2410 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|0x8000 },
2411 { WM_MOVE, sent|defwinproc },
2412 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2413 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2414 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2415 { HCBT_SETFOCUS, hook },
2416 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2417 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2418 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2419 { WM_SETFOCUS, sent },
2422 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
2423 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
2424 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
2425 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|0x8000 },
2426 { WM_NCCALCSIZE, sent|wparam, 1 },
2427 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|0x8000 },
2428 { WM_MOVE, sent|defwinproc },
2429 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
2430 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
2431 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2432 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2433 /* FIXME: Wine creates an icon/title window while Windows doesn't */
2434 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
2437 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
2438 static const struct message WmRestoreMDIchildInisibleSeq[] = {
2439 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
2440 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|0x8000 },
2441 { WM_NCCALCSIZE, sent|wparam, 1 },
2442 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2443 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2444 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|0x8000 },
2445 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2447 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2448 { WM_NCCALCSIZE, sent|wparam, 1 },
2449 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2450 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2451 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2455 static HWND mdi_client;
2456 static WNDPROC old_mdi_client_proc;
2458 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2462 /* do not log painting messages */
2463 if (message != WM_PAINT &&
2464 message != WM_NCPAINT &&
2465 message != WM_SYNCPAINT &&
2466 message != WM_ERASEBKGND &&
2467 message != WM_NCPAINT &&
2468 message != WM_NCHITTEST &&
2469 message != WM_GETTEXT &&
2470 message != WM_MDIGETACTIVE &&
2471 message != WM_GETICON &&
2472 message != WM_DEVICECHANGE)
2474 trace("mdi client: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2478 case WM_WINDOWPOSCHANGING:
2479 case WM_WINDOWPOSCHANGED:
2481 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2483 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2484 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2485 winpos->hwnd, winpos->hwndInsertAfter,
2486 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2487 dump_winpos_flags(winpos->flags);
2489 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2490 * in the high word for internal purposes
2492 wParam = winpos->flags & 0xffff;
2493 /* We are not interested in the flags that don't match under XP and Win9x */
2494 wParam &= ~(SWP_NOZORDER);
2499 msg.message = message;
2500 msg.flags = sent|wparam|lparam;
2501 msg.wParam = wParam;
2502 msg.lParam = lParam;
2506 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
2509 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2511 static long defwndproc_counter = 0;
2515 /* do not log painting messages */
2516 if (message != WM_PAINT &&
2517 message != WM_NCPAINT &&
2518 message != WM_SYNCPAINT &&
2519 message != WM_ERASEBKGND &&
2520 message != WM_NCPAINT &&
2521 message != WM_NCHITTEST &&
2522 message != WM_GETTEXT &&
2523 message != WM_GETICON &&
2524 message != WM_DEVICECHANGE)
2526 trace("mdi child: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2530 case WM_WINDOWPOSCHANGING:
2531 case WM_WINDOWPOSCHANGED:
2533 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2535 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2536 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2537 winpos->hwnd, winpos->hwndInsertAfter,
2538 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2539 dump_winpos_flags(winpos->flags);
2541 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2542 * in the high word for internal purposes
2544 wParam = winpos->flags & 0xffff;
2545 /* We are not interested in the flags that don't match under XP and Win9x */
2546 wParam &= ~(SWP_NOZORDER);
2550 case WM_MDIACTIVATE:
2552 HWND active, client = GetParent(hwnd);
2554 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
2556 if (hwnd == (HWND)lParam) /* if we are being activated */
2557 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
2559 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
2564 msg.message = message;
2565 msg.flags = sent|wparam|lparam;
2566 if (defwndproc_counter) msg.flags |= defwinproc;
2567 msg.wParam = wParam;
2568 msg.lParam = lParam;
2572 defwndproc_counter++;
2573 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
2574 defwndproc_counter--;
2579 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
2581 static long defwndproc_counter = 0;
2585 /* do not log painting messages */
2586 if (message != WM_PAINT &&
2587 message != WM_NCPAINT &&
2588 message != WM_SYNCPAINT &&
2589 message != WM_ERASEBKGND &&
2590 message != WM_NCPAINT &&
2591 message != WM_NCHITTEST &&
2592 message != WM_GETTEXT &&
2593 message != WM_GETICON &&
2594 message != WM_DEVICECHANGE)
2596 trace("mdi frame: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
2600 case WM_WINDOWPOSCHANGING:
2601 case WM_WINDOWPOSCHANGED:
2603 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
2605 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
2606 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2607 winpos->hwnd, winpos->hwndInsertAfter,
2608 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
2609 dump_winpos_flags(winpos->flags);
2611 /* Log only documented flags, win2k uses 0x1000 and 0x2000
2612 * in the high word for internal purposes
2614 wParam = winpos->flags & 0xffff;
2615 /* We are not interested in the flags that don't match under XP and Win9x */
2616 wParam &= ~(SWP_NOZORDER);
2621 msg.message = message;
2622 msg.flags = sent|wparam|lparam;
2623 if (defwndproc_counter) msg.flags |= defwinproc;
2624 msg.wParam = wParam;
2625 msg.lParam = lParam;
2629 defwndproc_counter++;
2630 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
2631 defwndproc_counter--;
2636 static BOOL mdi_RegisterWindowClasses(void)
2641 cls.lpfnWndProc = mdi_frame_wnd_proc;
2644 cls.hInstance = GetModuleHandleA(0);
2646 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
2647 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
2648 cls.lpszMenuName = NULL;
2649 cls.lpszClassName = "MDI_frame_class";
2650 if (!RegisterClassA(&cls)) return FALSE;
2652 cls.lpfnWndProc = mdi_child_wnd_proc;
2653 cls.lpszClassName = "MDI_child_class";
2654 if (!RegisterClassA(&cls)) return FALSE;
2656 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
2657 old_mdi_client_proc = cls.lpfnWndProc;
2658 cls.hInstance = GetModuleHandleA(0);
2659 cls.lpfnWndProc = mdi_client_hook_proc;
2660 cls.lpszClassName = "MDI_client_class";
2661 if (!RegisterClassA(&cls)) assert(0);
2666 static void test_mdi_messages(void)
2668 MDICREATESTRUCTA mdi_cs;
2669 CLIENTCREATESTRUCT client_cs;
2670 HWND mdi_frame, mdi_child, mdi_child2, active_child;
2672 HMENU hMenu = CreateMenu();
2674 assert(mdi_RegisterWindowClasses());
2678 trace("creating MDI frame window\n");
2679 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
2680 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
2681 WS_MAXIMIZEBOX | WS_VISIBLE,
2682 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
2683 GetDesktopWindow(), hMenu,
2684 GetModuleHandleA(0), NULL);
2686 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
2688 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2689 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
2691 trace("creating MDI client window\n");
2692 client_cs.hWindowMenu = 0;
2693 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
2694 mdi_client = CreateWindowExA(0, "MDI_client_class",
2696 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
2698 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
2700 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
2702 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2703 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
2705 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2706 ok(!active_child, "wrong active MDI child %p\n", active_child);
2707 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2712 trace("creating invisible MDI child window\n");
2713 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2715 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2716 mdi_client, 0, GetModuleHandleA(0), NULL);
2720 ShowWindow(mdi_child, SW_SHOWNORMAL);
2721 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
2723 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2724 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2726 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2727 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2729 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2730 ok(!active_child, "wrong active MDI child %p\n", active_child);
2731 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2733 ShowWindow(mdi_child, SW_HIDE);
2734 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
2737 ShowWindow(mdi_child, SW_SHOW);
2738 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
2740 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2741 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2743 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2744 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2746 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2747 ok(!active_child, "wrong active MDI child %p\n", active_child);
2748 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2750 DestroyWindow(mdi_child);
2753 trace("creating visible MDI child window\n");
2754 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2755 WS_CHILD | WS_VISIBLE,
2756 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2757 mdi_client, 0, GetModuleHandleA(0), NULL);
2759 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
2761 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2762 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
2764 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2765 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2767 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2768 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2769 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2772 DestroyWindow(mdi_child);
2773 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2775 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2776 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2778 /* Win2k: MDI client still returns a just destroyed child as active
2779 * Win9x: MDI client returns 0
2781 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2782 ok(active_child == mdi_child || /* win2k */
2783 !active_child, /* win9x */
2784 "wrong active MDI child %p\n", active_child);
2785 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2789 trace("creating invisible MDI child window\n");
2790 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2792 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2793 mdi_client, 0, GetModuleHandleA(0), NULL);
2795 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
2797 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
2798 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
2800 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2801 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2803 /* Win2k: MDI client still returns a just destroyed child as active
2804 * Win9x: MDI client returns mdi_child2
2806 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2807 ok(active_child == mdi_child || /* win2k */
2808 active_child == mdi_child2, /* win9x */
2809 "wrong active MDI child %p\n", active_child);
2810 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2813 ShowWindow(mdi_child2, SW_MAXIMIZE);
2814 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
2816 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2817 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2819 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2820 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2821 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2824 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2825 ok(GetFocus() == mdi_child2 || /* win2k */
2826 GetFocus() == 0, /* win9x */
2827 "wrong focus window %p\n", GetFocus());
2832 ShowWindow(mdi_child2, SW_HIDE);
2833 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2835 ShowWindow(mdi_child2, SW_RESTORE);
2836 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
2839 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
2840 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
2842 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2843 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2844 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2850 ShowWindow(mdi_child2, SW_HIDE);
2851 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2853 ShowWindow(mdi_child2, SW_SHOW);
2854 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
2856 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2857 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2859 ShowWindow(mdi_child2, SW_MAXIMIZE);
2860 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
2862 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2863 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2865 ShowWindow(mdi_child2, SW_RESTORE);
2866 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
2868 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2869 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2871 ShowWindow(mdi_child2, SW_MINIMIZE);
2872 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
2874 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2875 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2877 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2878 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2879 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2882 ShowWindow(mdi_child2, SW_RESTORE);
2883 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
2885 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2886 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2888 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2889 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2890 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
2896 ShowWindow(mdi_child2, SW_HIDE);
2897 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
2899 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2900 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2902 DestroyWindow(mdi_child2);
2903 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
2905 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2906 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2908 /* test for maximized MDI children */
2909 trace("creating maximized visible MDI child window 1\n");
2910 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2911 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2912 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2913 mdi_client, 0, GetModuleHandleA(0), NULL);
2915 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
2916 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2918 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2919 ok(GetFocus() == mdi_child || /* win2k */
2920 GetFocus() == 0, /* win9x */
2921 "wrong focus window %p\n", GetFocus());
2923 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2924 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2925 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2928 trace("creating maximized visible MDI child window 2\n");
2929 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2930 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2931 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2932 mdi_client, 0, GetModuleHandleA(0), NULL);
2934 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2935 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2936 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2938 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2939 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2941 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2942 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2943 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2946 trace("destroying maximized visible MDI child window 2\n");
2947 DestroyWindow(mdi_child2);
2948 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
2950 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2952 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2953 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2955 /* Win2k: MDI client still returns a just destroyed child as active
2956 * Win9x: MDI client returns 0
2958 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2959 ok(active_child == mdi_child2 || /* win2k */
2960 !active_child, /* win9x */
2961 "wrong active MDI child %p\n", active_child);
2964 ShowWindow(mdi_child, SW_MAXIMIZE);
2965 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2968 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2969 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2971 trace("re-creating maximized visible MDI child window 2\n");
2972 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
2973 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
2974 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
2975 mdi_client, 0, GetModuleHandleA(0), NULL);
2977 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
2978 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
2979 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
2981 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2982 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
2984 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2985 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
2986 ok(zoomed, "wrong zoomed state %d\n", zoomed);
2989 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
2990 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
2991 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
2993 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
2994 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
2995 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
2997 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
2998 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
2999 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3002 DestroyWindow(mdi_child);
3003 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3005 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3006 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3008 /* Win2k: MDI client still returns a just destroyed child as active
3009 * Win9x: MDI client returns 0
3011 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3012 ok(active_child == mdi_child || /* win2k */
3013 !active_child, /* win9x */
3014 "wrong active MDI child %p\n", active_child);
3017 trace("creating maximized invisible MDI child window\n");
3018 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3019 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3020 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3021 mdi_client, 0, GetModuleHandleA(0), NULL);
3023 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", TRUE);
3024 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3025 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3026 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3028 /* Win2k: MDI client still returns a just destroyed child as active
3029 * Win9x: MDI client returns 0
3031 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3032 ok(active_child == mdi_child || /* win2k */
3033 !active_child, /* win9x */
3034 "wrong active MDI child %p\n", active_child);
3037 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3038 ShowWindow(mdi_child2, SW_MAXIMIZE);
3039 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3040 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3041 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3042 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3044 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3045 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3046 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3049 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3052 /* end of test for maximized MDI children */
3054 mdi_cs.szClass = "MDI_child_Class";
3055 mdi_cs.szTitle = "MDI child";
3056 mdi_cs.hOwner = GetModuleHandleA(0);
3059 mdi_cs.cx = CW_USEDEFAULT;
3060 mdi_cs.cy = CW_USEDEFAULT;
3061 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3063 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3064 ok(mdi_child != 0, "MDI child creation failed\n");
3065 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3067 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3069 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3070 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3072 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3073 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3074 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3076 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3077 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3078 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3081 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3082 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3084 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3085 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3086 ok(!active_child, "wrong active MDI child %p\n", active_child);
3091 DestroyWindow(mdi_client);
3092 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3094 /* test maximization of MDI child with invisible parent */
3095 client_cs.hWindowMenu = 0;
3096 mdi_client = CreateWindow("MDI_client_class",
3098 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3100 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3101 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3103 ShowWindow(mdi_client, SW_HIDE);
3104 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3106 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3107 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3109 mdi_client, 0, GetModuleHandleA(0), NULL);
3110 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3112 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3113 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3114 zoomed = IsZoomed(mdi_child);
3115 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3117 ShowWindow(mdi_client, SW_SHOW);
3118 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3120 DestroyWindow(mdi_child);
3121 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3123 DestroyWindow(mdi_client);
3124 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3125 /* end of test for maximization of MDI child with invisible parent */
3127 DestroyWindow(mdi_frame);
3128 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3130 /************************* End of MDI test **********************************/
3132 static void test_WM_SETREDRAW(HWND hwnd)
3134 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3138 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3139 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3141 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3142 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3145 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3146 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3148 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3149 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3151 /* restore original WS_VISIBLE state */
3152 SetWindowLongA(hwnd, GWL_STYLE, style);
3157 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3161 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
3163 /* explicitly ignore WM_GETICON message */
3164 if (message == WM_GETICON) return 0;
3171 case WM_DEVICECHANGE:
3176 case WM_WINDOWPOSCHANGING:
3177 case WM_WINDOWPOSCHANGED:
3179 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
3181 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
3182 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
3183 winpos->hwnd, winpos->hwndInsertAfter,
3184 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
3185 dump_winpos_flags(winpos->flags);
3187 /* Log only documented flags, win2k uses 0x1000 and 0x2000
3188 * in the high word for internal purposes
3190 wParam = winpos->flags & 0xffff;
3191 /* We are not interested in the flags that don't match under XP and Win9x */
3192 wParam &= ~(SWP_NOZORDER);
3197 msg.message = message;
3198 msg.flags = sent|wparam|lparam;
3199 msg.wParam = wParam;
3200 msg.lParam = lParam;
3203 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3204 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3208 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3210 DWORD style, exstyle;
3214 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3215 style = GetWindowLongA(hwnd, GWL_STYLE);
3216 /* do not be confused by WS_DLGFRAME set */
3217 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3219 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3220 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3222 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3223 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3224 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3225 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3227 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3229 style = GetWindowLongA(hwnd, GWL_STYLE);
3230 if (set) ok(style & set, "style %08x should be set\n", set);
3231 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3233 /* a subsequent call should do nothing */
3234 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3235 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3236 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3240 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3241 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3242 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3243 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3244 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3245 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3248 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3250 DWORD style, exstyle;
3254 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3255 style = GetWindowLongA(hwnd, GWL_STYLE);
3256 /* do not be confused by WS_DLGFRAME set */
3257 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3259 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3260 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3262 si.cbSize = sizeof(si);
3263 si.fMask = SIF_RANGE;
3266 SetScrollInfo(hwnd, ctl, &si, TRUE);
3267 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3268 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3270 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3272 style = GetWindowLongA(hwnd, GWL_STYLE);
3273 if (set) ok(style & set, "style %08x should be set\n", set);
3274 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3276 /* a subsequent call should do nothing */
3277 SetScrollInfo(hwnd, ctl, &si, TRUE);
3278 if (style & WS_HSCROLL)
3279 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3280 else if (style & WS_VSCROLL)
3281 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3283 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3285 si.fMask = SIF_PAGE;
3287 SetScrollInfo(hwnd, ctl, &si, FALSE);
3288 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3292 SetScrollInfo(hwnd, ctl, &si, FALSE);
3293 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3295 si.fMask = SIF_RANGE;
3296 si.nMin = 0xdeadbeef;
3297 si.nMax = 0xdeadbeef;
3298 ret = GetScrollInfo(hwnd, ctl, &si);
3299 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3300 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3301 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3302 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3305 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3306 static void test_scroll_messages(HWND hwnd)
3314 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3315 ok( ret, "GetScrollRange error %d\n", GetLastError());
3316 if (sequence->message != WmGetScrollRangeSeq[0].message)
3317 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3318 /* values of min and max are undefined */
3321 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3322 ok( ret, "SetScrollRange error %d\n", GetLastError());
3323 if (sequence->message != WmSetScrollRangeSeq[0].message)
3324 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3329 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3330 ok( ret, "GetScrollRange error %d\n", GetLastError());
3331 if (sequence->message != WmGetScrollRangeSeq[0].message)
3332 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3333 /* values of min and max are undefined */
3336 si.cbSize = sizeof(si);
3337 si.fMask = SIF_RANGE;
3340 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3341 if (sequence->message != WmSetScrollRangeSeq[0].message)
3342 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3345 si.fMask = SIF_PAGE;
3347 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3348 if (sequence->message != WmSetScrollRangeSeq[0].message)
3349 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3354 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3355 if (sequence->message != WmSetScrollRangeSeq[0].message)
3356 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3359 si.fMask = SIF_RANGE;
3360 si.nMin = 0xdeadbeef;
3361 si.nMax = 0xdeadbeef;
3362 ret = GetScrollInfo(hwnd, SB_CTL, &si);
3363 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3364 if (sequence->message != WmGetScrollInfoSeq[0].message)
3365 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3366 /* values of min and max are undefined */
3369 /* set WS_HSCROLL */
3370 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3371 /* clear WS_HSCROLL */
3372 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3374 /* set WS_HSCROLL */
3375 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
3376 /* clear WS_HSCROLL */
3377 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
3379 /* set WS_VSCROLL */
3380 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3381 /* clear WS_VSCROLL */
3382 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3384 /* set WS_VSCROLL */
3385 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
3386 /* clear WS_VSCROLL */
3387 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
3390 static void test_showwindow(void)
3395 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3396 100, 100, 200, 200, 0, 0, 0, NULL);
3397 ok (hwnd != 0, "Failed to create overlapped window\n");
3398 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3399 0, 0, 10, 10, hwnd, 0, 0, NULL);
3400 ok (hchild != 0, "Failed to create child\n");
3403 /* ShowWindow( SW_SHOWNA) for invisible top level window */
3404 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
3405 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3406 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
3409 /* ShowWindow( SW_SHOWNA) for now visible top level window */
3410 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
3411 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3412 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
3414 /* back to invisible */
3415 ShowWindow(hchild, SW_HIDE);
3416 ShowWindow(hwnd, SW_HIDE);
3418 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
3419 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
3420 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3421 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
3423 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
3424 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
3426 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
3427 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3428 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
3430 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
3431 ShowWindow( hwnd, SW_SHOW);
3433 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
3434 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
3435 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
3438 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
3439 ShowWindow( hchild, SW_HIDE);
3441 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
3442 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
3443 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
3447 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
3448 DestroyWindow(hchild);
3449 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
3451 DestroyWindow(hwnd);
3456 * 1. Create invisible maximized popup window.
3457 * 2. Move and resize it.
3458 * 3. Show it maximized.
3460 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3461 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3462 100, 100, 200, 200, 0, 0, 0, NULL);
3463 ok (hwnd != 0, "Failed to create popup window\n");
3464 ok(IsZoomed(hwnd), "window should be maximized\n");
3465 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3468 GetWindowRect(hwnd, &rc);
3469 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3470 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3471 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
3472 rc.left, rc.top, rc.right, rc.bottom);
3473 /* Reset window's size & position */
3474 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
3475 ok(IsZoomed(hwnd), "window should be maximized\n");
3478 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3479 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3480 ok(IsZoomed(hwnd), "window should be maximized\n");
3481 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
3484 GetWindowRect(hwnd, &rc);
3485 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
3486 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
3487 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
3488 rc.left, rc.top, rc.right, rc.bottom);
3489 DestroyWindow(hwnd);
3493 * 1. Create invisible maximized popup window.
3494 * 2. Show it maximized.
3496 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
3497 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
3498 100, 100, 200, 200, 0, 0, 0, NULL);
3499 ok (hwnd != 0, "Failed to create popup window\n");
3500 ok(IsZoomed(hwnd), "window should be maximized\n");
3501 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3504 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
3505 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3506 ok(IsZoomed(hwnd), "window should be maximized\n");
3507 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
3509 DestroyWindow(hwnd);
3513 * 1. Create visible maximized popup window.
3515 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
3516 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
3517 100, 100, 200, 200, 0, 0, 0, NULL);
3518 ok (hwnd != 0, "Failed to create popup window\n");
3519 ok(IsZoomed(hwnd), "window should be maximized\n");
3520 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
3522 DestroyWindow(hwnd);
3526 * 1. Create visible popup window.
3529 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
3530 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
3531 100, 100, 200, 200, 0, 0, 0, NULL);
3532 ok (hwnd != 0, "Failed to create popup window\n");
3533 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
3534 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", TRUE);
3537 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
3538 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3539 ok(IsZoomed(hwnd), "window should be maximized\n");
3540 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
3542 DestroyWindow(hwnd);
3546 static void test_sys_menu(void)
3552 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3553 100, 100, 200, 200, 0, 0, 0, NULL);
3554 ok (hwnd != 0, "Failed to create overlapped window\n");
3558 /* test existing window without CS_NOCLOSE style */
3559 hmenu = GetSystemMenu(hwnd, FALSE);
3560 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3562 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3563 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3564 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3566 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
3567 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3569 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3570 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3571 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
3573 EnableMenuItem(hmenu, SC_CLOSE, 0);
3574 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
3576 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3577 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3578 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
3580 /* test whether removing WS_SYSMENU destroys a system menu */
3581 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
3582 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3584 hmenu = GetSystemMenu(hwnd, FALSE);
3585 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3587 DestroyWindow(hwnd);
3589 /* test new window with CS_NOCLOSE style */
3590 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3591 100, 100, 200, 200, 0, 0, 0, NULL);
3592 ok (hwnd != 0, "Failed to create overlapped window\n");
3594 hmenu = GetSystemMenu(hwnd, FALSE);
3595 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
3597 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
3598 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
3600 DestroyWindow(hwnd);
3602 /* test new window without WS_SYSMENU style */
3603 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
3604 100, 100, 200, 200, 0, 0, 0, NULL);
3605 ok(hwnd != 0, "Failed to create overlapped window\n");
3607 hmenu = GetSystemMenu(hwnd, FALSE);
3608 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
3610 DestroyWindow(hwnd);
3613 /* For shown WS_OVERLAPPEDWINDOW */
3614 static const struct message WmSetIcon_1[] = {
3615 { WM_SETICON, sent },
3616 { 0x00AE, sent|defwinproc|optional }, /* XP */
3617 { WM_GETTEXT, sent|defwinproc|optional },
3618 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
3622 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
3623 static const struct message WmSetIcon_2[] = {
3624 { WM_SETICON, sent },
3628 static void test_MsgWaitForMultipleObjects(HWND hwnd)
3633 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3634 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
3636 PostMessageA(hwnd, WM_USER, 0, 0);
3638 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3639 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
3641 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3642 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3644 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3645 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
3647 PostMessageA(hwnd, WM_USER, 0, 0);
3649 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3650 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
3652 ok(PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
3653 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3655 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
3656 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3657 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
3659 PostMessageA(hwnd, WM_USER, 0, 0);
3661 /* new incoming message causes it to become signaled again */
3662 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
3663 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
3665 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3666 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3667 ok(PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
3668 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
3671 /* test if we receive the right sequence of messages */
3672 static void test_messages(void)
3674 HWND hwnd, hparent, hchild;
3675 HWND hchild2, hbutton;
3681 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3682 100, 100, 200, 200, 0, 0, 0, NULL);
3683 ok (hwnd != 0, "Failed to create overlapped window\n");
3684 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3686 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
3687 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
3688 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
3690 /* test WM_SETREDRAW on a not visible top level window */
3691 test_WM_SETREDRAW(hwnd);
3693 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3694 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
3695 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
3697 ok(GetActiveWindow() == hwnd, "window should be active\n");
3698 ok(GetFocus() == hwnd, "window should have input focus\n");
3699 ShowWindow(hwnd, SW_HIDE);
3700 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", TRUE);
3702 ShowWindow(hwnd, SW_SHOW);
3703 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
3705 ShowWindow(hwnd, SW_HIDE);
3706 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
3708 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
3709 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
3711 ShowWindow(hwnd, SW_RESTORE);
3712 /* FIXME: add ok_sequence() here */
3715 ShowWindow(hwnd, SW_SHOW);
3716 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
3718 ok(GetActiveWindow() == hwnd, "window should be active\n");
3719 ok(GetFocus() == hwnd, "window should have input focus\n");
3720 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3721 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
3722 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
3723 ok(GetActiveWindow() == hwnd, "window should still be active\n");
3725 /* test WM_SETREDRAW on a visible top level window */
3726 ShowWindow(hwnd, SW_SHOW);
3727 test_WM_SETREDRAW(hwnd);
3729 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
3730 test_scroll_messages(hwnd);
3732 /* test resizing and moving */
3733 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
3734 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
3735 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
3736 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
3738 /* popups don't get WM_GETMINMAXINFO */
3739 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
3740 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
3742 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
3743 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
3745 DestroyWindow(hwnd);
3746 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
3748 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3749 100, 100, 200, 200, 0, 0, 0, NULL);
3750 ok (hparent != 0, "Failed to create parent window\n");
3753 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
3754 0, 0, 10, 10, hparent, 0, 0, NULL);
3755 ok (hchild != 0, "Failed to create child window\n");
3756 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
3757 DestroyWindow(hchild);
3760 /* visible child window with a caption */
3761 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
3762 WS_CHILD | WS_VISIBLE | WS_CAPTION,
3763 0, 0, 10, 10, hparent, 0, 0, NULL);
3764 ok (hchild != 0, "Failed to create child window\n");
3765 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
3767 trace("testing scroll APIs on a visible child window %p\n", hchild);
3768 test_scroll_messages(hchild);
3770 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3771 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
3773 DestroyWindow(hchild);
3776 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
3777 0, 0, 10, 10, hparent, 0, 0, NULL);
3778 ok (hchild != 0, "Failed to create child window\n");
3779 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
3781 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
3782 100, 100, 50, 50, hparent, 0, 0, NULL);
3783 ok (hchild2 != 0, "Failed to create child2 window\n");
3786 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
3787 0, 100, 50, 50, hchild, 0, 0, NULL);
3788 ok (hbutton != 0, "Failed to create button window\n");
3790 /* test WM_SETREDRAW on a not visible child window */
3791 test_WM_SETREDRAW(hchild);
3793 ShowWindow(hchild, SW_SHOW);
3794 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3796 ShowWindow(hchild, SW_HIDE);
3797 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
3799 ShowWindow(hchild, SW_SHOW);
3800 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
3802 /* test WM_SETREDRAW on a visible child window */
3803 test_WM_SETREDRAW(hchild);
3805 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
3806 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
3808 ShowWindow(hchild, SW_HIDE);
3810 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3811 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
3813 ShowWindow(hchild, SW_HIDE);
3815 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
3816 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
3818 /* DestroyWindow sequence below expects that a child has focus */
3822 DestroyWindow(hchild);
3823 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
3824 DestroyWindow(hchild2);
3825 DestroyWindow(hbutton);
3828 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
3829 0, 0, 100, 100, hparent, 0, 0, NULL);
3830 ok (hchild != 0, "Failed to create child popup window\n");
3831 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
3832 DestroyWindow(hchild);
3834 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
3836 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
3837 0, 0, 100, 100, hparent, 0, 0, NULL);
3838 ok (hchild != 0, "Failed to create popup window\n");
3839 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3840 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3841 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3843 ShowWindow(hchild, SW_SHOW);
3844 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3846 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3847 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3849 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
3850 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
3851 DestroyWindow(hchild);
3853 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
3854 * changes nothing in message sequences.
3857 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
3858 0, 0, 100, 100, hparent, 0, 0, NULL);
3859 ok (hchild != 0, "Failed to create popup window\n");
3860 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
3861 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3862 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
3864 ShowWindow(hchild, SW_SHOW);
3865 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
3867 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
3868 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
3869 DestroyWindow(hchild);
3872 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
3873 0, 0, 100, 100, hparent, 0, 0, NULL);
3874 ok(hwnd != 0, "Failed to create custom dialog window\n");
3875 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
3878 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
3879 test_scroll_messages(hwnd);
3885 SendMessage(hwnd, WM_NULL, 0, 0);
3888 after_end_dialog = 1;
3889 EndDialog( hwnd, 0 );
3890 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
3892 DestroyWindow(hwnd);
3893 after_end_dialog = 0;
3896 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
3897 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
3898 ok(hwnd != 0, "Failed to create custom dialog window\n");
3900 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
3901 ShowWindow(hwnd, SW_SHOW);
3902 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
3903 DestroyWindow(hwnd);
3906 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
3907 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
3909 DestroyWindow(hparent);
3912 /* Message sequence for SetMenu */
3913 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
3914 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
3916 hmenu = CreateMenu();
3917 ok (hmenu != 0, "Failed to create menu\n");
3918 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
3919 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
3920 100, 100, 200, 200, 0, hmenu, 0, NULL);
3921 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
3922 ok (SetMenu(hwnd, 0), "SetMenu\n");
3923 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
3924 ok (SetMenu(hwnd, 0), "SetMenu\n");
3925 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
3926 ShowWindow(hwnd, SW_SHOW);
3927 UpdateWindow( hwnd );
3928 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3930 ok (SetMenu(hwnd, 0), "SetMenu\n");
3931 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
3932 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
3933 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
3935 UpdateWindow( hwnd );
3936 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3938 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
3939 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3940 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
3942 DestroyWindow(hwnd);
3945 /* Message sequence for EnableWindow */
3946 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
3947 100, 100, 200, 200, 0, 0, 0, NULL);
3948 ok (hparent != 0, "Failed to create parent window\n");
3949 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
3950 0, 0, 10, 10, hparent, 0, 0, NULL);
3951 ok (hchild != 0, "Failed to create child window\n");
3957 EnableWindow(hparent, FALSE);
3958 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
3960 EnableWindow(hparent, TRUE);
3961 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
3963 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3966 test_MsgWaitForMultipleObjects(hparent);
3968 /* the following test causes an exception in user.exe under win9x */
3969 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
3971 DestroyWindow(hparent);
3975 PostMessageW( hparent, WM_USER+1, 0, 0 );
3976 /* PeekMessage(NULL) fails, but still removes the message */
3977 SetLastError(0xdeadbeef);
3978 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
3979 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
3980 GetLastError() == 0xdeadbeef, /* NT4 */
3981 "last error is %d\n", GetLastError() );
3982 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
3983 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
3985 DestroyWindow(hchild);
3986 DestroyWindow(hparent);
3989 /* Message sequences for WM_SETICON */
3990 trace("testing WM_SETICON\n");
3991 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
3992 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
3994 ShowWindow(hwnd, SW_SHOW);
3996 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
3998 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
3999 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4001 ShowWindow(hwnd, SW_HIDE);
4002 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4004 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4005 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4006 DestroyWindow(hwnd);
4009 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4010 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4012 ShowWindow(hwnd, SW_SHOW);
4014 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4016 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4017 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4019 ShowWindow(hwnd, SW_HIDE);
4020 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4022 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4023 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4024 DestroyWindow(hwnd);
4028 static void invisible_parent_tests(void)
4030 HWND hparent, hchild;
4032 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4033 100, 100, 200, 200, 0, 0, 0, NULL);
4034 ok (hparent != 0, "Failed to create parent window\n");
4037 /* test showing child with hidden parent */
4039 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4040 0, 0, 10, 10, hparent, 0, 0, NULL);
4041 ok (hchild != 0, "Failed to create child window\n");
4042 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4044 ShowWindow( hchild, SW_MINIMIZE );
4045 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4046 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4047 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4052 ShowWindow( hchild, SW_MINIMIZE );
4053 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4055 DestroyWindow(hchild);
4056 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4057 0, 0, 10, 10, hparent, 0, 0, NULL);
4060 ShowWindow( hchild, SW_MAXIMIZE );
4061 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4062 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4063 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4068 ShowWindow( hchild, SW_MAXIMIZE );
4069 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4071 DestroyWindow(hchild);
4072 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4073 0, 0, 10, 10, hparent, 0, 0, NULL);
4076 ShowWindow( hchild, SW_RESTORE );
4077 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4078 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4079 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4081 DestroyWindow(hchild);
4082 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4083 0, 0, 10, 10, hparent, 0, 0, NULL);
4086 ShowWindow( hchild, SW_SHOWMINIMIZED );
4087 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4088 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4089 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4094 ShowWindow( hchild, SW_SHOWMINIMIZED );
4095 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4097 DestroyWindow(hchild);
4098 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4099 0, 0, 10, 10, hparent, 0, 0, NULL);
4102 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4103 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4104 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
4105 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4106 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4108 DestroyWindow(hchild);
4109 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4110 0, 0, 10, 10, hparent, 0, 0, NULL);
4113 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4114 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4115 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4116 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4121 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4122 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4124 DestroyWindow(hchild);
4125 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4126 0, 0, 10, 10, hparent, 0, 0, NULL);
4129 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4130 ShowWindow( hchild, SW_FORCEMINIMIZE );
4131 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4133 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4135 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4137 DestroyWindow(hchild);
4138 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4139 0, 0, 10, 10, hparent, 0, 0, NULL);
4142 ShowWindow( hchild, SW_SHOWNA );
4143 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4144 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4145 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4150 ShowWindow( hchild, SW_SHOWNA );
4151 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4153 DestroyWindow(hchild);
4154 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4155 0, 0, 10, 10, hparent, 0, 0, NULL);
4158 ShowWindow( hchild, SW_SHOW );
4159 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4160 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4161 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4166 ShowWindow( hchild, SW_SHOW );
4167 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4169 ShowWindow( hchild, SW_HIDE );
4170 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4171 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4172 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4174 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4175 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4176 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4177 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4179 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4180 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4181 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4182 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4184 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4186 DestroyWindow(hchild);
4187 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4189 DestroyWindow(hparent);
4193 /****************** button message test *************************/
4194 static const struct message WmSetFocusButtonSeq[] =
4196 { HCBT_SETFOCUS, hook },
4197 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4198 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4199 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4200 { WM_SETFOCUS, sent|wparam, 0 },
4201 { WM_CTLCOLORBTN, sent|defwinproc },
4204 static const struct message WmKillFocusButtonSeq[] =
4206 { HCBT_SETFOCUS, hook },
4207 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4208 { WM_KILLFOCUS, sent|wparam, 0 },
4209 { WM_CTLCOLORBTN, sent|defwinproc },
4210 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4211 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4214 static const struct message WmSetFocusStaticSeq[] =
4216 { HCBT_SETFOCUS, hook },
4217 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
4218 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4219 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4220 { WM_SETFOCUS, sent|wparam, 0 },
4221 { WM_CTLCOLORSTATIC, sent|defwinproc },
4224 static const struct message WmKillFocusStaticSeq[] =
4226 { HCBT_SETFOCUS, hook },
4227 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4228 { WM_KILLFOCUS, sent|wparam, 0 },
4229 { WM_CTLCOLORSTATIC, sent|defwinproc },
4230 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
4231 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
4234 static const struct message WmLButtonDownSeq[] =
4236 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
4237 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
4238 { HCBT_SETFOCUS, hook },
4239 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4240 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4241 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4242 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4243 { WM_CTLCOLORBTN, sent|defwinproc },
4244 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
4245 { WM_CTLCOLORBTN, sent|defwinproc },
4246 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4249 static const struct message WmLButtonUpSeq[] =
4251 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
4252 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
4253 { WM_CTLCOLORBTN, sent|defwinproc },
4254 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
4255 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
4256 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
4259 static const struct message WmSetFontButtonSeq[] =
4261 { WM_SETFONT, sent },
4263 { WM_ERASEBKGND, sent|defwinproc|optional },
4264 { WM_CTLCOLORBTN, sent|defwinproc },
4268 static WNDPROC old_button_proc;
4270 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4272 static long defwndproc_counter = 0;
4276 trace("button: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4278 /* explicitly ignore WM_GETICON message */
4279 if (message == WM_GETICON) return 0;
4281 msg.message = message;
4282 msg.flags = sent|wparam|lparam;
4283 if (defwndproc_counter) msg.flags |= defwinproc;
4284 msg.wParam = wParam;
4285 msg.lParam = lParam;
4288 if (message == BM_SETSTATE)
4289 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
4291 defwndproc_counter++;
4292 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
4293 defwndproc_counter--;
4298 static void subclass_button(void)
4302 if (!GetClassInfoA(0, "button", &cls)) assert(0);
4304 old_button_proc = cls.lpfnWndProc;
4306 cls.hInstance = GetModuleHandle(0);
4307 cls.lpfnWndProc = button_hook_proc;
4308 cls.lpszClassName = "my_button_class";
4309 UnregisterClass(cls.lpszClassName, cls.hInstance);
4310 if (!RegisterClassA(&cls)) assert(0);
4313 static void test_button_messages(void)
4319 const struct message *setfocus;
4320 const struct message *killfocus;
4322 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4323 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4324 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
4325 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4326 { BS_CHECKBOX, DLGC_BUTTON,
4327 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4328 { BS_AUTOCHECKBOX, DLGC_BUTTON,
4329 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4330 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4331 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4332 { BS_3STATE, DLGC_BUTTON,
4333 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4334 { BS_AUTO3STATE, DLGC_BUTTON,
4335 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4336 { BS_GROUPBOX, DLGC_STATIC,
4337 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4338 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
4339 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
4340 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
4341 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
4342 { BS_OWNERDRAW, DLGC_BUTTON,
4343 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
4352 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
4354 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
4355 0, 0, 50, 14, 0, 0, 0, NULL);
4356 ok(hwnd != 0, "Failed to create button window\n");
4358 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4359 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4361 ShowWindow(hwnd, SW_SHOW);
4366 trace("button style %08x\n", button[i].style);
4368 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
4371 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
4373 DestroyWindow(hwnd);
4376 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
4377 0, 0, 50, 14, 0, 0, 0, NULL);
4378 ok(hwnd != 0, "Failed to create button window\n");
4383 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
4384 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
4386 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
4387 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
4390 zfont = (HFONT)GetStockObject(SYSTEM_FONT);
4391 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
4393 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
4395 DestroyWindow(hwnd);
4398 /****************** static message test *************************/
4399 static const struct message WmSetFontStaticSeq[] =
4401 { WM_SETFONT, sent },
4402 { WM_PAINT, sent|defwinproc },
4403 { WM_ERASEBKGND, sent|defwinproc|optional },
4404 { WM_CTLCOLORSTATIC, sent|defwinproc },
4408 static WNDPROC old_static_proc;
4410 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
4412 static long defwndproc_counter = 0;
4416 trace("static: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
4418 /* explicitly ignore WM_GETICON message */
4419 if (message == WM_GETICON) return 0;
4421 msg.message = message;
4422 msg.flags = sent|wparam|lparam;
4423 if (defwndproc_counter) msg.flags |= defwinproc;
4424 msg.wParam = wParam;
4425 msg.lParam = lParam;
4429 defwndproc_counter++;
4430 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
4431 defwndproc_counter--;
4436 static void subclass_static(void)
4440 if (!GetClassInfoA(0, "static", &cls)) assert(0);
4442 old_static_proc = cls.lpfnWndProc;
4444 cls.hInstance = GetModuleHandle(0);
4445 cls.lpfnWndProc = static_hook_proc;
4446 cls.lpszClassName = "my_static_class";
4447 UnregisterClass(cls.lpszClassName, cls.hInstance);
4448 if (!RegisterClassA(&cls)) assert(0);
4451 static void test_static_messages(void)
4453 /* FIXME: make as comprehensive as the button message test */
4458 const struct message *setfont;
4460 { SS_LEFT, DLGC_STATIC,
4461 WmSetFontStaticSeq }
4469 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
4471 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
4472 0, 0, 50, 14, 0, 0, 0, NULL);
4473 ok(hwnd != 0, "Failed to create static window\n");
4475 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
4476 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
4478 ShowWindow(hwnd, SW_SHOW);
4483 trace("static style %08x\n", static_ctrl[i].style);
4484 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
4485 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
4487 DestroyWindow(hwnd);
4491 /************* painting message test ********************/
4493 void dump_region(HRGN hrgn)
4496 RGNDATA *data = NULL;
4501 printf( "null region\n" );
4504 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
4505 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
4506 GetRegionData( hrgn, size, data );
4507 printf("%d rects:", data->rdh.nCount );
4508 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
4509 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
4511 HeapFree( GetProcessHeap(), 0, data );
4514 static void check_update_rgn( HWND hwnd, HRGN hrgn )
4518 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
4519 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
4521 ret = GetUpdateRgn( hwnd, update, FALSE );
4522 ok( ret != ERROR, "GetUpdateRgn failed\n" );
4523 if (ret == NULLREGION)
4525 ok( !hrgn, "Update region shouldn't be empty\n" );
4529 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
4531 ok( 0, "Regions are different\n" );
4532 if (winetest_debug > 0)
4534 printf( "Update region: " );
4535 dump_region( update );
4536 printf( "Wanted region: " );
4537 dump_region( hrgn );
4541 GetRgnBox( update, &r1 );
4542 GetUpdateRect( hwnd, &r2, FALSE );
4543 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
4544 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
4545 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
4547 DeleteObject( tmp );
4548 DeleteObject( update );
4551 static const struct message WmInvalidateRgn[] = {
4552 { WM_NCPAINT, sent },
4553 { WM_GETTEXT, sent|defwinproc|optional },
4557 static const struct message WmGetUpdateRect[] = {
4558 { WM_NCPAINT, sent },
4559 { WM_GETTEXT, sent|defwinproc|optional },
4564 static const struct message WmInvalidateFull[] = {
4565 { WM_NCPAINT, sent|wparam, 1 },
4566 { WM_GETTEXT, sent|defwinproc|optional },
4570 static const struct message WmInvalidateErase[] = {
4571 { WM_NCPAINT, sent|wparam, 1 },
4572 { WM_GETTEXT, sent|defwinproc|optional },
4573 { WM_ERASEBKGND, sent },
4577 static const struct message WmInvalidatePaint[] = {
4579 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
4580 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4584 static const struct message WmInvalidateErasePaint[] = {
4586 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
4587 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4588 { WM_ERASEBKGND, sent|beginpaint },
4592 static const struct message WmInvalidateErasePaint2[] = {
4594 { WM_NCPAINT, sent|beginpaint },
4595 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4596 { WM_ERASEBKGND, sent|beginpaint },
4600 static const struct message WmErase[] = {
4601 { WM_ERASEBKGND, sent },
4605 static const struct message WmPaint[] = {
4610 static const struct message WmParentOnlyPaint[] = {
4611 { WM_PAINT, sent|parent },
4615 static const struct message WmInvalidateParent[] = {
4616 { WM_NCPAINT, sent|parent },
4617 { WM_GETTEXT, sent|defwinproc|parent|optional },
4618 { WM_ERASEBKGND, sent|parent },
4622 static const struct message WmInvalidateParentChild[] = {
4623 { WM_NCPAINT, sent|parent },
4624 { WM_GETTEXT, sent|defwinproc|parent|optional },
4625 { WM_ERASEBKGND, sent|parent },
4626 { WM_NCPAINT, sent },
4627 { WM_GETTEXT, sent|defwinproc|optional },
4628 { WM_ERASEBKGND, sent },
4632 static const struct message WmInvalidateParentChild2[] = {
4633 { WM_ERASEBKGND, sent|parent },
4634 { WM_NCPAINT, sent },
4635 { WM_GETTEXT, sent|defwinproc|optional },
4636 { WM_ERASEBKGND, sent },
4640 static const struct message WmParentPaint[] = {
4641 { WM_PAINT, sent|parent },
4646 static const struct message WmParentPaintNc[] = {
4647 { WM_PAINT, sent|parent },
4649 { WM_NCPAINT, sent|beginpaint },
4650 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4651 { WM_ERASEBKGND, sent|beginpaint },
4655 static const struct message WmChildPaintNc[] = {
4657 { WM_NCPAINT, sent|beginpaint },
4658 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4659 { WM_ERASEBKGND, sent|beginpaint },
4663 static const struct message WmParentErasePaint[] = {
4664 { WM_PAINT, sent|parent },
4665 { WM_NCPAINT, sent|parent|beginpaint },
4666 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4667 { WM_ERASEBKGND, sent|parent|beginpaint },
4669 { WM_NCPAINT, sent|beginpaint },
4670 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4671 { WM_ERASEBKGND, sent|beginpaint },
4675 static const struct message WmParentOnlyNcPaint[] = {
4676 { WM_PAINT, sent|parent },
4677 { WM_NCPAINT, sent|parent|beginpaint },
4678 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
4682 static const struct message WmSetParentStyle[] = {
4683 { WM_STYLECHANGING, sent|parent },
4684 { WM_STYLECHANGED, sent|parent },
4688 static void test_paint_messages(void)
4694 HWND hparent, hchild;
4695 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
4696 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
4697 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4698 100, 100, 200, 200, 0, 0, 0, NULL);
4699 ok (hwnd != 0, "Failed to create overlapped window\n");
4701 ShowWindow( hwnd, SW_SHOW );
4702 UpdateWindow( hwnd );
4706 check_update_rgn( hwnd, 0 );
4707 SetRectRgn( hrgn, 10, 10, 20, 20 );
4708 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4709 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4710 check_update_rgn( hwnd, hrgn );
4711 SetRectRgn( hrgn2, 20, 20, 30, 30 );
4712 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
4713 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4714 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
4715 check_update_rgn( hwnd, hrgn );
4716 /* validate everything */
4717 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4718 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4719 check_update_rgn( hwnd, 0 );
4721 /* test empty region */
4722 SetRectRgn( hrgn, 10, 10, 10, 15 );
4723 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4724 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4725 check_update_rgn( hwnd, 0 );
4726 /* test empty rect */
4727 SetRect( &rect, 10, 10, 10, 15 );
4728 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
4729 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
4730 check_update_rgn( hwnd, 0 );
4732 /* flush pending messages */
4733 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4736 GetClientRect( hwnd, &rect );
4737 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
4738 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
4739 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4741 trace("testing InvalidateRect(0, NULL, FALSE)\n");
4742 SetRectEmpty( &rect );
4743 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
4744 check_update_rgn( hwnd, hrgn );
4745 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4746 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4747 ok_sequence( WmPaint, "Paint", FALSE );
4748 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4749 check_update_rgn( hwnd, 0 );
4751 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
4752 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
4754 trace("testing ValidateRect(0, NULL)\n");
4755 SetRectEmpty( &rect );
4756 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
4757 check_update_rgn( hwnd, hrgn );
4758 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4759 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4760 ok_sequence( WmPaint, "Paint", FALSE );
4761 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
4762 check_update_rgn( hwnd, 0 );
4764 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
4765 SetLastError(0xdeadbeef);
4766 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
4767 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
4768 check_update_rgn( hwnd, 0 );
4769 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4770 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4772 trace("testing ValidateRgn(0, NULL)\n");
4773 SetLastError(0xdeadbeef);
4774 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
4775 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error code %d\n", GetLastError());
4776 check_update_rgn( hwnd, 0 );
4777 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4778 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
4780 /* now with frame */
4781 SetRectRgn( hrgn, -5, -5, 20, 20 );
4783 /* flush pending messages */
4784 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4787 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4788 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4790 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
4791 check_update_rgn( hwnd, hrgn );
4794 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4795 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4798 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
4799 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
4801 GetClientRect( hwnd, &rect );
4802 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
4803 check_update_rgn( hwnd, hrgn );
4806 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
4807 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
4810 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
4811 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
4812 check_update_rgn( hwnd, 0 );
4815 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
4816 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
4817 check_update_rgn( hwnd, 0 );
4820 SetRectRgn( hrgn, 0, 0, 100, 100 );
4821 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
4822 SetRectRgn( hrgn, 0, 0, 50, 100 );
4823 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
4824 SetRectRgn( hrgn, 50, 0, 100, 100 );
4825 check_update_rgn( hwnd, hrgn );
4826 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4827 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
4828 check_update_rgn( hwnd, 0 );
4831 SetRectRgn( hrgn, 0, 0, 100, 100 );
4832 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4833 SetRectRgn( hrgn, 0, 0, 100, 50 );
4834 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
4835 ok_sequence( WmErase, "Erase", FALSE );
4836 SetRectRgn( hrgn, 0, 50, 100, 100 );
4837 check_update_rgn( hwnd, hrgn );
4840 SetRectRgn( hrgn, 0, 0, 100, 100 );
4841 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
4842 SetRectRgn( hrgn, 0, 0, 50, 50 );
4843 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
4844 ok_sequence( WmPaint, "Paint", FALSE );
4847 SetRectRgn( hrgn, -4, -4, -2, -2 );
4848 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4849 SetRectRgn( hrgn, -200, -200, -198, -198 );
4850 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
4851 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
4854 SetRectRgn( hrgn, -4, -4, -2, -2 );
4855 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4856 SetRectRgn( hrgn, -4, -4, -3, -3 );
4857 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
4858 SetRectRgn( hrgn, 0, 0, 1, 1 );
4859 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
4860 ok_sequence( WmPaint, "Paint", FALSE );
4863 SetRectRgn( hrgn, -4, -4, -1, -1 );
4864 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4865 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
4866 /* make sure no WM_PAINT was generated */
4867 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4868 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
4871 SetRectRgn( hrgn, -4, -4, -1, -1 );
4872 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
4873 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
4875 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
4877 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
4878 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
4879 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
4880 ret = GetUpdateRect( hwnd, &rect, FALSE );
4881 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
4882 /* this will send WM_NCPAINT and validate the non client area */
4883 ret = GetUpdateRect( hwnd, &rect, TRUE );
4884 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
4886 DispatchMessage( &msg );
4888 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
4890 DestroyWindow( hwnd );
4892 /* now test with a child window */
4894 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4895 100, 100, 200, 200, 0, 0, 0, NULL);
4896 ok (hparent != 0, "Failed to create parent window\n");
4898 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
4899 10, 10, 100, 100, hparent, 0, 0, NULL);
4900 ok (hchild != 0, "Failed to create child window\n");
4902 ShowWindow( hparent, SW_SHOW );
4903 UpdateWindow( hparent );
4904 UpdateWindow( hchild );
4907 log_all_parent_messages++;
4909 SetRect( &rect, 0, 0, 50, 50 );
4910 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4911 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4912 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
4914 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4916 MapWindowPoints( hchild, hparent, &pt, 1 );
4917 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
4918 check_update_rgn( hchild, hrgn );
4919 SetRectRgn( hrgn, 0, 0, 50, 50 );
4920 check_update_rgn( hparent, hrgn );
4921 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4922 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
4923 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4924 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4926 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4927 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
4929 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4930 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4931 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
4932 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
4933 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
4935 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
4936 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
4937 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
4939 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
4941 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4942 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
4943 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
4945 /* flush all paint messages */
4946 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4949 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
4950 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
4951 SetRectRgn( hrgn, 0, 0, 50, 50 );
4952 check_update_rgn( hparent, hrgn );
4953 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4954 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4955 SetRectRgn( hrgn, 0, 0, 50, 50 );
4956 check_update_rgn( hparent, hrgn );
4958 /* flush all paint messages */
4959 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4960 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
4963 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
4964 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4965 SetRectRgn( hrgn, 0, 0, 50, 50 );
4966 check_update_rgn( hparent, hrgn );
4967 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4968 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4969 SetRectRgn( hrgn2, 10, 10, 50, 50 );
4970 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
4971 check_update_rgn( hparent, hrgn );
4972 /* flush all paint messages */
4973 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4976 /* same as above but parent gets completely validated */
4977 SetRect( &rect, 20, 20, 30, 30 );
4978 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4979 SetRectRgn( hrgn, 20, 20, 30, 30 );
4980 check_update_rgn( hparent, hrgn );
4981 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
4982 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
4983 check_update_rgn( hparent, 0 ); /* no update region */
4984 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
4985 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
4987 /* make sure RDW_VALIDATE on child doesn't have the same effect */
4989 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
4990 SetRectRgn( hrgn, 20, 20, 30, 30 );
4991 check_update_rgn( hparent, hrgn );
4992 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
4993 SetRectRgn( hrgn, 20, 20, 30, 30 );
4994 check_update_rgn( hparent, hrgn );
4996 /* same as above but normal WM_PAINT doesn't validate parent */
4998 SetRect( &rect, 20, 20, 30, 30 );
4999 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5000 SetRectRgn( hrgn, 20, 20, 30, 30 );
5001 check_update_rgn( hparent, hrgn );
5002 /* no WM_PAINT in child while parent still pending */
5003 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5004 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5005 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5006 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
5009 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5010 /* no WM_PAINT in child while parent still pending */
5011 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5012 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5013 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
5014 /* now that parent is valid child should get WM_PAINT */
5015 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5016 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5017 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5018 ok_sequence( WmEmptySeq, "No other message", FALSE );
5020 /* same thing with WS_CLIPCHILDREN in parent */
5022 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5023 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5024 /* changing style invalidates non client area, but we need to invalidate something else to see it */
5025 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
5026 ok_sequence( WmEmptySeq, "No message", FALSE );
5027 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
5028 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
5031 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
5032 SetRectRgn( hrgn, 20, 20, 30, 30 );
5033 check_update_rgn( hparent, hrgn );
5034 /* no WM_PAINT in child while parent still pending */
5035 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5036 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5037 /* WM_PAINT in parent first */
5038 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5039 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
5041 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
5043 SetRect( &rect, 0, 0, 30, 30 );
5044 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
5045 SetRectRgn( hrgn, 0, 0, 30, 30 );
5046 check_update_rgn( hparent, hrgn );
5047 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5048 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
5050 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5052 SetRect( &rect, -10, 0, 30, 30 );
5053 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5054 SetRect( &rect, 0, 0, 20, 20 );
5055 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5056 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5057 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
5059 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
5061 SetRect( &rect, -10, 0, 30, 30 );
5062 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
5063 SetRect( &rect, 0, 0, 100, 100 );
5064 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
5065 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
5066 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
5067 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5068 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
5070 /* test RDW_INTERNALPAINT behavior */
5073 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
5074 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5075 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5077 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
5078 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5079 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5081 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5082 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5083 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
5085 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
5086 UpdateWindow( hparent );
5087 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5089 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
5090 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5091 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5092 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5093 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5094 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
5096 UpdateWindow( hparent );
5097 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5099 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
5100 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5101 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5102 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5103 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5104 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5106 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5107 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
5108 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
5109 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5110 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
5112 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
5113 UpdateWindow( hparent );
5114 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5116 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
5117 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5118 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
5119 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5120 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5121 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
5123 UpdateWindow( hparent );
5124 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5126 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
5127 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5128 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
5129 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
5130 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5131 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
5133 log_all_parent_messages--;
5134 DestroyWindow( hparent );
5135 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
5137 DeleteObject( hrgn );
5138 DeleteObject( hrgn2 );
5147 static DWORD WINAPI thread_proc(void *param)
5150 struct wnd_event *wnd_event = (struct wnd_event *)param;
5152 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
5153 100, 100, 200, 200, 0, 0, 0, NULL);
5154 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
5156 SetEvent(wnd_event->event);
5158 while (GetMessage(&msg, 0, 0, 0))
5160 TranslateMessage(&msg);
5161 DispatchMessage(&msg);
5164 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
5169 static void test_interthread_messages(void)
5176 int len, expected_len;
5177 struct wnd_event wnd_event;
5180 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
5181 if (!wnd_event.event)
5183 trace("skipping interthread message test under win9x\n");
5187 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
5188 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
5190 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5192 CloseHandle(wnd_event.event);
5194 SetLastError(0xdeadbeef);
5195 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
5196 ok(GetLastError() == ERROR_ACCESS_DENIED, "wrong error code %d\n", GetLastError());
5198 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5199 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
5201 expected_len = lstrlenA("window caption text");
5202 memset(buf, 0, sizeof(buf));
5203 SetLastError(0xdeadbeef);
5204 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
5205 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
5206 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
5208 msg.hwnd = wnd_event.hwnd;
5209 msg.message = WM_GETTEXT;
5210 msg.wParam = sizeof(buf);
5211 msg.lParam = (LPARAM)buf;
5212 memset(buf, 0, sizeof(buf));
5213 SetLastError(0xdeadbeef);
5214 len = DispatchMessageA(&msg);
5215 ok(!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY,
5216 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
5218 /* the following test causes an exception in user.exe under win9x */
5219 msg.hwnd = wnd_event.hwnd;
5220 msg.message = WM_TIMER;
5222 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
5223 SetLastError(0xdeadbeef);
5224 len = DispatchMessageA(&msg);
5225 ok(!len && GetLastError() == 0xdeadbeef,
5226 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
5228 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
5229 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
5231 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
5232 CloseHandle(hThread);
5234 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
5238 static const struct message WmVkN[] = {
5239 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5240 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5241 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5242 { WM_CHAR, wparam|lparam, 'n', 1 },
5243 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
5244 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5245 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5246 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5249 static const struct message WmShiftVkN[] = {
5250 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5251 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5252 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5253 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5254 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5255 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5256 { WM_CHAR, wparam|lparam, 'N', 1 },
5257 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
5258 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5259 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5260 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5261 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5262 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5263 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5266 static const struct message WmCtrlVkN[] = {
5267 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5268 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5269 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5270 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5271 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5272 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
5273 { WM_CHAR, wparam|lparam, 0x000e, 1 },
5274 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
5275 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5276 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5277 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5278 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5279 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5280 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5283 static const struct message WmCtrlVkN_2[] = {
5284 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5285 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5286 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5287 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5288 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5289 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
5290 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5291 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5292 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5293 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5294 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5295 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5298 static const struct message WmAltVkN[] = {
5299 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5300 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5301 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5302 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5303 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
5304 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
5305 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
5306 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
5307 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
5308 { HCBT_SYSCOMMAND, hook },
5309 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
5310 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5311 { 0x00AE, sent|defwinproc|optional }, /* XP */
5312 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
5313 { WM_INITMENU, sent|defwinproc },
5314 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5315 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
5316 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
5317 { WM_CAPTURECHANGED, sent|defwinproc },
5318 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
5319 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5320 { WM_EXITMENULOOP, sent|defwinproc },
5321 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
5322 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
5323 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5324 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
5325 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5326 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5327 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5328 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5331 static const struct message WmAltVkN_2[] = {
5332 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5333 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5334 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5335 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5336 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
5337 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
5338 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5339 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
5340 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5341 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5342 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5343 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5346 static const struct message WmCtrlAltVkN[] = {
5347 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5348 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5349 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5350 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5351 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5352 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5353 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5354 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
5355 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
5356 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5357 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
5358 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5359 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5360 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5361 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5362 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5363 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5364 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5367 static const struct message WmCtrlShiftVkN[] = {
5368 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5369 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5370 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5371 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
5372 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
5373 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
5374 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
5375 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
5376 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
5377 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
5378 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
5379 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
5380 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
5381 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
5382 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
5383 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5384 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5385 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5388 static const struct message WmCtrlAltShiftVkN[] = {
5389 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
5390 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
5391 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
5392 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5393 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5394 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5395 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
5396 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
5397 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
5398 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
5399 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
5400 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
5401 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
5402 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
5403 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
5404 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
5405 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
5406 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
5407 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5408 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5409 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5410 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
5411 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
5412 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
5415 static const struct message WmAltPressRelease[] = {
5416 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5417 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5418 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5419 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5420 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5421 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5422 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
5423 { HCBT_SYSCOMMAND, hook },
5424 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
5425 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5426 { WM_INITMENU, sent|defwinproc },
5427 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5428 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
5429 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
5431 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
5433 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5434 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
5435 { WM_CAPTURECHANGED, sent|defwinproc },
5436 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
5437 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
5438 { WM_EXITMENULOOP, sent|defwinproc },
5439 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5440 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5441 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5444 static const struct message WmAltMouseButton[] = {
5445 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
5446 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
5447 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
5448 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
5449 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
5450 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
5451 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
5452 { WM_LBUTTONUP, wparam, 0, 0 },
5453 { WM_LBUTTONUP, sent|wparam, 0, 0 },
5454 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
5455 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
5456 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
5459 static const struct message WmF1Seq[] = {
5460 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
5461 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
5462 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
5463 { 0x4d, wparam|lparam, 0, 0 },
5464 { 0x4d, sent|wparam|lparam, 0, 0 },
5465 { WM_HELP, sent|defwinproc },
5466 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
5467 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
5468 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
5471 static const struct message WmVkAppsSeq[] = {
5472 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
5473 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
5474 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
5475 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
5476 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
5477 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
5478 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
5479 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
5483 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
5487 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
5489 struct message log_msg;
5491 trace("accel: %p, %04x, %08x, %08lx\n", msg.hwnd, msg.message, msg.wParam, msg.lParam);
5493 /* ignore some unwanted messages */
5494 if (msg.message == WM_MOUSEMOVE ||
5495 msg.message == WM_GETICON ||
5496 msg.message == WM_DEVICECHANGE)
5499 log_msg.message = msg.message;
5500 log_msg.flags = wparam|lparam;
5501 log_msg.wParam = msg.wParam;
5502 log_msg.lParam = msg.lParam;
5503 add_message(&log_msg);
5505 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
5507 TranslateMessage(&msg);
5508 DispatchMessage(&msg);
5513 static void test_accelerators(void)
5518 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5519 100, 100, 200, 200, 0, 0, 0, NULL);
5528 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
5530 state = GetKeyState(VK_SHIFT);
5531 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
5532 state = GetKeyState(VK_CAPITAL);
5533 ok(state == 0, "wrong CapsLock state %04x\n", state);
5535 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
5536 assert(hAccel != 0);
5538 pump_msg_loop(hwnd, 0);
5541 trace("testing VK_N press/release\n");
5543 keybd_event('N', 0, 0, 0);
5544 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5545 pump_msg_loop(hwnd, hAccel);
5546 ok_sequence(WmVkN, "VK_N press/release", FALSE);
5548 trace("testing Shift+VK_N press/release\n");
5550 keybd_event(VK_SHIFT, 0, 0, 0);
5551 keybd_event('N', 0, 0, 0);
5552 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5553 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5554 pump_msg_loop(hwnd, hAccel);
5555 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
5557 trace("testing Ctrl+VK_N press/release\n");
5559 keybd_event(VK_CONTROL, 0, 0, 0);
5560 keybd_event('N', 0, 0, 0);
5561 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5562 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5563 pump_msg_loop(hwnd, hAccel);
5564 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
5566 trace("testing Alt+VK_N press/release\n");
5568 keybd_event(VK_MENU, 0, 0, 0);
5569 keybd_event('N', 0, 0, 0);
5570 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5571 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5572 pump_msg_loop(hwnd, hAccel);
5573 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
5575 trace("testing Ctrl+Alt+VK_N press/release 1\n");
5577 keybd_event(VK_CONTROL, 0, 0, 0);
5578 keybd_event(VK_MENU, 0, 0, 0);
5579 keybd_event('N', 0, 0, 0);
5580 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5581 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5582 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5583 pump_msg_loop(hwnd, hAccel);
5584 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
5586 ret = DestroyAcceleratorTable(hAccel);
5587 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
5589 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
5590 assert(hAccel != 0);
5592 trace("testing VK_N press/release\n");
5594 keybd_event('N', 0, 0, 0);
5595 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5596 pump_msg_loop(hwnd, hAccel);
5597 ok_sequence(WmVkN, "VK_N press/release", FALSE);
5599 trace("testing Shift+VK_N press/release\n");
5601 keybd_event(VK_SHIFT, 0, 0, 0);
5602 keybd_event('N', 0, 0, 0);
5603 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5604 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5605 pump_msg_loop(hwnd, hAccel);
5606 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
5608 trace("testing Ctrl+VK_N press/release 2\n");
5610 keybd_event(VK_CONTROL, 0, 0, 0);
5611 keybd_event('N', 0, 0, 0);
5612 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5613 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5614 pump_msg_loop(hwnd, hAccel);
5615 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
5617 trace("testing Alt+VK_N press/release 2\n");
5619 keybd_event(VK_MENU, 0, 0, 0);
5620 keybd_event('N', 0, 0, 0);
5621 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5622 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5623 pump_msg_loop(hwnd, hAccel);
5624 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
5626 trace("testing Ctrl+Alt+VK_N press/release 2\n");
5628 keybd_event(VK_CONTROL, 0, 0, 0);
5629 keybd_event(VK_MENU, 0, 0, 0);
5630 keybd_event('N', 0, 0, 0);
5631 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5632 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5633 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5634 pump_msg_loop(hwnd, hAccel);
5635 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
5637 trace("testing Ctrl+Shift+VK_N press/release\n");
5639 keybd_event(VK_CONTROL, 0, 0, 0);
5640 keybd_event(VK_SHIFT, 0, 0, 0);
5641 keybd_event('N', 0, 0, 0);
5642 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5643 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5644 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5645 pump_msg_loop(hwnd, hAccel);
5646 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
5648 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
5650 keybd_event(VK_CONTROL, 0, 0, 0);
5651 keybd_event(VK_MENU, 0, 0, 0);
5652 keybd_event(VK_SHIFT, 0, 0, 0);
5653 keybd_event('N', 0, 0, 0);
5654 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
5655 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
5656 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5657 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
5658 pump_msg_loop(hwnd, hAccel);
5659 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
5661 ret = DestroyAcceleratorTable(hAccel);
5662 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
5664 trace("testing Alt press/release\n");
5666 keybd_event(VK_MENU, 0, 0, 0);
5667 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5668 keybd_event(VK_MENU, 0, 0, 0);
5669 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5670 pump_msg_loop(hwnd, 0);
5671 /* this test doesn't pass in Wine for managed windows */
5672 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
5674 trace("testing Alt+MouseButton press/release\n");
5675 /* first, move mouse pointer inside of the window client area */
5676 GetClientRect(hwnd, &rc);
5677 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
5678 rc.left += (rc.right - rc.left)/2;
5679 rc.top += (rc.bottom - rc.top)/2;
5680 SetCursorPos(rc.left, rc.top);
5682 pump_msg_loop(hwnd, 0);
5684 keybd_event(VK_MENU, 0, 0, 0);
5685 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
5686 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
5687 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
5688 pump_msg_loop(hwnd, 0);
5689 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
5691 trace("testing VK_F1 press/release\n");
5692 keybd_event(VK_F1, 0, 0, 0);
5693 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
5694 pump_msg_loop(hwnd, 0);
5695 ok_sequence(WmF1Seq, "F1 press/release", TRUE);
5697 trace("testing VK_APPS press/release\n");
5698 keybd_event(VK_APPS, 0, 0, 0);
5699 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
5700 pump_msg_loop(hwnd, 0);
5701 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
5703 DestroyWindow(hwnd);
5706 /************* window procedures ********************/
5708 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
5709 WPARAM wParam, LPARAM lParam)
5711 static long defwndproc_counter = 0;
5712 static long beginpaint_counter = 0;
5716 trace("%p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5718 /* explicitly ignore WM_GETICON message */
5719 if (message == WM_GETICON) return 0;
5725 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
5726 ok((BOOL)wParam == !(style & WS_DISABLED),
5727 "wrong WS_DISABLED state: %d != %d\n", wParam, !(style & WS_DISABLED));
5731 case WM_CAPTURECHANGED:
5732 if (test_DestroyWindow_flag)
5734 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5735 if (style & WS_CHILD)
5736 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5737 else if (style & WS_POPUP)
5738 lParam = WND_POPUP_ID;
5740 lParam = WND_PARENT_ID;
5748 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
5749 capture = GetCapture();
5752 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
5753 trace("current capture %p, releasing...\n", capture);
5760 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
5761 if (test_DestroyWindow_flag)
5763 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
5764 if (style & WS_CHILD)
5765 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
5766 else if (style & WS_POPUP)
5767 lParam = WND_POPUP_ID;
5769 lParam = WND_PARENT_ID;
5773 /* test_accelerators() depends on this */
5780 case WM_DEVICECHANGE:
5783 case WM_WINDOWPOSCHANGING:
5784 case WM_WINDOWPOSCHANGED:
5786 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5788 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5789 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5790 winpos->hwnd, winpos->hwndInsertAfter,
5791 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5792 dump_winpos_flags(winpos->flags);
5794 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5795 * in the high word for internal purposes
5797 wParam = winpos->flags & 0xffff;
5798 /* We are not interested in the flags that don't match under XP and Win9x */
5799 wParam &= ~(SWP_NOZORDER);
5804 msg.message = message;
5805 msg.flags = sent|wparam|lparam;
5806 if (defwndproc_counter) msg.flags |= defwinproc;
5807 if (beginpaint_counter) msg.flags |= beginpaint;
5808 msg.wParam = wParam;
5809 msg.lParam = lParam;
5812 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
5814 HWND parent = GetParent(hwnd);
5816 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
5818 GetClientRect(parent, &rc);
5819 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
5821 trace("ptReserved = (%d,%d)\n"
5822 "ptMaxSize = (%d,%d)\n"
5823 "ptMaxPosition = (%d,%d)\n"
5824 "ptMinTrackSize = (%d,%d)\n"
5825 "ptMaxTrackSize = (%d,%d)\n",
5826 minmax->ptReserved.x, minmax->ptReserved.y,
5827 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
5828 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
5829 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
5830 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
5832 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
5833 minmax->ptMaxSize.x, rc.right);
5834 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
5835 minmax->ptMaxSize.y, rc.bottom);
5838 if (message == WM_PAINT)
5841 beginpaint_counter++;
5842 BeginPaint( hwnd, &ps );
5843 beginpaint_counter--;
5844 EndPaint( hwnd, &ps );
5848 defwndproc_counter++;
5849 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
5850 : DefWindowProcA(hwnd, message, wParam, lParam);
5851 defwndproc_counter--;
5856 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5858 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
5861 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5863 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
5866 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5868 static long defwndproc_counter = 0;
5872 trace("popup: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5874 /* explicitly ignore WM_GETICON message */
5875 if (message == WM_GETICON) return 0;
5877 msg.message = message;
5878 msg.flags = sent|wparam|lparam;
5879 if (defwndproc_counter) msg.flags |= defwinproc;
5880 msg.wParam = wParam;
5881 msg.lParam = lParam;
5884 if (message == WM_CREATE)
5886 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
5887 SetWindowLongA(hwnd, GWL_STYLE, style);
5890 defwndproc_counter++;
5891 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5892 defwndproc_counter--;
5897 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5899 static long defwndproc_counter = 0;
5900 static long beginpaint_counter = 0;
5904 trace("parent: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5906 /* explicitly ignore WM_GETICON message */
5907 if (message == WM_GETICON) return 0;
5909 if (log_all_parent_messages ||
5910 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
5911 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
5912 message == WM_ENABLE || message == WM_ENTERIDLE ||
5913 message == WM_IME_SETCONTEXT)
5927 INT ret = GetClipBox((HDC)wParam, &rc);
5929 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
5930 ret, rc.left, rc.top, rc.right, rc.bottom);
5934 case WM_WINDOWPOSCHANGING:
5935 case WM_WINDOWPOSCHANGED:
5937 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
5939 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
5940 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
5941 winpos->hwnd, winpos->hwndInsertAfter,
5942 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
5943 dump_winpos_flags(winpos->flags);
5945 /* Log only documented flags, win2k uses 0x1000 and 0x2000
5946 * in the high word for internal purposes
5948 wParam = winpos->flags & 0xffff;
5949 /* We are not interested in the flags that don't match under XP and Win9x */
5950 wParam &= ~(SWP_NOZORDER);
5955 msg.message = message;
5956 msg.flags = sent|parent|wparam|lparam;
5957 if (defwndproc_counter) msg.flags |= defwinproc;
5958 if (beginpaint_counter) msg.flags |= beginpaint;
5959 msg.wParam = wParam;
5960 msg.lParam = lParam;
5964 if (message == WM_PAINT)
5967 beginpaint_counter++;
5968 BeginPaint( hwnd, &ps );
5969 beginpaint_counter--;
5970 EndPaint( hwnd, &ps );
5974 defwndproc_counter++;
5975 ret = DefWindowProcA(hwnd, message, wParam, lParam);
5976 defwndproc_counter--;
5981 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5983 static long defwndproc_counter = 0;
5987 trace("dialog: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
5989 /* explicitly ignore WM_GETICON message */
5990 if (message == WM_GETICON) return 0;
5994 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
5995 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
5996 if (after_end_dialog)
5997 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
5999 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
6004 case WM_WINDOWPOSCHANGING:
6005 case WM_WINDOWPOSCHANGED:
6007 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6009 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6010 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6011 winpos->hwnd, winpos->hwndInsertAfter,
6012 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6013 dump_winpos_flags(winpos->flags);
6015 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6016 * in the high word for internal purposes
6018 wParam = winpos->flags & 0xffff;
6019 /* We are not interested in the flags that don't match under XP and Win9x */
6020 wParam &= ~(SWP_NOZORDER);
6025 msg.message = message;
6026 msg.flags = sent|wparam|lparam;
6027 if (defwndproc_counter) msg.flags |= defwinproc;
6028 msg.wParam = wParam;
6029 msg.lParam = lParam;
6032 defwndproc_counter++;
6033 ret = DefDlgProcA(hwnd, message, wParam, lParam);
6034 defwndproc_counter--;
6039 static void dump_winpos_flags(UINT flags)
6041 if (!winetest_debug) return;
6043 if (flags & SWP_SHOWWINDOW) printf("|SWP_SHOWWINDOW");
6044 if (flags & SWP_HIDEWINDOW) printf("|SWP_HIDEWINDOW");
6045 if (flags & SWP_NOACTIVATE) printf("|SWP_NOACTIVATE");
6046 if (flags & SWP_FRAMECHANGED) printf("|SWP_FRAMECHANGED");
6047 if (flags & SWP_NOCOPYBITS) printf("|SWP_NOCOPYBITS");
6048 if (flags & SWP_NOOWNERZORDER) printf("|SWP_NOOWNERZORDER");
6049 if (flags & SWP_NOSENDCHANGING) printf("|SWP_NOSENDCHANGING");
6050 if (flags & SWP_DEFERERASE) printf("|SWP_DEFERERASE");
6051 if (flags & SWP_ASYNCWINDOWPOS) printf("|SWP_ASYNCWINDOWPOS");
6052 if (flags & SWP_NOZORDER) printf("|SWP_NOZORDER");
6053 if (flags & SWP_NOREDRAW) printf("|SWP_NOREDRAW");
6054 if (flags & SWP_NOSIZE) printf("|SWP_NOSIZE");
6055 if (flags & SWP_NOMOVE) printf("|SWP_NOMOVE");
6056 if (flags & SWP_NOCLIENTSIZE) printf("|SWP_NOCLIENTSIZE");
6057 if (flags & SWP_NOCLIENTMOVE) printf("|SWP_NOCLIENTMOVE");
6059 #define DUMPED_FLAGS \
6065 SWP_FRAMECHANGED | \
6069 SWP_NOOWNERZORDER | \
6070 SWP_NOSENDCHANGING | \
6072 SWP_ASYNCWINDOWPOS | \
6073 SWP_NOCLIENTSIZE | \
6076 if(flags & ~DUMPED_FLAGS) printf("|0x%04x", flags & ~DUMPED_FLAGS);
6081 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6083 static long defwndproc_counter = 0;
6087 /* log only specific messages we are interested in */
6090 #if 0 /* probably log these as well */
6096 trace("WM_SHOWWINDOW %d\n", wParam);
6099 trace("WM_SIZE %d\n", wParam);
6104 case WM_GETMINMAXINFO:
6105 trace("WM_GETMINMAXINFO\n");
6108 case WM_WINDOWPOSCHANGING:
6109 case WM_WINDOWPOSCHANGED:
6111 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
6113 trace("%s\n", (message == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
6114 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
6115 winpos->hwnd, winpos->hwndInsertAfter,
6116 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
6118 dump_winpos_flags(winpos->flags);
6120 /* Log only documented flags, win2k uses 0x1000 and 0x2000
6121 * in the high word for internal purposes
6123 wParam = winpos->flags & 0xffff;
6124 /* We are not interested in the flags that don't match under XP and Win9x */
6125 wParam &= ~(SWP_NOZORDER);
6129 default: /* ignore */
6130 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
6131 return DefWindowProcA(hwnd, message, wParam, lParam);
6134 msg.message = message;
6135 msg.flags = sent|wparam|lparam;
6136 if (defwndproc_counter) msg.flags |= defwinproc;
6137 msg.wParam = wParam;
6138 msg.lParam = lParam;
6141 defwndproc_counter++;
6142 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6143 defwndproc_counter--;
6148 static BOOL RegisterWindowClasses(void)
6153 cls.lpfnWndProc = MsgCheckProcA;
6156 cls.hInstance = GetModuleHandleA(0);
6158 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
6159 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6160 cls.lpszMenuName = NULL;
6161 cls.lpszClassName = "TestWindowClass";
6162 if(!RegisterClassA(&cls)) return FALSE;
6164 cls.lpfnWndProc = ShowWindowProcA;
6165 cls.lpszClassName = "ShowWindowClass";
6166 if(!RegisterClassA(&cls)) return FALSE;
6168 cls.lpfnWndProc = PopupMsgCheckProcA;
6169 cls.lpszClassName = "TestPopupClass";
6170 if(!RegisterClassA(&cls)) return FALSE;
6172 cls.lpfnWndProc = ParentMsgCheckProcA;
6173 cls.lpszClassName = "TestParentClass";
6174 if(!RegisterClassA(&cls)) return FALSE;
6176 cls.lpfnWndProc = DefWindowProcA;
6177 cls.lpszClassName = "SimpleWindowClass";
6178 if(!RegisterClassA(&cls)) return FALSE;
6180 cls.style = CS_NOCLOSE;
6181 cls.lpszClassName = "NoCloseWindowClass";
6182 if(!RegisterClassA(&cls)) return FALSE;
6184 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
6186 cls.hInstance = GetModuleHandleA(0);
6187 cls.hbrBackground = 0;
6188 cls.lpfnWndProc = TestDlgProcA;
6189 cls.lpszClassName = "TestDialogClass";
6190 if(!RegisterClassA(&cls)) return FALSE;
6195 static HHOOK hCBT_hook;
6196 static DWORD cbt_hook_thread_id;
6198 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6200 static const char * const CBT_code_name[10] = {
6207 "HCBT_CLICKSKIPPED",
6211 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
6215 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
6217 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6219 if (nCode == HCBT_CLICKSKIPPED)
6221 /* ignore this event, XP sends it a lot when switching focus between windows */
6222 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6225 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
6229 msg.message = nCode;
6230 msg.flags = hook|wparam|lparam;
6231 msg.wParam = wParam;
6232 msg.lParam = lParam;
6235 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6238 if (nCode == HCBT_DESTROYWND)
6240 if (test_DestroyWindow_flag)
6242 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
6243 if (style & WS_CHILD)
6244 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
6245 else if (style & WS_POPUP)
6246 lParam = WND_POPUP_ID;
6248 lParam = WND_PARENT_ID;
6252 /* Log also SetFocus(0) calls */
6253 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
6255 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6257 if (!lstrcmpiA(buf, "TestWindowClass") ||
6258 !lstrcmpiA(buf, "ShowWindowClass") ||
6259 !lstrcmpiA(buf, "TestParentClass") ||
6260 !lstrcmpiA(buf, "TestPopupClass") ||
6261 !lstrcmpiA(buf, "SimpleWindowClass") ||
6262 !lstrcmpiA(buf, "TestDialogClass") ||
6263 !lstrcmpiA(buf, "MDI_frame_class") ||
6264 !lstrcmpiA(buf, "MDI_client_class") ||
6265 !lstrcmpiA(buf, "MDI_child_class") ||
6266 !lstrcmpiA(buf, "my_button_class") ||
6267 !lstrcmpiA(buf, "my_edit_class") ||
6268 !lstrcmpiA(buf, "static") ||
6269 !lstrcmpiA(buf, "#32770"))
6273 msg.message = nCode;
6274 msg.flags = hook|wparam|lparam;
6275 msg.wParam = wParam;
6276 msg.lParam = lParam;
6280 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
6283 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
6293 trace("WEH:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6294 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
6296 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
6298 /* ignore mouse cursor events */
6299 if (object_id == OBJID_CURSOR) return;
6301 if (!hwnd || GetClassNameA(hwnd, buf, sizeof(buf)))
6304 !lstrcmpiA(buf, "TestWindowClass") ||
6305 !lstrcmpiA(buf, "TestParentClass") ||
6306 !lstrcmpiA(buf, "TestPopupClass") ||
6307 !lstrcmpiA(buf, "SimpleWindowClass") ||
6308 !lstrcmpiA(buf, "TestDialogClass") ||
6309 !lstrcmpiA(buf, "MDI_frame_class") ||
6310 !lstrcmpiA(buf, "MDI_client_class") ||
6311 !lstrcmpiA(buf, "MDI_child_class") ||
6312 !lstrcmpiA(buf, "my_button_class") ||
6313 !lstrcmpiA(buf, "my_edit_class") ||
6314 !lstrcmpiA(buf, "static") ||
6315 !lstrcmpiA(buf, "#32770"))
6319 msg.message = event;
6320 msg.flags = winevent_hook|wparam|lparam;
6321 msg.wParam = object_id;
6322 msg.lParam = child_id;
6328 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
6329 static const WCHAR wszAnsi[] = {'U',0};
6331 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
6335 case CB_FINDSTRINGEXACT:
6336 trace("String: %p\n", (LPCWSTR)lParam);
6337 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
6339 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
6343 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
6346 static const struct message WmGetTextLengthAfromW[] = {
6347 { WM_GETTEXTLENGTH, sent },
6348 { WM_GETTEXT, sent },
6352 static const WCHAR testWindowClassW[] =
6353 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
6355 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
6357 /* dummy window proc for WM_GETTEXTLENGTH test */
6358 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
6362 case WM_GETTEXTLENGTH:
6363 return lstrlenW(dummy_window_text) + 37; /* some random length */
6365 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
6366 return lstrlenW( (LPWSTR)lp );
6368 return DefWindowProcW( hwnd, msg, wp, lp );
6372 static void test_message_conversion(void)
6374 static const WCHAR wszMsgConversionClass[] =
6375 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
6379 WNDPROC wndproc, newproc;
6383 cls.lpfnWndProc = MsgConversionProcW;
6386 cls.hInstance = GetModuleHandleW(NULL);
6388 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
6389 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
6390 cls.lpszMenuName = NULL;
6391 cls.lpszClassName = wszMsgConversionClass;
6392 /* this call will fail on Win9x, but that doesn't matter as this test is
6393 * meaningless on those platforms */
6394 if(!RegisterClassW(&cls)) return;
6397 cls.lpfnWndProc = MsgCheckProcW;
6400 cls.hInstance = GetModuleHandleW(0);
6402 cls.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
6403 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
6404 cls.lpszMenuName = NULL;
6405 cls.lpszClassName = testWindowClassW;
6406 if(!RegisterClassW(&cls)) return;
6408 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
6409 100, 100, 200, 200, 0, 0, 0, NULL);
6410 ok(hwnd != NULL, "Window creation failed\n");
6414 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
6415 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6416 ok(lRes == 0, "String should have been converted\n");
6417 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6418 ok(lRes == 1, "String shouldn't have been converted\n");
6422 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
6423 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6424 ok(lRes == 1, "String shouldn't have been converted\n");
6425 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6426 ok(lRes == 1, "String shouldn't have been converted\n");
6428 /* Synchronous messages */
6430 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6431 ok(lRes == 0, "String should have been converted\n");
6432 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6433 ok(lRes == 1, "String shouldn't have been converted\n");
6435 /* Asynchronous messages */
6438 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6439 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6440 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6442 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6443 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6444 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6446 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6447 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6448 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6450 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6451 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6452 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6454 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6455 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6456 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6458 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
6459 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6460 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6462 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
6463 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6464 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6466 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
6467 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
6468 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
6470 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
6472 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
6473 WS_OVERLAPPEDWINDOW,
6474 100, 100, 200, 200, 0, 0, 0, NULL);
6477 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
6478 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
6479 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
6480 "got bad length %ld\n", lRes );
6483 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
6484 hwnd, WM_GETTEXTLENGTH, 0, 0);
6485 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
6486 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
6487 "got bad length %ld\n", lRes );
6489 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
6490 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
6491 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
6492 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
6493 NULL, 0, NULL, NULL ),
6494 "got bad length %ld\n", lRes );
6496 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
6497 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
6498 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
6499 NULL, 0, NULL, NULL ),
6500 "got bad length %ld\n", lRes );
6502 ret = DestroyWindow(hwnd);
6503 ok( ret, "DestroyWindow() error %d\n", GetLastError());
6513 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT id, DWORD dwTime)
6517 #define TIMER_ID 0x19
6519 static DWORD WINAPI timer_thread_proc(LPVOID x)
6521 struct timer_info *info = x;
6524 r = KillTimer(info->hWnd, 0x19);
6525 ok(r,"KillTimer failed in thread\n");
6526 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
6527 ok(r,"SetTimer failed in thread\n");
6528 ok(r==TIMER_ID,"SetTimer id different\n");
6529 r = SetEvent(info->handles[0]);
6530 ok(r,"SetEvent failed in thread\n");
6534 static void test_timers(void)
6536 struct timer_info info;
6539 info.hWnd = CreateWindow ("TestWindowClass", NULL,
6540 WS_OVERLAPPEDWINDOW ,
6541 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
6544 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
6545 ok(info.id, "SetTimer failed\n");
6546 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
6547 info.handles[0] = CreateEvent(NULL,0,0,NULL);
6548 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
6550 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
6552 WaitForSingleObject(info.handles[1], INFINITE);
6554 CloseHandle(info.handles[0]);
6555 CloseHandle(info.handles[1]);
6557 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
6559 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
6562 /* Various win events with arbitrary parameters */
6563 static const struct message WmWinEventsSeq[] = {
6564 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
6565 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6566 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
6567 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
6568 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
6569 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
6570 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
6571 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
6572 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
6573 /* our win event hook ignores OBJID_CURSOR events */
6574 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
6575 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
6576 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
6577 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
6578 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
6579 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
6580 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6581 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
6582 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
6583 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
6584 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
6585 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
6586 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
6587 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
6590 static const struct message WmWinEventCaretSeq[] = {
6591 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
6592 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
6593 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
6594 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
6597 static const struct message WmWinEventCaretSeq_2[] = {
6598 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
6599 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
6600 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
6603 static const struct message WmWinEventAlertSeq[] = {
6604 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
6607 static const struct message WmWinEventAlertSeq_2[] = {
6608 /* create window in the thread proc */
6609 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
6610 /* our test event */
6611 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
6614 static const struct message WmGlobalHookSeq_1[] = {
6615 /* create window in the thread proc */
6616 { HCBT_CREATEWND, hook|lparam, 0, 2 },
6617 /* our test events */
6618 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
6619 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
6622 static const struct message WmGlobalHookSeq_2[] = {
6623 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
6624 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
6625 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
6626 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
6630 static const struct message WmMouseLLHookSeq[] = {
6631 { WM_MOUSEMOVE, hook },
6632 { WM_LBUTTONUP, hook },
6633 { WM_MOUSEMOVE, hook },
6637 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
6647 trace("WEH_2:%p,event %08x,hwnd %p,obj %08x,id %08x,thread %08x,time %08x\n",
6648 hevent, event, hwnd, object_id, child_id, thread_id, event_time);
6650 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6652 if (!lstrcmpiA(buf, "TestWindowClass") ||
6653 !lstrcmpiA(buf, "static"))
6657 msg.message = event;
6658 msg.flags = winevent_hook|wparam|lparam;
6659 msg.wParam = object_id;
6660 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
6666 static HHOOK hCBT_global_hook;
6667 static DWORD cbt_global_hook_thread_id;
6669 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
6674 trace("CBT_2: %d, %08x, %08lx\n", nCode, wParam, lParam);
6676 if (nCode == HCBT_SYSCOMMAND)
6680 msg.message = nCode;
6681 msg.flags = hook|wparam|lparam;
6682 msg.wParam = wParam;
6683 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
6686 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6688 /* WH_MOUSE_LL hook */
6689 if (nCode == HC_ACTION)
6692 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
6694 /* we can't test for real mouse events */
6695 if (mhll->flags & LLMHF_INJECTED)
6697 msg.message = wParam;
6701 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6704 /* Log also SetFocus(0) calls */
6705 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
6707 if (GetClassNameA(hwnd, buf, sizeof(buf)))
6709 if (!lstrcmpiA(buf, "TestWindowClass") ||
6710 !lstrcmpiA(buf, "static"))
6714 msg.message = nCode;
6715 msg.flags = hook|wparam|lparam;
6716 msg.wParam = wParam;
6717 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
6721 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
6724 static DWORD WINAPI win_event_global_thread_proc(void *param)
6728 HANDLE hevent = *(HANDLE *)param;
6729 HMODULE user32 = GetModuleHandleA("user32.dll");
6730 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
6732 assert(pNotifyWinEvent);
6734 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6736 trace("created thread window %p\n", hwnd);
6738 *(HWND *)param = hwnd;
6741 /* this event should be received only by our new hook proc,
6742 * an old one does not expect an event from another thread.
6744 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
6747 while (GetMessage(&msg, 0, 0, 0))
6749 TranslateMessage(&msg);
6750 DispatchMessage(&msg);
6755 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
6759 HANDLE hevent = *(HANDLE *)param;
6762 /* these events should be received only by our new hook proc,
6763 * an old one does not expect an event from another thread.
6766 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6768 trace("created thread window %p\n", hwnd);
6770 *(HWND *)param = hwnd;
6772 /* Windows doesn't like when a thread plays games with the focus,
6773 that leads to all kinds of misbehaviours and failures to activate
6774 a window. So, better keep next lines commented out.
6778 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6779 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6783 while (GetMessage(&msg, 0, 0, 0))
6785 TranslateMessage(&msg);
6786 DispatchMessage(&msg);
6791 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
6795 HANDLE hevent = *(HANDLE *)param;
6797 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
6799 trace("created thread window %p\n", hwnd);
6801 *(HWND *)param = hwnd;
6805 /* Windows doesn't like when a thread plays games with the focus,
6806 * that leads to all kinds of misbehaviours and failures to activate
6807 * a window. So, better don't generate a mouse click message below.
6809 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
6810 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6811 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
6814 while (GetMessage(&msg, 0, 0, 0))
6816 TranslateMessage(&msg);
6817 DispatchMessage(&msg);
6822 static void test_winevents(void)
6828 HANDLE hthread, hevent;
6830 HWINEVENTHOOK hhook;
6831 const struct message *events = WmWinEventsSeq;
6832 HMODULE user32 = GetModuleHandleA("user32.dll");
6833 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
6834 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
6835 FARPROC pNotifyWinEvent = GetProcAddress(user32, "NotifyWinEvent");
6837 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
6838 WS_OVERLAPPEDWINDOW,
6839 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
6843 /****** start of global hook test *************/
6844 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6845 assert(hCBT_global_hook);
6847 hevent = CreateEventA(NULL, 0, 0, NULL);
6849 hwnd2 = (HWND)hevent;
6851 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
6852 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6854 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6856 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
6859 /* this one should be received only by old hook proc */
6860 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
6861 /* this one should be received only by old hook proc */
6862 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
6864 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
6866 ret = UnhookWindowsHookEx(hCBT_global_hook);
6867 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
6869 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6870 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6871 CloseHandle(hthread);
6872 CloseHandle(hevent);
6873 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6874 /****** end of global hook test *************/
6876 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
6878 ok(DestroyWindow(hwnd), "failed to destroy window\n");
6886 /* this test doesn't pass under Win9x */
6887 /* win2k ignores events with hwnd == 0 */
6888 SetLastError(0xdeadbeef);
6889 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
6890 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
6891 GetLastError() == 0xdeadbeef, /* Win9x */
6892 "unexpected error %d\n", GetLastError());
6893 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6896 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
6897 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
6899 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
6901 /****** start of event filtering test *************/
6902 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6903 EVENT_OBJECT_SHOW, /* 0x8002 */
6904 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
6905 GetModuleHandleA(0), win_event_global_hook_proc,
6906 GetCurrentProcessId(), 0,
6907 WINEVENT_INCONTEXT);
6908 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
6910 hevent = CreateEventA(NULL, 0, 0, NULL);
6912 hwnd2 = (HWND)hevent;
6914 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6915 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6917 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6919 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
6922 /* this one should be received only by old hook proc */
6923 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6924 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6925 /* this one should be received only by old hook proc */
6926 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6928 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
6930 ret = pUnhookWinEvent(hhook);
6931 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
6933 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6934 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6935 CloseHandle(hthread);
6936 CloseHandle(hevent);
6937 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6938 /****** end of event filtering test *************/
6940 /****** start of out of context event test *************/
6941 hhook = (HWINEVENTHOOK)pSetWinEventHook(
6942 EVENT_MIN, EVENT_MAX,
6943 0, win_event_global_hook_proc,
6944 GetCurrentProcessId(), 0,
6945 WINEVENT_OUTOFCONTEXT);
6946 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
6948 hevent = CreateEventA(NULL, 0, 0, NULL);
6950 hwnd2 = (HWND)hevent;
6954 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
6955 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
6957 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6959 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
6960 /* process pending winevent messages */
6961 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6962 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
6965 /* this one should be received only by old hook proc */
6966 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
6967 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
6968 /* this one should be received only by old hook proc */
6969 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
6971 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
6972 /* process pending winevent messages */
6973 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
6974 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
6976 ret = pUnhookWinEvent(hhook);
6977 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
6979 PostThreadMessageA(tid, WM_QUIT, 0, 0);
6980 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6981 CloseHandle(hthread);
6982 CloseHandle(hevent);
6983 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
6984 /****** end of out of context event test *************/
6986 /****** start of MOUSE_LL hook test *************/
6987 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
6988 /* WH_MOUSE_LL is not supported on Win9x platforms */
6989 if (!hCBT_global_hook)
6991 trace("Skipping WH_MOUSE_LL test on this platform\n");
6992 goto skip_mouse_ll_hook_test;
6995 hevent = CreateEventA(NULL, 0, 0, NULL);
6997 hwnd2 = (HWND)hevent;
6999 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
7000 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7002 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
7003 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7005 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
7008 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7009 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7010 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7012 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
7014 ret = UnhookWindowsHookEx(hCBT_global_hook);
7015 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7017 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7018 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7019 CloseHandle(hthread);
7020 CloseHandle(hevent);
7021 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7022 /****** end of MOUSE_LL hook test *************/
7023 skip_mouse_ll_hook_test:
7025 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7028 static void test_set_hook(void)
7032 HWINEVENTHOOK hwinevent_hook;
7033 HMODULE user32 = GetModuleHandleA("user32.dll");
7034 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
7035 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
7037 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
7038 ok(hhook != 0, "local hook does not require hModule set to 0\n");
7039 UnhookWindowsHookEx(hhook);
7043 /* this test doesn't pass under Win9x: BUG! */
7044 SetLastError(0xdeadbeef);
7045 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
7046 ok(!hhook, "global hook requires hModule != 0\n");
7047 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
7050 SetLastError(0xdeadbeef);
7051 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
7052 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
7053 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
7054 GetLastError() == 0xdeadbeef, /* Win9x */
7055 "unexpected error %d\n", GetLastError());
7057 SetLastError(0xdeadbeef);
7058 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
7059 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
7060 GetLastError() == 0xdeadbeef, /* Win9x */
7061 "unexpected error %d\n", GetLastError());
7063 if (!pSetWinEventHook || !pUnhookWinEvent) return;
7065 /* even process local incontext hooks require hmodule */
7066 SetLastError(0xdeadbeef);
7067 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7068 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
7069 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7070 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7071 GetLastError() == 0xdeadbeef, /* Win9x */
7072 "unexpected error %d\n", GetLastError());
7074 /* even thread local incontext hooks require hmodule */
7075 SetLastError(0xdeadbeef);
7076 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7077 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
7078 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
7079 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
7080 GetLastError() == 0xdeadbeef, /* Win9x */
7081 "unexpected error %d\n", GetLastError());
7085 /* these 3 tests don't pass under Win9x */
7086 SetLastError(0xdeadbeef);
7087 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
7088 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7089 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7090 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7092 SetLastError(0xdeadbeef);
7093 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
7094 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7095 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
7096 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
7098 SetLastError(0xdeadbeef);
7099 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7100 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
7101 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
7102 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
7105 SetLastError(0xdeadbeef);
7106 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
7107 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
7108 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7109 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7110 ret = pUnhookWinEvent(hwinevent_hook);
7111 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7114 /* This call succeeds under win2k SP4, but fails under Wine.
7115 Does win2k test/use passed process id? */
7116 SetLastError(0xdeadbeef);
7117 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
7118 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
7119 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
7120 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
7121 ret = pUnhookWinEvent(hwinevent_hook);
7122 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7125 SetLastError(0xdeadbeef);
7126 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
7127 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
7128 GetLastError() == 0xdeadbeef, /* Win9x */
7129 "unexpected error %d\n", GetLastError());
7132 static const struct message ScrollWindowPaint1[] = {
7134 { WM_ERASEBKGND, sent|beginpaint },
7138 static const struct message ScrollWindowPaint2[] = {
7143 static void test_scrollwindowex(void)
7146 RECT rect={0,0,130,130};
7149 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
7150 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
7151 100, 100, 200, 200, 0, 0, 0, NULL);
7152 ok (hwnd != 0, "Failed to create overlapped window\n");
7153 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
7154 WS_VISIBLE|WS_CAPTION|WS_CHILD,
7155 10, 10, 150, 150, hwnd, 0, 0, NULL);
7156 ok (hchild != 0, "Failed to create child\n");
7161 /* scroll without the child window */
7162 trace("start scroll\n");
7163 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7164 SW_ERASE|SW_INVALIDATE);
7165 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7166 trace("end scroll\n");
7168 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7169 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7173 /* Now without the SW_ERASE flag */
7174 trace("start scroll\n");
7175 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
7176 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7177 trace("end scroll\n");
7179 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7180 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
7184 /* now scroll the child window as well */
7185 trace("start scroll\n");
7186 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
7187 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
7188 todo_wine { /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
7189 /* windows sometimes a WM_MOVE */
7190 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
7192 trace("end scroll\n");
7194 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7195 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
7199 /* now scroll with ScrollWindow() */
7200 trace("start scroll with ScrollWindow\n");
7201 ScrollWindow( hwnd, 5, 5, NULL, NULL);
7202 trace("end scroll\n");
7204 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7205 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
7207 ok(DestroyWindow(hchild), "failed to destroy window\n");
7208 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7212 static const struct message destroy_window_with_children[] = {
7213 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7214 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
7215 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
7216 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
7217 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7218 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7219 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
7220 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
7221 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7222 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7223 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7224 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7225 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
7226 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
7227 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
7228 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
7232 static void test_DestroyWindow(void)
7235 HWND parent, child1, child2, child3, child4, test;
7236 UINT child_id = WND_CHILD_ID + 1;
7238 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7239 100, 100, 200, 200, 0, 0, 0, NULL);
7240 assert(parent != 0);
7241 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7242 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
7243 assert(child1 != 0);
7244 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7245 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
7246 assert(child2 != 0);
7247 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
7248 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
7249 assert(child3 != 0);
7250 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
7251 0, 0, 50, 50, parent, 0, 0, NULL);
7252 assert(child4 != 0);
7254 /* test owner/parent of child2 */
7255 test = GetParent(child2);
7256 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7257 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
7259 test = pGetAncestor(child2, GA_PARENT);
7260 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7262 test = GetWindow(child2, GW_OWNER);
7263 ok(!test, "wrong owner %p\n", test);
7265 test = SetParent(child2, parent);
7266 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
7268 /* test owner/parent of the parent */
7269 test = GetParent(parent);
7270 ok(!test, "wrong parent %p\n", test);
7272 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
7275 test = pGetAncestor(parent, GA_PARENT);
7276 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7278 test = GetWindow(parent, GW_OWNER);
7279 ok(!test, "wrong owner %p\n", test);
7281 /* test owner/parent of child1 */
7282 test = GetParent(child1);
7283 ok(test == parent, "wrong parent %p\n", test);
7284 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
7286 test = pGetAncestor(child1, GA_PARENT);
7287 ok(test == parent, "wrong parent %p\n", test);
7289 test = GetWindow(child1, GW_OWNER);
7290 ok(!test, "wrong owner %p\n", test);
7292 /* test owner/parent of child2 */
7293 test = GetParent(child2);
7294 ok(test == parent, "wrong parent %p\n", test);
7295 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
7297 test = pGetAncestor(child2, GA_PARENT);
7298 ok(test == parent, "wrong parent %p\n", test);
7300 test = GetWindow(child2, GW_OWNER);
7301 ok(!test, "wrong owner %p\n", test);
7303 /* test owner/parent of child3 */
7304 test = GetParent(child3);
7305 ok(test == child1, "wrong parent %p\n", test);
7306 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
7308 test = pGetAncestor(child3, GA_PARENT);
7309 ok(test == child1, "wrong parent %p\n", test);
7311 test = GetWindow(child3, GW_OWNER);
7312 ok(!test, "wrong owner %p\n", test);
7314 /* test owner/parent of child4 */
7315 test = GetParent(child4);
7316 ok(test == parent, "wrong parent %p\n", test);
7317 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
7319 test = pGetAncestor(child4, GA_PARENT);
7320 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
7322 test = GetWindow(child4, GW_OWNER);
7323 ok(test == parent, "wrong owner %p\n", test);
7327 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
7328 parent, child1, child2, child3, child4);
7331 test = GetCapture();
7332 ok(test == child4, "wrong capture window %p\n", test);
7334 test_DestroyWindow_flag = TRUE;
7335 ret = DestroyWindow(parent);
7336 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7337 test_DestroyWindow_flag = FALSE;
7338 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
7340 ok(!IsWindow(parent), "parent still exists\n");
7341 ok(!IsWindow(child1), "child1 still exists\n");
7342 ok(!IsWindow(child2), "child2 still exists\n");
7343 ok(!IsWindow(child3), "child3 still exists\n");
7344 ok(!IsWindow(child4), "child4 still exists\n");
7346 test = GetCapture();
7347 ok(!test, "wrong capture window %p\n", test);
7351 static const struct message WmDispatchPaint[] = {
7352 { WM_NCPAINT, sent },
7353 { WM_GETTEXT, sent|defwinproc|optional },
7354 { WM_GETTEXT, sent|defwinproc|optional },
7355 { WM_ERASEBKGND, sent },
7359 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7361 if (message == WM_PAINT) return 0;
7362 return MsgCheckProcA( hwnd, message, wParam, lParam );
7365 static void test_DispatchMessage(void)
7370 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7371 100, 100, 200, 200, 0, 0, 0, NULL);
7372 ShowWindow( hwnd, SW_SHOW );
7373 UpdateWindow( hwnd );
7374 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7376 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
7378 SetRect( &rect, -5, -5, 5, 5 );
7379 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
7381 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
7383 if (msg.message != WM_PAINT) DispatchMessage( &msg );
7387 DispatchMessage( &msg );
7388 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
7389 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
7390 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
7391 if (++count > 10) break;
7394 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
7396 trace("now without DispatchMessage\n");
7398 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
7400 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
7402 if (msg.message != WM_PAINT) DispatchMessage( &msg );
7405 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
7407 /* this will send WM_NCCPAINT just like DispatchMessage does */
7408 GetUpdateRgn( hwnd, hrgn, TRUE );
7409 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
7410 DeleteObject( hrgn );
7411 GetClientRect( hwnd, &rect );
7412 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
7413 ok( !count, "Got multiple WM_PAINTs\n" );
7414 if (++count > 10) break;
7417 DestroyWindow(hwnd);
7421 static const struct message WmUser[] = {
7433 static DWORD CALLBACK send_msg_thread( LPVOID arg )
7435 struct sendmsg_info *info = arg;
7436 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
7437 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT, "unexpected error %d\n", GetLastError());
7441 static void wait_for_thread( HANDLE thread )
7443 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
7446 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
7450 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7452 if (message == WM_USER) Sleep(200);
7453 return MsgCheckProcA( hwnd, message, wParam, lParam );
7456 static void test_SendMessageTimeout(void)
7460 struct sendmsg_info info;
7463 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7464 100, 100, 200, 200, 0, 0, 0, NULL);
7465 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
7468 info.timeout = 1000;
7469 info.ret = 0xdeadbeef;
7470 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7471 wait_for_thread( thread );
7472 CloseHandle( thread );
7473 ok( info.ret == 1, "SendMessageTimeout failed\n" );
7474 ok_sequence( WmUser, "WmUser", FALSE );
7477 info.ret = 0xdeadbeef;
7478 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7479 Sleep(100); /* SendMessageTimeout should timeout here */
7480 wait_for_thread( thread );
7481 CloseHandle( thread );
7482 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
7483 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
7485 /* 0 means infinite timeout */
7487 info.ret = 0xdeadbeef;
7488 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7490 wait_for_thread( thread );
7491 CloseHandle( thread );
7492 ok( info.ret == 1, "SendMessageTimeout failed\n" );
7493 ok_sequence( WmUser, "WmUser", FALSE );
7495 /* timeout is treated as signed despite the prototype */
7496 info.timeout = 0x7fffffff;
7497 info.ret = 0xdeadbeef;
7498 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7500 wait_for_thread( thread );
7501 CloseHandle( thread );
7502 ok( info.ret == 1, "SendMessageTimeout failed\n" );
7503 ok_sequence( WmUser, "WmUser", FALSE );
7505 info.timeout = 0x80000000;
7506 info.ret = 0xdeadbeef;
7507 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7509 wait_for_thread( thread );
7510 CloseHandle( thread );
7511 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
7512 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
7514 /* now check for timeout during message processing */
7515 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
7517 info.ret = 0xdeadbeef;
7518 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
7519 wait_for_thread( thread );
7520 CloseHandle( thread );
7521 /* we should timeout but still get the message */
7522 ok( info.ret == 0, "SendMessageTimeout failed\n" );
7523 ok_sequence( WmUser, "WmUser", FALSE );
7525 DestroyWindow( info.hwnd );
7529 /****************** edit message test *************************/
7530 #define ID_EDIT 0x1234
7531 static const struct message sl_edit_setfocus[] =
7533 { HCBT_SETFOCUS, hook },
7534 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
7535 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7536 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7537 { WM_SETFOCUS, sent|wparam, 0 },
7538 { WM_CTLCOLOREDIT, sent|parent },
7539 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7540 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7541 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7544 static const struct message ml_edit_setfocus[] =
7546 { HCBT_SETFOCUS, hook },
7547 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
7548 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7549 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7550 { WM_SETFOCUS, sent|wparam, 0 },
7551 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7552 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7553 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7554 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7557 static const struct message sl_edit_killfocus[] =
7559 { HCBT_SETFOCUS, hook },
7560 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7561 { WM_KILLFOCUS, sent|wparam, 0 },
7562 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7563 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7564 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
7565 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
7566 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
7569 static const struct message sl_edit_lbutton_dblclk[] =
7571 { WM_LBUTTONDBLCLK, sent },
7572 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7575 static const struct message sl_edit_lbutton_down[] =
7577 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
7578 { HCBT_SETFOCUS, hook },
7579 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
7580 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7581 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7582 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
7583 { WM_CTLCOLOREDIT, sent|parent },
7584 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7585 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7586 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7587 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7588 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7589 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7590 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7591 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7594 static const struct message ml_edit_lbutton_down[] =
7596 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
7597 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7598 { HCBT_SETFOCUS, hook },
7599 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
7600 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
7601 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
7602 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
7603 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7604 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7605 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
7608 static const struct message sl_edit_lbutton_up[] =
7610 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
7611 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7612 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
7613 { WM_CAPTURECHANGED, sent|defwinproc },
7614 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
7617 static const struct message ml_edit_lbutton_up[] =
7619 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
7620 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
7621 { WM_CAPTURECHANGED, sent|defwinproc },
7625 static WNDPROC old_edit_proc;
7627 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7629 static long defwndproc_counter = 0;
7633 trace("edit: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);
7635 /* explicitly ignore WM_GETICON message */
7636 if (message == WM_GETICON) return 0;
7638 msg.message = message;
7639 msg.flags = sent|wparam|lparam;
7640 if (defwndproc_counter) msg.flags |= defwinproc;
7641 msg.wParam = wParam;
7642 msg.lParam = lParam;
7645 defwndproc_counter++;
7646 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
7647 defwndproc_counter--;
7652 static void subclass_edit(void)
7656 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
7658 old_edit_proc = cls.lpfnWndProc;
7660 cls.hInstance = GetModuleHandle(0);
7661 cls.lpfnWndProc = edit_hook_proc;
7662 cls.lpszClassName = "my_edit_class";
7663 UnregisterClass(cls.lpszClassName, cls.hInstance);
7664 if (!RegisterClassA(&cls)) assert(0);
7667 static void test_edit_messages(void)
7673 log_all_parent_messages++;
7675 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
7676 100, 100, 200, 200, 0, 0, 0, NULL);
7677 ok (parent != 0, "Failed to create parent window\n");
7679 /* test single line edit */
7680 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
7681 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
7682 ok(hwnd != 0, "Failed to create edit window\n");
7684 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
7685 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
7687 ShowWindow(hwnd, SW_SHOW);
7693 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
7696 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
7702 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
7703 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
7709 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
7710 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
7712 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
7713 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
7715 DestroyWindow(hwnd);
7717 /* test multiline edit */
7718 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
7719 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
7720 ok(hwnd != 0, "Failed to create edit window\n");
7722 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
7723 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
7724 "wrong dlg_code %08x\n", dlg_code);
7726 ShowWindow(hwnd, SW_SHOW);
7732 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
7735 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
7741 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
7742 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
7748 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
7749 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
7751 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
7752 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
7754 DestroyWindow(hwnd);
7755 DestroyWindow(parent);
7757 log_all_parent_messages--;
7760 /**************************** End of Edit test ******************************/
7762 static const struct message WmKeyDownSkippedSeq[] =
7764 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
7767 static const struct message WmKeyUpSkippedSeq[] =
7769 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
7773 #define EV_START_STOP 0
7774 #define EV_SENDMSG 1
7780 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
7783 static DWORD CALLBACK send_msg_thread_2(void *param)
7786 struct peekmsg_info *info = param;
7788 trace("thread: waiting for start\n");
7789 WaitForSingleObject(info->hevent[EV_START_STOP], INFINITE);
7790 trace("thread: looping\n");
7794 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
7798 case WAIT_OBJECT_0 + EV_START_STOP:
7799 trace("thread: exiting\n");
7802 case WAIT_OBJECT_0 + EV_SENDMSG:
7803 trace("thread: sending message\n");
7804 SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
7805 SetEvent(info->hevent[EV_ACK]);
7809 trace("unexpected return: %04x\n", ret);
7817 static void test_PeekMessage(void)
7822 UINT qs_all_input = QS_ALLINPUT;
7823 UINT qs_input = QS_INPUT;
7825 struct peekmsg_info info;
7827 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
7828 100, 100, 200, 200, 0, 0, 0, NULL);
7830 ShowWindow(info.hwnd, SW_SHOW);
7831 UpdateWindow(info.hwnd);
7832 SetFocus(info.hwnd);
7834 info.hevent[EV_START_STOP] = CreateEventA(NULL, 0, 0, NULL);
7835 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
7836 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
7838 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
7841 trace("signalling to start looping\n");
7842 SetEvent(info.hevent[EV_START_STOP]);
7844 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
7847 SetLastError(0xdeadbeef);
7848 qstatus = GetQueueStatus(qs_all_input);
7849 if (GetLastError() == ERROR_INVALID_FLAGS)
7851 trace("QS_RAWINPUT not supported on this platform\n");
7852 qs_all_input &= ~QS_RAWINPUT;
7853 qs_input &= ~QS_RAWINPUT;
7855 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
7857 trace("signalling to send message\n");
7858 SetEvent(info.hevent[EV_SENDMSG]);
7859 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7861 /* pass invalid QS_xxxx flags */
7862 SetLastError(0xdeadbeef);
7863 qstatus = GetQueueStatus(0xffffffff);
7864 ok(qstatus == 0, "GetQueueStatus should fail: %08x\n", qstatus);
7865 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
7867 qstatus = GetQueueStatus(qs_all_input);
7868 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
7869 "wrong qstatus %08x\n", qstatus);
7872 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
7874 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7876 ok_sequence(WmUser, "WmUser", FALSE);
7878 qstatus = GetQueueStatus(qs_all_input);
7879 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
7881 keybd_event('N', 0, 0, 0);
7882 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7883 qstatus = GetQueueStatus(qs_all_input);
7884 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
7885 "wrong qstatus %08x\n", qstatus);
7887 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7888 qstatus = GetQueueStatus(qs_all_input);
7889 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
7890 "wrong qstatus %08x\n", qstatus);
7892 InvalidateRect(info.hwnd, NULL, FALSE);
7893 qstatus = GetQueueStatus(qs_all_input);
7894 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7895 "wrong qstatus %08x\n", qstatus);
7897 trace("signalling to send message\n");
7898 SetEvent(info.hevent[EV_SENDMSG]);
7899 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7901 qstatus = GetQueueStatus(qs_all_input);
7902 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7903 "wrong qstatus %08x\n", qstatus);
7906 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
7908 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7910 ok_sequence(WmUser, "WmUser", FALSE);
7912 qstatus = GetQueueStatus(qs_all_input);
7913 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7914 "wrong qstatus %08x\n", qstatus);
7916 trace("signalling to send message\n");
7917 SetEvent(info.hevent[EV_SENDMSG]);
7918 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7920 qstatus = GetQueueStatus(qs_all_input);
7921 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7922 "wrong qstatus %08x\n", qstatus);
7925 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
7927 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7929 ok_sequence(WmUser, "WmUser", FALSE);
7931 qstatus = GetQueueStatus(qs_all_input);
7932 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
7933 "wrong qstatus %08x\n", qstatus);
7936 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
7937 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
7938 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
7939 ret, msg.message, msg.wParam);
7940 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7942 qstatus = GetQueueStatus(qs_all_input);
7943 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
7944 "wrong qstatus %08x\n", qstatus);
7947 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
7949 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7951 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7953 qstatus = GetQueueStatus(qs_all_input);
7954 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
7955 "wrong qstatus %08x\n", qstatus);
7958 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
7959 ok(ret && msg.message == WM_PAINT,
7960 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
7961 DispatchMessageA(&msg);
7962 ok_sequence(WmPaint, "WmPaint", FALSE);
7964 qstatus = GetQueueStatus(qs_all_input);
7965 ok(qstatus == MAKELONG(0, QS_KEY),
7966 "wrong qstatus %08x\n", qstatus);
7969 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
7971 "PeekMessageA should have returned FALSE instead of msg %04x\n",
7973 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
7975 qstatus = GetQueueStatus(qs_all_input);
7976 ok(qstatus == MAKELONG(0, QS_KEY),
7977 "wrong qstatus %08x\n", qstatus);
7979 trace("signalling to send message\n");
7980 SetEvent(info.hevent[EV_SENDMSG]);
7981 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
7983 qstatus = GetQueueStatus(qs_all_input);
7984 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
7985 "wrong qstatus %08x\n", qstatus);
7987 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
7989 qstatus = GetQueueStatus(qs_all_input);
7990 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
7991 "wrong qstatus %08x\n", qstatus);
7994 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
7995 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
7996 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
7997 ret, msg.message, msg.wParam);
7998 ok_sequence(WmUser, "WmUser", FALSE);
8000 qstatus = GetQueueStatus(qs_all_input);
8001 ok(qstatus == MAKELONG(0, QS_KEY),
8002 "wrong qstatus %08x\n", qstatus);
8005 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
8007 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8009 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8011 qstatus = GetQueueStatus(qs_all_input);
8012 ok(qstatus == MAKELONG(0, QS_KEY),
8013 "wrong qstatus %08x\n", qstatus);
8015 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8017 qstatus = GetQueueStatus(qs_all_input);
8018 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8019 "wrong qstatus %08x\n", qstatus);
8021 trace("signalling to send message\n");
8022 SetEvent(info.hevent[EV_SENDMSG]);
8023 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8025 qstatus = GetQueueStatus(qs_all_input);
8026 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
8027 "wrong qstatus %08x\n", qstatus);
8030 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
8032 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8034 ok_sequence(WmUser, "WmUser", FALSE);
8036 qstatus = GetQueueStatus(qs_all_input);
8037 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8038 "wrong qstatus %08x\n", qstatus);
8041 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8042 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8043 else /* workaround for a missing QS_RAWINPUT support */
8044 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
8045 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
8046 "got %d and %04x wParam %08x instead of TRUE and WM_KEYDOWN wParam 'N'\n",
8047 ret, msg.message, msg.wParam);
8048 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
8050 qstatus = GetQueueStatus(qs_all_input);
8051 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
8052 "wrong qstatus %08x\n", qstatus);
8055 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
8056 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
8057 else /* workaround for a missing QS_RAWINPUT support */
8058 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
8059 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
8060 "got %d and %04x wParam %08x instead of TRUE and WM_KEYUP wParam 'N'\n",
8061 ret, msg.message, msg.wParam);
8062 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
8064 qstatus = GetQueueStatus(qs_all_input);
8065 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8066 "wrong qstatus %08x\n", qstatus);
8069 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
8071 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8073 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8075 qstatus = GetQueueStatus(qs_all_input);
8076 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8077 "wrong qstatus %08x\n", qstatus);
8080 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8081 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8082 "got %d and %04x wParam %08x instead of TRUE and WM_CHAR wParam 'z'\n",
8083 ret, msg.message, msg.wParam);
8084 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8086 qstatus = GetQueueStatus(qs_all_input);
8088 "wrong qstatus %08x\n", qstatus);
8091 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8093 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8095 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8097 qstatus = GetQueueStatus(qs_all_input);
8099 "wrong qstatus %08x\n", qstatus);
8101 /* test whether presence of the quit flag in the queue affects
8104 PostQuitMessage(0x1234abcd);
8106 qstatus = GetQueueStatus(qs_all_input);
8107 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8108 "wrong qstatus %08x\n", qstatus);
8110 PostMessageA(info.hwnd, WM_USER, 0, 0);
8112 qstatus = GetQueueStatus(qs_all_input);
8113 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
8114 "wrong qstatus %08x\n", qstatus);
8117 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8118 ok(ret && msg.message == WM_USER,
8119 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
8120 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8122 qstatus = GetQueueStatus(qs_all_input);
8123 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8124 "wrong qstatus %08x\n", qstatus);
8127 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8128 ok(ret && msg.message == WM_QUIT,
8129 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
8130 ok(msg.wParam == 0x1234abcd, "got wParam %08x instead of 0x1234abcd\n", msg.wParam);
8131 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
8132 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8134 qstatus = GetQueueStatus(qs_all_input);
8136 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
8137 "wrong qstatus %08x\n", qstatus);
8141 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8143 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8145 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8147 qstatus = GetQueueStatus(qs_all_input);
8149 "wrong qstatus %08x\n", qstatus);
8151 trace("signalling to exit\n");
8152 SetEvent(info.hevent[EV_START_STOP]);
8154 WaitForSingleObject(hthread, INFINITE);
8156 CloseHandle(hthread);
8157 CloseHandle(info.hevent[0]);
8158 CloseHandle(info.hevent[1]);
8159 CloseHandle(info.hevent[2]);
8161 DestroyWindow(info.hwnd);
8165 static void test_quit_message(void)
8170 /* test using PostQuitMessage */
8171 PostQuitMessage(0xbeef);
8173 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
8174 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
8175 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8176 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
8178 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
8179 ok(ret, "PostMessage failed with error %d\n", GetLastError());
8181 ret = GetMessage(&msg, NULL, 0, 0);
8182 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
8183 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
8185 /* note: WM_QUIT message received after WM_USER message */
8186 ret = GetMessage(&msg, NULL, 0, 0);
8187 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
8188 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8189 ok(msg.wParam == 0xbeef, "wParam was 0x%x instead of 0xbeef\n", msg.wParam);
8191 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
8192 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
8194 /* now test with PostThreadMessage - different behaviour! */
8195 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
8197 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
8198 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
8199 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8200 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
8202 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
8203 ok(ret, "PostMessage failed with error %d\n", GetLastError());
8205 /* note: we receive the WM_QUIT message first this time */
8206 ret = GetMessage(&msg, NULL, 0, 0);
8207 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
8208 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
8209 ok(msg.wParam == 0xdead, "wParam was 0x%x instead of 0xdead\n", msg.wParam);
8211 ret = GetMessage(&msg, NULL, 0, 0);
8212 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
8213 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
8216 static const struct message WmMouseHoverSeq[] = {
8217 { WM_TIMER, sent|optional }, /* XP sends it */
8218 { WM_SYSTIMER, sent },
8219 { WM_MOUSEHOVER, sent|wparam, 0 },
8223 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
8226 DWORD start_ticks, end_ticks;
8228 start_ticks = GetTickCount();
8229 /* add some deviation (5%) to cover not expected delays */
8230 start_ticks += timeout / 20;
8234 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
8236 /* Timer proc messages are not dispatched to the window proc,
8237 * and therefore not logged.
8239 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
8241 struct message s_msg;
8243 s_msg.message = msg.message;
8244 s_msg.flags = sent|wparam|lparam;
8245 s_msg.wParam = msg.wParam;
8246 s_msg.lParam = msg.lParam;
8247 add_message(&s_msg);
8249 DispatchMessage(&msg);
8252 end_ticks = GetTickCount();
8254 /* inject WM_MOUSEMOVE to see how it changes tracking */
8255 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
8257 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8258 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8260 inject_mouse_move = FALSE;
8262 } while (start_ticks + timeout >= end_ticks);
8265 static void test_TrackMouseEvent(void)
8268 TRACKMOUSEEVENT tme;
8271 RECT rc_parent, rc_child;
8272 UINT default_hover_time, hover_width = 0, hover_height = 0;
8274 #define track_hover(track_hwnd, track_hover_time) \
8275 tme.cbSize = sizeof(tme); \
8276 tme.dwFlags = TME_HOVER; \
8277 tme.hwndTrack = track_hwnd; \
8278 tme.dwHoverTime = track_hover_time; \
8279 SetLastError(0xdeadbeef); \
8280 ret = TrackMouseEvent(&tme); \
8281 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
8283 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
8284 tme.cbSize = sizeof(tme); \
8285 tme.dwFlags = TME_QUERY; \
8286 tme.hwndTrack = (HWND)0xdeadbeef; \
8287 tme.dwHoverTime = 0xdeadbeef; \
8288 SetLastError(0xdeadbeef); \
8289 ret = TrackMouseEvent(&tme); \
8290 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
8291 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
8292 ok(tme.dwFlags == (expected_track_flags), \
8293 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
8294 ok(tme.hwndTrack == (expected_track_hwnd), \
8295 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
8296 ok(tme.dwHoverTime == (expected_hover_time), \
8297 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
8299 #define track_hover_cancel(track_hwnd) \
8300 tme.cbSize = sizeof(tme); \
8301 tme.dwFlags = TME_HOVER | TME_CANCEL; \
8302 tme.hwndTrack = track_hwnd; \
8303 tme.dwHoverTime = 0xdeadbeef; \
8304 SetLastError(0xdeadbeef); \
8305 ret = TrackMouseEvent(&tme); \
8306 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
8308 default_hover_time = 0xdeadbeef;
8309 SetLastError(0xdeadbeef);
8310 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
8311 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
8312 if (!ret) default_hover_time = 400;
8313 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
8315 SetLastError(0xdeadbeef);
8316 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
8317 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
8318 if (!ret) hover_width = 4;
8319 SetLastError(0xdeadbeef);
8320 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
8321 ok(ret, "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
8322 if (!ret) hover_height = 4;
8323 trace("hover rect is %u x %d\n", hover_width, hover_height);
8325 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
8326 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8327 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8331 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
8332 WS_CHILD | WS_BORDER | WS_VISIBLE,
8333 50, 50, 200, 200, hwnd,
8341 tme.dwFlags = TME_QUERY;
8342 tme.hwndTrack = (HWND)0xdeadbeef;
8343 tme.dwHoverTime = 0xdeadbeef;
8344 SetLastError(0xdeadbeef);
8345 ret = TrackMouseEvent(&tme);
8346 ok(!ret, "TrackMouseEvent should fail\n");
8347 ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
8349 tme.cbSize = sizeof(tme);
8350 tme.dwFlags = TME_HOVER;
8351 tme.hwndTrack = (HWND)0xdeadbeef;
8352 tme.dwHoverTime = 0xdeadbeef;
8353 SetLastError(0xdeadbeef);
8354 ret = TrackMouseEvent(&tme);
8355 ok(!ret, "TrackMouseEvent should fail\n");
8356 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
8358 tme.cbSize = sizeof(tme);
8359 tme.dwFlags = TME_HOVER | TME_CANCEL;
8360 tme.hwndTrack = (HWND)0xdeadbeef;
8361 tme.dwHoverTime = 0xdeadbeef;
8362 SetLastError(0xdeadbeef);
8363 ret = TrackMouseEvent(&tme);
8364 ok(!ret, "TrackMouseEvent should fail\n");
8365 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
8367 GetWindowRect(hwnd, &rc_parent);
8368 GetWindowRect(hchild, &rc_child);
8369 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
8371 /* Process messages so that the system updates its internal current
8372 * window and hittest, otherwise TrackMouseEvent calls don't have any
8375 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8378 track_query(0, NULL, 0);
8379 track_hover(hchild, 0);
8380 track_query(0, NULL, 0);
8382 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8385 track_hover(hwnd, 0);
8386 track_query(TME_HOVER, hwnd, default_hover_time);
8388 pump_msg_loop_timeout(default_hover_time, FALSE);
8389 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
8391 track_query(0, NULL, 0);
8393 track_hover(hwnd, HOVER_DEFAULT);
8394 track_query(TME_HOVER, hwnd, default_hover_time);
8396 Sleep(default_hover_time / 2);
8397 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8398 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8400 track_query(TME_HOVER, hwnd, default_hover_time);
8402 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
8403 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
8405 track_query(0, NULL, 0);
8407 track_hover(hwnd, HOVER_DEFAULT);
8408 track_query(TME_HOVER, hwnd, default_hover_time);
8410 pump_msg_loop_timeout(default_hover_time, TRUE);
8411 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
8413 track_query(0, NULL, 0);
8415 track_hover(hwnd, HOVER_DEFAULT);
8416 track_query(TME_HOVER, hwnd, default_hover_time);
8417 track_hover_cancel(hwnd);
8419 DestroyWindow(hwnd);
8423 #undef track_hover_cancel
8427 static const struct message WmSetWindowRgn[] = {
8428 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8429 { WM_NCCALCSIZE, sent|wparam, 1 },
8430 { WM_NCPAINT, sent }, /* wparam != 1 */
8431 { WM_GETTEXT, sent|defwinproc|optional },
8432 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
8433 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8434 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8438 static const struct message WmSetWindowRgn_no_redraw[] = {
8439 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
8440 { WM_NCCALCSIZE, sent|wparam, 1 },
8441 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
8442 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8446 static const struct message WmSetWindowRgn_clear[] = {
8447 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8448 { WM_NCCALCSIZE, sent|wparam, 1 },
8449 { WM_NCPAINT, sent }, /* wparam != 1 */
8450 { WM_GETTEXT, sent|defwinproc|optional },
8451 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
8452 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
8453 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
8454 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
8455 { WM_GETTEXT, sent|defwinproc|optional },
8456 { WM_ERASEBKGND, sent|optional },
8457 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8458 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
8462 static void test_SetWindowRgn(void)
8465 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
8466 100, 100, 200, 200, 0, 0, 0, NULL);
8467 ok( hwnd != 0, "Failed to create overlapped window\n" );
8469 ShowWindow( hwnd, SW_SHOW );
8470 UpdateWindow( hwnd );
8474 trace("testing SetWindowRgn\n");
8475 hrgn = CreateRectRgn( 0, 0, 150, 150 );
8476 SetWindowRgn( hwnd, hrgn, TRUE );
8477 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
8479 hrgn = CreateRectRgn( 30, 30, 160, 160 );
8480 SetWindowRgn( hwnd, hrgn, FALSE );
8481 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
8483 hrgn = CreateRectRgn( 0, 0, 180, 180 );
8484 SetWindowRgn( hwnd, hrgn, TRUE );
8485 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
8487 SetWindowRgn( hwnd, 0, TRUE );
8488 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
8490 DestroyWindow( hwnd );
8493 /*************************** ShowWindow() test ******************************/
8494 static const struct message WmShowNormal[] = {
8495 { WM_SHOWWINDOW, sent|wparam, 1 },
8496 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8497 { HCBT_ACTIVATE, hook },
8498 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
8499 { HCBT_SETFOCUS, hook },
8500 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8503 static const struct message WmShow[] = {
8504 { WM_SHOWWINDOW, sent|wparam, 1 },
8505 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8506 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8507 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8508 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8509 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8512 static const struct message WmShowNoActivate_1[] = {
8513 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
8514 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
8515 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|0x8000 },
8516 { WM_MOVE, sent|defwinproc },
8517 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8520 static const struct message WmShowNoActivate_2[] = {
8521 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
8522 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8523 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8524 { WM_MOVE, sent|defwinproc },
8525 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8526 { HCBT_SETFOCUS, hook },
8527 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
8528 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
8529 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
8532 static const struct message WmShowNA_1[] = {
8533 { WM_SHOWWINDOW, sent|wparam, 1 },
8534 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
8535 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8538 static const struct message WmShowNA_2[] = {
8539 { WM_SHOWWINDOW, sent|wparam, 1 },
8540 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
8543 static const struct message WmRestore_1[] = {
8544 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
8545 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8546 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8547 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8548 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8549 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8550 { WM_MOVE, sent|defwinproc },
8551 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8552 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
8555 static const struct message WmRestore_2[] = {
8556 { WM_SHOWWINDOW, sent|wparam, 1 },
8557 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8558 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8561 static const struct message WmRestore_3[] = {
8562 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
8563 { WM_GETMINMAXINFO, sent },
8564 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8565 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
8566 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
8567 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
8568 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8569 { WM_MOVE, sent|defwinproc },
8570 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8571 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
8574 static const struct message WmRestore_4[] = {
8575 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
8576 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8578 { WM_MOVE, sent|defwinproc },
8579 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8582 static const struct message WmRestore_5[] = {
8583 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
8584 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8585 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8586 { WM_MOVE, sent|defwinproc },
8587 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
8590 static const struct message WmHide_1[] = {
8591 { WM_SHOWWINDOW, sent|wparam, 0 },
8592 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8593 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8594 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
8597 static const struct message WmHide_2[] = {
8598 { WM_SHOWWINDOW, sent|wparam, 0 },
8599 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8600 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
8603 static const struct message WmHide_3[] = {
8604 { WM_SHOWWINDOW, sent|wparam, 0 },
8605 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
8606 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8607 { HCBT_SETFOCUS, hook },
8610 static const struct message WmShowMinimized_1[] = {
8611 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
8612 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8613 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8614 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8615 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8616 { WM_MOVE, sent|defwinproc },
8617 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8620 static const struct message WmMinimize_1[] = {
8621 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8622 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8623 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8624 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8625 { WM_MOVE, sent|defwinproc },
8626 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8629 static const struct message WmMinimize_2[] = {
8630 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8631 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8632 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8633 { WM_MOVE, sent|defwinproc },
8634 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8637 static const struct message WmMinimize_3[] = {
8638 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8639 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8640 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8641 { WM_MOVE, sent|defwinproc },
8642 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
8645 static const struct message WmShowMinNoActivate[] = {
8646 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
8647 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
8648 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8651 static const struct message WmMinMax_1[] = {
8652 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
8655 static const struct message WmMinMax_2[] = {
8656 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8659 static const struct message WmMinMax_3[] = {
8660 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
8663 static const struct message WmMinMax_4[] = {
8664 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
8667 static const struct message WmShowMaximized_1[] = {
8668 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8669 { WM_GETMINMAXINFO, sent },
8670 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8671 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
8672 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
8673 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
8674 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8675 { WM_MOVE, sent|defwinproc },
8676 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8677 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
8680 static const struct message WmShowMaximized_2[] = {
8681 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8682 { WM_GETMINMAXINFO, sent },
8683 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
8684 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
8685 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
8686 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
8687 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8688 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|0x8000 },
8689 { WM_MOVE, sent|defwinproc },
8690 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8691 { HCBT_SETFOCUS, hook },
8694 static const struct message WmShowMaximized_3[] = {
8695 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
8696 { WM_GETMINMAXINFO, sent },
8697 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8698 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|0x8000 },
8699 { WM_MOVE, sent|defwinproc },
8700 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
8704 static void test_ShowWindow(void)
8706 /* ShowWindow commands in random order */
8709 INT cmd; /* ShowWindow command */
8710 LPARAM ret; /* ShowWindow return value */
8711 DWORD style; /* window style after the command */
8712 const struct message *msg; /* message sequence the command produces */
8713 BOOL todo_msg; /* message sequence doesn't match what Wine does */
8716 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
8717 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8718 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
8719 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8720 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
8721 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
8722 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
8723 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
8724 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
8725 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
8726 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
8727 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
8728 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
8729 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8730 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
8731 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8732 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
8733 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8734 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, TRUE },
8735 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
8736 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8737 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
8738 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
8739 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8740 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
8741 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
8742 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
8743 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8744 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
8745 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
8746 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8747 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, TRUE },
8748 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8749 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, TRUE }, /* what does this mean?! */
8750 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, TRUE },
8751 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8752 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
8753 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8754 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8755 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, TRUE },
8756 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
8757 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
8758 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
8759 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, TRUE },
8760 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
8761 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
8762 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
8763 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
8764 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
8765 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
8766 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
8767 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
8768 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
8769 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, TRUE },
8770 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
8771 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
8772 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
8779 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
8780 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
8785 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
8786 ok(style == 0, "expected style 0, got %08x\n", style);
8791 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
8793 static const char * const sw_cmd_name[13] =
8795 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
8796 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
8797 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
8798 "SW_NORMALNA" /* 0xCC */
8801 INT idx; /* index into the above array of names */
8803 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
8805 style = GetWindowLong(hwnd, GWL_STYLE);
8806 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
8807 ret = ShowWindow(hwnd, sw[i].cmd);
8808 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
8809 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
8810 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
8812 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
8813 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
8819 DestroyWindow(hwnd);
8822 static const struct message WmDefDlgSetFocus_1[] = {
8823 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
8824 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
8825 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
8826 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
8827 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
8828 { HCBT_SETFOCUS, hook },
8829 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8830 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8831 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8832 { WM_SETFOCUS, sent|wparam, 0 },
8833 { WM_CTLCOLOREDIT, sent },
8834 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8835 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8836 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8837 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
8840 static const struct message WmDefDlgSetFocus_2[] = {
8841 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
8842 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
8843 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
8844 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
8845 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
8849 static void test_dialog_messages(void)
8851 HWND hdlg, hedit1, hedit2, hfocus;
8854 #define set_selection(hctl, start, end) \
8855 ret = SendMessage(hctl, EM_SETSEL, start, end); \
8856 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
8858 #define check_selection(hctl, start, end) \
8859 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
8860 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
8864 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
8865 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
8866 0, 0, 100, 100, 0, 0, 0, NULL);
8867 ok(hdlg != 0, "Failed to create custom dialog window\n");
8869 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
8870 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
8871 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
8872 ok(hedit1 != 0, "Failed to create edit control\n");
8873 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
8874 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
8875 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
8876 ok(hedit2 != 0, "Failed to create edit control\n");
8878 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
8879 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
8881 hfocus = GetFocus();
8882 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
8885 hfocus = GetFocus();
8886 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
8888 check_selection(hedit1, 0, 0);
8889 check_selection(hedit2, 0, 0);
8891 set_selection(hedit2, 0, -1);
8892 check_selection(hedit2, 0, 3);
8895 hfocus = GetFocus();
8896 ok(hfocus == 0, "wrong focus %p\n", hfocus);
8899 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
8900 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
8901 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
8903 hfocus = GetFocus();
8904 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
8906 check_selection(hedit1, 0, 5);
8907 check_selection(hedit2, 0, 3);
8910 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
8911 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
8912 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
8914 hfocus = GetFocus();
8915 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
8917 check_selection(hedit1, 0, 5);
8918 check_selection(hedit2, 0, 3);
8922 #undef set_selection
8923 #undef check_selection
8926 static void test_nullCallback(void)
8931 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
8932 100, 100, 200, 200, 0, 0, 0, NULL);
8933 ok (hwnd != 0, "Failed to create overlapped window\n");
8935 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
8936 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
8937 DestroyWindow(hwnd);
8943 HMODULE user32 = GetModuleHandleA("user32.dll");
8944 FARPROC pSetWinEventHook = GetProcAddress(user32, "SetWinEventHook");
8945 FARPROC pUnhookWinEvent = GetProcAddress(user32, "UnhookWinEvent");
8946 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
8947 pGetAncestor = (void*) GetProcAddress(user32, "GetAncestor");
8949 if (!RegisterWindowClasses()) assert(0);
8951 if (pSetWinEventHook)
8953 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8954 GetModuleHandleA(0),
8957 GetCurrentThreadId(),
8958 WINEVENT_INCONTEXT);
8959 assert(hEvent_hook);
8961 if (pIsWinEventHookInstalled)
8964 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
8965 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
8969 cbt_hook_thread_id = GetCurrentThreadId();
8970 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
8975 /* Fix message sequences before removing 4 lines below */
8977 if (pUnhookWinEvent && hEvent_hook)
8979 ret = pUnhookWinEvent(hEvent_hook);
8980 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8981 pUnhookWinEvent = 0;
8988 test_scrollwindowex();
8991 invisible_parent_tests();
8992 test_mdi_messages();
8993 test_button_messages();
8994 test_static_messages();
8995 test_paint_messages();
8996 test_interthread_messages();
8997 test_message_conversion();
8998 test_accelerators();
9001 test_DestroyWindow();
9002 test_DispatchMessage();
9003 test_SendMessageTimeout();
9004 test_edit_messages();
9005 test_quit_message();
9006 test_TrackMouseEvent();
9007 test_SetWindowRgn();
9009 test_dialog_messages();
9010 test_nullCallback();
9012 UnhookWindowsHookEx(hCBT_hook);
9013 if (pUnhookWinEvent)
9015 ret = pUnhookWinEvent(hEvent_hook);
9016 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
9017 SetLastError(0xdeadbeef);
9018 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
9019 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
9020 GetLastError() == 0xdeadbeef, /* Win9x */
9021 "unexpected error %d\n", GetLastError());