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
23 #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
42 #define SWP_STATECHANGED 0x8000
44 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
47 #define WM_KEYF1 0x004d
51 #define WM_SYSTIMER 0x0118
54 #define WND_PARENT_ID 1
55 #define WND_POPUP_ID 2
56 #define WND_CHILD_ID 3
58 #ifndef WM_LBTRACKPOINT
59 #define WM_LBTRACKPOINT 0x0131
62 /* encoded DRAWITEMSTRUCT into an LPARAM */
69 UINT type : 4; /* ODT_* flags */
70 UINT ctl_id : 4; /* Control ID */
71 UINT item_id : 4; /* Menu item ID */
72 UINT action : 4; /* ODA_* flags */
73 UINT state : 16; /* ODS_* flags */
79 static BOOL test_DestroyWindow_flag;
80 static HWINEVENTHOOK hEvent_hook;
81 static HHOOK hCBT_hook;
82 static DWORD cbt_hook_thread_id;
84 static const WCHAR testWindowClassW[] =
85 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
88 FIXME: add tests for these
89 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
90 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
91 WS_THICKFRAME: thick border
92 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
93 WS_BORDER (default for overlapped windows): single black border
94 none (default for child (and popup?) windows): no border
111 UINT message; /* the WM_* code */
112 msg_flags_t flags; /* message props */
113 WPARAM wParam; /* expected value of wParam */
114 LPARAM lParam; /* expected value of lParam */
115 WPARAM wp_mask; /* mask for wParam checks */
116 LPARAM lp_mask; /* mask for lParam checks */
119 struct recvd_message {
120 UINT message; /* the WM_* code */
121 msg_flags_t flags; /* message props */
122 HWND hwnd; /* window that received the message */
123 WPARAM wParam; /* expected value of wParam */
124 LPARAM lParam; /* expected value of lParam */
125 int line; /* source line where logged */
126 const char *descr; /* description for trace output */
127 char output[512]; /* trace output */
130 /* Empty message sequence */
131 static const struct message WmEmptySeq[] =
135 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
136 static const struct message WmCreateOverlappedSeq[] = {
137 { HCBT_CREATEWND, hook },
138 { WM_GETMINMAXINFO, sent },
139 { WM_NCCREATE, sent },
140 { WM_NCCALCSIZE, sent|wparam, 0 },
141 { 0x0093, sent|defwinproc|optional },
142 { 0x0094, sent|defwinproc|optional },
143 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
145 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
148 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
149 * for a not visible overlapped window.
151 static const struct message WmSWP_ShowOverlappedSeq[] = {
152 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
153 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
154 { WM_NCPAINT, sent|wparam|optional, 1 },
155 { WM_GETTEXT, sent|defwinproc|optional },
156 { WM_ERASEBKGND, sent|optional },
157 { HCBT_ACTIVATE, hook },
158 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
159 { WM_NOTIFYFORMAT, sent|optional },
160 { WM_QUERYUISTATE, sent|optional },
161 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
162 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
163 { WM_ACTIVATEAPP, sent|wparam, 1 },
164 { WM_NCACTIVATE, sent|wparam, 1 },
165 { WM_GETTEXT, sent|defwinproc|optional },
166 { WM_ACTIVATE, sent|wparam, 1 },
167 { HCBT_SETFOCUS, hook },
168 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
169 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
170 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
171 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
172 { WM_GETTEXT, sent|optional },
173 { WM_NCPAINT, sent|wparam|optional, 1 },
174 { WM_GETTEXT, sent|defwinproc|optional },
175 { WM_ERASEBKGND, sent|optional },
176 /* Win9x adds SWP_NOZORDER below */
177 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
178 { WM_GETTEXT, sent|optional },
179 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
180 { WM_NCPAINT, sent|wparam|optional, 1 },
181 { WM_ERASEBKGND, sent|optional },
182 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
183 { WM_PAINT, sent|optional },
184 { WM_NCPAINT, sent|beginpaint|optional },
185 { WM_ERASEBKGND, sent|beginpaint|optional },
188 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
189 * for a visible overlapped window.
191 static const struct message WmSWP_HideOverlappedSeq[] = {
192 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
193 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
194 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
198 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
199 * for a visible overlapped window.
201 static const struct message WmSWP_ResizeSeq[] = {
202 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
203 { WM_GETMINMAXINFO, sent|defwinproc },
204 { WM_NCCALCSIZE, sent|wparam, TRUE },
205 { WM_NCPAINT, sent|optional },
206 { WM_GETTEXT, sent|defwinproc|optional },
207 { WM_ERASEBKGND, sent|optional },
208 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
209 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
210 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
211 { WM_NCPAINT, sent|optional },
212 { WM_GETTEXT, sent|defwinproc|optional },
213 { WM_ERASEBKGND, sent|optional },
214 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
215 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
219 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
220 * for a visible popup window.
222 static const struct message WmSWP_ResizePopupSeq[] = {
223 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
224 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
225 { WM_NCCALCSIZE, sent|wparam, TRUE },
226 { WM_NCPAINT, sent|optional },
227 { WM_GETTEXT, sent|defwinproc|optional },
228 { WM_ERASEBKGND, sent|optional },
229 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
230 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
231 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
232 { WM_NCPAINT, sent|optional },
233 { WM_GETTEXT, sent|defwinproc|optional },
234 { WM_ERASEBKGND, sent|optional },
235 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
239 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
240 * for a visible overlapped window.
242 static const struct message WmSWP_MoveSeq[] = {
243 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
244 { WM_NCPAINT, sent|optional },
245 { WM_GETTEXT, sent|defwinproc|optional },
246 { WM_ERASEBKGND, sent|optional },
247 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
248 { WM_MOVE, sent|defwinproc|wparam, 0 },
249 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
252 /* Resize with SetWindowPos(SWP_NOZORDER)
253 * for a visible overlapped window
254 * SWP_NOZORDER is stripped by the logging code
256 static const struct message WmSWP_ResizeNoZOrder[] = {
257 { WM_WINDOWPOSCHANGING, sent|wparam, /*SWP_NOZORDER|*/SWP_NOACTIVATE },
258 { WM_GETMINMAXINFO, sent|defwinproc },
259 { WM_NCCALCSIZE, sent|wparam, 1 },
260 { WM_NCPAINT, sent },
261 { WM_GETTEXT, sent|defwinproc|optional },
262 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
263 { WM_WINDOWPOSCHANGED, sent|wparam, /*SWP_NOZORDER|*/SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE },
264 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
265 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
266 { WM_NCPAINT, sent|optional }, /* Win9x doesn't send it */
267 { WM_GETTEXT, sent|defwinproc|optional }, /* Win9x doesn't send it */
268 { WM_ERASEBKGND, sent|optional }, /* Win9x doesn't send it */
269 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
270 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
274 /* Switch visible mdi children */
275 static const struct message WmSwitchChild[] = {
276 /* Switch MDI child */
277 { WM_MDIACTIVATE, sent },/* in the MDI client */
278 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 1st MDI child */
279 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
280 { WM_CHILDACTIVATE, sent },/* in the 1st MDI child */
281 /* Deactivate 2nd MDI child */
282 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
283 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
284 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
285 /* Preparing for maximize and maximaze the 1st MDI child */
286 { WM_GETMINMAXINFO, sent|defwinproc }, /* in the 1st MDI child */
287 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED }, /* in the 1st MDI child */
288 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
289 { WM_CHILDACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
290 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 1st MDI child */
291 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, /* in the 1st MDI child */
292 /* Lock redraw 2nd MDI child */
293 { WM_SETREDRAW, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
294 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
295 /* Restore 2nd MDI child */
296 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },/* in the 2nd MDI child */
297 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
298 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
299 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 2nd MDI child */
300 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, /* in the 2nd MDI child */
301 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
302 /* Redraw 2nd MDI child */
303 { WM_SETREDRAW, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
304 /* Redraw MDI frame */
305 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },/* in MDI frame */
306 { WM_NCCALCSIZE, sent|wparam, 1 },/* in MDI frame */
307 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in MDI frame */
308 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in MDI frame */
309 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
310 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
311 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
312 { HCBT_SETFOCUS, hook },
313 { WM_KILLFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
314 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },/* in the 1st MDI child */
315 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
316 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
317 { WM_SETFOCUS, sent },/* in the MDI client */
318 { HCBT_SETFOCUS, hook },
319 { WM_KILLFOCUS, sent },/* in the MDI client */
320 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
321 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, /* in the 1st MDI child */
322 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
323 { WM_SETFOCUS, sent|defwinproc }, /* in the 1st MDI child */
324 { WM_MDIACTIVATE, sent|defwinproc },/* in the 1st MDI child */
325 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* in the 1st MDI child */
329 /* Switch visible not maximized mdi children */
330 static const struct message WmSwitchNotMaximizedChild[] = {
331 /* Switch not maximized MDI child */
332 { WM_MDIACTIVATE, sent },/* in the MDI client */
333 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 2nd MDI child */
334 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
335 { WM_CHILDACTIVATE, sent },/* in the 2nd MDI child */
336 /* Deactivate 1st MDI child */
337 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
338 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
339 /* Activate 2nd MDI child */
340 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE}, /* in the 2nd MDI child */
341 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 2nd MDI child */
342 { HCBT_SETFOCUS, hook }, /* in the 1st MDI child */
343 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
344 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
345 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
346 { WM_SETFOCUS, sent, 0 }, /* in the MDI client */
347 { HCBT_SETFOCUS, hook },
348 { WM_KILLFOCUS, sent }, /* in the MDI client */
349 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
350 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
351 { WM_SETFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
352 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
353 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in the 2nd MDI child */
358 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
359 SWP_NOZORDER|SWP_FRAMECHANGED)
360 * for a visible overlapped window with WS_CLIPCHILDREN style set.
362 static const struct message WmSWP_FrameChanged_clip[] = {
363 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
364 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
365 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
366 { WM_GETTEXT, sent|parent|defwinproc|optional },
367 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
368 { WM_NCPAINT, sent }, /* wparam != 1 */
369 { WM_ERASEBKGND, sent },
370 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
371 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
375 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
376 SWP_NOZORDER|SWP_FRAMECHANGED)
377 * for a visible overlapped window.
379 static const struct message WmSWP_FrameChangedDeferErase[] = {
380 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
381 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
382 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
383 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
384 { WM_PAINT, sent|parent },
385 { WM_NCPAINT, sent|beginpaint|parent }, /* wparam != 1 */
386 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
388 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
389 { WM_ERASEBKGND, sent|beginpaint },
393 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
394 SWP_NOZORDER|SWP_FRAMECHANGED)
395 * for a visible overlapped window without WS_CLIPCHILDREN style set.
397 static const struct message WmSWP_FrameChanged_noclip[] = {
398 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
399 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
400 { WM_NCPAINT, sent|parent }, /* wparam != 1 */
401 { WM_GETTEXT, sent|parent|defwinproc|optional },
402 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
403 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
404 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
406 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
407 { WM_ERASEBKGND, sent|beginpaint },
411 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
412 static const struct message WmShowOverlappedSeq[] = {
413 { WM_SHOWWINDOW, sent|wparam, 1 },
414 { WM_NCPAINT, sent|wparam|optional, 1 },
415 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
416 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
417 { WM_NCPAINT, sent|wparam|optional, 1 },
418 { WM_GETTEXT, sent|defwinproc|optional },
419 { WM_ERASEBKGND, sent|optional },
420 { HCBT_ACTIVATE, hook },
421 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
422 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
423 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
424 { WM_NCPAINT, sent|wparam|optional, 1 },
425 { WM_ACTIVATEAPP, sent|wparam, 1 },
426 { WM_NCACTIVATE, sent|wparam, 1 },
427 { WM_GETTEXT, sent|defwinproc|optional },
428 { WM_ACTIVATE, sent|wparam, 1 },
429 { HCBT_SETFOCUS, hook },
430 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
431 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
432 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
433 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
434 { WM_GETTEXT, sent|optional },
435 { WM_NCPAINT, sent|wparam|optional, 1 },
436 { WM_GETTEXT, sent|defwinproc|optional },
437 { WM_ERASEBKGND, sent|optional },
438 /* Win9x adds SWP_NOZORDER below */
439 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
440 { WM_NCCALCSIZE, sent|optional },
441 { WM_GETTEXT, sent|optional },
442 { WM_NCPAINT, sent|optional },
443 { WM_ERASEBKGND, sent|optional },
444 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
445 * messages. Does that mean that CreateWindow doesn't set initial
446 * window dimensions for overlapped windows?
451 { WM_PAINT, sent|optional },
452 { WM_NCPAINT, sent|beginpaint|optional },
455 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
456 static const struct message WmShowMaxOverlappedSeq[] = {
457 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
458 { WM_GETMINMAXINFO, sent },
459 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
460 { WM_GETMINMAXINFO, sent|defwinproc },
461 { WM_NCCALCSIZE, sent|wparam, TRUE },
462 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
463 { HCBT_ACTIVATE, hook },
464 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
465 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
466 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
467 { WM_ACTIVATEAPP, sent|wparam, 1 },
468 { WM_NCACTIVATE, sent|wparam, 1 },
469 { WM_GETTEXT, sent|defwinproc|optional },
470 { WM_ACTIVATE, sent|wparam, 1 },
471 { HCBT_SETFOCUS, hook },
472 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
473 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
474 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
475 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
476 { WM_GETTEXT, sent|optional },
477 { WM_NCPAINT, sent|wparam|optional, 1 },
478 { WM_GETTEXT, sent|defwinproc|optional },
479 { WM_ERASEBKGND, sent|optional },
480 /* Win9x adds SWP_NOZORDER below */
481 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
482 { WM_MOVE, sent|defwinproc },
483 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
484 { WM_GETTEXT, sent|optional },
485 { WM_NCCALCSIZE, sent|optional },
486 { WM_NCPAINT, sent|optional },
487 { WM_ERASEBKGND, sent|optional },
488 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
489 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
490 { WM_PAINT, sent|optional },
491 { WM_NCPAINT, sent|beginpaint|optional },
492 { WM_ERASEBKGND, sent|beginpaint|optional },
495 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
496 static const struct message WmShowRestoreMaxOverlappedSeq[] = {
497 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
498 { WM_GETTEXT, sent|optional },
499 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
500 { WM_GETMINMAXINFO, sent|defwinproc },
501 { WM_NCCALCSIZE, sent|wparam, TRUE },
502 { WM_NCPAINT, sent|optional },
503 { WM_GETTEXT, sent|defwinproc|optional },
504 { WM_ERASEBKGND, sent|optional },
505 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
506 { WM_MOVE, sent|defwinproc|optional },
507 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
508 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
509 { WM_NCPAINT, sent|optional },
510 { WM_ERASEBKGND, sent|optional },
511 { WM_PAINT, sent|optional },
512 { WM_NCPAINT, sent|beginpaint|optional },
513 { WM_ERASEBKGND, sent|beginpaint|optional },
516 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
517 static const struct message WmShowRestoreMinOverlappedSeq[] = {
518 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
519 { WM_QUERYOPEN, sent|optional },
520 { WM_GETTEXT, sent|optional },
521 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED|SWP_NOCOPYBITS },
522 { WM_GETMINMAXINFO, sent|defwinproc },
523 { WM_NCCALCSIZE, sent|wparam, TRUE },
524 { HCBT_ACTIVATE, hook },
525 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
526 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
527 { WM_ACTIVATEAPP, sent|wparam, 1 },
528 { WM_NCACTIVATE, sent|wparam, 1 },
529 { WM_GETTEXT, sent|defwinproc|optional },
530 { WM_ACTIVATE, sent|wparam, 1 },
531 { HCBT_SETFOCUS, hook },
532 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
533 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
534 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
535 { WM_GETTEXT, sent|optional },
536 { WM_NCPAINT, sent|wparam|optional, 1 },
537 { WM_GETTEXT, sent|defwinproc|optional },
538 { WM_ERASEBKGND, sent },
539 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_STATECHANGED|SWP_FRAMECHANGED|SWP_NOCOPYBITS },
540 { WM_MOVE, sent|defwinproc },
541 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
542 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
543 { WM_NCPAINT, sent|wparam|optional, 1 },
544 { WM_ERASEBKGND, sent|optional },
545 { WM_ACTIVATE, sent|wparam, 1 },
546 { WM_GETTEXT, sent|optional },
547 { WM_PAINT, sent|optional },
548 { WM_NCPAINT, sent|beginpaint|optional },
549 { WM_ERASEBKGND, sent|beginpaint|optional },
552 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
553 static const struct message WmShowMinOverlappedSeq[] = {
554 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
555 { HCBT_SETFOCUS, hook },
556 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
557 { WM_KILLFOCUS, sent },
558 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
559 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
560 { WM_GETTEXT, sent|optional },
561 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
562 { WM_GETMINMAXINFO, sent|defwinproc },
563 { WM_NCCALCSIZE, sent|wparam, TRUE },
564 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
565 { WM_NCPAINT, sent|optional },
566 { WM_GETTEXT, sent|defwinproc|optional },
567 { WM_WINDOWPOSCHANGED, sent },
568 { WM_MOVE, sent|defwinproc },
569 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
570 { WM_NCCALCSIZE, sent|optional },
571 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
572 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
573 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
574 { WM_NCACTIVATE, sent|wparam, 0 },
575 { WM_GETTEXT, sent|defwinproc|optional },
576 { WM_ACTIVATE, sent },
577 { WM_ACTIVATEAPP, sent|wparam, 0 },
578 { WM_PAINT, sent|optional },
579 { WM_NCPAINT, sent|beginpaint|optional },
580 { WM_ERASEBKGND, sent|beginpaint|optional },
583 /* ShowWindow(SW_HIDE) for a visible overlapped window */
584 static const struct message WmHideOverlappedSeq[] = {
585 { WM_SHOWWINDOW, sent|wparam, 0 },
586 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
587 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
588 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
589 { WM_SIZE, sent|optional }, /* XP doesn't send it */
590 { WM_MOVE, sent|optional }, /* XP doesn't send it */
591 { WM_NCACTIVATE, sent|wparam, 0 },
592 { WM_ACTIVATE, sent|wparam, 0 },
593 { WM_ACTIVATEAPP, sent|wparam, 0 },
594 { WM_KILLFOCUS, sent|wparam, 0 },
595 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
596 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
599 /* DestroyWindow for a visible overlapped window */
600 static const struct message WmDestroyOverlappedSeq[] = {
601 { HCBT_DESTROYWND, hook },
602 { 0x0090, sent|optional },
603 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
604 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
605 { 0x0090, sent|optional },
606 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
607 { WM_NCACTIVATE, sent|optional|wparam, 0 },
608 { WM_ACTIVATE, sent|optional|wparam, 0 },
609 { WM_ACTIVATEAPP, sent|optional|wparam, 0 },
610 { WM_KILLFOCUS, sent|optional|wparam, 0 },
611 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
612 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
613 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
614 { WM_DESTROY, sent },
615 { WM_NCDESTROY, sent },
618 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
619 static const struct message WmCreateMaxPopupSeq[] = {
620 { HCBT_CREATEWND, hook },
621 { WM_NCCREATE, sent },
622 { WM_NCCALCSIZE, sent|wparam, 0 },
624 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
625 { WM_SIZE, sent|wparam, SIZE_RESTORED },
627 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
628 { WM_GETMINMAXINFO, sent },
629 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
630 { WM_NCCALCSIZE, sent|wparam, TRUE },
631 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
632 { WM_MOVE, sent|defwinproc },
633 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
634 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
635 { WM_SHOWWINDOW, sent|wparam, 1 },
636 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
637 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
638 { HCBT_ACTIVATE, hook },
639 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
640 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
641 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
642 { WM_NCPAINT, sent|wparam|optional, 1 },
643 { WM_ERASEBKGND, sent|optional },
644 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_NOMOVE|SWP_NOSIZE },
645 { WM_ACTIVATEAPP, sent|wparam, 1 },
646 { WM_NCACTIVATE, sent|wparam, 1 },
647 { WM_ACTIVATE, sent|wparam, 1 },
648 { HCBT_SETFOCUS, hook },
649 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
650 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
651 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
652 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
653 { WM_GETTEXT, sent|optional },
654 { WM_SYNCPAINT, sent|wparam|optional, 4 },
655 { WM_NCPAINT, sent|wparam|optional, 1 },
656 { WM_ERASEBKGND, sent|optional },
657 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
660 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
661 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
662 { HCBT_CREATEWND, hook },
663 { WM_NCCREATE, sent },
664 { WM_NCCALCSIZE, sent|wparam, 0 },
666 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
667 { WM_SIZE, sent|wparam, SIZE_RESTORED },
669 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
670 { WM_GETMINMAXINFO, sent },
671 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
672 { WM_NCCALCSIZE, sent|wparam, TRUE },
673 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
674 { WM_MOVE, sent|defwinproc },
675 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
676 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
679 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
680 static const struct message WmShowMaxPopupResizedSeq[] = {
681 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
682 { WM_GETMINMAXINFO, sent },
683 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
684 { WM_NCCALCSIZE, sent|wparam, TRUE },
685 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
686 { HCBT_ACTIVATE, hook },
687 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
688 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
689 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
690 { WM_ACTIVATEAPP, sent|wparam, 1 },
691 { WM_NCACTIVATE, sent|wparam, 1 },
692 { WM_ACTIVATE, sent|wparam, 1 },
693 { HCBT_SETFOCUS, hook },
694 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
695 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
696 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
697 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
698 { WM_GETTEXT, sent|optional },
699 { WM_NCPAINT, sent|wparam|optional, 1 },
700 { WM_ERASEBKGND, sent|optional },
701 { WM_WINDOWPOSCHANGED, sent },
702 /* WinNT4.0 sends WM_MOVE */
703 { WM_MOVE, sent|defwinproc|optional },
704 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
705 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
708 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
709 static const struct message WmShowMaxPopupSeq[] = {
710 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
711 { WM_GETMINMAXINFO, sent },
712 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
713 { WM_NCCALCSIZE, sent|wparam, TRUE },
714 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
715 { HCBT_ACTIVATE, hook },
716 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
717 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
718 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
719 { WM_ACTIVATEAPP, sent|wparam, 1 },
720 { WM_NCACTIVATE, sent|wparam, 1 },
721 { WM_ACTIVATE, sent|wparam, 1 },
722 { HCBT_SETFOCUS, hook },
723 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
724 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
725 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
726 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
727 { WM_GETTEXT, sent|optional },
728 { WM_SYNCPAINT, sent|wparam|optional, 4 },
729 { WM_NCPAINT, sent|wparam|optional, 1 },
730 { WM_ERASEBKGND, sent|optional },
731 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
732 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
735 /* CreateWindow(WS_VISIBLE) for popup window */
736 static const struct message WmCreatePopupSeq[] = {
737 { HCBT_CREATEWND, hook },
738 { WM_NCCREATE, sent },
739 { WM_NCCALCSIZE, sent|wparam, 0 },
741 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
742 { WM_SIZE, sent|wparam, SIZE_RESTORED },
744 { WM_SHOWWINDOW, sent|wparam, 1 },
745 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
746 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
747 { HCBT_ACTIVATE, hook },
748 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
749 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
750 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
751 { WM_NCPAINT, sent|wparam|optional, 1 },
752 { WM_ERASEBKGND, sent|optional },
753 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
754 { WM_ACTIVATEAPP, sent|wparam, 1 },
755 { WM_NCACTIVATE, sent|wparam, 1 },
756 { WM_ACTIVATE, sent|wparam, 1 },
757 { HCBT_SETFOCUS, hook },
758 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
759 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
760 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
761 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
762 { WM_GETTEXT, sent|optional },
763 { WM_SYNCPAINT, sent|wparam|optional, 4 },
764 { WM_NCPAINT, sent|wparam|optional, 1 },
765 { WM_ERASEBKGND, sent|optional },
766 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
769 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
770 static const struct message WmShowVisMaxPopupSeq[] = {
771 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
772 { WM_GETMINMAXINFO, sent },
773 { WM_GETTEXT, sent|optional },
774 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
775 { WM_GETTEXT, sent|optional },
776 { WM_NCCALCSIZE, sent|wparam, TRUE },
777 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
778 { WM_NCPAINT, sent|wparam|optional, 1 },
779 { WM_ERASEBKGND, sent|optional },
780 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
781 { WM_MOVE, sent|defwinproc },
782 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
783 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
786 /* CreateWindow (for a child popup window, not initially visible) */
787 static const struct message WmCreateChildPopupSeq[] = {
788 { HCBT_CREATEWND, hook },
789 { WM_NCCREATE, sent },
790 { WM_NCCALCSIZE, sent|wparam, 0 },
792 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
793 { WM_SIZE, sent|wparam, SIZE_RESTORED },
797 /* CreateWindow (for a popup window, not initially visible,
798 * which sets WS_VISIBLE in WM_CREATE handler)
800 static const struct message WmCreateInvisiblePopupSeq[] = {
801 { HCBT_CREATEWND, hook },
802 { WM_NCCREATE, sent },
803 { WM_NCCALCSIZE, sent|wparam, 0 },
805 { WM_STYLECHANGING, sent },
806 { WM_STYLECHANGED, sent },
807 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
808 { WM_SIZE, sent|wparam, SIZE_RESTORED },
812 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
813 * for a popup window with WS_VISIBLE style set
815 static const struct message WmShowVisiblePopupSeq_2[] = {
816 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
819 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
820 * for a popup window with WS_VISIBLE style set
822 static const struct message WmShowVisiblePopupSeq_3[] = {
823 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
824 { HCBT_ACTIVATE, hook },
825 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
826 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
827 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
828 { WM_NCACTIVATE, sent|wparam, 1 },
829 { WM_ACTIVATE, sent|wparam, 1 },
830 { HCBT_SETFOCUS, hook },
831 { WM_KILLFOCUS, sent|parent },
832 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
833 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
834 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
835 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
836 { WM_SETFOCUS, sent|defwinproc },
837 { WM_GETTEXT, sent|optional },
838 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
841 /* CreateWindow (for child window, not initially visible) */
842 static const struct message WmCreateChildSeq[] = {
843 { HCBT_CREATEWND, hook },
844 { WM_NCCREATE, sent },
845 /* child is inserted into parent's child list after WM_NCCREATE returns */
846 { WM_NCCALCSIZE, sent|wparam, 0 },
848 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
849 { WM_SIZE, sent|wparam, SIZE_RESTORED },
851 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
854 /* CreateWindow (for maximized child window, not initially visible) */
855 static const struct message WmCreateMaximizedChildSeq[] = {
856 { HCBT_CREATEWND, hook },
857 { WM_NCCREATE, sent },
858 { WM_NCCALCSIZE, sent|wparam, 0 },
860 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
861 { WM_SIZE, sent|wparam, SIZE_RESTORED },
863 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
864 { WM_GETMINMAXINFO, sent },
865 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
866 { WM_NCCALCSIZE, sent|wparam, 1 },
867 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
868 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
869 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
870 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
873 /* CreateWindow (for a child window, initially visible) */
874 static const struct message WmCreateVisibleChildSeq[] = {
875 { HCBT_CREATEWND, hook },
876 { WM_NCCREATE, sent },
877 /* child is inserted into parent's child list after WM_NCCREATE returns */
878 { WM_NCCALCSIZE, sent|wparam, 0 },
879 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
881 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
882 { WM_SIZE, sent|wparam, SIZE_RESTORED },
884 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
885 { WM_SHOWWINDOW, sent|wparam, 1 },
886 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
887 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
888 { WM_ERASEBKGND, sent|parent|optional },
889 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
890 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
891 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
894 /* ShowWindow(SW_SHOW) for a not visible child window */
895 static const struct message WmShowChildSeq[] = {
896 { WM_SHOWWINDOW, sent|wparam, 1 },
897 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
898 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
899 { WM_ERASEBKGND, sent|parent|optional },
900 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
903 /* ShowWindow(SW_HIDE) for a visible child window */
904 static const struct message WmHideChildSeq[] = {
905 { WM_SHOWWINDOW, sent|wparam, 0 },
906 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
907 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
908 { WM_ERASEBKGND, sent|parent|optional },
909 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
912 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
913 static const struct message WmHideChildSeq2[] = {
914 { WM_SHOWWINDOW, sent|wparam, 0 },
915 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
916 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
917 { WM_ERASEBKGND, sent|parent },
918 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
921 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
922 * for a not visible child window
924 static const struct message WmShowChildSeq_2[] = {
925 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
926 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
927 { WM_CHILDACTIVATE, sent },
928 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
931 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
932 * for a not visible child window
934 static const struct message WmShowChildSeq_3[] = {
935 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
936 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
937 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
940 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
941 * for a visible child window with a caption
943 static const struct message WmShowChildSeq_4[] = {
944 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
945 { WM_CHILDACTIVATE, sent },
948 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
949 static const struct message WmShowChildInvisibleParentSeq_1[] = {
950 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
951 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE },
952 { WM_NCCALCSIZE, sent|wparam, 1 },
953 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
954 { WM_CHILDACTIVATE, sent|optional },
955 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE },
956 { WM_MOVE, sent|defwinproc },
957 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
958 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
959 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
960 /* FIXME: Wine creates an icon/title window while Windows doesn't */
961 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
962 { WM_GETTEXT, sent|optional },
965 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
966 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
967 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
970 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
971 static const struct message WmShowChildInvisibleParentSeq_2[] = {
972 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
973 { WM_GETMINMAXINFO, sent },
974 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
975 { WM_NCCALCSIZE, sent|wparam, 1 },
976 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
977 { WM_CHILDACTIVATE, sent },
978 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
979 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
980 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
983 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
984 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
985 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
988 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
989 static const struct message WmShowChildInvisibleParentSeq_3[] = {
990 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
991 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
992 { WM_NCCALCSIZE, sent|wparam, 1 },
993 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
994 { WM_CHILDACTIVATE, sent },
995 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
996 { WM_MOVE, sent|defwinproc },
997 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
998 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
999 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1000 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1001 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1002 { WM_GETTEXT, sent|optional },
1005 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1006 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
1007 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
1010 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1011 static const struct message WmShowChildInvisibleParentSeq_4[] = {
1012 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
1013 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
1014 { WM_NCCALCSIZE, sent|wparam, 1 },
1015 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1016 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
1017 { WM_MOVE, sent|defwinproc },
1018 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
1019 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1020 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1021 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1022 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1023 { WM_GETTEXT, sent|optional },
1026 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1027 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
1028 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
1031 /* ShowWindow(SW_SHOW) for child with invisible parent */
1032 static const struct message WmShowChildInvisibleParentSeq_5[] = {
1033 { WM_SHOWWINDOW, sent|wparam, 1 },
1036 /* ShowWindow(SW_HIDE) for child with invisible parent */
1037 static const struct message WmHideChildInvisibleParentSeq[] = {
1038 { WM_SHOWWINDOW, sent|wparam, 0 },
1041 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1042 static const struct message WmShowChildInvisibleParentSeq_6[] = {
1043 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1044 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1045 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1048 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1049 static const struct message WmHideChildInvisibleParentSeq_2[] = {
1050 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1051 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1052 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1055 /* DestroyWindow for a visible child window */
1056 static const struct message WmDestroyChildSeq[] = {
1057 { HCBT_DESTROYWND, hook },
1058 { 0x0090, sent|optional },
1059 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1060 { WM_SHOWWINDOW, sent|wparam, 0 },
1061 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1062 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1063 { WM_ERASEBKGND, sent|parent|optional },
1064 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1065 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
1066 { WM_KILLFOCUS, sent },
1067 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1068 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
1069 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1070 { WM_SETFOCUS, sent|parent },
1071 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1072 { WM_DESTROY, sent },
1073 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
1074 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
1075 { WM_NCDESTROY, sent },
1078 /* DestroyWindow for a visible child window with invisible parent */
1079 static const struct message WmDestroyInvisibleChildSeq[] = {
1080 { HCBT_DESTROYWND, hook },
1081 { 0x0090, sent|optional },
1082 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1083 { WM_SHOWWINDOW, sent|wparam, 0 },
1084 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1085 { WM_DESTROY, sent },
1086 { WM_NCDESTROY, sent },
1089 /* Moving the mouse in nonclient area */
1090 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
1091 { WM_NCHITTEST, sent },
1092 { WM_SETCURSOR, sent },
1093 { WM_NCMOUSEMOVE, posted },
1096 /* Moving the mouse in client area */
1097 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
1098 { WM_NCHITTEST, sent },
1099 { WM_SETCURSOR, sent },
1100 { WM_MOUSEMOVE, posted },
1103 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1104 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
1105 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
1106 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
1107 { WM_GETMINMAXINFO, sent|defwinproc },
1108 { WM_ENTERSIZEMOVE, sent|defwinproc },
1109 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1110 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1111 { WM_MOVE, sent|defwinproc },
1112 { WM_EXITSIZEMOVE, sent|defwinproc },
1115 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1116 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
1117 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
1118 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
1119 { WM_GETMINMAXINFO, sent|defwinproc },
1120 { WM_ENTERSIZEMOVE, sent|defwinproc },
1121 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
1122 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1123 { WM_GETMINMAXINFO, sent|defwinproc },
1124 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1125 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
1126 { WM_GETTEXT, sent|defwinproc },
1127 { WM_ERASEBKGND, sent|defwinproc },
1128 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1129 { WM_MOVE, sent|defwinproc },
1130 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1131 { WM_EXITSIZEMOVE, sent|defwinproc },
1134 /* Resizing child window with MoveWindow (32) */
1135 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1136 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1137 { WM_NCCALCSIZE, sent|wparam, 1 },
1138 { WM_ERASEBKGND, sent|parent|optional },
1139 { WM_ERASEBKGND, sent|optional },
1140 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1141 { WM_MOVE, sent|defwinproc },
1142 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1143 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1146 /* Clicking on inactive button */
1147 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
1148 { WM_NCHITTEST, sent },
1149 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
1150 { WM_MOUSEACTIVATE, sent },
1151 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
1152 { WM_SETCURSOR, sent },
1153 { WM_SETCURSOR, sent|parent|defwinproc },
1154 { WM_LBUTTONDOWN, posted },
1155 { WM_KILLFOCUS, posted|parent },
1156 { WM_SETFOCUS, posted },
1157 { WM_CTLCOLORBTN, posted|parent },
1158 { BM_SETSTATE, posted },
1159 { WM_CTLCOLORBTN, posted|parent },
1160 { WM_LBUTTONUP, posted },
1161 { BM_SETSTATE, posted },
1162 { WM_CTLCOLORBTN, posted|parent },
1163 { WM_COMMAND, posted|parent },
1166 /* Reparenting a button (16/32) */
1167 /* The last child (button) reparented gets topmost for its new parent. */
1168 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
1169 { WM_SHOWWINDOW, sent|wparam, 0 },
1170 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1171 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1172 { WM_ERASEBKGND, sent|parent },
1173 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1174 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
1175 { WM_CHILDACTIVATE, sent },
1176 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
1177 { WM_MOVE, sent|defwinproc },
1178 { WM_SHOWWINDOW, sent|wparam, 1 },
1181 /* Creation of a custom dialog (32) */
1182 static const struct message WmCreateCustomDialogSeq[] = {
1183 { HCBT_CREATEWND, hook },
1184 { WM_GETMINMAXINFO, sent },
1185 { WM_NCCREATE, sent },
1186 { WM_NCCALCSIZE, sent|wparam, 0 },
1187 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1188 { WM_CREATE, sent },
1189 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1190 { WM_NOTIFYFORMAT, sent|optional },
1191 { WM_QUERYUISTATE, sent|optional },
1192 { WM_WINDOWPOSCHANGING, sent|optional },
1193 { WM_GETMINMAXINFO, sent|optional },
1194 { WM_NCCALCSIZE, sent|optional },
1195 { WM_WINDOWPOSCHANGED, sent|optional },
1196 { WM_SHOWWINDOW, sent|wparam, 1 },
1197 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1198 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1199 { HCBT_ACTIVATE, hook },
1200 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1203 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1205 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
1207 { WM_NCACTIVATE, sent|wparam, 1 },
1208 { WM_GETTEXT, sent|optional|defwinproc },
1209 { WM_GETTEXT, sent|optional|defwinproc },
1210 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1211 { WM_ACTIVATE, sent|wparam, 1 },
1212 { WM_GETTEXT, sent|optional },
1213 { WM_KILLFOCUS, sent|parent },
1214 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1215 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1216 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1217 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1218 { WM_SETFOCUS, sent },
1219 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1220 { WM_NCPAINT, sent|wparam, 1 },
1221 { WM_GETTEXT, sent|optional|defwinproc },
1222 { WM_GETTEXT, sent|optional|defwinproc },
1223 { WM_ERASEBKGND, sent },
1224 { WM_CTLCOLORDLG, sent|defwinproc },
1225 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1226 { WM_GETTEXT, sent|optional },
1227 { WM_GETTEXT, sent|optional },
1228 { WM_NCCALCSIZE, sent|optional },
1229 { WM_NCPAINT, sent|optional },
1230 { WM_GETTEXT, sent|optional|defwinproc },
1231 { WM_GETTEXT, sent|optional|defwinproc },
1232 { WM_ERASEBKGND, sent|optional },
1233 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1234 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1235 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1239 /* Calling EndDialog for a custom dialog (32) */
1240 static const struct message WmEndCustomDialogSeq[] = {
1241 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1242 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1243 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1244 { WM_GETTEXT, sent|optional },
1245 { HCBT_ACTIVATE, hook },
1246 { WM_NCACTIVATE, sent|wparam, 0 },
1247 { WM_GETTEXT, sent|optional|defwinproc },
1248 { WM_GETTEXT, sent|optional|defwinproc },
1249 { WM_ACTIVATE, sent|wparam, 0 },
1250 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1251 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1252 { HCBT_SETFOCUS, hook },
1253 { WM_KILLFOCUS, sent },
1254 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1255 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1256 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1257 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1258 { WM_SETFOCUS, sent|parent|defwinproc },
1261 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1262 static const struct message WmShowCustomDialogSeq[] = {
1263 { WM_SHOWWINDOW, sent|wparam, 1 },
1264 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1265 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1266 { HCBT_ACTIVATE, hook },
1267 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1269 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1271 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
1272 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1273 { WM_NCACTIVATE, sent|wparam, 1 },
1274 { WM_ACTIVATE, sent|wparam, 1 },
1275 { WM_GETTEXT, sent|optional },
1277 { WM_KILLFOCUS, sent|parent },
1278 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1279 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1280 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1281 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1282 { WM_SETFOCUS, sent },
1283 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1284 { WM_NCPAINT, sent|wparam, 1 },
1285 { WM_ERASEBKGND, sent },
1286 { WM_CTLCOLORDLG, sent|defwinproc },
1287 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1290 /* Creation and destruction of a modal dialog (32) */
1291 static const struct message WmModalDialogSeq[] = {
1292 { WM_CANCELMODE, sent|parent },
1293 { HCBT_SETFOCUS, hook },
1294 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1295 { WM_KILLFOCUS, sent|parent },
1296 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1297 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1298 { WM_ENABLE, sent|parent|wparam, 0 },
1299 { HCBT_CREATEWND, hook },
1300 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1301 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1302 { WM_SETFONT, sent },
1303 { WM_INITDIALOG, sent },
1304 { WM_CHANGEUISTATE, sent|optional },
1305 { WM_UPDATEUISTATE, sent|optional },
1306 { WM_SHOWWINDOW, sent },
1307 { HCBT_ACTIVATE, hook },
1308 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1309 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1310 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1311 { WM_NCACTIVATE, sent|wparam, 1 },
1312 { WM_GETTEXT, sent|optional },
1313 { WM_ACTIVATE, sent|wparam, 1 },
1314 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1315 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1316 { WM_NCPAINT, sent },
1317 { WM_GETTEXT, sent|optional },
1318 { WM_ERASEBKGND, sent },
1319 { WM_CTLCOLORDLG, sent },
1320 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1321 { WM_GETTEXT, sent|optional },
1322 { WM_NCCALCSIZE, sent|optional },
1323 { WM_NCPAINT, sent|optional },
1324 { WM_GETTEXT, sent|optional },
1325 { WM_ERASEBKGND, sent|optional },
1326 { WM_CTLCOLORDLG, sent|optional },
1327 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1328 { WM_PAINT, sent|optional },
1329 { WM_CTLCOLORBTN, sent },
1330 { WM_ENTERIDLE, sent|parent|optional },
1331 { WM_ENTERIDLE, sent|parent|optional },
1332 { WM_ENTERIDLE, sent|parent|optional },
1333 { WM_ENTERIDLE, sent|parent|optional },
1334 { WM_ENTERIDLE, sent|parent|optional },
1335 { WM_ENTERIDLE, sent|parent|optional },
1336 { WM_ENTERIDLE, sent|parent|optional },
1337 { WM_ENTERIDLE, sent|parent|optional },
1338 { WM_ENTERIDLE, sent|parent|optional },
1339 { WM_ENTERIDLE, sent|parent|optional },
1340 { WM_ENTERIDLE, sent|parent|optional },
1341 { WM_ENTERIDLE, sent|parent|optional },
1342 { WM_ENTERIDLE, sent|parent|optional },
1343 { WM_ENTERIDLE, sent|parent|optional },
1344 { WM_ENTERIDLE, sent|parent|optional },
1345 { WM_ENTERIDLE, sent|parent|optional },
1346 { WM_ENTERIDLE, sent|parent|optional },
1347 { WM_ENTERIDLE, sent|parent|optional },
1348 { WM_ENTERIDLE, sent|parent|optional },
1349 { WM_ENTERIDLE, sent|parent|optional },
1351 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1352 { WM_ENABLE, sent|parent|wparam, 1 },
1353 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1354 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1355 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1356 { WM_GETTEXT, sent|optional },
1357 { HCBT_ACTIVATE, hook },
1358 { WM_NCACTIVATE, sent|wparam, 0 },
1359 { WM_GETTEXT, sent|optional },
1360 { WM_ACTIVATE, sent|wparam, 0 },
1361 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1362 { WM_WINDOWPOSCHANGING, sent|optional },
1363 { WM_WINDOWPOSCHANGED, sent|optional },
1364 { HCBT_SETFOCUS, hook },
1365 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1366 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1367 { WM_SETFOCUS, sent|parent|defwinproc },
1368 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1369 { HCBT_DESTROYWND, hook },
1370 { 0x0090, sent|optional },
1371 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1372 { WM_DESTROY, sent },
1373 { WM_NCDESTROY, sent },
1376 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1377 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1378 /* (inside dialog proc, handling WM_INITDIALOG) */
1379 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1380 { WM_NCCALCSIZE, sent },
1381 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1382 { WM_GETTEXT, sent|defwinproc },
1383 { WM_ACTIVATE, sent|parent|wparam, 0 },
1384 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1385 { WM_WINDOWPOSCHANGING, sent|parent },
1386 { WM_NCACTIVATE, sent|wparam, 1 },
1387 { WM_ACTIVATE, sent|wparam, 1 },
1388 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1389 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1390 /* (setting focus) */
1391 { WM_SHOWWINDOW, sent|wparam, 1 },
1392 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1393 { WM_NCPAINT, sent },
1394 { WM_GETTEXT, sent|defwinproc },
1395 { WM_ERASEBKGND, sent },
1396 { WM_CTLCOLORDLG, sent|defwinproc },
1397 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1399 /* (bunch of WM_CTLCOLOR* for each control) */
1400 { WM_PAINT, sent|parent },
1401 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1402 { WM_SETCURSOR, sent|parent },
1405 /* SetMenu for NonVisible windows with size change*/
1406 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1407 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1408 { WM_NCCALCSIZE, sent|wparam, 1 },
1409 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1410 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1411 { WM_MOVE, sent|defwinproc },
1412 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1413 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1414 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1415 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1416 { WM_GETTEXT, sent|optional },
1417 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1420 /* SetMenu for NonVisible windows with no size change */
1421 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1422 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1423 { WM_NCCALCSIZE, sent|wparam, 1 },
1424 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1425 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1428 /* SetMenu for Visible windows with size change */
1429 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1430 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1431 { WM_NCCALCSIZE, sent|wparam, 1 },
1432 { 0x0093, sent|defwinproc|optional },
1433 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1434 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1435 { 0x0093, sent|defwinproc|optional },
1436 { 0x0093, sent|defwinproc|optional },
1437 { 0x0091, sent|defwinproc|optional },
1438 { 0x0092, sent|defwinproc|optional },
1439 { WM_GETTEXT, sent|defwinproc|optional },
1440 { WM_ERASEBKGND, sent|optional },
1441 { WM_ACTIVATE, sent|optional },
1442 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1443 { WM_MOVE, sent|defwinproc },
1444 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1445 { 0x0093, sent|optional },
1446 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1447 { 0x0093, sent|defwinproc|optional },
1448 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1449 { 0x0093, sent|defwinproc|optional },
1450 { 0x0093, sent|defwinproc|optional },
1451 { 0x0091, sent|defwinproc|optional },
1452 { 0x0092, sent|defwinproc|optional },
1453 { WM_ERASEBKGND, sent|optional },
1454 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1455 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1458 /* SetMenu for Visible windows with no size change */
1459 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1460 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1461 { WM_NCCALCSIZE, sent|wparam, 1 },
1462 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1463 { WM_GETTEXT, sent|defwinproc|optional },
1464 { WM_ERASEBKGND, sent|optional },
1465 { WM_ACTIVATE, sent|optional },
1466 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1467 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1470 /* DrawMenuBar for a visible window */
1471 static const struct message WmDrawMenuBarSeq[] =
1473 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1474 { WM_NCCALCSIZE, sent|wparam, 1 },
1475 { 0x0093, sent|defwinproc|optional },
1476 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1477 { 0x0093, sent|defwinproc|optional },
1478 { 0x0093, sent|defwinproc|optional },
1479 { 0x0091, sent|defwinproc|optional },
1480 { 0x0092, sent|defwinproc|optional },
1481 { WM_GETTEXT, sent|defwinproc|optional },
1482 { WM_ERASEBKGND, sent|optional },
1483 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1484 { 0x0093, sent|optional },
1485 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1489 static const struct message WmSetRedrawFalseSeq[] =
1491 { WM_SETREDRAW, sent|wparam, 0 },
1495 static const struct message WmSetRedrawTrueSeq[] =
1497 { WM_SETREDRAW, sent|wparam, 1 },
1501 static const struct message WmEnableWindowSeq_1[] =
1503 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1504 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1505 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1509 static const struct message WmEnableWindowSeq_2[] =
1511 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1512 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1516 static const struct message WmGetScrollRangeSeq[] =
1518 { SBM_GETRANGE, sent },
1521 static const struct message WmGetScrollInfoSeq[] =
1523 { SBM_GETSCROLLINFO, sent },
1526 static const struct message WmSetScrollRangeSeq[] =
1528 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1529 sends SBM_SETSCROLLINFO.
1531 { SBM_SETSCROLLINFO, sent },
1534 /* SetScrollRange for a window without a non-client area */
1535 static const struct message WmSetScrollRangeHSeq_empty[] =
1537 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1540 static const struct message WmSetScrollRangeVSeq_empty[] =
1542 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1545 static const struct message WmSetScrollRangeHVSeq[] =
1547 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1548 { WM_NCCALCSIZE, sent|wparam, 1 },
1549 { WM_GETTEXT, sent|defwinproc|optional },
1550 { WM_ERASEBKGND, sent|optional },
1551 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1552 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1553 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1556 /* SetScrollRange for a window with a non-client area */
1557 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1559 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1560 { WM_NCCALCSIZE, sent|wparam, 1 },
1561 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1562 { WM_NCPAINT, sent|optional },
1563 { WM_STYLECHANGING, sent|defwinproc|optional },
1564 { WM_STYLECHANGED, sent|defwinproc|optional },
1565 { WM_STYLECHANGING, sent|defwinproc|optional },
1566 { WM_STYLECHANGED, sent|defwinproc|optional },
1567 { WM_STYLECHANGING, sent|defwinproc|optional },
1568 { WM_STYLECHANGED, sent|defwinproc|optional },
1569 { WM_STYLECHANGING, sent|defwinproc|optional },
1570 { WM_STYLECHANGED, sent|defwinproc|optional },
1571 { WM_GETTEXT, sent|defwinproc|optional },
1572 { WM_GETTEXT, sent|defwinproc|optional },
1573 { WM_ERASEBKGND, sent|optional },
1574 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1575 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE },
1576 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1577 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1578 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1579 { WM_GETTEXT, sent|optional },
1580 { WM_GETTEXT, sent|optional },
1581 { WM_GETTEXT, sent|optional },
1582 { WM_GETTEXT, sent|optional },
1585 /* test if we receive the right sequence of messages */
1586 /* after calling ShowWindow( SW_SHOWNA) */
1587 static const struct message WmSHOWNAChildInvisParInvis[] = {
1588 { WM_SHOWWINDOW, sent|wparam, 1 },
1591 static const struct message WmSHOWNAChildVisParInvis[] = {
1592 { WM_SHOWWINDOW, sent|wparam, 1 },
1595 static const struct message WmSHOWNAChildVisParVis[] = {
1596 { WM_SHOWWINDOW, sent|wparam, 1 },
1597 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1600 static const struct message WmSHOWNAChildInvisParVis[] = {
1601 { WM_SHOWWINDOW, sent|wparam, 1 },
1602 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1603 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1604 { WM_ERASEBKGND, sent|optional },
1605 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1608 static const struct message WmSHOWNATopVisible[] = {
1609 { WM_SHOWWINDOW, sent|wparam, 1 },
1610 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1611 { WM_NCPAINT, sent|wparam|optional, 1 },
1612 { WM_GETTEXT, sent|defwinproc|optional },
1613 { WM_ERASEBKGND, sent|optional },
1614 { WM_WINDOWPOSCHANGED, sent|optional },
1617 static const struct message WmSHOWNATopInvisible[] = {
1618 { WM_NOTIFYFORMAT, sent|optional },
1619 { WM_QUERYUISTATE, sent|optional },
1620 { WM_WINDOWPOSCHANGING, sent|optional },
1621 { WM_GETMINMAXINFO, sent|optional },
1622 { WM_NCCALCSIZE, sent|optional },
1623 { WM_WINDOWPOSCHANGED, sent|optional },
1624 { WM_SHOWWINDOW, sent|wparam, 1 },
1625 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1626 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1627 { WM_NCPAINT, sent|wparam, 1 },
1628 { WM_GETTEXT, sent|defwinproc|optional },
1629 { WM_ERASEBKGND, sent|optional },
1630 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1631 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1632 { WM_NCPAINT, sent|wparam|optional, 1 },
1633 { WM_ERASEBKGND, sent|optional },
1634 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1635 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1640 static int after_end_dialog, test_def_id;
1641 static int sequence_cnt, sequence_size;
1642 static struct recvd_message* sequence;
1643 static int log_all_parent_messages;
1644 static int paint_loop_done;
1646 /* user32 functions */
1647 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
1648 static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
1649 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
1650 static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
1651 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
1652 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
1653 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
1654 /* kernel32 functions */
1655 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1657 static void init_procs(void)
1659 HMODULE user32 = GetModuleHandleA("user32.dll");
1660 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1662 #define GET_PROC(dll, func) \
1663 p ## func = (void*)GetProcAddress(dll, #func); \
1665 trace("GetProcAddress(%s) failed\n", #func); \
1668 GET_PROC(user32, GetAncestor)
1669 GET_PROC(user32, GetMenuInfo)
1670 GET_PROC(user32, NotifyWinEvent)
1671 GET_PROC(user32, SetMenuInfo)
1672 GET_PROC(user32, SetWinEventHook)
1673 GET_PROC(user32, TrackMouseEvent)
1674 GET_PROC(user32, UnhookWinEvent)
1676 GET_PROC(kernel32, GetCPInfoExA)
1681 static const char *get_winpos_flags(UINT flags)
1683 static char buffer[300];
1686 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1687 DUMP( SWP_SHOWWINDOW );
1688 DUMP( SWP_HIDEWINDOW );
1689 DUMP( SWP_NOACTIVATE );
1690 DUMP( SWP_FRAMECHANGED );
1691 DUMP( SWP_NOCOPYBITS );
1692 DUMP( SWP_NOOWNERZORDER );
1693 DUMP( SWP_NOSENDCHANGING );
1694 DUMP( SWP_DEFERERASE );
1695 DUMP( SWP_ASYNCWINDOWPOS );
1696 DUMP( SWP_NOZORDER );
1697 DUMP( SWP_NOREDRAW );
1700 DUMP( SWP_NOCLIENTSIZE );
1701 DUMP( SWP_NOCLIENTMOVE );
1702 if (flags) sprintf(buffer + strlen(buffer),"|0x%04x", flags);
1708 #define add_message(msg) add_message_(__LINE__,msg);
1709 static void add_message_(int line, const struct recvd_message *msg)
1711 struct recvd_message *seq;
1716 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
1718 if (sequence_cnt == sequence_size)
1721 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof(*sequence) );
1725 seq = &sequence[sequence_cnt];
1726 seq->hwnd = msg->hwnd;
1727 seq->message = msg->message;
1728 seq->flags = msg->flags;
1729 seq->wParam = msg->wParam;
1730 seq->lParam = msg->lParam;
1732 seq->descr = msg->descr;
1737 if (msg->flags & hook)
1739 static const char * const CBT_code_name[10] =
1747 "HCBT_CLICKSKIPPED",
1752 const char *code_name = (msg->message <= HCBT_SETFOCUS) ? CBT_code_name[msg->message] : "Unknown";
1754 snprintf( seq->output, sizeof(seq->output), "%s: hook %d (%s) wp %08lx lp %08lx",
1755 msg->descr, msg->message, code_name, msg->wParam, msg->lParam );
1757 else if (msg->flags & winevent_hook)
1759 snprintf( seq->output, sizeof(seq->output), "%s: winevent %p %08x %08lx %08lx",
1760 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
1764 switch (msg->message)
1766 case WM_WINDOWPOSCHANGING:
1767 case WM_WINDOWPOSCHANGED:
1769 WINDOWPOS *winpos = (WINDOWPOS *)msg->lParam;
1771 snprintf( seq->output, sizeof(seq->output),
1772 "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1773 msg->descr, msg->hwnd,
1774 (msg->message == WM_WINDOWPOSCHANGING) ? "CHANGING" : "CHANGED",
1775 msg->wParam, msg->lParam, winpos->hwndInsertAfter,
1776 winpos->x, winpos->y, winpos->cx, winpos->cy,
1777 get_winpos_flags(winpos->flags) );
1779 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1780 * in the high word for internal purposes
1782 seq->wParam = winpos->flags & 0xffff;
1783 /* We are not interested in the flags that don't match under XP and Win9x */
1784 seq->wParam &= ~SWP_NOZORDER;
1790 DRAW_ITEM_STRUCT di;
1791 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)msg->lParam;
1793 snprintf( seq->output, sizeof(seq->output),
1794 "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1795 msg->descr, msg->hwnd, dis->CtlType, dis->CtlID,
1796 dis->itemID, dis->itemAction, dis->itemState);
1798 di.u.item.type = dis->CtlType;
1799 di.u.item.ctl_id = dis->CtlID;
1800 di.u.item.item_id = dis->itemID;
1801 di.u.item.action = dis->itemAction;
1802 di.u.item.state = dis->itemState;
1804 seq->lParam = di.u.lp;
1808 if (msg->message >= 0xc000) return; /* ignore registered messages */
1809 snprintf( seq->output, sizeof(seq->output), "%s: %p %04x wp %08lx lp %08lx",
1810 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
1818 /* try to make sure pending X events have been processed before continuing */
1819 static void flush_events(void)
1823 int min_timeout = 100;
1824 DWORD time = GetTickCount() + diff;
1828 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1829 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1830 diff = time - GetTickCount();
1835 static void flush_sequence(void)
1837 HeapFree(GetProcessHeap(), 0, sequence);
1839 sequence_cnt = sequence_size = 0;
1842 static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
1844 const struct recvd_message *actual = sequence;
1845 unsigned int count = 0;
1847 trace_(file, line)("Failed sequence %s:\n", context );
1848 while (expected->message && actual->message)
1850 if (actual->output[0])
1852 if (expected->flags & hook)
1854 trace_(file, line)( " %u: expected: hook %04x - actual: %s\n",
1855 count, expected->message, actual->output );
1857 else if (expected->flags & winevent_hook)
1859 trace_(file, line)( " %u: expected: winevent %04x - actual: %s\n",
1860 count, expected->message, actual->output );
1864 trace_(file, line)( " %u: expected: msg %04x - actual: %s\n",
1865 count, expected->message, actual->output );
1869 if (expected->message == actual->message)
1874 /* silently drop winevent messages if there is no support for them */
1875 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1885 /* optional trailing messages */
1886 while (expected->message && ((expected->flags & optional) ||
1887 ((expected->flags & winevent_hook) && !hEvent_hook)))
1889 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
1894 if (expected->message)
1895 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
1896 else if (actual->message && actual->output[0])
1897 trace_(file, line)( " %u: expected: nothing - actual: %s\n", count, actual->output );
1900 #define ok_sequence( exp, contx, todo) \
1901 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
1904 static void ok_sequence_(const struct message *expected_list, const char *context, int todo,
1905 const char *file, int line)
1907 static const struct recvd_message end_of_sequence;
1908 const struct message *expected = expected_list;
1909 const struct recvd_message *actual;
1910 int failcount = 0, dump = 0;
1911 unsigned int count = 0;
1913 add_message(&end_of_sequence);
1917 while (expected->message && actual->message)
1919 if (expected->message == actual->message)
1921 if (expected->flags & wparam)
1923 if (((expected->wParam ^ actual->wParam) & ~expected->wp_mask) && todo)
1927 if (strcmp(winetest_platform, "wine")) dump++;
1928 ok_( file, line) (FALSE,
1929 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1930 context, count, expected->message, expected->wParam, actual->wParam);
1935 ok_( file, line)( ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) == 0,
1936 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
1937 context, count, expected->message, expected->wParam, actual->wParam);
1938 if ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) dump++;
1942 if (expected->flags & lparam)
1944 if (((expected->lParam ^ actual->lParam) & ~expected->lp_mask) && todo)
1948 if (strcmp(winetest_platform, "wine")) dump++;
1949 ok_( file, line) (FALSE,
1950 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1951 context, count, expected->message, expected->lParam, actual->lParam);
1956 ok_( file, line)(((expected->lParam ^ actual->lParam) & ~expected->lp_mask) == 0,
1957 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
1958 context, count, expected->message, expected->lParam, actual->lParam);
1959 if ((expected->lParam ^ actual->lParam) & ~expected->lp_mask) dump++;
1962 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) &&
1963 (expected->flags & optional))
1965 /* don't match messages if their defwinproc status differs */
1970 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
1974 if (strcmp(winetest_platform, "wine")) dump++;
1975 ok_( file, line) (FALSE,
1976 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1977 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1982 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
1983 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
1984 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
1985 if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
1988 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
1989 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
1990 context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
1991 if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++;
1993 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
1994 "%s: %u: the msg 0x%04x should have been %s\n",
1995 context, count, expected->message, (expected->flags & posted) ? "posted" : "sent");
1996 if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
1998 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
1999 "%s: %u: the msg 0x%04x was expected in %s\n",
2000 context, count, expected->message, (expected->flags & parent) ? "parent" : "child");
2001 if ((expected->flags & parent) != (actual->flags & parent)) dump++;
2003 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
2004 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2005 context, count, expected->message);
2006 if ((expected->flags & hook) != (actual->flags & hook)) dump++;
2008 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
2009 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2010 context, count, expected->message);
2011 if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++;
2016 /* silently drop hook messages if there is no support for them */
2017 else if ((expected->flags & optional) ||
2018 ((expected->flags & hook) && !hCBT_hook) ||
2019 ((expected->flags & winevent_hook) && !hEvent_hook))
2025 if (strcmp(winetest_platform, "wine")) dump++;
2026 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2027 context, count, expected->message, actual->message);
2033 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2034 context, count, expected->message, actual->message);
2042 /* skip all optional trailing messages */
2043 while (expected->message && ((expected->flags & optional) ||
2044 ((expected->flags & hook) && !hCBT_hook) ||
2045 ((expected->flags & winevent_hook) && !hEvent_hook)))
2051 if (expected->message || actual->message) {
2053 if (strcmp(winetest_platform, "wine")) dump++;
2054 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2055 context, count, expected->message, actual->message);
2061 if (expected->message || actual->message)
2064 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2065 context, count, expected->message, actual->message);
2068 if( todo && !failcount) /* succeeded yet marked todo */
2070 if (!strcmp(winetest_platform, "wine")) dump++;
2071 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
2075 if (dump) dump_sequence(expected_list, context, file, line);
2079 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2081 /******************************** MDI test **********************************/
2083 /* CreateWindow for MDI frame window, initially visible */
2084 static const struct message WmCreateMDIframeSeq[] = {
2085 { HCBT_CREATEWND, hook },
2086 { WM_GETMINMAXINFO, sent },
2087 { WM_NCCREATE, sent },
2088 { WM_NCCALCSIZE, sent|wparam, 0 },
2089 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2090 { WM_CREATE, sent },
2091 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2092 { WM_NOTIFYFORMAT, sent|optional },
2093 { WM_QUERYUISTATE, sent|optional },
2094 { WM_WINDOWPOSCHANGING, sent|optional },
2095 { WM_GETMINMAXINFO, sent|optional },
2096 { WM_NCCALCSIZE, sent|optional },
2097 { WM_WINDOWPOSCHANGED, sent|optional },
2098 { WM_SHOWWINDOW, sent|wparam, 1 },
2099 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2100 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2101 { HCBT_ACTIVATE, hook },
2102 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
2103 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
2104 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
2105 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
2106 { WM_NCACTIVATE, sent|wparam, 1 },
2107 { WM_GETTEXT, sent|defwinproc|optional },
2108 { WM_ACTIVATE, sent|wparam, 1 },
2109 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
2110 { HCBT_SETFOCUS, hook },
2111 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2112 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2113 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2114 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
2115 /* Win9x adds SWP_NOZORDER below */
2116 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2117 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2118 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2119 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2123 /* DestroyWindow for MDI frame window, initially visible */
2124 static const struct message WmDestroyMDIframeSeq[] = {
2125 { HCBT_DESTROYWND, hook },
2126 { 0x0090, sent|optional },
2127 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2128 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2129 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2130 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2131 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
2132 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2133 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
2134 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
2135 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2136 { WM_DESTROY, sent },
2137 { WM_NCDESTROY, sent },
2140 /* CreateWindow for MDI client window, initially visible */
2141 static const struct message WmCreateMDIclientSeq[] = {
2142 { HCBT_CREATEWND, hook },
2143 { WM_NCCREATE, sent },
2144 { WM_NCCALCSIZE, sent|wparam, 0 },
2145 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2146 { WM_CREATE, sent },
2147 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2148 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2149 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2151 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
2152 { WM_SHOWWINDOW, sent|wparam, 1 },
2153 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2154 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2155 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2158 /* ShowWindow(SW_SHOW) for MDI client window */
2159 static const struct message WmShowMDIclientSeq[] = {
2160 { WM_SHOWWINDOW, sent|wparam, 1 },
2161 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2162 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2163 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2166 /* ShowWindow(SW_HIDE) for MDI client window */
2167 static const struct message WmHideMDIclientSeq[] = {
2168 { WM_SHOWWINDOW, sent|wparam, 0 },
2169 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2170 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
2171 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
2172 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2175 /* DestroyWindow for MDI client window, initially visible */
2176 static const struct message WmDestroyMDIclientSeq[] = {
2177 { HCBT_DESTROYWND, hook },
2178 { 0x0090, sent|optional },
2179 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
2180 { WM_SHOWWINDOW, sent|wparam, 0 },
2181 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2182 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2183 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2184 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2185 { WM_DESTROY, sent },
2186 { WM_NCDESTROY, sent },
2189 /* CreateWindow for MDI child window, initially visible */
2190 static const struct message WmCreateMDIchildVisibleSeq[] = {
2191 { HCBT_CREATEWND, hook },
2192 { WM_NCCREATE, sent },
2193 { WM_NCCALCSIZE, sent|wparam, 0 },
2194 { WM_CREATE, sent },
2195 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2196 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2198 /* Win2k sends wparam set to
2199 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2200 * while Win9x doesn't bother to set child window id according to
2201 * CLIENTCREATESTRUCT.idFirstChild
2203 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2204 { WM_SHOWWINDOW, sent|wparam, 1 },
2205 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2206 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2207 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2208 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2209 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2210 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2211 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2213 /* Win9x: message sequence terminates here. */
2215 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2216 { HCBT_SETFOCUS, hook }, /* in MDI client */
2217 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2218 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2219 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2220 { WM_SETFOCUS, sent }, /* in MDI client */
2221 { HCBT_SETFOCUS, hook },
2222 { WM_KILLFOCUS, sent }, /* in MDI client */
2223 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2224 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2225 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2226 { WM_SETFOCUS, sent|defwinproc },
2227 { WM_MDIACTIVATE, sent|defwinproc },
2230 /* CreateWindow for MDI child window with invisible parent */
2231 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
2232 { HCBT_CREATEWND, hook },
2233 { WM_GETMINMAXINFO, sent },
2234 { WM_NCCREATE, sent },
2235 { WM_NCCALCSIZE, sent|wparam, 0 },
2236 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2237 { WM_CREATE, sent },
2238 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2239 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2241 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2242 { WM_SHOWWINDOW, sent|wparam, 1 },
2243 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2244 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2245 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2246 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2248 /* Win9x: message sequence terminates here. */
2250 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2251 { HCBT_SETFOCUS, hook }, /* in MDI client */
2252 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2253 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2254 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2255 { WM_SETFOCUS, sent }, /* in MDI client */
2256 { HCBT_SETFOCUS, hook },
2257 { WM_KILLFOCUS, sent }, /* in MDI client */
2258 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2259 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2260 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2261 { WM_SETFOCUS, sent|defwinproc },
2262 { WM_MDIACTIVATE, sent|defwinproc },
2265 /* DestroyWindow for MDI child window, initially visible */
2266 static const struct message WmDestroyMDIchildVisibleSeq[] = {
2267 { HCBT_DESTROYWND, hook },
2268 /* Win2k sends wparam set to
2269 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2270 * while Win9x doesn't bother to set child window id according to
2271 * CLIENTCREATESTRUCT.idFirstChild
2273 { 0x0090, sent|optional },
2274 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2275 { WM_SHOWWINDOW, sent|wparam, 0 },
2276 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2277 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2278 { WM_ERASEBKGND, sent|parent|optional },
2279 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2281 /* { WM_DESTROY, sent }
2282 * Win9x: message sequence terminates here.
2285 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2286 { WM_KILLFOCUS, sent },
2287 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2288 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2289 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2290 { WM_SETFOCUS, sent }, /* in MDI client */
2292 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2293 { WM_KILLFOCUS, sent }, /* in MDI client */
2294 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2295 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2296 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2297 { WM_SETFOCUS, sent }, /* in MDI client */
2299 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2301 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2302 { WM_KILLFOCUS, sent },
2303 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2304 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2305 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2306 { WM_SETFOCUS, sent }, /* in MDI client */
2308 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2309 { WM_KILLFOCUS, sent }, /* in MDI client */
2310 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2311 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2312 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2313 { WM_SETFOCUS, sent }, /* in MDI client */
2315 { WM_DESTROY, sent },
2317 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2318 { WM_KILLFOCUS, sent },
2319 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2320 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2321 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2322 { WM_SETFOCUS, sent }, /* in MDI client */
2324 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2325 { WM_KILLFOCUS, sent }, /* in MDI client */
2326 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2327 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2328 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2329 { WM_SETFOCUS, sent }, /* in MDI client */
2331 { WM_NCDESTROY, sent },
2334 /* CreateWindow for MDI child window, initially invisible */
2335 static const struct message WmCreateMDIchildInvisibleSeq[] = {
2336 { HCBT_CREATEWND, hook },
2337 { WM_NCCREATE, sent },
2338 { WM_NCCALCSIZE, sent|wparam, 0 },
2339 { WM_CREATE, sent },
2340 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2341 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2343 /* Win2k sends wparam set to
2344 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2345 * while Win9x doesn't bother to set child window id according to
2346 * CLIENTCREATESTRUCT.idFirstChild
2348 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2351 /* DestroyWindow for MDI child window, initially invisible */
2352 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
2353 { HCBT_DESTROYWND, hook },
2354 /* Win2k sends wparam set to
2355 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2356 * while Win9x doesn't bother to set child window id according to
2357 * CLIENTCREATESTRUCT.idFirstChild
2359 { 0x0090, sent|optional },
2360 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2361 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2362 { WM_DESTROY, sent },
2363 { WM_NCDESTROY, sent },
2364 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2365 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
2368 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2369 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
2370 { HCBT_CREATEWND, hook },
2371 { WM_NCCREATE, sent },
2372 { WM_NCCALCSIZE, sent|wparam, 0 },
2373 { WM_CREATE, sent },
2374 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2375 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2377 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2378 { WM_GETMINMAXINFO, sent },
2379 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2380 { WM_NCCALCSIZE, sent|wparam, 1 },
2381 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2382 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2384 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2385 { WM_NCCALCSIZE, sent|wparam, 1 },
2386 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2387 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2388 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2389 /* Win2k sends wparam set to
2390 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2391 * while Win9x doesn't bother to set child window id according to
2392 * CLIENTCREATESTRUCT.idFirstChild
2394 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2395 { WM_SHOWWINDOW, sent|wparam, 1 },
2396 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2397 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2398 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2399 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2400 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2401 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2402 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2404 /* Win9x: message sequence terminates here. */
2406 { WM_NCACTIVATE, sent|wparam|defwinproc|optional, 1 },
2407 { HCBT_SETFOCUS, hook|optional }, /* in MDI client */
2408 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2409 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2410 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2411 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2412 { HCBT_SETFOCUS, hook|optional },
2413 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
2414 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2415 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2416 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2417 { WM_SETFOCUS, sent|defwinproc|optional },
2418 { WM_MDIACTIVATE, sent|defwinproc|optional },
2420 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2421 { WM_NCCALCSIZE, sent|wparam, 1 },
2422 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2423 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2426 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2427 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2428 /* restore the 1st MDI child */
2429 { WM_SETREDRAW, sent|wparam, 0 },
2430 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2431 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2432 { WM_NCCALCSIZE, sent|wparam, 1 },
2433 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2434 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2435 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2437 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2438 { WM_NCCALCSIZE, sent|wparam, 1 },
2439 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2440 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2441 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2442 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2443 /* create the 2nd MDI child */
2444 { HCBT_CREATEWND, hook },
2445 { WM_NCCREATE, sent },
2446 { WM_NCCALCSIZE, sent|wparam, 0 },
2447 { WM_CREATE, sent },
2448 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2449 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2451 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2452 { WM_GETMINMAXINFO, sent },
2453 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2454 { WM_NCCALCSIZE, sent|wparam, 1 },
2455 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2456 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2457 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2459 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2460 { WM_NCCALCSIZE, sent|wparam, 1 },
2461 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2462 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2463 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2464 /* Win2k sends wparam set to
2465 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2466 * while Win9x doesn't bother to set child window id according to
2467 * CLIENTCREATESTRUCT.idFirstChild
2469 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2470 { WM_SHOWWINDOW, sent|wparam, 1 },
2471 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2472 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2473 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2474 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2475 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2476 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2478 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2479 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2481 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2483 /* Win9x: message sequence terminates here. */
2485 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2486 { HCBT_SETFOCUS, hook },
2487 { WM_KILLFOCUS, sent|defwinproc|optional }, /* in the 1st MDI child */
2488 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2489 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2490 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2491 { WM_SETFOCUS, sent }, /* in MDI client */
2492 { HCBT_SETFOCUS, hook },
2493 { WM_KILLFOCUS, sent }, /* in MDI client */
2494 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2495 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2496 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2497 { WM_SETFOCUS, sent|defwinproc },
2499 { WM_MDIACTIVATE, sent|defwinproc },
2501 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2502 { WM_NCCALCSIZE, sent|wparam, 1 },
2503 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2504 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2507 /* WM_MDICREATE MDI child window, initially visible and maximized */
2508 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2509 { WM_MDICREATE, sent },
2510 { HCBT_CREATEWND, hook },
2511 { WM_NCCREATE, sent },
2512 { WM_NCCALCSIZE, sent|wparam, 0 },
2513 { WM_CREATE, sent },
2514 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2515 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2517 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2518 { WM_GETMINMAXINFO, sent },
2519 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2520 { WM_NCCALCSIZE, sent|wparam, 1 },
2521 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2522 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2525 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2526 { WM_NCCALCSIZE, sent|wparam, 1 },
2527 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2528 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2529 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2531 /* Win2k sends wparam set to
2532 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2533 * while Win9x doesn't bother to set child window id according to
2534 * CLIENTCREATESTRUCT.idFirstChild
2536 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2537 { WM_SHOWWINDOW, sent|wparam, 1 },
2538 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2540 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2543 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2544 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2546 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2547 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2549 /* Win9x: message sequence terminates here. */
2551 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2552 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2553 { HCBT_SETFOCUS, hook }, /* in MDI client */
2554 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2555 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2556 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2557 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2558 { HCBT_SETFOCUS, hook|optional },
2559 { WM_KILLFOCUS, sent }, /* in MDI client */
2560 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2561 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2562 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2563 { WM_SETFOCUS, sent|defwinproc },
2565 { WM_MDIACTIVATE, sent|defwinproc },
2568 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2569 { WM_NCCALCSIZE, sent|wparam, 1 },
2570 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2571 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2574 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2575 { WM_NCCALCSIZE, sent|wparam, 1 },
2576 { 0x0093, sent|defwinproc|optional },
2577 { 0x0093, sent|defwinproc|optional },
2578 { 0x0093, sent|defwinproc|optional },
2579 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2580 { WM_MOVE, sent|defwinproc },
2581 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2584 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2585 { WM_NCCALCSIZE, sent|wparam, 1 },
2586 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2587 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2590 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2591 { WM_NCCALCSIZE, sent|wparam, 1 },
2592 { 0x0093, sent|optional },
2593 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2594 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2596 { 0x0093, sent|optional },
2597 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2598 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2599 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2600 { 0x0093, sent|defwinproc|optional },
2601 { 0x0093, sent|defwinproc|optional },
2602 { 0x0093, sent|defwinproc|optional },
2603 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2604 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2608 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2609 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2610 { HCBT_CREATEWND, hook },
2611 { WM_GETMINMAXINFO, sent },
2612 { WM_NCCREATE, sent },
2613 { WM_NCCALCSIZE, sent|wparam, 0 },
2614 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2615 { WM_CREATE, sent },
2616 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2617 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2618 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_NOZORDER }, /* MDI frame */
2619 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI frame */
2620 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOZORDER }, /* MDI frame */
2622 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2623 { WM_GETMINMAXINFO, sent },
2624 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2625 { WM_GETMINMAXINFO, sent|defwinproc },
2626 { WM_NCCALCSIZE, sent|wparam, 1 },
2627 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
2628 { WM_MOVE, sent|defwinproc },
2629 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2631 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2632 { WM_NCCALCSIZE, sent|wparam, 1 },
2633 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2634 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2635 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2636 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2637 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2638 /* Win2k sends wparam set to
2639 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2640 * while Win9x doesn't bother to set child window id according to
2641 * CLIENTCREATESTRUCT.idFirstChild
2643 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2646 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2647 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2648 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2649 { HCBT_SYSCOMMAND, hook },
2650 { WM_CLOSE, sent|defwinproc },
2651 { WM_MDIDESTROY, sent }, /* in MDI client */
2653 /* bring the 1st MDI child to top */
2654 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2655 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2657 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2659 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2660 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2661 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2663 /* maximize the 1st MDI child */
2664 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2665 { WM_GETMINMAXINFO, sent|defwinproc },
2666 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED },
2667 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2668 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2669 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2670 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2672 /* restore the 2nd MDI child */
2673 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2674 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2675 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2676 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2678 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2680 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2681 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2683 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2685 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2687 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2688 { WM_NCCALCSIZE, sent|wparam, 1 },
2689 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2690 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2691 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2693 /* bring the 1st MDI child to top */
2694 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2695 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2696 { HCBT_SETFOCUS, hook },
2697 { WM_KILLFOCUS, sent|defwinproc },
2698 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2699 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2700 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2701 { WM_SETFOCUS, sent }, /* in MDI client */
2702 { HCBT_SETFOCUS, hook },
2703 { WM_KILLFOCUS, sent }, /* in MDI client */
2704 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2705 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2706 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2707 { WM_SETFOCUS, sent|defwinproc },
2708 { WM_MDIACTIVATE, sent|defwinproc },
2709 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2711 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2712 { WM_SHOWWINDOW, sent|wparam, 1 },
2713 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2714 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2715 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2716 { WM_MDIREFRESHMENU, sent },
2718 { HCBT_DESTROYWND, hook },
2719 /* Win2k sends wparam set to
2720 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2721 * while Win9x doesn't bother to set child window id according to
2722 * CLIENTCREATESTRUCT.idFirstChild
2724 { 0x0090, sent|defwinproc|optional },
2725 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2726 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2727 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2728 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2729 { WM_ERASEBKGND, sent|parent|optional },
2730 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2732 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2733 { WM_DESTROY, sent|defwinproc },
2734 { WM_NCDESTROY, sent|defwinproc },
2737 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2738 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2739 { WM_MDIDESTROY, sent }, /* in MDI client */
2740 { WM_SHOWWINDOW, sent|wparam, 0 },
2741 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2742 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2743 { WM_ERASEBKGND, sent|parent|optional },
2744 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2746 { HCBT_SETFOCUS, hook },
2747 { WM_KILLFOCUS, sent },
2748 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2749 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2750 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2751 { WM_SETFOCUS, sent }, /* in MDI client */
2752 { HCBT_SETFOCUS, hook },
2753 { WM_KILLFOCUS, sent }, /* in MDI client */
2754 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2755 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2756 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2757 { WM_SETFOCUS, sent },
2760 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2761 { WM_NCCALCSIZE, sent|wparam, 1 },
2762 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2763 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2766 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2767 { WM_NCCALCSIZE, sent|wparam, 1 },
2768 { 0x0093, sent|defwinproc|optional },
2769 { 0x0093, sent|defwinproc|optional },
2770 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2771 { WM_MOVE, sent|defwinproc },
2772 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2775 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2776 { WM_NCCALCSIZE, sent|wparam, 1 },
2777 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2778 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2781 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2782 { WM_NCCALCSIZE, sent|wparam, 1 },
2783 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2784 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2787 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2788 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2789 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2790 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2793 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2794 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2795 { 0x0093, sent|defwinproc|optional },
2796 { 0x0093, sent|defwinproc|optional },
2797 { 0x0093, sent|defwinproc|optional },
2798 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2799 { WM_MOVE, sent|defwinproc },
2800 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2804 { WM_NCCALCSIZE, sent|wparam, 1 },
2805 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2806 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2809 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2810 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2811 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2812 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2813 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2814 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2816 { 0x0093, sent|defwinproc|optional },
2817 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2818 { 0x0093, sent|defwinproc|optional },
2819 { 0x0093, sent|defwinproc|optional },
2820 { 0x0093, sent|defwinproc|optional },
2821 { 0x0093, sent|optional },
2823 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2824 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2825 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2826 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2827 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2830 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2831 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2832 { 0x0093, sent|defwinproc|optional },
2833 { 0x0093, sent|defwinproc|optional },
2834 { 0x0093, sent|defwinproc|optional },
2835 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2836 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2837 { 0x0093, sent|optional },
2839 { WM_NCACTIVATE, sent|wparam, 0 },
2840 { WM_MDIACTIVATE, sent },
2842 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2843 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2844 { WM_NCCALCSIZE, sent|wparam, 1 },
2846 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2848 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2849 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2850 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2853 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2854 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2855 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2856 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2859 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2860 { WM_NCCALCSIZE, sent|wparam, 1 },
2861 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2862 { WM_MOVE, sent|defwinproc },
2863 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2866 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2867 { WM_NCCALCSIZE, sent|wparam, 1 },
2868 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2869 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2870 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2871 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2872 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2873 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2874 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2876 { HCBT_SETFOCUS, hook },
2877 { WM_KILLFOCUS, sent },
2878 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2879 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2880 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2881 { WM_SETFOCUS, sent }, /* in MDI client */
2883 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2885 { HCBT_DESTROYWND, hook },
2886 /* Win2k sends wparam set to
2887 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2888 * while Win9x doesn't bother to set child window id according to
2889 * CLIENTCREATESTRUCT.idFirstChild
2891 { 0x0090, sent|optional },
2892 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2894 { WM_SHOWWINDOW, sent|wparam, 0 },
2895 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2896 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2897 { WM_ERASEBKGND, sent|parent|optional },
2898 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2900 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2901 { WM_DESTROY, sent },
2902 { WM_NCDESTROY, sent },
2905 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
2906 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
2907 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2908 { WM_GETMINMAXINFO, sent },
2909 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
2910 { WM_NCCALCSIZE, sent|wparam, 1 },
2911 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2912 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2914 { WM_WINDOWPOSCHANGING, sent|wparam|optional|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2915 { WM_NCACTIVATE, sent|wparam|optional|defwinproc, 1 },
2916 { HCBT_SETFOCUS, hook|optional },
2917 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2918 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2919 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2920 { HCBT_SETFOCUS, hook|optional },
2921 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
2922 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2923 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2924 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2925 { WM_SETFOCUS, sent|optional|defwinproc },
2926 { WM_MDIACTIVATE, sent|optional|defwinproc },
2927 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2928 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2930 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2931 { WM_NCCALCSIZE, sent|wparam, 1 },
2932 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2933 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2934 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2937 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
2938 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
2939 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2940 { WM_GETMINMAXINFO, sent },
2941 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
2942 { WM_GETMINMAXINFO, sent|defwinproc },
2943 { WM_NCCALCSIZE, sent|wparam, 1 },
2944 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2945 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2947 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2948 { WM_NCACTIVATE, sent|wparam|defwinproc|optional, 1 },
2949 { HCBT_SETFOCUS, hook|optional },
2950 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2951 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2952 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2953 { HCBT_SETFOCUS, hook|optional },
2954 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
2955 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2956 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2957 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2958 { WM_SETFOCUS, sent|defwinproc|optional },
2959 { WM_MDIACTIVATE, sent|defwinproc|optional },
2960 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2961 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2964 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
2965 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
2966 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
2967 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2968 { WM_GETMINMAXINFO, sent },
2969 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2970 { WM_GETMINMAXINFO, sent|defwinproc },
2971 { WM_NCCALCSIZE, sent|wparam, 1 },
2972 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
2973 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2974 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
2975 { WM_MOVE, sent|defwinproc },
2976 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2978 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2979 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2980 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2981 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
2982 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
2983 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
2985 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2986 { WM_NCCALCSIZE, sent|wparam, 1 },
2987 { 0x0093, sent|defwinproc|optional },
2988 { 0x0094, sent|defwinproc|optional },
2989 { 0x0094, sent|defwinproc|optional },
2990 { 0x0094, sent|defwinproc|optional },
2991 { 0x0094, sent|defwinproc|optional },
2992 { 0x0093, sent|defwinproc|optional },
2993 { 0x0093, sent|defwinproc|optional },
2994 { 0x0091, sent|defwinproc|optional },
2995 { 0x0092, sent|defwinproc|optional },
2996 { 0x0092, sent|defwinproc|optional },
2997 { 0x0092, sent|defwinproc|optional },
2998 { 0x0092, sent|defwinproc|optional },
2999 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3000 { WM_MOVE, sent|defwinproc },
3001 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3002 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
3004 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
3005 { WM_NCCALCSIZE, sent|wparam, 1 },
3006 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
3007 { WM_SIZE, sent|wparam, SIZE_RESTORED },
3009 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
3010 { WM_GETMINMAXINFO, sent|defwinproc },
3011 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
3012 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
3013 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3014 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
3015 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
3016 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3017 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3018 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
3020 { 0x0093, sent|optional },
3021 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
3022 { 0x0093, sent|defwinproc|optional },
3023 { 0x0093, sent|defwinproc|optional },
3024 { 0x0093, sent|defwinproc|optional },
3025 { 0x0091, sent|defwinproc|optional },
3026 { 0x0092, sent|defwinproc|optional },
3027 { 0x0092, sent|defwinproc|optional },
3028 { 0x0092, sent|defwinproc|optional },
3029 { 0x0092, sent|defwinproc|optional },
3030 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
3031 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
3032 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3035 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3036 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
3037 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3038 { WM_GETMINMAXINFO, sent },
3039 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3040 { WM_NCCALCSIZE, sent|wparam, 1 },
3041 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3042 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3043 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3045 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3046 { WM_NCCALCSIZE, sent|wparam, 1 },
3047 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3048 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3049 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3052 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3053 static const struct message WmRestoreMDIchildVisibleSeq[] = {
3054 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3055 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3056 { WM_NCCALCSIZE, sent|wparam, 1 },
3057 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3058 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3059 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3061 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3062 { WM_NCCALCSIZE, sent|wparam, 1 },
3063 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3064 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3065 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3068 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3069 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
3070 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3071 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
3072 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
3073 { WM_NCCALCSIZE, sent|wparam, 1 },
3074 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3075 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
3076 { WM_MOVE, sent|defwinproc },
3077 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3078 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3079 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3080 { HCBT_SETFOCUS, hook },
3081 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3082 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
3083 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3084 { WM_SETFOCUS, sent },
3087 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3088 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
3089 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
3090 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
3091 { WM_NCCALCSIZE, sent|wparam, 1 },
3092 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOCLIENTSIZE|SWP_STATECHANGED },
3093 { WM_MOVE, sent|defwinproc },
3094 { WM_SIZE, sent|defwinproc|wparam, SIZE_MINIMIZED },
3095 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
3096 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3097 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3098 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3099 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
3102 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3103 static const struct message WmRestoreMDIchildInisibleSeq[] = {
3104 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3105 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
3106 { WM_NCCALCSIZE, sent|wparam, 1 },
3107 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3108 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3109 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3110 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3112 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3113 { WM_NCCALCSIZE, sent|wparam, 1 },
3114 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3115 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3116 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3120 static HWND mdi_client;
3121 static WNDPROC old_mdi_client_proc;
3123 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3125 struct recvd_message msg;
3127 /* do not log painting messages */
3128 if (message != WM_PAINT &&
3129 message != WM_NCPAINT &&
3130 message != WM_SYNCPAINT &&
3131 message != WM_ERASEBKGND &&
3132 message != WM_NCHITTEST &&
3133 message != WM_GETTEXT &&
3134 message != WM_MDIGETACTIVE &&
3135 message != WM_GETICON &&
3136 message != WM_GETOBJECT &&
3137 message != WM_DEVICECHANGE)
3140 msg.message = message;
3141 msg.flags = sent|wparam|lparam;
3142 msg.wParam = wParam;
3143 msg.lParam = lParam;
3144 msg.descr = "mdi client";
3148 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
3151 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3153 static long defwndproc_counter = 0;
3155 struct recvd_message msg;
3157 /* do not log painting messages */
3158 if (message != WM_PAINT &&
3159 message != WM_NCPAINT &&
3160 message != WM_SYNCPAINT &&
3161 message != WM_ERASEBKGND &&
3162 message != WM_NCHITTEST &&
3163 message != WM_GETTEXT &&
3164 message != WM_GETICON &&
3165 message != WM_GETOBJECT &&
3166 message != WM_DEVICECHANGE)
3170 case WM_MDIACTIVATE:
3172 HWND active, client = GetParent(hwnd);
3174 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
3176 if (hwnd == (HWND)lParam) /* if we are being activated */
3177 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
3179 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
3185 msg.message = message;
3186 msg.flags = sent|wparam|lparam;
3187 if (defwndproc_counter) msg.flags |= defwinproc;
3188 msg.wParam = wParam;
3189 msg.lParam = lParam;
3190 msg.descr = "mdi child";
3194 defwndproc_counter++;
3195 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
3196 defwndproc_counter--;
3201 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3203 static long defwndproc_counter = 0;
3205 struct recvd_message msg;
3207 /* do not log painting messages */
3208 if (message != WM_PAINT &&
3209 message != WM_NCPAINT &&
3210 message != WM_SYNCPAINT &&
3211 message != WM_ERASEBKGND &&
3212 message != WM_NCHITTEST &&
3213 message != WM_GETTEXT &&
3214 message != WM_GETICON &&
3215 message != WM_GETOBJECT &&
3216 message != WM_DEVICECHANGE)
3219 msg.message = message;
3220 msg.flags = sent|wparam|lparam;
3221 if (defwndproc_counter) msg.flags |= defwinproc;
3222 msg.wParam = wParam;
3223 msg.lParam = lParam;
3224 msg.descr = "mdi frame";
3228 defwndproc_counter++;
3229 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
3230 defwndproc_counter--;
3235 static BOOL mdi_RegisterWindowClasses(void)
3240 cls.lpfnWndProc = mdi_frame_wnd_proc;
3243 cls.hInstance = GetModuleHandleA(0);
3245 cls.hCursor = LoadCursorA(0, IDC_ARROW);
3246 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
3247 cls.lpszMenuName = NULL;
3248 cls.lpszClassName = "MDI_frame_class";
3249 if (!RegisterClassA(&cls)) return FALSE;
3251 cls.lpfnWndProc = mdi_child_wnd_proc;
3252 cls.lpszClassName = "MDI_child_class";
3253 if (!RegisterClassA(&cls)) return FALSE;
3255 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
3256 old_mdi_client_proc = cls.lpfnWndProc;
3257 cls.hInstance = GetModuleHandleA(0);
3258 cls.lpfnWndProc = mdi_client_hook_proc;
3259 cls.lpszClassName = "MDI_client_class";
3260 if (!RegisterClassA(&cls)) assert(0);
3265 static void test_mdi_messages(void)
3267 MDICREATESTRUCTA mdi_cs;
3268 CLIENTCREATESTRUCT client_cs;
3269 HWND mdi_frame, mdi_child, mdi_child2, active_child;
3271 HMENU hMenu = CreateMenu();
3273 assert(mdi_RegisterWindowClasses());
3277 trace("creating MDI frame window\n");
3278 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3279 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
3280 WS_MAXIMIZEBOX | WS_VISIBLE,
3281 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
3282 GetDesktopWindow(), hMenu,
3283 GetModuleHandleA(0), NULL);
3285 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
3287 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3288 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
3290 trace("creating MDI client window\n");
3291 client_cs.hWindowMenu = 0;
3292 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
3293 mdi_client = CreateWindowExA(0, "MDI_client_class",
3295 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
3297 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3299 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
3301 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3302 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
3304 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3305 ok(!active_child, "wrong active MDI child %p\n", active_child);
3306 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3311 trace("creating invisible MDI child window\n");
3312 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3314 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3315 mdi_client, 0, GetModuleHandleA(0), NULL);
3319 ShowWindow(mdi_child, SW_SHOWNORMAL);
3320 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3322 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3323 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3325 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3326 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3328 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3329 ok(!active_child, "wrong active MDI child %p\n", active_child);
3330 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3332 ShowWindow(mdi_child, SW_HIDE);
3333 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3336 ShowWindow(mdi_child, SW_SHOW);
3337 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3339 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3340 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3342 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3343 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3345 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3346 ok(!active_child, "wrong active MDI child %p\n", active_child);
3347 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3349 DestroyWindow(mdi_child);
3352 trace("creating visible MDI child window\n");
3353 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3354 WS_CHILD | WS_VISIBLE,
3355 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3356 mdi_client, 0, GetModuleHandleA(0), NULL);
3358 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3360 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3361 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3363 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3364 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3366 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3367 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3368 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3371 DestroyWindow(mdi_child);
3372 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3374 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3375 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3377 /* Win2k: MDI client still returns a just destroyed child as active
3378 * Win9x: MDI client returns 0
3380 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3381 ok(active_child == mdi_child || /* win2k */
3382 !active_child, /* win9x */
3383 "wrong active MDI child %p\n", active_child);
3384 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3388 trace("creating invisible MDI child window\n");
3389 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3391 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3392 mdi_client, 0, GetModuleHandleA(0), NULL);
3394 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3396 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3397 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3399 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3400 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3402 /* Win2k: MDI client still returns a just destroyed child as active
3403 * Win9x: MDI client returns mdi_child2
3405 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3406 ok(active_child == mdi_child || /* win2k */
3407 active_child == mdi_child2, /* win9x */
3408 "wrong active MDI child %p\n", active_child);
3409 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3412 ShowWindow(mdi_child2, SW_MAXIMIZE);
3413 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3415 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3416 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3418 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3419 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3420 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3423 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3424 ok(GetFocus() == mdi_child2 || /* win2k */
3425 GetFocus() == 0, /* win9x */
3426 "wrong focus window %p\n", GetFocus());
3431 ShowWindow(mdi_child2, SW_HIDE);
3432 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3434 ShowWindow(mdi_child2, SW_RESTORE);
3435 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3438 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3439 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3441 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3442 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3443 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3449 ShowWindow(mdi_child2, SW_HIDE);
3450 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3452 ShowWindow(mdi_child2, SW_SHOW);
3453 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3455 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3456 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3458 ShowWindow(mdi_child2, SW_MAXIMIZE);
3459 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3461 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3462 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3464 ShowWindow(mdi_child2, SW_RESTORE);
3465 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3467 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3468 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3470 ShowWindow(mdi_child2, SW_MINIMIZE);
3471 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3473 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3474 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3476 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3477 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3478 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3481 ShowWindow(mdi_child2, SW_RESTORE);
3482 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", TRUE);
3484 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3485 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3487 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3488 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3489 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3495 ShowWindow(mdi_child2, SW_HIDE);
3496 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3498 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3499 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3501 DestroyWindow(mdi_child2);
3502 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3504 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3505 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3507 /* test for maximized MDI children */
3508 trace("creating maximized visible MDI child window 1\n");
3509 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3510 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3511 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3512 mdi_client, 0, GetModuleHandleA(0), NULL);
3514 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3515 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3517 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3518 ok(GetFocus() == mdi_child || /* win2k */
3519 GetFocus() == 0, /* win9x */
3520 "wrong focus window %p\n", GetFocus());
3522 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3523 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3524 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3527 trace("creating maximized visible MDI child window 2\n");
3528 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3529 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3530 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3531 mdi_client, 0, GetModuleHandleA(0), NULL);
3533 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3534 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3535 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3537 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3538 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3540 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3541 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3542 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3545 trace("destroying maximized visible MDI child window 2\n");
3546 DestroyWindow(mdi_child2);
3547 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3549 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3551 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3552 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3554 /* Win2k: MDI client still returns a just destroyed child as active
3555 * Win9x: MDI client returns 0
3557 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3558 ok(active_child == mdi_child2 || /* win2k */
3559 !active_child, /* win9x */
3560 "wrong active MDI child %p\n", active_child);
3563 ShowWindow(mdi_child, SW_MAXIMIZE);
3564 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3567 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3568 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3570 trace("re-creating maximized visible MDI child window 2\n");
3571 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3572 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3573 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3574 mdi_client, 0, GetModuleHandleA(0), NULL);
3576 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3577 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3578 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3580 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3581 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3583 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3584 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3585 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3588 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3589 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3590 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3592 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3593 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3594 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3596 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3597 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3598 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3601 DestroyWindow(mdi_child);
3602 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3604 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3605 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3607 /* Win2k: MDI client still returns a just destroyed child as active
3608 * Win9x: MDI client returns 0
3610 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3611 ok(active_child == mdi_child || /* win2k */
3612 !active_child, /* win9x */
3613 "wrong active MDI child %p\n", active_child);
3616 trace("creating maximized invisible MDI child window\n");
3617 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3618 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3619 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3620 mdi_client, 0, GetModuleHandleA(0), NULL);
3622 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", FALSE);
3623 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3624 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3625 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3627 /* Win2k: MDI client still returns a just destroyed child as active
3628 * Win9x: MDI client returns 0
3630 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3631 ok(active_child == mdi_child || /* win2k */
3632 !active_child, /* win9x */
3633 "wrong active MDI child %p\n", active_child);
3636 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3637 ShowWindow(mdi_child2, SW_MAXIMIZE);
3638 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3639 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3640 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3641 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3643 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3644 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3645 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3648 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3651 /* end of test for maximized MDI children */
3654 trace("creating maximized visible MDI child window 1(Switch test)\n");
3655 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3656 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3657 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3658 mdi_client, 0, GetModuleHandleA(0), NULL);
3660 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3661 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3663 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3664 ok(GetFocus() == mdi_child || /* win2k */
3665 GetFocus() == 0, /* win9x */
3666 "wrong focus window %p(Switch test)\n", GetFocus());
3668 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3669 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3670 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3673 trace("creating maximized visible MDI child window 2(Switch test)\n");
3674 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3675 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3676 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3677 mdi_client, 0, GetModuleHandleA(0), NULL);
3679 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3681 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3682 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3684 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3685 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3687 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3688 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3689 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3692 trace("Switch child window.\n");
3693 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3694 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3695 trace("end of test for switch maximized MDI children\n");
3698 /* Prepare for switching test of not maximized MDI children */
3699 ShowWindow( mdi_child, SW_NORMAL );
3700 ok(!IsZoomed(mdi_child), "wrong zoomed state for %p(Switch test)\n", mdi_child);
3701 ok(!IsZoomed(mdi_child2), "wrong zoomed state for %p(Switch test)\n", mdi_child2);
3702 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
3703 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3706 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child2, 0);
3707 ok_sequence(WmSwitchNotMaximizedChild, "Not maximized child did not switch correctly", FALSE);
3708 trace("end of test for switch not maximized MDI children\n");
3711 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3714 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3719 /* end of tests for switch maximized/not maximized MDI children */
3721 mdi_cs.szClass = "MDI_child_Class";
3722 mdi_cs.szTitle = "MDI child";
3723 mdi_cs.hOwner = GetModuleHandleA(0);
3726 mdi_cs.cx = CW_USEDEFAULT;
3727 mdi_cs.cy = CW_USEDEFAULT;
3728 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3730 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3731 ok(mdi_child != 0, "MDI child creation failed\n");
3732 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3734 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3736 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3737 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3739 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3740 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3741 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3743 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3744 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3745 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3748 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3749 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3751 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3752 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3753 ok(!active_child, "wrong active MDI child %p\n", active_child);
3758 DestroyWindow(mdi_client);
3759 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3761 /* test maximization of MDI child with invisible parent */
3762 client_cs.hWindowMenu = 0;
3763 mdi_client = CreateWindow("MDI_client_class",
3765 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3767 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3768 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3770 ShowWindow(mdi_client, SW_HIDE);
3771 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3773 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3774 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3776 mdi_client, 0, GetModuleHandleA(0), NULL);
3777 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3779 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3780 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3781 zoomed = IsZoomed(mdi_child);
3782 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3784 ShowWindow(mdi_client, SW_SHOW);
3785 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3787 DestroyWindow(mdi_child);
3788 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3790 /* end of test for maximization of MDI child with invisible parent */
3792 DestroyWindow(mdi_client);
3793 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3795 DestroyWindow(mdi_frame);
3796 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3798 /************************* End of MDI test **********************************/
3800 static void test_WM_SETREDRAW(HWND hwnd)
3802 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3807 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3808 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3810 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3811 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3814 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3815 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3817 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3818 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3820 /* restore original WS_VISIBLE state */
3821 SetWindowLongA(hwnd, GWL_STYLE, style);
3827 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3829 struct recvd_message msg;
3838 case WM_DEVICECHANGE:
3845 msg.message = message;
3846 msg.flags = sent|wparam|lparam;
3847 msg.wParam = wParam;
3848 msg.lParam = lParam;
3849 msg.descr = "dialog";
3852 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3853 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3857 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3859 DWORD style, exstyle;
3863 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3864 style = GetWindowLongA(hwnd, GWL_STYLE);
3865 /* do not be confused by WS_DLGFRAME set */
3866 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3868 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3869 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3871 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3872 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3873 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3874 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3876 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3878 style = GetWindowLongA(hwnd, GWL_STYLE);
3879 if (set) ok(style & set, "style %08x should be set\n", set);
3880 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3882 /* a subsequent call should do nothing */
3883 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3884 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3885 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3889 trace("Ignore GetScrollRange error below if you are on Win9x\n");
3890 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
3891 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
3892 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3893 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
3894 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
3897 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3899 DWORD style, exstyle;
3903 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3904 style = GetWindowLongA(hwnd, GWL_STYLE);
3905 /* do not be confused by WS_DLGFRAME set */
3906 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3908 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3909 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3911 si.cbSize = sizeof(si);
3912 si.fMask = SIF_RANGE;
3915 SetScrollInfo(hwnd, ctl, &si, TRUE);
3916 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3917 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
3919 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
3921 style = GetWindowLongA(hwnd, GWL_STYLE);
3922 if (set) ok(style & set, "style %08x should be set\n", set);
3923 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3925 /* a subsequent call should do nothing */
3926 SetScrollInfo(hwnd, ctl, &si, TRUE);
3927 if (style & WS_HSCROLL)
3928 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3929 else if (style & WS_VSCROLL)
3930 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3932 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3934 si.fMask = SIF_PAGE;
3936 SetScrollInfo(hwnd, ctl, &si, FALSE);
3937 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3941 SetScrollInfo(hwnd, ctl, &si, FALSE);
3942 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
3944 si.fMask = SIF_RANGE;
3945 si.nMin = 0xdeadbeef;
3946 si.nMax = 0xdeadbeef;
3947 ret = GetScrollInfo(hwnd, ctl, &si);
3948 ok( ret, "GetScrollInfo error %d\n", GetLastError());
3949 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
3950 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
3951 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
3954 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
3955 static void test_scroll_messages(HWND hwnd)
3966 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3967 ok( ret, "GetScrollRange error %d\n", GetLastError());
3968 if (sequence->message != WmGetScrollRangeSeq[0].message)
3969 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3970 /* values of min and max are undefined */
3973 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
3974 ok( ret, "SetScrollRange error %d\n", GetLastError());
3975 if (sequence->message != WmSetScrollRangeSeq[0].message)
3976 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3981 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
3982 ok( ret, "GetScrollRange error %d\n", GetLastError());
3983 if (sequence->message != WmGetScrollRangeSeq[0].message)
3984 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
3985 /* values of min and max are undefined */
3988 si.cbSize = sizeof(si);
3989 si.fMask = SIF_RANGE;
3992 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
3993 if (sequence->message != WmSetScrollRangeSeq[0].message)
3994 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
3997 si.fMask = SIF_PAGE;
3999 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4000 if (sequence->message != WmSetScrollRangeSeq[0].message)
4001 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4006 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4007 if (sequence->message != WmSetScrollRangeSeq[0].message)
4008 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4011 si.fMask = SIF_RANGE;
4012 si.nMin = 0xdeadbeef;
4013 si.nMax = 0xdeadbeef;
4014 ret = GetScrollInfo(hwnd, SB_CTL, &si);
4015 ok( ret, "GetScrollInfo error %d\n", GetLastError());
4016 if (sequence->message != WmGetScrollInfoSeq[0].message)
4017 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4018 /* values of min and max are undefined */
4021 /* set WS_HSCROLL */
4022 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
4023 /* clear WS_HSCROLL */
4024 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
4026 /* set WS_HSCROLL */
4027 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
4028 /* clear WS_HSCROLL */
4029 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
4031 /* set WS_VSCROLL */
4032 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
4033 /* clear WS_VSCROLL */
4034 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
4036 /* set WS_VSCROLL */
4037 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
4038 /* clear WS_VSCROLL */
4039 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
4042 static void test_showwindow(void)
4047 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4048 100, 100, 200, 200, 0, 0, 0, NULL);
4049 ok (hwnd != 0, "Failed to create overlapped window\n");
4050 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4051 0, 0, 10, 10, hwnd, 0, 0, NULL);
4052 ok (hchild != 0, "Failed to create child\n");
4055 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4056 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4057 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4058 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", TRUE);
4060 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4061 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4062 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4063 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
4064 /* back to invisible */
4065 ShowWindow(hchild, SW_HIDE);
4066 ShowWindow(hwnd, SW_HIDE);
4068 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4069 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4070 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4071 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
4072 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4073 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
4075 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4076 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4077 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
4078 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4079 ShowWindow( hwnd, SW_SHOW);
4081 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4082 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4083 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
4085 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4086 ShowWindow( hchild, SW_HIDE);
4088 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4089 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4090 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
4093 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
4094 DestroyWindow(hchild);
4095 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4097 DestroyWindow(hwnd);
4102 * 1. Create invisible maximized popup window.
4103 * 2. Move and resize it.
4104 * 3. Show it maximized.
4106 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4107 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
4108 100, 100, 200, 200, 0, 0, 0, NULL);
4109 ok (hwnd != 0, "Failed to create popup window\n");
4110 ok(IsZoomed(hwnd), "window should be maximized\n");
4111 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4113 GetWindowRect(hwnd, &rc);
4114 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
4115 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
4116 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4117 rc.left, rc.top, rc.right, rc.bottom);
4118 /* Reset window's size & position */
4119 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
4120 ok(IsZoomed(hwnd), "window should be maximized\n");
4123 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4124 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4125 ok(IsZoomed(hwnd), "window should be maximized\n");
4126 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
4128 GetWindowRect(hwnd, &rc);
4129 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
4130 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
4131 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4132 rc.left, rc.top, rc.right, rc.bottom);
4133 DestroyWindow(hwnd);
4137 * 1. Create invisible maximized popup window.
4138 * 2. Show it maximized.
4140 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4141 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
4142 100, 100, 200, 200, 0, 0, 0, NULL);
4143 ok (hwnd != 0, "Failed to create popup window\n");
4144 ok(IsZoomed(hwnd), "window should be maximized\n");
4145 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4147 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4148 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4149 ok(IsZoomed(hwnd), "window should be maximized\n");
4150 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
4151 DestroyWindow(hwnd);
4155 * 1. Create visible maximized popup window.
4157 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4158 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4159 100, 100, 200, 200, 0, 0, 0, NULL);
4160 ok (hwnd != 0, "Failed to create popup window\n");
4161 ok(IsZoomed(hwnd), "window should be maximized\n");
4162 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4163 DestroyWindow(hwnd);
4167 * 1. Create visible popup window.
4170 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4171 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
4172 100, 100, 200, 200, 0, 0, 0, NULL);
4173 ok (hwnd != 0, "Failed to create popup window\n");
4174 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
4175 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
4177 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4178 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4179 ok(IsZoomed(hwnd), "window should be maximized\n");
4180 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
4181 DestroyWindow(hwnd);
4185 static void test_sys_menu(void)
4191 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4192 100, 100, 200, 200, 0, 0, 0, NULL);
4193 ok (hwnd != 0, "Failed to create overlapped window\n");
4197 /* test existing window without CS_NOCLOSE style */
4198 hmenu = GetSystemMenu(hwnd, FALSE);
4199 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4201 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4202 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4203 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4205 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
4206 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4208 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4209 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4210 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
4212 EnableMenuItem(hmenu, SC_CLOSE, 0);
4213 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4215 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4216 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4217 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4219 /* test whether removing WS_SYSMENU destroys a system menu */
4220 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
4221 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4223 hmenu = GetSystemMenu(hwnd, FALSE);
4224 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4226 DestroyWindow(hwnd);
4228 /* test new window with CS_NOCLOSE style */
4229 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4230 100, 100, 200, 200, 0, 0, 0, NULL);
4231 ok (hwnd != 0, "Failed to create overlapped window\n");
4233 hmenu = GetSystemMenu(hwnd, FALSE);
4234 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4236 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4237 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4239 DestroyWindow(hwnd);
4241 /* test new window without WS_SYSMENU style */
4242 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
4243 100, 100, 200, 200, 0, 0, 0, NULL);
4244 ok(hwnd != 0, "Failed to create overlapped window\n");
4246 hmenu = GetSystemMenu(hwnd, FALSE);
4247 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
4249 DestroyWindow(hwnd);
4252 /* For shown WS_OVERLAPPEDWINDOW */
4253 static const struct message WmSetIcon_1[] = {
4254 { WM_SETICON, sent },
4255 { 0x00AE, sent|defwinproc|optional }, /* XP */
4256 { WM_GETTEXT, sent|defwinproc|optional },
4257 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
4261 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4262 static const struct message WmSetIcon_2[] = {
4263 { WM_SETICON, sent },
4267 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4268 static const struct message WmInitEndSession[] = {
4270 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4274 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4275 static const struct message WmInitEndSession_2[] = {
4277 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4281 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4282 static const struct message WmInitEndSession_3[] = {
4284 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4288 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4289 static const struct message WmInitEndSession_4[] = {
4291 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4295 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4296 static const struct message WmInitEndSession_5[] = {
4298 { WM_ENDSESSION, sent|defwinproc/*|wparam*/|lparam, 1, ENDSESSION_LOGOFF },
4302 static const struct message WmOptionalPaint[] = {
4303 { WM_PAINT, sent|optional },
4304 { WM_NCPAINT, sent|beginpaint|optional },
4305 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4306 { WM_ERASEBKGND, sent|beginpaint|optional },
4310 static const struct message WmZOrder[] = {
4311 { WM_WINDOWPOSCHANGING, sent|wparam, 0, 0 },
4312 { WM_GETMINMAXINFO, sent|defwinproc|wparam, 0, 0 },
4313 { HCBT_ACTIVATE, hook },
4314 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
4315 { WM_WINDOWPOSCHANGING, sent|wparam, 3, 0 },
4316 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0 },
4317 { WM_GETTEXT, sent|optional },
4318 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
4319 { WM_ACTIVATEAPP, sent|wparam, 1, 0 },
4320 { WM_NCACTIVATE, sent|wparam|lparam, 1, 0 },
4321 { WM_GETTEXT, sent|defwinproc|optional },
4322 { WM_GETTEXT, sent|defwinproc|optional },
4323 { WM_ACTIVATE, sent|wparam|lparam, 1, 0 },
4324 { HCBT_SETFOCUS, hook },
4325 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4326 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4327 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4328 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
4329 { WM_GETTEXT, sent|optional },
4330 { WM_NCCALCSIZE, sent|optional },
4334 static void test_MsgWaitForMultipleObjects(HWND hwnd)
4339 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4340 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4342 PostMessageA(hwnd, WM_USER, 0, 0);
4344 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4345 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4347 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4348 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4350 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4351 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4353 PostMessageA(hwnd, WM_USER, 0, 0);
4355 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4356 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4358 ok(PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4359 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4361 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4362 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4363 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4365 PostMessageA(hwnd, WM_USER, 0, 0);
4367 /* new incoming message causes it to become signaled again */
4368 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4369 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4371 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4372 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4373 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4374 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4377 /* test if we receive the right sequence of messages */
4378 static void test_messages(void)
4380 HWND hwnd, hparent, hchild;
4381 HWND hchild2, hbutton;
4388 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4389 100, 100, 200, 200, 0, 0, 0, NULL);
4390 ok (hwnd != 0, "Failed to create overlapped window\n");
4391 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4393 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4394 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4395 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4397 /* test WM_SETREDRAW on a not visible top level window */
4398 test_WM_SETREDRAW(hwnd);
4400 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4402 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4403 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4405 ok(GetActiveWindow() == hwnd, "window should be active\n");
4406 ok(GetFocus() == hwnd, "window should have input focus\n");
4407 ShowWindow(hwnd, SW_HIDE);
4409 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4411 ShowWindow(hwnd, SW_SHOW);
4413 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4415 ShowWindow(hwnd, SW_HIDE);
4417 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4419 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4421 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4423 ShowWindow(hwnd, SW_RESTORE);
4424 ok_sequence(WmShowRestoreMaxOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", FALSE);
4428 ShowWindow(hwnd, SW_MINIMIZE);
4430 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4433 ShowWindow(hwnd, SW_RESTORE);
4435 ok_sequence(WmShowRestoreMinOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", TRUE);
4438 ShowWindow(hwnd, SW_SHOW);
4440 ok_sequence(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4442 ok(GetActiveWindow() == hwnd, "window should be active\n");
4443 ok(GetFocus() == hwnd, "window should have input focus\n");
4444 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4445 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4446 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4447 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4449 /* test WM_SETREDRAW on a visible top level window */
4450 ShowWindow(hwnd, SW_SHOW);
4452 test_WM_SETREDRAW(hwnd);
4454 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4455 test_scroll_messages(hwnd);
4457 /* test resizing and moving */
4458 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4459 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4462 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4463 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4466 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER|SWP_NOACTIVATE );
4467 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4471 /* popups don't get WM_GETMINMAXINFO */
4472 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4473 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4475 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4476 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4478 DestroyWindow(hwnd);
4479 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4481 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4482 100, 100, 200, 200, 0, 0, 0, NULL);
4483 ok (hparent != 0, "Failed to create parent window\n");
4486 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4487 0, 0, 10, 10, hparent, 0, 0, NULL);
4488 ok (hchild != 0, "Failed to create child window\n");
4489 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4490 DestroyWindow(hchild);
4493 /* visible child window with a caption */
4494 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4495 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4496 0, 0, 10, 10, hparent, 0, 0, NULL);
4497 ok (hchild != 0, "Failed to create child window\n");
4498 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4500 trace("testing scroll APIs on a visible child window %p\n", hchild);
4501 test_scroll_messages(hchild);
4503 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4504 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4506 DestroyWindow(hchild);
4509 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4510 0, 0, 10, 10, hparent, 0, 0, NULL);
4511 ok (hchild != 0, "Failed to create child window\n");
4512 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4514 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4515 100, 100, 50, 50, hparent, 0, 0, NULL);
4516 ok (hchild2 != 0, "Failed to create child2 window\n");
4519 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4520 0, 100, 50, 50, hchild, 0, 0, NULL);
4521 ok (hbutton != 0, "Failed to create button window\n");
4523 /* test WM_SETREDRAW on a not visible child window */
4524 test_WM_SETREDRAW(hchild);
4526 ShowWindow(hchild, SW_SHOW);
4527 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4529 /* check parent messages too */
4530 log_all_parent_messages++;
4531 ShowWindow(hchild, SW_HIDE);
4532 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4533 log_all_parent_messages--;
4535 ShowWindow(hchild, SW_SHOW);
4536 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4538 ShowWindow(hchild, SW_HIDE);
4539 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4541 ShowWindow(hchild, SW_SHOW);
4542 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4544 /* test WM_SETREDRAW on a visible child window */
4545 test_WM_SETREDRAW(hchild);
4547 log_all_parent_messages++;
4548 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4549 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4550 log_all_parent_messages--;
4552 ShowWindow(hchild, SW_HIDE);
4554 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4555 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4557 ShowWindow(hchild, SW_HIDE);
4559 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4560 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4562 /* DestroyWindow sequence below expects that a child has focus */
4566 DestroyWindow(hchild);
4567 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4568 DestroyWindow(hchild2);
4569 DestroyWindow(hbutton);
4572 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4573 0, 0, 100, 100, hparent, 0, 0, NULL);
4574 ok (hchild != 0, "Failed to create child popup window\n");
4575 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4576 DestroyWindow(hchild);
4578 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4580 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4581 0, 0, 100, 100, hparent, 0, 0, NULL);
4582 ok (hchild != 0, "Failed to create popup window\n");
4583 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4584 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4585 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4587 ShowWindow(hchild, SW_SHOW);
4588 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4590 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4591 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4593 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4594 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
4595 DestroyWindow(hchild);
4597 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4598 * changes nothing in message sequences.
4601 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4602 0, 0, 100, 100, hparent, 0, 0, NULL);
4603 ok (hchild != 0, "Failed to create popup window\n");
4604 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4605 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4606 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4608 ShowWindow(hchild, SW_SHOW);
4609 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4611 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4612 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4613 DestroyWindow(hchild);
4616 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4617 0, 0, 100, 100, hparent, 0, 0, NULL);
4618 ok(hwnd != 0, "Failed to create custom dialog window\n");
4619 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4622 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4623 test_scroll_messages(hwnd);
4629 SendMessage(hwnd, WM_NULL, 0, 0);
4632 after_end_dialog = 1;
4633 EndDialog( hwnd, 0 );
4634 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4636 DestroyWindow(hwnd);
4637 after_end_dialog = 0;
4640 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4641 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4642 ok(hwnd != 0, "Failed to create custom dialog window\n");
4644 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4645 ShowWindow(hwnd, SW_SHOW);
4646 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4647 DestroyWindow(hwnd);
4650 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4651 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4653 DestroyWindow(hparent);
4656 /* Message sequence for SetMenu */
4657 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4658 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4660 hmenu = CreateMenu();
4661 ok (hmenu != 0, "Failed to create menu\n");
4662 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4663 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4664 100, 100, 200, 200, 0, hmenu, 0, NULL);
4665 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4666 ok (SetMenu(hwnd, 0), "SetMenu\n");
4667 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4668 ok (SetMenu(hwnd, 0), "SetMenu\n");
4669 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4670 ShowWindow(hwnd, SW_SHOW);
4671 UpdateWindow( hwnd );
4674 ok (SetMenu(hwnd, 0), "SetMenu\n");
4675 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4676 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4677 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4679 UpdateWindow( hwnd );
4682 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4684 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4686 DestroyWindow(hwnd);
4689 /* Message sequence for EnableWindow */
4690 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4691 100, 100, 200, 200, 0, 0, 0, NULL);
4692 ok (hparent != 0, "Failed to create parent window\n");
4693 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4694 0, 0, 10, 10, hparent, 0, 0, NULL);
4695 ok (hchild != 0, "Failed to create child window\n");
4701 EnableWindow(hparent, FALSE);
4702 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4704 EnableWindow(hparent, TRUE);
4705 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4710 test_MsgWaitForMultipleObjects(hparent);
4712 /* the following test causes an exception in user.exe under win9x */
4713 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4715 DestroyWindow(hparent);
4719 PostMessageW( hparent, WM_USER+1, 0, 0 );
4720 /* PeekMessage(NULL) fails, but still removes the message */
4721 SetLastError(0xdeadbeef);
4722 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4723 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4724 GetLastError() == 0xdeadbeef, /* NT4 */
4725 "last error is %d\n", GetLastError() );
4726 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4727 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4729 DestroyWindow(hchild);
4730 DestroyWindow(hparent);
4733 /* Message sequences for WM_SETICON */
4734 trace("testing WM_SETICON\n");
4735 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4736 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4738 ShowWindow(hwnd, SW_SHOW);
4742 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4743 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4745 ShowWindow(hwnd, SW_HIDE);
4748 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4749 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4750 DestroyWindow(hwnd);
4753 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4754 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4756 ShowWindow(hwnd, SW_SHOW);
4760 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4761 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4763 ShowWindow(hwnd, SW_HIDE);
4766 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4767 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4770 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4773 todo_wine win_skip( "Message 0x3b not supported\n" );
4776 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4777 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4778 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4779 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4780 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4781 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4782 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4783 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4786 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4787 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4788 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4789 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4790 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4791 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4793 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4794 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4795 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4797 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4798 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4799 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4802 DestroyWindow(hwnd);
4806 static void test_setwindowpos(void)
4811 const INT winX = 100;
4812 const INT winY = 100;
4813 const INT sysX = GetSystemMetrics(SM_CXMINTRACK);
4815 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0,
4816 0, 0, winX, winY, 0,
4819 GetWindowRect(hwnd, &rc);
4820 expect(sysX, rc.right);
4821 expect(winY, rc.bottom);
4825 res = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, winX, winY, 0);
4826 ok_sequence(WmZOrder, "Z-Order", TRUE);
4827 ok(res == TRUE, "SetWindowPos expected TRUE, got %ld\n", res);
4829 GetWindowRect(hwnd, &rc);
4830 expect(sysX, rc.right);
4831 expect(winY, rc.bottom);
4832 DestroyWindow(hwnd);
4835 static void invisible_parent_tests(void)
4837 HWND hparent, hchild;
4839 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4840 100, 100, 200, 200, 0, 0, 0, NULL);
4841 ok (hparent != 0, "Failed to create parent window\n");
4844 /* test showing child with hidden parent */
4846 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4847 0, 0, 10, 10, hparent, 0, 0, NULL);
4848 ok (hchild != 0, "Failed to create child window\n");
4849 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4851 ShowWindow( hchild, SW_MINIMIZE );
4852 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4853 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4854 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4859 ShowWindow( hchild, SW_MINIMIZE );
4860 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4862 DestroyWindow(hchild);
4863 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4864 0, 0, 10, 10, hparent, 0, 0, NULL);
4867 ShowWindow( hchild, SW_MAXIMIZE );
4868 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4869 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4870 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4875 ShowWindow( hchild, SW_MAXIMIZE );
4876 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4878 DestroyWindow(hchild);
4879 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4880 0, 0, 10, 10, hparent, 0, 0, NULL);
4883 ShowWindow( hchild, SW_RESTORE );
4884 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
4885 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4886 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4888 DestroyWindow(hchild);
4889 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4890 0, 0, 10, 10, hparent, 0, 0, NULL);
4893 ShowWindow( hchild, SW_SHOWMINIMIZED );
4894 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4895 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4896 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4901 ShowWindow( hchild, SW_SHOWMINIMIZED );
4902 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
4904 DestroyWindow(hchild);
4905 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4906 0, 0, 10, 10, hparent, 0, 0, NULL);
4909 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
4910 ShowWindow( hchild, SW_SHOWMAXIMIZED );
4911 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
4912 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4913 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4915 DestroyWindow(hchild);
4916 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4917 0, 0, 10, 10, hparent, 0, 0, NULL);
4920 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4921 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4922 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4923 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4928 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
4929 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
4931 DestroyWindow(hchild);
4932 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4933 0, 0, 10, 10, hparent, 0, 0, NULL);
4936 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
4937 ShowWindow( hchild, SW_FORCEMINIMIZE );
4938 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
4940 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4942 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4944 DestroyWindow(hchild);
4945 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4946 0, 0, 10, 10, hparent, 0, 0, NULL);
4949 ShowWindow( hchild, SW_SHOWNA );
4950 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4951 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4952 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4957 ShowWindow( hchild, SW_SHOWNA );
4958 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
4960 DestroyWindow(hchild);
4961 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4962 0, 0, 10, 10, hparent, 0, 0, NULL);
4965 ShowWindow( hchild, SW_SHOW );
4966 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4967 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4968 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4973 ShowWindow( hchild, SW_SHOW );
4974 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
4976 ShowWindow( hchild, SW_HIDE );
4977 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
4978 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
4979 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4981 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4982 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
4983 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4984 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4986 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4987 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
4988 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
4989 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4991 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4993 DestroyWindow(hchild);
4994 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
4996 DestroyWindow(hparent);
5000 /****************** button message test *************************/
5001 static const struct message WmSetFocusButtonSeq[] =
5003 { HCBT_SETFOCUS, hook },
5004 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5005 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5006 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5007 { WM_SETFOCUS, sent|wparam, 0 },
5008 { WM_CTLCOLORBTN, sent|defwinproc },
5011 static const struct message WmKillFocusButtonSeq[] =
5013 { HCBT_SETFOCUS, hook },
5014 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5015 { WM_KILLFOCUS, sent|wparam, 0 },
5016 { WM_CTLCOLORBTN, sent|defwinproc },
5017 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5018 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5021 static const struct message WmSetFocusStaticSeq[] =
5023 { HCBT_SETFOCUS, hook },
5024 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5025 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5026 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5027 { WM_SETFOCUS, sent|wparam, 0 },
5028 { WM_CTLCOLORSTATIC, sent|defwinproc },
5031 static const struct message WmKillFocusStaticSeq[] =
5033 { HCBT_SETFOCUS, hook },
5034 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5035 { WM_KILLFOCUS, sent|wparam, 0 },
5036 { WM_CTLCOLORSTATIC, sent|defwinproc },
5037 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5038 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5041 static const struct message WmLButtonDownSeq[] =
5043 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
5044 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5045 { HCBT_SETFOCUS, hook },
5046 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
5047 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5048 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5049 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
5050 { WM_CTLCOLORBTN, sent|defwinproc },
5051 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
5052 { WM_CTLCOLORBTN, sent|defwinproc },
5053 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5056 static const struct message WmLButtonUpSeq[] =
5058 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
5059 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
5060 { WM_CTLCOLORBTN, sent|defwinproc },
5061 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5062 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
5063 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
5066 static const struct message WmSetFontButtonSeq[] =
5068 { WM_SETFONT, sent },
5070 { WM_ERASEBKGND, sent|defwinproc|optional },
5071 { WM_CTLCOLORBTN, sent|defwinproc },
5075 static WNDPROC old_button_proc;
5077 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5079 static long defwndproc_counter = 0;
5081 struct recvd_message msg;
5087 return 0; /* ignore them */
5091 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
5095 msg.message = message;
5096 msg.flags = sent|wparam|lparam;
5097 if (defwndproc_counter) msg.flags |= defwinproc;
5098 msg.wParam = wParam;
5099 msg.lParam = lParam;
5100 msg.descr = "button";
5104 defwndproc_counter++;
5105 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
5106 defwndproc_counter--;
5111 static void subclass_button(void)
5115 if (!GetClassInfoA(0, "button", &cls)) assert(0);
5117 old_button_proc = cls.lpfnWndProc;
5119 cls.hInstance = GetModuleHandle(0);
5120 cls.lpfnWndProc = button_hook_proc;
5121 cls.lpszClassName = "my_button_class";
5122 UnregisterClass(cls.lpszClassName, cls.hInstance);
5123 if (!RegisterClassA(&cls)) assert(0);
5126 static void test_button_messages(void)
5132 const struct message *setfocus;
5133 const struct message *killfocus;
5135 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
5136 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
5137 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
5138 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
5139 { BS_CHECKBOX, DLGC_BUTTON,
5140 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5141 { BS_AUTOCHECKBOX, DLGC_BUTTON,
5142 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5143 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
5144 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5145 { BS_3STATE, DLGC_BUTTON,
5146 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5147 { BS_AUTO3STATE, DLGC_BUTTON,
5148 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5149 { BS_GROUPBOX, DLGC_STATIC,
5150 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5151 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
5152 WmSetFocusButtonSeq, WmKillFocusButtonSeq },
5153 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
5154 WmSetFocusStaticSeq, WmKillFocusStaticSeq },
5155 { BS_OWNERDRAW, DLGC_BUTTON,
5156 WmSetFocusButtonSeq, WmKillFocusButtonSeq }
5165 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
5167 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_POPUP,
5168 0, 0, 50, 14, 0, 0, 0, NULL);
5169 ok(hwnd != 0, "Failed to create button window\n");
5171 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5172 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5174 ShowWindow(hwnd, SW_SHOW);
5179 trace("button style %08x\n", button[i].style);
5181 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
5184 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
5186 DestroyWindow(hwnd);
5189 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
5190 0, 0, 50, 14, 0, 0, 0, NULL);
5191 ok(hwnd != 0, "Failed to create button window\n");
5193 SetForegroundWindow(hwnd);
5198 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
5199 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
5201 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
5202 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
5205 zfont = GetStockObject(SYSTEM_FONT);
5206 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
5208 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
5210 DestroyWindow(hwnd);
5213 /****************** static message test *************************/
5214 static const struct message WmSetFontStaticSeq[] =
5216 { WM_SETFONT, sent },
5217 { WM_PAINT, sent|defwinproc|optional },
5218 { WM_ERASEBKGND, sent|defwinproc|optional },
5219 { WM_CTLCOLORSTATIC, sent|defwinproc|optional },
5223 static WNDPROC old_static_proc;
5225 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5227 static long defwndproc_counter = 0;
5229 struct recvd_message msg;
5231 if (message == WM_GETICON || message == WM_GETOBJECT) return 0; /* ignore them */
5234 msg.message = message;
5235 msg.flags = sent|wparam|lparam;
5236 if (defwndproc_counter) msg.flags |= defwinproc;
5237 msg.wParam = wParam;
5238 msg.lParam = lParam;
5239 msg.descr = "static";
5242 defwndproc_counter++;
5243 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
5244 defwndproc_counter--;
5249 static void subclass_static(void)
5253 if (!GetClassInfoA(0, "static", &cls)) assert(0);
5255 old_static_proc = cls.lpfnWndProc;
5257 cls.hInstance = GetModuleHandle(0);
5258 cls.lpfnWndProc = static_hook_proc;
5259 cls.lpszClassName = "my_static_class";
5260 UnregisterClass(cls.lpszClassName, cls.hInstance);
5261 if (!RegisterClassA(&cls)) assert(0);
5264 static void test_static_messages(void)
5266 /* FIXME: make as comprehensive as the button message test */
5271 const struct message *setfont;
5273 { SS_LEFT, DLGC_STATIC,
5274 WmSetFontStaticSeq }
5282 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
5284 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
5285 0, 0, 50, 14, 0, 0, 0, NULL);
5286 ok(hwnd != 0, "Failed to create static window\n");
5288 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5289 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5291 ShowWindow(hwnd, SW_SHOW);
5296 trace("static style %08x\n", static_ctrl[i].style);
5297 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
5298 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
5300 DestroyWindow(hwnd);
5304 /****************** ComboBox message test *************************/
5305 #define ID_COMBOBOX 0x000f
5307 static const struct message WmKeyDownComboSeq[] =
5309 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
5310 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
5311 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
5312 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
5313 { WM_CTLCOLOREDIT, sent|parent },
5314 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
5318 static WNDPROC old_combobox_proc;
5320 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5322 static long defwndproc_counter = 0;
5324 struct recvd_message msg;
5326 /* do not log painting messages */
5327 if (message != WM_PAINT &&
5328 message != WM_NCPAINT &&
5329 message != WM_SYNCPAINT &&
5330 message != WM_ERASEBKGND &&
5331 message != WM_NCHITTEST &&
5332 message != WM_GETTEXT &&
5333 message != WM_GETICON &&
5334 message != WM_GETOBJECT &&
5335 message != WM_DEVICECHANGE)
5338 msg.message = message;
5339 msg.flags = sent|wparam|lparam;
5340 if (defwndproc_counter) msg.flags |= defwinproc;
5341 msg.wParam = wParam;
5342 msg.lParam = lParam;
5343 msg.descr = "combo";
5347 defwndproc_counter++;
5348 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
5349 defwndproc_counter--;
5354 static void subclass_combobox(void)
5358 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
5360 old_combobox_proc = cls.lpfnWndProc;
5362 cls.hInstance = GetModuleHandle(0);
5363 cls.lpfnWndProc = combobox_hook_proc;
5364 cls.lpszClassName = "my_combobox_class";
5365 UnregisterClass(cls.lpszClassName, cls.hInstance);
5366 if (!RegisterClassA(&cls)) assert(0);
5369 static void test_combobox_messages(void)
5374 subclass_combobox();
5376 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5377 100, 100, 200, 200, 0, 0, 0, NULL);
5378 ok(parent != 0, "Failed to create parent window\n");
5381 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
5382 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
5383 ok(combo != 0, "Failed to create combobox window\n");
5385 UpdateWindow(combo);
5387 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5388 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5390 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5391 ok(ret == 0, "expected 0, got %ld\n", ret);
5392 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5393 ok(ret == 1, "expected 1, got %ld\n", ret);
5394 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5395 ok(ret == 2, "expected 2, got %ld\n", ret);
5397 SendMessage(combo, CB_SETCURSEL, 0, 0);
5401 log_all_parent_messages++;
5402 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5403 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5404 log_all_parent_messages--;
5405 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5407 DestroyWindow(combo);
5408 DestroyWindow(parent);
5411 /****************** WM_IME_KEYDOWN message test *******************/
5413 static const struct message WmImeKeydownMsgSeq_0[] =
5415 { WM_IME_KEYDOWN, wparam, VK_RETURN },
5416 { WM_CHAR, wparam, 'A' },
5420 static const struct message WmImeKeydownMsgSeq_1[] =
5422 { WM_KEYDOWN, optional|wparam, VK_RETURN },
5423 { WM_CHAR, optional|wparam, VK_RETURN },
5427 static LRESULT WINAPI wmime_keydown_procA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5429 struct recvd_message msg;
5432 msg.message = message;
5433 msg.flags = wparam|lparam;
5434 msg.wParam = wParam;
5435 msg.lParam = lParam;
5436 msg.descr = "wmime_keydown";
5439 return DefWindowProcA(hwnd, message, wParam, lParam);
5442 static void register_wmime_keydown_class(void)
5446 ZeroMemory(&cls, sizeof(WNDCLASSA));
5447 cls.lpfnWndProc = wmime_keydown_procA;
5448 cls.hInstance = GetModuleHandleA(0);
5449 cls.lpszClassName = "wmime_keydown_class";
5450 if (!RegisterClassA(&cls)) assert(0);
5453 static void test_wmime_keydown_message(void)
5458 trace("Message sequences by WM_IME_KEYDOWN\n");
5460 register_wmime_keydown_class();
5461 hwnd = CreateWindowExA(0, "wmime_keydown_class", NULL, WS_OVERLAPPEDWINDOW,
5462 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5467 SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
5468 SendMessage(hwnd, WM_CHAR, 'A', 1);
5469 ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
5471 while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
5473 TranslateMessage(&msg);
5474 DispatchMessage(&msg);
5476 ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
5478 DestroyWindow(hwnd);
5481 /************* painting message test ********************/
5483 void dump_region(HRGN hrgn)
5486 RGNDATA *data = NULL;
5491 printf( "null region\n" );
5494 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5495 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5496 GetRegionData( hrgn, size, data );
5497 printf("%d rects:", data->rdh.nCount );
5498 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5499 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5501 HeapFree( GetProcessHeap(), 0, data );
5504 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5508 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5509 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5511 ret = GetUpdateRgn( hwnd, update, FALSE );
5512 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5513 if (ret == NULLREGION)
5515 ok( !hrgn, "Update region shouldn't be empty\n" );
5519 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5521 ok( 0, "Regions are different\n" );
5522 if (winetest_debug > 0)
5524 printf( "Update region: " );
5525 dump_region( update );
5526 printf( "Wanted region: " );
5527 dump_region( hrgn );
5531 GetRgnBox( update, &r1 );
5532 GetUpdateRect( hwnd, &r2, FALSE );
5533 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5534 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5535 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5537 DeleteObject( tmp );
5538 DeleteObject( update );
5541 static const struct message WmInvalidateRgn[] = {
5542 { WM_NCPAINT, sent },
5543 { WM_GETTEXT, sent|defwinproc|optional },
5547 static const struct message WmGetUpdateRect[] = {
5548 { WM_NCPAINT, sent },
5549 { WM_GETTEXT, sent|defwinproc|optional },
5554 static const struct message WmInvalidateFull[] = {
5555 { WM_NCPAINT, sent|wparam, 1 },
5556 { WM_GETTEXT, sent|defwinproc|optional },
5560 static const struct message WmInvalidateErase[] = {
5561 { WM_NCPAINT, sent|wparam, 1 },
5562 { WM_GETTEXT, sent|defwinproc|optional },
5563 { WM_ERASEBKGND, sent },
5567 static const struct message WmInvalidatePaint[] = {
5569 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5570 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5574 static const struct message WmInvalidateErasePaint[] = {
5576 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5577 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5578 { WM_ERASEBKGND, sent|beginpaint },
5582 static const struct message WmInvalidateErasePaint2[] = {
5584 { WM_NCPAINT, sent|beginpaint },
5585 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5586 { WM_ERASEBKGND, sent|beginpaint|optional },
5590 static const struct message WmErase[] = {
5591 { WM_ERASEBKGND, sent },
5595 static const struct message WmPaint[] = {
5600 static const struct message WmParentOnlyPaint[] = {
5601 { WM_PAINT, sent|parent },
5605 static const struct message WmInvalidateParent[] = {
5606 { WM_NCPAINT, sent|parent },
5607 { WM_GETTEXT, sent|defwinproc|parent|optional },
5608 { WM_ERASEBKGND, sent|parent },
5612 static const struct message WmInvalidateParentChild[] = {
5613 { WM_NCPAINT, sent|parent },
5614 { WM_GETTEXT, sent|defwinproc|parent|optional },
5615 { WM_ERASEBKGND, sent|parent },
5616 { WM_NCPAINT, sent },
5617 { WM_GETTEXT, sent|defwinproc|optional },
5618 { WM_ERASEBKGND, sent },
5622 static const struct message WmInvalidateParentChild2[] = {
5623 { WM_ERASEBKGND, sent|parent },
5624 { WM_NCPAINT, sent },
5625 { WM_GETTEXT, sent|defwinproc|optional },
5626 { WM_ERASEBKGND, sent },
5630 static const struct message WmParentPaint[] = {
5631 { WM_PAINT, sent|parent },
5636 static const struct message WmParentPaintNc[] = {
5637 { WM_PAINT, sent|parent },
5639 { WM_NCPAINT, sent|beginpaint },
5640 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5641 { WM_ERASEBKGND, sent|beginpaint|optional },
5645 static const struct message WmChildPaintNc[] = {
5647 { WM_NCPAINT, sent|beginpaint },
5648 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5649 { WM_ERASEBKGND, sent|beginpaint },
5653 static const struct message WmParentErasePaint[] = {
5654 { WM_PAINT, sent|parent },
5655 { WM_NCPAINT, sent|parent|beginpaint },
5656 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5657 { WM_ERASEBKGND, sent|parent|beginpaint|optional },
5659 { WM_NCPAINT, sent|beginpaint },
5660 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5661 { WM_ERASEBKGND, sent|beginpaint },
5665 static const struct message WmParentOnlyNcPaint[] = {
5666 { WM_PAINT, sent|parent },
5667 { WM_NCPAINT, sent|parent|beginpaint },
5668 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
5672 static const struct message WmSetParentStyle[] = {
5673 { WM_STYLECHANGING, sent|parent },
5674 { WM_STYLECHANGED, sent|parent },
5678 static void test_paint_messages(void)
5684 HWND hparent, hchild;
5685 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
5686 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
5687 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
5688 100, 100, 200, 200, 0, 0, 0, NULL);
5689 ok (hwnd != 0, "Failed to create overlapped window\n");
5691 ShowWindow( hwnd, SW_SHOW );
5692 UpdateWindow( hwnd );
5696 check_update_rgn( hwnd, 0 );
5697 SetRectRgn( hrgn, 10, 10, 20, 20 );
5698 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5699 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5700 check_update_rgn( hwnd, hrgn );
5701 SetRectRgn( hrgn2, 20, 20, 30, 30 );
5702 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
5703 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5704 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
5705 check_update_rgn( hwnd, hrgn );
5706 /* validate everything */
5707 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5708 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5709 check_update_rgn( hwnd, 0 );
5711 /* test empty region */
5712 SetRectRgn( hrgn, 10, 10, 10, 15 );
5713 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5714 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5715 check_update_rgn( hwnd, 0 );
5716 /* test empty rect */
5717 SetRect( &rect, 10, 10, 10, 15 );
5718 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
5719 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
5720 check_update_rgn( hwnd, 0 );
5722 /* flush pending messages */
5726 GetClientRect( hwnd, &rect );
5727 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
5728 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
5729 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5731 trace("testing InvalidateRect(0, NULL, FALSE)\n");
5732 SetRectEmpty( &rect );
5733 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
5734 check_update_rgn( hwnd, hrgn );
5735 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5737 ok_sequence( WmPaint, "Paint", FALSE );
5738 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5739 check_update_rgn( hwnd, 0 );
5741 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
5742 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
5744 trace("testing ValidateRect(0, NULL)\n");
5745 SetRectEmpty( &rect );
5746 ok(ValidateRect(0, &rect), "ValidateRect(0, &rc) should not fail\n");
5747 check_update_rgn( hwnd, hrgn );
5748 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5750 ok_sequence( WmPaint, "Paint", FALSE );
5751 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
5752 check_update_rgn( hwnd, 0 );
5754 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
5755 SetLastError(0xdeadbeef);
5756 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
5757 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
5758 "wrong error code %d\n", GetLastError());
5759 check_update_rgn( hwnd, 0 );
5761 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5763 trace("testing ValidateRgn(0, NULL)\n");
5764 SetLastError(0xdeadbeef);
5765 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
5766 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
5767 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
5768 "wrong error code %d\n", GetLastError());
5769 check_update_rgn( hwnd, 0 );
5771 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
5773 /* now with frame */
5774 SetRectRgn( hrgn, -5, -5, 20, 20 );
5776 /* flush pending messages */
5779 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5780 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5782 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
5783 check_update_rgn( hwnd, hrgn );
5786 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5787 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5790 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
5791 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
5793 GetClientRect( hwnd, &rect );
5794 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
5795 check_update_rgn( hwnd, hrgn );
5798 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
5799 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
5802 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
5803 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
5804 check_update_rgn( hwnd, 0 );
5807 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
5808 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
5809 check_update_rgn( hwnd, 0 );
5812 SetRectRgn( hrgn, 0, 0, 100, 100 );
5813 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
5814 SetRectRgn( hrgn, 0, 0, 50, 100 );
5815 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
5816 SetRectRgn( hrgn, 50, 0, 100, 100 );
5817 check_update_rgn( hwnd, hrgn );
5818 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5819 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
5820 check_update_rgn( hwnd, 0 );
5823 SetRectRgn( hrgn, 0, 0, 100, 100 );
5824 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5825 SetRectRgn( hrgn, 0, 0, 100, 50 );
5826 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
5827 ok_sequence( WmErase, "Erase", FALSE );
5828 SetRectRgn( hrgn, 0, 50, 100, 100 );
5829 check_update_rgn( hwnd, hrgn );
5832 SetRectRgn( hrgn, 0, 0, 100, 100 );
5833 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
5834 SetRectRgn( hrgn, 0, 0, 50, 50 );
5835 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
5836 ok_sequence( WmPaint, "Paint", FALSE );
5839 SetRectRgn( hrgn, -4, -4, -2, -2 );
5840 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5841 SetRectRgn( hrgn, -200, -200, -198, -198 );
5842 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
5843 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
5846 SetRectRgn( hrgn, -4, -4, -2, -2 );
5847 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5848 SetRectRgn( hrgn, -4, -4, -3, -3 );
5849 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
5850 SetRectRgn( hrgn, 0, 0, 1, 1 );
5851 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
5852 ok_sequence( WmPaint, "Paint", FALSE );
5855 SetRectRgn( hrgn, -4, -4, -1, -1 );
5856 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5857 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
5858 /* make sure no WM_PAINT was generated */
5860 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
5863 SetRectRgn( hrgn, -4, -4, -1, -1 );
5864 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
5865 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
5867 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
5869 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
5870 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
5871 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
5872 ret = GetUpdateRect( hwnd, &rect, FALSE );
5873 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
5874 /* this will send WM_NCPAINT and validate the non client area */
5875 ret = GetUpdateRect( hwnd, &rect, TRUE );
5876 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
5878 DispatchMessage( &msg );
5880 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
5882 DestroyWindow( hwnd );
5884 /* now test with a child window */
5886 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
5887 100, 100, 200, 200, 0, 0, 0, NULL);
5888 ok (hparent != 0, "Failed to create parent window\n");
5890 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
5891 10, 10, 100, 100, hparent, 0, 0, NULL);
5892 ok (hchild != 0, "Failed to create child window\n");
5894 ShowWindow( hparent, SW_SHOW );
5895 UpdateWindow( hparent );
5896 UpdateWindow( hchild );
5899 log_all_parent_messages++;
5901 SetRect( &rect, 0, 0, 50, 50 );
5902 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5903 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5904 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
5906 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5908 MapWindowPoints( hchild, hparent, &pt, 1 );
5909 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
5910 check_update_rgn( hchild, hrgn );
5911 SetRectRgn( hrgn, 0, 0, 50, 50 );
5912 check_update_rgn( hparent, hrgn );
5913 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5914 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
5915 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5916 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5919 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
5921 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5922 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5923 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
5924 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
5925 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
5927 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
5928 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
5929 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
5931 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
5933 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5934 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
5935 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
5937 /* flush all paint messages */
5941 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
5942 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
5943 SetRectRgn( hrgn, 0, 0, 50, 50 );
5944 check_update_rgn( hparent, hrgn );
5945 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5946 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5947 SetRectRgn( hrgn, 0, 0, 50, 50 );
5948 check_update_rgn( hparent, hrgn );
5950 /* flush all paint messages */
5952 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
5955 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
5956 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5957 SetRectRgn( hrgn, 0, 0, 50, 50 );
5958 check_update_rgn( hparent, hrgn );
5959 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5960 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5961 SetRectRgn( hrgn2, 10, 10, 50, 50 );
5962 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
5963 check_update_rgn( hparent, hrgn );
5964 /* flush all paint messages */
5968 /* same as above but parent gets completely validated */
5969 SetRect( &rect, 20, 20, 30, 30 );
5970 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5971 SetRectRgn( hrgn, 20, 20, 30, 30 );
5972 check_update_rgn( hparent, hrgn );
5973 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
5974 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
5975 check_update_rgn( hparent, 0 ); /* no update region */
5977 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
5979 /* make sure RDW_VALIDATE on child doesn't have the same effect */
5981 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5982 SetRectRgn( hrgn, 20, 20, 30, 30 );
5983 check_update_rgn( hparent, hrgn );
5984 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
5985 SetRectRgn( hrgn, 20, 20, 30, 30 );
5986 check_update_rgn( hparent, hrgn );
5988 /* same as above but normal WM_PAINT doesn't validate parent */
5990 SetRect( &rect, 20, 20, 30, 30 );
5991 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
5992 SetRectRgn( hrgn, 20, 20, 30, 30 );
5993 check_update_rgn( hparent, hrgn );
5994 /* no WM_PAINT in child while parent still pending */
5995 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5996 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
5997 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
5998 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
6001 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6002 /* no WM_PAINT in child while parent still pending */
6003 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6004 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6005 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
6006 /* now that parent is valid child should get WM_PAINT */
6007 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6008 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6009 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6010 ok_sequence( WmEmptySeq, "No other message", FALSE );
6012 /* same thing with WS_CLIPCHILDREN in parent */
6014 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
6015 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
6016 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6017 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
6018 ok_sequence( WmEmptySeq, "No message", FALSE );
6019 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
6020 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
6023 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
6024 SetRectRgn( hrgn, 20, 20, 30, 30 );
6025 check_update_rgn( hparent, hrgn );
6026 /* no WM_PAINT in child while parent still pending */
6027 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6028 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6029 /* WM_PAINT in parent first */
6030 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6031 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
6033 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6035 SetRect( &rect, 0, 0, 30, 30 );
6036 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
6037 SetRectRgn( hrgn, 0, 0, 30, 30 );
6038 check_update_rgn( hparent, hrgn );
6040 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
6042 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6044 SetRect( &rect, -10, 0, 30, 30 );
6045 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
6046 SetRect( &rect, 0, 0, 20, 20 );
6047 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
6048 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
6049 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
6051 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6053 SetRect( &rect, -10, 0, 30, 30 );
6054 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
6055 SetRect( &rect, 0, 0, 100, 100 );
6056 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
6057 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
6058 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
6059 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6060 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
6062 /* test RDW_INTERNALPAINT behavior */
6065 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
6067 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
6069 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
6071 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
6073 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
6075 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
6077 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
6078 UpdateWindow( hparent );
6081 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6082 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6083 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
6084 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6086 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
6088 UpdateWindow( hparent );
6091 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6092 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6093 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
6094 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6096 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
6098 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
6099 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
6100 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
6102 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
6104 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
6105 UpdateWindow( hparent );
6108 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6109 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6110 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
6111 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6113 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
6115 UpdateWindow( hparent );
6118 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6119 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6120 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
6121 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6123 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
6125 ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
6126 ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
6128 UpdateWindow( hparent );
6131 trace("testing SetWindowPos(-10000, -10000) on child\n");
6132 SetWindowPos( hchild, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
6133 check_update_rgn( hchild, 0 );
6136 #if 0 /* this one doesn't pass under Wine yet */
6137 UpdateWindow( hparent );
6140 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6141 ShowWindow( hchild, SW_MINIMIZE );
6142 check_update_rgn( hchild, 0 );
6146 UpdateWindow( hparent );
6149 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6150 SetWindowPos( hparent, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
6151 check_update_rgn( hparent, 0 );
6154 log_all_parent_messages--;
6155 DestroyWindow( hparent );
6156 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6158 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6160 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP | WS_VISIBLE,
6161 100, 100, 200, 200, 0, 0, 0, NULL);
6162 ok (hparent != 0, "Failed to create parent window\n");
6164 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
6165 10, 10, 100, 100, hparent, 0, 0, NULL);
6166 ok (hchild != 0, "Failed to create child window\n");
6168 ShowWindow( hparent, SW_SHOW );
6169 UpdateWindow( hparent );
6170 UpdateWindow( hchild );
6174 /* moving child outside of parent boundaries changes update region */
6175 SetRect( &rect, 0, 0, 40, 40 );
6176 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6177 SetRectRgn( hrgn, 0, 0, 40, 40 );
6178 check_update_rgn( hchild, hrgn );
6179 MoveWindow( hchild, -10, 10, 100, 100, FALSE );
6180 SetRectRgn( hrgn, 10, 0, 40, 40 );
6181 check_update_rgn( hchild, hrgn );
6182 MoveWindow( hchild, -10, -10, 100, 100, FALSE );
6183 SetRectRgn( hrgn, 10, 10, 40, 40 );
6184 check_update_rgn( hchild, hrgn );
6186 /* moving parent off-screen does too */
6187 SetRect( &rect, 0, 0, 100, 100 );
6188 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
6189 SetRectRgn( hrgn, 0, 0, 100, 100 );
6190 check_update_rgn( hparent, hrgn );
6191 SetRectRgn( hrgn, 10, 10, 40, 40 );
6192 check_update_rgn( hchild, hrgn );
6193 MoveWindow( hparent, -20, -20, 200, 200, FALSE );
6194 SetRectRgn( hrgn, 20, 20, 100, 100 );
6195 check_update_rgn( hparent, hrgn );
6196 SetRectRgn( hrgn, 30, 30, 40, 40 );
6197 check_update_rgn( hchild, hrgn );
6199 /* invalidated region is cropped by the parent rects */
6200 SetRect( &rect, 0, 0, 50, 50 );
6201 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6202 SetRectRgn( hrgn, 30, 30, 50, 50 );
6203 check_update_rgn( hchild, hrgn );
6205 DestroyWindow( hparent );
6206 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6209 DeleteObject( hrgn );
6210 DeleteObject( hrgn2 );
6219 static DWORD WINAPI thread_proc(void *param)
6222 struct wnd_event *wnd_event = (struct wnd_event *)param;
6224 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
6225 100, 100, 200, 200, 0, 0, 0, NULL);
6226 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
6228 SetEvent(wnd_event->event);
6230 while (GetMessage(&msg, 0, 0, 0))
6232 TranslateMessage(&msg);
6233 DispatchMessage(&msg);
6236 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
6241 static void test_interthread_messages(void)
6248 int len, expected_len;
6249 struct wnd_event wnd_event;
6252 wnd_event.event = CreateEventW(NULL, 0, 0, NULL);
6253 if (!wnd_event.event)
6255 trace("skipping interthread message test under win9x\n");
6259 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
6260 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
6262 ok(WaitForSingleObject(wnd_event.event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6264 CloseHandle(wnd_event.event);
6266 SetLastError(0xdeadbeef);
6267 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
6268 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
6269 "wrong error code %d\n", GetLastError());
6271 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6272 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6274 expected_len = lstrlenA("window caption text");
6275 memset(buf, 0, sizeof(buf));
6276 SetLastError(0xdeadbeef);
6277 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
6278 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
6279 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
6281 msg.hwnd = wnd_event.hwnd;
6282 msg.message = WM_GETTEXT;
6283 msg.wParam = sizeof(buf);
6284 msg.lParam = (LPARAM)buf;
6285 memset(buf, 0, sizeof(buf));
6286 SetLastError(0xdeadbeef);
6287 len = DispatchMessageA(&msg);
6288 ok((!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY) || broken(len), /* nt4 */
6289 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
6291 /* the following test causes an exception in user.exe under win9x */
6292 msg.hwnd = wnd_event.hwnd;
6293 msg.message = WM_TIMER;
6295 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6296 SetLastError(0xdeadbeef);
6297 len = DispatchMessageA(&msg);
6298 ok(!len && GetLastError() == 0xdeadbeef,
6299 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
6301 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
6302 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6304 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6305 CloseHandle(hThread);
6307 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
6311 static const struct message WmVkN[] = {
6312 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6313 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6314 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6315 { WM_CHAR, wparam|lparam, 'n', 1 },
6316 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
6317 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6318 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6319 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6322 static const struct message WmShiftVkN[] = {
6323 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6324 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6325 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6326 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6327 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6328 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6329 { WM_CHAR, wparam|lparam, 'N', 1 },
6330 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
6331 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6332 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6333 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6334 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6335 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6336 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6339 static const struct message WmCtrlVkN[] = {
6340 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6341 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6342 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6343 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6344 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6345 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6346 { WM_CHAR, wparam|lparam, 0x000e, 1 },
6347 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6348 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6349 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6350 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6351 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6352 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6353 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6356 static const struct message WmCtrlVkN_2[] = {
6357 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6358 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6359 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6360 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6361 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6362 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6363 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6364 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6365 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6366 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6367 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6368 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6371 static const struct message WmAltVkN[] = {
6372 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6373 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6374 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6375 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6376 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6377 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6378 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
6379 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
6380 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
6381 { HCBT_SYSCOMMAND, hook },
6382 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6383 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6384 { 0x00AE, sent|defwinproc|optional }, /* XP */
6385 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
6386 { WM_INITMENU, sent|defwinproc },
6387 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6388 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
6389 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6390 { WM_CAPTURECHANGED, sent|defwinproc },
6391 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
6392 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6393 { WM_EXITMENULOOP, sent|defwinproc },
6394 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6395 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
6396 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6397 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6398 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6399 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6400 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6401 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6404 static const struct message WmAltVkN_2[] = {
6405 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6406 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6407 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6408 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6409 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6410 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
6411 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6412 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6413 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6414 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6415 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6416 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6419 static const struct message WmCtrlAltVkN[] = {
6420 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6421 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6422 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6423 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6424 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6425 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6426 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6427 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6428 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6429 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6430 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6431 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6432 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6433 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6434 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6435 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6436 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6437 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6440 static const struct message WmCtrlShiftVkN[] = {
6441 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6442 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6443 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6444 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6445 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6446 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6447 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6448 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6449 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
6450 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6451 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6452 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6453 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6454 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6455 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6456 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6457 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6458 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6461 static const struct message WmCtrlAltShiftVkN[] = {
6462 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6463 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6464 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6465 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6466 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6467 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6468 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
6469 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
6470 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
6471 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6472 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6473 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
6474 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6475 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6476 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6477 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
6478 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
6479 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
6480 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6481 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6482 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6483 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6484 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6485 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6488 static const struct message WmAltPressRelease[] = {
6489 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6490 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6491 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6492 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6493 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6494 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6495 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
6496 { HCBT_SYSCOMMAND, hook },
6497 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6498 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6499 { WM_INITMENU, sent|defwinproc },
6500 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6501 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
6502 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
6504 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
6506 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6507 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
6508 { WM_CAPTURECHANGED, sent|defwinproc },
6509 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
6510 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6511 { WM_EXITMENULOOP, sent|defwinproc },
6512 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6513 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6514 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6517 static const struct message WmAltMouseButton[] = {
6518 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6519 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6520 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6521 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
6522 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
6523 { WM_LBUTTONDOWN, wparam, MK_LBUTTON, 0 },
6524 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON, 0 },
6525 { WM_LBUTTONUP, wparam, 0, 0 },
6526 { WM_LBUTTONUP, sent|wparam, 0, 0 },
6527 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6528 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6529 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6532 static const struct message WmF1Seq[] = {
6533 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
6534 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
6535 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
6536 { WM_KEYF1, wparam|lparam, 0, 0 },
6537 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
6538 { WM_HELP, sent|defwinproc },
6539 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
6540 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
6541 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
6544 static const struct message WmVkAppsSeq[] = {
6545 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
6546 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
6547 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
6548 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
6549 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
6550 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
6551 { WM_CONTEXTMENU, lparam, /*hwnd*/0, (LPARAM)-1 },
6552 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, (LPARAM)-1 },
6556 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
6560 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
6562 struct recvd_message log_msg;
6564 /* ignore some unwanted messages */
6565 if (msg.message == WM_MOUSEMOVE ||
6566 msg.message == WM_GETICON ||
6567 msg.message == WM_GETOBJECT ||
6568 msg.message == WM_TIMER ||
6569 msg.message == WM_DEVICECHANGE)
6572 log_msg.hwnd = msg.hwnd;
6573 log_msg.message = msg.message;
6574 log_msg.flags = wparam|lparam;
6575 log_msg.wParam = msg.wParam;
6576 log_msg.lParam = msg.lParam;
6577 log_msg.descr = "accel";
6578 add_message(&log_msg);
6580 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
6582 TranslateMessage(&msg);
6583 DispatchMessage(&msg);
6588 static void test_accelerators(void)
6593 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6594 100, 100, 200, 200, 0, 0, 0, NULL);
6603 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
6605 state = GetKeyState(VK_SHIFT);
6606 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
6607 state = GetKeyState(VK_CAPITAL);
6608 ok(state == 0, "wrong CapsLock state %04x\n", state);
6610 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
6611 assert(hAccel != 0);
6614 pump_msg_loop(hwnd, 0);
6617 trace("testing VK_N press/release\n");
6619 keybd_event('N', 0, 0, 0);
6620 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6621 pump_msg_loop(hwnd, hAccel);
6622 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6624 trace("testing Shift+VK_N press/release\n");
6626 keybd_event(VK_SHIFT, 0, 0, 0);
6627 keybd_event('N', 0, 0, 0);
6628 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6629 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6630 pump_msg_loop(hwnd, hAccel);
6631 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6633 trace("testing Ctrl+VK_N press/release\n");
6635 keybd_event(VK_CONTROL, 0, 0, 0);
6636 keybd_event('N', 0, 0, 0);
6637 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6638 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6639 pump_msg_loop(hwnd, hAccel);
6640 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
6642 trace("testing Alt+VK_N press/release\n");
6644 keybd_event(VK_MENU, 0, 0, 0);
6645 keybd_event('N', 0, 0, 0);
6646 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6647 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6648 pump_msg_loop(hwnd, hAccel);
6649 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
6651 trace("testing Ctrl+Alt+VK_N press/release 1\n");
6653 keybd_event(VK_CONTROL, 0, 0, 0);
6654 keybd_event(VK_MENU, 0, 0, 0);
6655 keybd_event('N', 0, 0, 0);
6656 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6657 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6658 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6659 pump_msg_loop(hwnd, hAccel);
6660 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
6662 ret = DestroyAcceleratorTable(hAccel);
6663 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6665 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
6666 assert(hAccel != 0);
6668 trace("testing VK_N press/release\n");
6670 keybd_event('N', 0, 0, 0);
6671 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6672 pump_msg_loop(hwnd, hAccel);
6673 ok_sequence(WmVkN, "VK_N press/release", FALSE);
6675 trace("testing Shift+VK_N press/release\n");
6677 keybd_event(VK_SHIFT, 0, 0, 0);
6678 keybd_event('N', 0, 0, 0);
6679 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6680 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6681 pump_msg_loop(hwnd, hAccel);
6682 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
6684 trace("testing Ctrl+VK_N press/release 2\n");
6686 keybd_event(VK_CONTROL, 0, 0, 0);
6687 keybd_event('N', 0, 0, 0);
6688 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6689 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6690 pump_msg_loop(hwnd, hAccel);
6691 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
6693 trace("testing Alt+VK_N press/release 2\n");
6695 keybd_event(VK_MENU, 0, 0, 0);
6696 keybd_event('N', 0, 0, 0);
6697 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6698 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6699 pump_msg_loop(hwnd, hAccel);
6700 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
6702 trace("testing Ctrl+Alt+VK_N press/release 2\n");
6704 keybd_event(VK_CONTROL, 0, 0, 0);
6705 keybd_event(VK_MENU, 0, 0, 0);
6706 keybd_event('N', 0, 0, 0);
6707 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6708 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6709 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6710 pump_msg_loop(hwnd, hAccel);
6711 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
6713 trace("testing Ctrl+Shift+VK_N press/release\n");
6715 keybd_event(VK_CONTROL, 0, 0, 0);
6716 keybd_event(VK_SHIFT, 0, 0, 0);
6717 keybd_event('N', 0, 0, 0);
6718 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6719 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6720 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6721 pump_msg_loop(hwnd, hAccel);
6722 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
6724 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
6726 keybd_event(VK_CONTROL, 0, 0, 0);
6727 keybd_event(VK_MENU, 0, 0, 0);
6728 keybd_event(VK_SHIFT, 0, 0, 0);
6729 keybd_event('N', 0, 0, 0);
6730 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
6731 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
6732 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6733 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
6734 pump_msg_loop(hwnd, hAccel);
6735 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
6737 ret = DestroyAcceleratorTable(hAccel);
6738 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
6740 trace("testing Alt press/release\n");
6742 keybd_event(VK_MENU, 0, 0, 0);
6743 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6744 keybd_event(VK_MENU, 0, 0, 0);
6745 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6746 pump_msg_loop(hwnd, 0);
6747 /* this test doesn't pass in Wine for managed windows */
6748 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
6750 trace("testing Alt+MouseButton press/release\n");
6751 /* first, move mouse pointer inside of the window client area */
6752 GetClientRect(hwnd, &rc);
6753 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
6754 rc.left += (rc.right - rc.left)/2;
6755 rc.top += (rc.bottom - rc.top)/2;
6756 SetCursorPos(rc.left, rc.top);
6760 keybd_event(VK_MENU, 0, 0, 0);
6761 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
6762 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
6763 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
6764 pump_msg_loop(hwnd, 0);
6765 ok_sequence(WmAltMouseButton, "Alt+MouseButton press/release", FALSE);
6767 trace("testing VK_F1 press/release\n");
6768 keybd_event(VK_F1, 0, 0, 0);
6769 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
6770 pump_msg_loop(hwnd, 0);
6771 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
6773 trace("testing VK_APPS press/release\n");
6774 keybd_event(VK_APPS, 0, 0, 0);
6775 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
6776 pump_msg_loop(hwnd, 0);
6777 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
6779 DestroyWindow(hwnd);
6782 /************* window procedures ********************/
6784 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
6785 WPARAM wParam, LPARAM lParam)
6787 static long defwndproc_counter = 0;
6788 static long beginpaint_counter = 0;
6790 struct recvd_message msg;
6792 /* ignore registered messages */
6793 if (message >= 0xc000) return 0;
6799 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
6800 ok((BOOL)wParam == !(style & WS_DISABLED),
6801 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
6805 case WM_CAPTURECHANGED:
6806 if (test_DestroyWindow_flag)
6808 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6809 if (style & WS_CHILD)
6810 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6811 else if (style & WS_POPUP)
6812 lParam = WND_POPUP_ID;
6814 lParam = WND_PARENT_ID;
6822 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
6823 capture = GetCapture();
6826 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
6827 trace("current capture %p, releasing...\n", capture);
6834 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
6835 if (test_DestroyWindow_flag)
6837 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
6838 if (style & WS_CHILD)
6839 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
6840 else if (style & WS_POPUP)
6841 lParam = WND_POPUP_ID;
6843 lParam = WND_PARENT_ID;
6847 /* test_accelerators() depends on this */
6853 case WM_MOUSEACTIVATE:
6854 case WM_NCMOUSEMOVE:
6858 case WM_DEVICECHANGE:
6863 msg.message = message;
6864 msg.flags = sent|wparam|lparam;
6865 if (defwndproc_counter) msg.flags |= defwinproc;
6866 if (beginpaint_counter) msg.flags |= beginpaint;
6867 msg.wParam = wParam;
6868 msg.lParam = lParam;
6869 msg.descr = "MsgCheckProc";
6872 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
6874 HWND parent = GetParent(hwnd);
6876 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
6878 GetClientRect(parent, &rc);
6879 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
6880 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
6881 minmax->ptReserved.x, minmax->ptReserved.y,
6882 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
6883 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
6884 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
6885 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
6887 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
6888 minmax->ptMaxSize.x, rc.right);
6889 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
6890 minmax->ptMaxSize.y, rc.bottom);
6893 if (message == WM_PAINT)
6896 beginpaint_counter++;
6897 BeginPaint( hwnd, &ps );
6898 beginpaint_counter--;
6899 EndPaint( hwnd, &ps );
6903 defwndproc_counter++;
6904 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
6905 : DefWindowProcA(hwnd, message, wParam, lParam);
6906 defwndproc_counter--;
6911 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6913 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
6916 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6918 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
6921 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6923 static long defwndproc_counter = 0;
6925 struct recvd_message msg;
6931 return 0; /* ignore them */
6932 case WM_QUERYENDSESSION:
6934 lParam &= ~0x01; /* Vista adds a 0x01 flag */
6939 msg.message = message;
6940 msg.flags = sent|wparam|lparam;
6941 if (defwndproc_counter) msg.flags |= defwinproc;
6942 msg.wParam = wParam;
6943 msg.lParam = lParam;
6944 msg.descr = "popup";
6947 if (message == WM_CREATE)
6949 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
6950 SetWindowLongA(hwnd, GWL_STYLE, style);
6953 defwndproc_counter++;
6954 ret = DefWindowProcA(hwnd, message, wParam, lParam);
6955 defwndproc_counter--;
6960 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
6962 static long defwndproc_counter = 0;
6963 static long beginpaint_counter = 0;
6965 struct recvd_message msg;
6967 if (message == WM_GETICON || message == WM_GETOBJECT) return 0; /* ignore them */
6969 /* ignore registered messages */
6970 if (message >= 0xc000) return 0;
6972 if (log_all_parent_messages ||
6973 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
6974 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
6975 message == WM_ENABLE || message == WM_ENTERIDLE ||
6976 message == WM_DRAWITEM ||
6977 message == WM_IME_SETCONTEXT)
6991 INT ret = GetClipBox((HDC)wParam, &rc);
6993 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
6994 ret, rc.left, rc.top, rc.right, rc.bottom);
7000 msg.message = message;
7001 msg.flags = sent|parent|wparam|lparam;
7002 if (defwndproc_counter) msg.flags |= defwinproc;
7003 if (beginpaint_counter) msg.flags |= beginpaint;
7004 msg.wParam = wParam;
7005 msg.lParam = lParam;
7006 msg.descr = "parent";
7010 if (message == WM_PAINT)
7013 beginpaint_counter++;
7014 BeginPaint( hwnd, &ps );
7015 beginpaint_counter--;
7016 EndPaint( hwnd, &ps );
7020 defwndproc_counter++;
7021 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7022 defwndproc_counter--;
7027 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7029 static long defwndproc_counter = 0;
7031 struct recvd_message msg;
7033 if (message == WM_GETICON || message == WM_GETOBJECT) return 0; /* ignore them */
7037 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
7038 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
7039 if (after_end_dialog)
7040 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
7042 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
7046 msg.message = message;
7047 msg.flags = sent|wparam|lparam;
7048 if (defwndproc_counter) msg.flags |= defwinproc;
7049 msg.wParam = wParam;
7050 msg.lParam = lParam;
7051 msg.descr = "dialog";
7054 defwndproc_counter++;
7055 ret = DefDlgProcA(hwnd, message, wParam, lParam);
7056 defwndproc_counter--;
7061 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7063 static long defwndproc_counter = 0;
7065 struct recvd_message msg;
7067 /* log only specific messages we are interested in */
7070 #if 0 /* probably log these as well */
7078 case WM_GETMINMAXINFO:
7079 case WM_WINDOWPOSCHANGING:
7080 case WM_WINDOWPOSCHANGED:
7083 default: /* ignore */
7084 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7085 return DefWindowProcA(hwnd, message, wParam, lParam);
7089 msg.message = message;
7090 msg.flags = sent|wparam|lparam;
7091 if (defwndproc_counter) msg.flags |= defwinproc;
7092 msg.wParam = wParam;
7093 msg.lParam = lParam;
7097 defwndproc_counter++;
7098 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7099 defwndproc_counter--;
7104 static LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
7108 case WM_CREATE: return 0;
7117 if (PeekMessageA(&msg2, 0, 0, 0, 1))
7119 TranslateMessage(&msg2);
7120 DispatchMessage(&msg2);
7124 else ok(broken(1), "infinite loop\n");
7126 paint_loop_done = 1;
7127 return DefWindowProcA(hWnd,msg,wParam,lParam);
7130 return DefWindowProcA(hWnd,msg,wParam,lParam);
7133 static BOOL RegisterWindowClasses(void)
7139 cls.lpfnWndProc = MsgCheckProcA;
7142 cls.hInstance = GetModuleHandleA(0);
7144 cls.hCursor = LoadCursorA(0, IDC_ARROW);
7145 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
7146 cls.lpszMenuName = NULL;
7147 cls.lpszClassName = "TestWindowClass";
7148 if(!RegisterClassA(&cls)) return FALSE;
7150 cls.lpfnWndProc = ShowWindowProcA;
7151 cls.lpszClassName = "ShowWindowClass";
7152 if(!RegisterClassA(&cls)) return FALSE;
7154 cls.lpfnWndProc = PopupMsgCheckProcA;
7155 cls.lpszClassName = "TestPopupClass";
7156 if(!RegisterClassA(&cls)) return FALSE;
7158 cls.lpfnWndProc = ParentMsgCheckProcA;
7159 cls.lpszClassName = "TestParentClass";
7160 if(!RegisterClassA(&cls)) return FALSE;
7162 cls.lpfnWndProc = DefWindowProcA;
7163 cls.lpszClassName = "SimpleWindowClass";
7164 if(!RegisterClassA(&cls)) return FALSE;
7166 cls.lpfnWndProc = PaintLoopProcA;
7167 cls.lpszClassName = "PaintLoopWindowClass";
7168 if(!RegisterClassA(&cls)) return FALSE;
7170 cls.style = CS_NOCLOSE;
7171 cls.lpszClassName = "NoCloseWindowClass";
7172 if(!RegisterClassA(&cls)) return FALSE;
7174 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
7176 cls.hInstance = GetModuleHandleA(0);
7177 cls.hbrBackground = 0;
7178 cls.lpfnWndProc = TestDlgProcA;
7179 cls.lpszClassName = "TestDialogClass";
7180 if(!RegisterClassA(&cls)) return FALSE;
7183 clsW.lpfnWndProc = MsgCheckProcW;
7184 clsW.cbClsExtra = 0;
7185 clsW.cbWndExtra = 0;
7186 clsW.hInstance = GetModuleHandleW(0);
7188 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
7189 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
7190 clsW.lpszMenuName = NULL;
7191 clsW.lpszClassName = testWindowClassW;
7192 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
7197 static BOOL is_our_logged_class(HWND hwnd)
7201 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7203 if (!lstrcmpiA(buf, "TestWindowClass") ||
7204 !lstrcmpiA(buf, "ShowWindowClass") ||
7205 !lstrcmpiA(buf, "TestParentClass") ||
7206 !lstrcmpiA(buf, "TestPopupClass") ||
7207 !lstrcmpiA(buf, "SimpleWindowClass") ||
7208 !lstrcmpiA(buf, "TestDialogClass") ||
7209 !lstrcmpiA(buf, "MDI_frame_class") ||
7210 !lstrcmpiA(buf, "MDI_client_class") ||
7211 !lstrcmpiA(buf, "MDI_child_class") ||
7212 !lstrcmpiA(buf, "my_button_class") ||
7213 !lstrcmpiA(buf, "my_edit_class") ||
7214 !lstrcmpiA(buf, "static") ||
7215 !lstrcmpiA(buf, "ListBox") ||
7216 !lstrcmpiA(buf, "ComboBox") ||
7217 !lstrcmpiA(buf, "MyDialogClass") ||
7218 !lstrcmpiA(buf, "#32770") ||
7219 !lstrcmpiA(buf, "#32768"))
7225 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7229 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7231 if (nCode == HCBT_CLICKSKIPPED)
7233 /* ignore this event, XP sends it a lot when switching focus between windows */
7234 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7237 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
7239 struct recvd_message msg;
7242 msg.message = nCode;
7243 msg.flags = hook|wparam|lparam;
7244 msg.wParam = wParam;
7245 msg.lParam = lParam;
7249 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7252 if (nCode == HCBT_DESTROYWND)
7254 if (test_DestroyWindow_flag)
7256 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
7257 if (style & WS_CHILD)
7258 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
7259 else if (style & WS_POPUP)
7260 lParam = WND_POPUP_ID;
7262 lParam = WND_PARENT_ID;
7266 /* Log also SetFocus(0) calls */
7267 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7269 if (is_our_logged_class(hwnd))
7271 struct recvd_message msg;
7274 msg.message = nCode;
7275 msg.flags = hook|wparam|lparam;
7276 msg.wParam = wParam;
7277 msg.lParam = lParam;
7281 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7284 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
7292 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7294 /* ignore mouse cursor events */
7295 if (object_id == OBJID_CURSOR) return;
7297 if (!hwnd || is_our_logged_class(hwnd))
7299 struct recvd_message msg;
7302 msg.message = event;
7303 msg.flags = winevent_hook|wparam|lparam;
7304 msg.wParam = object_id;
7305 msg.lParam = child_id;
7311 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
7312 static const WCHAR wszAnsi[] = {'U',0};
7314 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
7318 case CB_FINDSTRINGEXACT:
7319 trace("String: %p\n", (LPCWSTR)lParam);
7320 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
7322 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
7326 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7329 static const struct message WmGetTextLengthAfromW[] = {
7330 { WM_GETTEXTLENGTH, sent },
7331 { WM_GETTEXT, sent|optional },
7335 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7337 /* dummy window proc for WM_GETTEXTLENGTH test */
7338 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
7342 case WM_GETTEXTLENGTH:
7343 return lstrlenW(dummy_window_text) + 37; /* some random length */
7345 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
7346 return lstrlenW( (LPWSTR)lp );
7348 return DefWindowProcW( hwnd, msg, wp, lp );
7352 static void test_message_conversion(void)
7354 static const WCHAR wszMsgConversionClass[] =
7355 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7359 WNDPROC wndproc, newproc;
7363 cls.lpfnWndProc = MsgConversionProcW;
7366 cls.hInstance = GetModuleHandleW(NULL);
7368 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
7369 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
7370 cls.lpszMenuName = NULL;
7371 cls.lpszClassName = wszMsgConversionClass;
7372 /* this call will fail on Win9x, but that doesn't matter as this test is
7373 * meaningless on those platforms */
7374 if(!RegisterClassW(&cls)) return;
7376 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
7377 100, 100, 200, 200, 0, 0, 0, NULL);
7378 ok(hwnd != NULL, "Window creation failed\n");
7382 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
7383 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7384 ok(lRes == 0, "String should have been converted\n");
7385 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7386 ok(lRes == 1, "String shouldn't have been converted\n");
7390 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
7391 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7392 ok(lRes == 1, "String shouldn't have been converted\n");
7393 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7394 ok(lRes == 1, "String shouldn't have been converted\n");
7396 /* Synchronous messages */
7398 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7399 ok(lRes == 0, "String should have been converted\n");
7400 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7401 ok(lRes == 1, "String shouldn't have been converted\n");
7403 /* Asynchronous messages */
7406 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7407 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7408 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7410 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7411 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7412 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7414 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7415 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7416 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7418 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7419 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7420 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7422 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7423 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7424 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7426 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
7427 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7428 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7430 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7431 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7432 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7434 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
7435 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
7436 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
7438 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
7440 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
7441 WS_OVERLAPPEDWINDOW,
7442 100, 100, 200, 200, 0, 0, 0, NULL);
7445 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
7446 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7447 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7448 "got bad length %ld\n", lRes );
7451 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
7452 hwnd, WM_GETTEXTLENGTH, 0, 0);
7453 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
7454 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
7455 "got bad length %ld\n", lRes );
7457 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
7458 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
7459 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7460 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7461 NULL, 0, NULL, NULL ) ||
7462 broken(lRes == lstrlenW(dummy_window_text) + 37),
7463 "got bad length %ld\n", lRes );
7465 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
7466 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
7467 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
7468 NULL, 0, NULL, NULL ) ||
7469 broken(lRes == lstrlenW(dummy_window_text) + 37),
7470 "got bad length %ld\n", lRes );
7472 ret = DestroyWindow(hwnd);
7473 ok( ret, "DestroyWindow() error %d\n", GetLastError());
7483 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
7487 #define TIMER_ID 0x19
7489 static DWORD WINAPI timer_thread_proc(LPVOID x)
7491 struct timer_info *info = x;
7494 r = KillTimer(info->hWnd, 0x19);
7495 ok(r,"KillTimer failed in thread\n");
7496 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
7497 ok(r,"SetTimer failed in thread\n");
7498 ok(r==TIMER_ID,"SetTimer id different\n");
7499 r = SetEvent(info->handles[0]);
7500 ok(r,"SetEvent failed in thread\n");
7504 static void test_timers(void)
7506 struct timer_info info;
7509 info.hWnd = CreateWindow ("TestWindowClass", NULL,
7510 WS_OVERLAPPEDWINDOW ,
7511 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7514 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
7515 ok(info.id, "SetTimer failed\n");
7516 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
7517 info.handles[0] = CreateEvent(NULL,0,0,NULL);
7518 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
7520 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
7522 WaitForSingleObject(info.handles[1], INFINITE);
7524 CloseHandle(info.handles[0]);
7525 CloseHandle(info.handles[1]);
7527 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
7529 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
7532 static int count = 0;
7533 static VOID CALLBACK callback_count(
7543 static void test_timers_no_wnd(void)
7549 id = SetTimer(NULL, 0, 100, callback_count);
7550 ok(id != 0, "did not get id from SetTimer.\n");
7551 id2 = SetTimer(NULL, id, 200, callback_count);
7552 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
7554 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7555 ok(count == 0, "did not get zero count as expected (%i).\n", count);
7557 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7558 ok(count == 1, "did not get one count as expected (%i).\n", count);
7559 KillTimer(NULL, id);
7561 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
7562 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
7565 /* Various win events with arbitrary parameters */
7566 static const struct message WmWinEventsSeq[] = {
7567 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7568 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7569 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7570 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7571 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7572 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7573 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7574 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7575 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7576 /* our win event hook ignores OBJID_CURSOR events */
7577 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
7578 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
7579 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
7580 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
7581 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
7582 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
7583 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7584 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
7585 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
7586 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
7587 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
7588 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
7589 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
7590 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
7593 static const struct message WmWinEventCaretSeq[] = {
7594 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7595 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7596 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
7597 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
7600 static const struct message WmWinEventCaretSeq_2[] = {
7601 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7602 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7603 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
7606 static const struct message WmWinEventAlertSeq[] = {
7607 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
7610 static const struct message WmWinEventAlertSeq_2[] = {
7611 /* create window in the thread proc */
7612 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
7613 /* our test event */
7614 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
7617 static const struct message WmGlobalHookSeq_1[] = {
7618 /* create window in the thread proc */
7619 { HCBT_CREATEWND, hook|lparam, 0, 2 },
7620 /* our test events */
7621 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
7622 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
7625 static const struct message WmGlobalHookSeq_2[] = {
7626 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
7627 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
7628 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
7629 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
7633 static const struct message WmMouseLLHookSeq[] = {
7634 { WM_MOUSEMOVE, hook },
7635 { WM_LBUTTONUP, hook },
7636 { WM_MOUSEMOVE, hook },
7640 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
7650 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7652 if (!lstrcmpiA(buf, "TestWindowClass") ||
7653 !lstrcmpiA(buf, "static"))
7655 struct recvd_message msg;
7658 msg.message = event;
7659 msg.flags = winevent_hook|wparam|lparam;
7660 msg.wParam = object_id;
7661 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
7662 msg.descr = "WEH_2";
7668 static HHOOK hCBT_global_hook;
7669 static DWORD cbt_global_hook_thread_id;
7671 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7676 if (nCode == HCBT_SYSCOMMAND)
7678 struct recvd_message msg;
7681 msg.message = nCode;
7682 msg.flags = hook|wparam|lparam;
7683 msg.wParam = wParam;
7684 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7685 msg.descr = "CBT_2";
7688 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7690 /* WH_MOUSE_LL hook */
7691 if (nCode == HC_ACTION)
7693 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
7695 /* we can't test for real mouse events */
7696 if (mhll->flags & LLMHF_INJECTED)
7698 struct recvd_message msg;
7700 memset (&msg, 0, sizeof (msg));
7701 msg.message = wParam;
7703 msg.descr = "CBT_2";
7706 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7709 /* Log also SetFocus(0) calls */
7710 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7712 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7714 if (!lstrcmpiA(buf, "TestWindowClass") ||
7715 !lstrcmpiA(buf, "static"))
7717 struct recvd_message msg;
7720 msg.message = nCode;
7721 msg.flags = hook|wparam|lparam;
7722 msg.wParam = wParam;
7723 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
7724 msg.descr = "CBT_2";
7728 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
7731 static DWORD WINAPI win_event_global_thread_proc(void *param)
7735 HANDLE hevent = *(HANDLE *)param;
7737 assert(pNotifyWinEvent);
7739 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7741 trace("created thread window %p\n", hwnd);
7743 *(HWND *)param = hwnd;
7746 /* this event should be received only by our new hook proc,
7747 * an old one does not expect an event from another thread.
7749 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
7752 while (GetMessage(&msg, 0, 0, 0))
7754 TranslateMessage(&msg);
7755 DispatchMessage(&msg);
7760 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
7764 HANDLE hevent = *(HANDLE *)param;
7767 /* these events should be received only by our new hook proc,
7768 * an old one does not expect an event from another thread.
7771 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7773 trace("created thread window %p\n", hwnd);
7775 *(HWND *)param = hwnd;
7777 /* Windows doesn't like when a thread plays games with the focus,
7778 that leads to all kinds of misbehaviours and failures to activate
7779 a window. So, better keep next lines commented out.
7783 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7784 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7788 while (GetMessage(&msg, 0, 0, 0))
7790 TranslateMessage(&msg);
7791 DispatchMessage(&msg);
7796 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
7800 HANDLE hevent = *(HANDLE *)param;
7802 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
7804 trace("created thread window %p\n", hwnd);
7806 *(HWND *)param = hwnd;
7810 /* Windows doesn't like when a thread plays games with the focus,
7811 * that leads to all kinds of misbehaviours and failures to activate
7812 * a window. So, better don't generate a mouse click message below.
7814 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
7815 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7816 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
7819 while (GetMessage(&msg, 0, 0, 0))
7821 TranslateMessage(&msg);
7822 DispatchMessage(&msg);
7827 static void test_winevents(void)
7833 HANDLE hthread, hevent;
7835 HWINEVENTHOOK hhook;
7836 const struct message *events = WmWinEventsSeq;
7838 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
7839 WS_OVERLAPPEDWINDOW,
7840 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
7844 /****** start of global hook test *************/
7845 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7846 if (!hCBT_global_hook)
7848 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7849 skip( "cannot set global hook\n" );
7853 hevent = CreateEventA(NULL, 0, 0, NULL);
7855 hwnd2 = (HWND)hevent;
7857 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
7858 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7860 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7862 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
7865 /* this one should be received only by old hook proc */
7866 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
7867 /* this one should be received only by old hook proc */
7868 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
7870 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
7872 ret = UnhookWindowsHookEx(hCBT_global_hook);
7873 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
7875 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7876 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7877 CloseHandle(hthread);
7878 CloseHandle(hevent);
7879 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7880 /****** end of global hook test *************/
7882 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
7884 ok(DestroyWindow(hwnd), "failed to destroy window\n");
7892 /* this test doesn't pass under Win9x */
7893 /* win2k ignores events with hwnd == 0 */
7894 SetLastError(0xdeadbeef);
7895 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
7896 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
7897 GetLastError() == 0xdeadbeef, /* Win9x */
7898 "unexpected error %d\n", GetLastError());
7899 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7902 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
7903 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
7905 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
7907 /****** start of event filtering test *************/
7908 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7909 EVENT_OBJECT_SHOW, /* 0x8002 */
7910 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
7911 GetModuleHandleA(0), win_event_global_hook_proc,
7912 GetCurrentProcessId(), 0,
7913 WINEVENT_INCONTEXT);
7914 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7916 hevent = CreateEventA(NULL, 0, 0, NULL);
7918 hwnd2 = (HWND)hevent;
7920 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7921 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7923 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7925 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
7928 /* this one should be received only by old hook proc */
7929 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7930 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7931 /* this one should be received only by old hook proc */
7932 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7934 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
7936 ret = pUnhookWinEvent(hhook);
7937 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7939 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7940 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7941 CloseHandle(hthread);
7942 CloseHandle(hevent);
7943 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7944 /****** end of event filtering test *************/
7946 /****** start of out of context event test *************/
7947 hhook = (HWINEVENTHOOK)pSetWinEventHook(
7948 EVENT_MIN, EVENT_MAX,
7949 0, win_event_global_hook_proc,
7950 GetCurrentProcessId(), 0,
7951 WINEVENT_OUTOFCONTEXT);
7952 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
7954 hevent = CreateEventA(NULL, 0, 0, NULL);
7956 hwnd2 = (HWND)hevent;
7960 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
7961 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
7963 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7965 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
7966 /* process pending winevent messages */
7967 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7968 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
7971 /* this one should be received only by old hook proc */
7972 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
7973 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
7974 /* this one should be received only by old hook proc */
7975 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
7977 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
7978 /* process pending winevent messages */
7979 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
7980 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
7982 ret = pUnhookWinEvent(hhook);
7983 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
7985 PostThreadMessageA(tid, WM_QUIT, 0, 0);
7986 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
7987 CloseHandle(hthread);
7988 CloseHandle(hevent);
7989 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
7990 /****** end of out of context event test *************/
7992 /****** start of MOUSE_LL hook test *************/
7993 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
7994 /* WH_MOUSE_LL is not supported on Win9x platforms */
7995 if (!hCBT_global_hook)
7997 trace("Skipping WH_MOUSE_LL test on this platform\n");
7998 goto skip_mouse_ll_hook_test;
8001 hevent = CreateEventA(NULL, 0, 0, NULL);
8003 hwnd2 = (HWND)hevent;
8005 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
8006 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8008 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
8009 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
8011 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
8014 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8015 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
8016 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8018 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
8020 ret = UnhookWindowsHookEx(hCBT_global_hook);
8021 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
8023 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8024 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8025 CloseHandle(hthread);
8026 CloseHandle(hevent);
8027 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8028 /****** end of MOUSE_LL hook test *************/
8029 skip_mouse_ll_hook_test:
8031 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8034 static void test_set_hook(void)
8038 HWINEVENTHOOK hwinevent_hook;
8040 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
8041 ok(hhook != 0, "local hook does not require hModule set to 0\n");
8042 UnhookWindowsHookEx(hhook);
8046 /* this test doesn't pass under Win9x: BUG! */
8047 SetLastError(0xdeadbeef);
8048 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
8049 ok(!hhook, "global hook requires hModule != 0\n");
8050 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
8053 SetLastError(0xdeadbeef);
8054 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
8055 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
8056 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
8057 GetLastError() == 0xdeadbeef, /* Win9x */
8058 "unexpected error %d\n", GetLastError());
8060 SetLastError(0xdeadbeef);
8061 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8062 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
8063 GetLastError() == 0xdeadbeef, /* Win9x */
8064 "unexpected error %d\n", GetLastError());
8066 if (!pSetWinEventHook || !pUnhookWinEvent) return;
8068 /* even process local incontext hooks require hmodule */
8069 SetLastError(0xdeadbeef);
8070 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8071 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
8072 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8073 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8074 GetLastError() == 0xdeadbeef, /* Win9x */
8075 "unexpected error %d\n", GetLastError());
8077 /* even thread local incontext hooks require hmodule */
8078 SetLastError(0xdeadbeef);
8079 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8080 0, win_event_proc, GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
8081 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8082 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8083 GetLastError() == 0xdeadbeef, /* Win9x */
8084 "unexpected error %d\n", GetLastError());
8088 /* these 3 tests don't pass under Win9x */
8089 SetLastError(0xdeadbeef);
8090 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(1, 0,
8091 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8092 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8093 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8095 SetLastError(0xdeadbeef);
8096 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(-1, 1,
8097 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8098 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8099 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8101 SetLastError(0xdeadbeef);
8102 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8103 0, win_event_proc, 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
8104 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
8105 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
8108 SetLastError(0xdeadbeef);
8109 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(0, 0,
8110 0, win_event_proc, GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8111 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8112 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8113 ret = pUnhookWinEvent(hwinevent_hook);
8114 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8117 /* This call succeeds under win2k SP4, but fails under Wine.
8118 Does win2k test/use passed process id? */
8119 SetLastError(0xdeadbeef);
8120 hwinevent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
8121 0, win_event_proc, 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
8122 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8123 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8124 ret = pUnhookWinEvent(hwinevent_hook);
8125 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8128 SetLastError(0xdeadbeef);
8129 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
8130 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
8131 GetLastError() == 0xdeadbeef, /* Win9x */
8132 "unexpected error %d\n", GetLastError());
8135 static const struct message ScrollWindowPaint1[] = {
8137 { WM_ERASEBKGND, sent|beginpaint },
8141 static const struct message ScrollWindowPaint2[] = {
8146 static void test_scrollwindowex(void)
8149 RECT rect={0,0,130,130};
8151 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8152 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
8153 100, 100, 200, 200, 0, 0, 0, NULL);
8154 ok (hwnd != 0, "Failed to create overlapped window\n");
8155 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
8156 WS_VISIBLE|WS_CAPTION|WS_CHILD,
8157 10, 10, 150, 150, hwnd, 0, 0, NULL);
8158 ok (hchild != 0, "Failed to create child\n");
8163 /* scroll without the child window */
8164 trace("start scroll\n");
8165 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8166 SW_ERASE|SW_INVALIDATE);
8167 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8168 trace("end scroll\n");
8171 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8175 /* Now without the SW_ERASE flag */
8176 trace("start scroll\n");
8177 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
8178 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8179 trace("end scroll\n");
8182 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
8186 /* now scroll the child window as well */
8187 trace("start scroll\n");
8188 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8189 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
8190 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8191 /* windows sometimes a WM_MOVE */
8192 ok_sequence(WmEmptySeq, "ScrollWindowEx", TRUE);
8193 trace("end scroll\n");
8196 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8200 /* now scroll with ScrollWindow() */
8201 trace("start scroll with ScrollWindow\n");
8202 ScrollWindow( hwnd, 5, 5, NULL, NULL);
8203 trace("end scroll\n");
8206 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
8208 ok(DestroyWindow(hchild), "failed to destroy window\n");
8209 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8213 static const struct message destroy_window_with_children[] = {
8214 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8215 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
8216 { 0x0090, sent|optional },
8217 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
8218 { 0x0090, sent|optional },
8219 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8220 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8221 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8222 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8223 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
8224 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8225 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8226 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8227 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8228 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8229 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8230 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8231 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8235 static void test_DestroyWindow(void)
8238 HWND parent, child1, child2, child3, child4, test;
8239 UINT_PTR child_id = WND_CHILD_ID + 1;
8241 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8242 100, 100, 200, 200, 0, 0, 0, NULL);
8243 assert(parent != 0);
8244 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8245 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
8246 assert(child1 != 0);
8247 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8248 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
8249 assert(child2 != 0);
8250 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8251 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
8252 assert(child3 != 0);
8253 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
8254 0, 0, 50, 50, parent, 0, 0, NULL);
8255 assert(child4 != 0);
8257 /* test owner/parent of child2 */
8258 test = GetParent(child2);
8259 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8260 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8262 test = pGetAncestor(child2, GA_PARENT);
8263 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8265 test = GetWindow(child2, GW_OWNER);
8266 ok(!test, "wrong owner %p\n", test);
8268 test = SetParent(child2, parent);
8269 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
8271 /* test owner/parent of the parent */
8272 test = GetParent(parent);
8273 ok(!test, "wrong parent %p\n", test);
8274 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
8276 test = pGetAncestor(parent, GA_PARENT);
8277 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8279 test = GetWindow(parent, GW_OWNER);
8280 ok(!test, "wrong owner %p\n", test);
8282 /* test owner/parent of child1 */
8283 test = GetParent(child1);
8284 ok(test == parent, "wrong parent %p\n", test);
8285 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
8287 test = pGetAncestor(child1, GA_PARENT);
8288 ok(test == parent, "wrong parent %p\n", test);
8290 test = GetWindow(child1, GW_OWNER);
8291 ok(!test, "wrong owner %p\n", test);
8293 /* test owner/parent of child2 */
8294 test = GetParent(child2);
8295 ok(test == parent, "wrong parent %p\n", test);
8296 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8298 test = pGetAncestor(child2, GA_PARENT);
8299 ok(test == parent, "wrong parent %p\n", test);
8301 test = GetWindow(child2, GW_OWNER);
8302 ok(!test, "wrong owner %p\n", test);
8304 /* test owner/parent of child3 */
8305 test = GetParent(child3);
8306 ok(test == child1, "wrong parent %p\n", test);
8307 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
8309 test = pGetAncestor(child3, GA_PARENT);
8310 ok(test == child1, "wrong parent %p\n", test);
8312 test = GetWindow(child3, GW_OWNER);
8313 ok(!test, "wrong owner %p\n", test);
8315 /* test owner/parent of child4 */
8316 test = GetParent(child4);
8317 ok(test == parent, "wrong parent %p\n", test);
8318 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
8320 test = pGetAncestor(child4, GA_PARENT);
8321 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8323 test = GetWindow(child4, GW_OWNER);
8324 ok(test == parent, "wrong owner %p\n", test);
8328 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8329 parent, child1, child2, child3, child4);
8332 test = GetCapture();
8333 ok(test == child4, "wrong capture window %p\n", test);
8335 test_DestroyWindow_flag = TRUE;
8336 ret = DestroyWindow(parent);
8337 ok( ret, "DestroyWindow() error %d\n", GetLastError());
8338 test_DestroyWindow_flag = FALSE;
8339 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
8341 ok(!IsWindow(parent), "parent still exists\n");
8342 ok(!IsWindow(child1), "child1 still exists\n");
8343 ok(!IsWindow(child2), "child2 still exists\n");
8344 ok(!IsWindow(child3), "child3 still exists\n");
8345 ok(!IsWindow(child4), "child4 still exists\n");
8347 test = GetCapture();
8348 ok(!test, "wrong capture window %p\n", test);
8352 static const struct message WmDispatchPaint[] = {
8353 { WM_NCPAINT, sent },
8354 { WM_GETTEXT, sent|defwinproc|optional },
8355 { WM_GETTEXT, sent|defwinproc|optional },
8356 { WM_ERASEBKGND, sent },
8360 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8362 if (message == WM_PAINT) return 0;
8363 return MsgCheckProcA( hwnd, message, wParam, lParam );
8366 static void test_DispatchMessage(void)
8371 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8372 100, 100, 200, 200, 0, 0, 0, NULL);
8373 ShowWindow( hwnd, SW_SHOW );
8374 UpdateWindow( hwnd );
8377 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
8379 SetRect( &rect, -5, -5, 5, 5 );
8380 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8382 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8384 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8388 DispatchMessage( &msg );
8389 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
8390 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8391 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
8392 if (++count > 10) break;
8395 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
8397 trace("now without DispatchMessage\n");
8399 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
8401 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
8403 if (msg.message != WM_PAINT) DispatchMessage( &msg );
8406 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
8408 /* this will send WM_NCCPAINT just like DispatchMessage does */
8409 GetUpdateRgn( hwnd, hrgn, TRUE );
8410 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
8411 DeleteObject( hrgn );
8412 GetClientRect( hwnd, &rect );
8413 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
8414 ok( !count, "Got multiple WM_PAINTs\n" );
8415 if (++count > 10) break;
8418 DestroyWindow(hwnd);
8422 static const struct message WmUser[] = {
8434 static DWORD CALLBACK send_msg_thread( LPVOID arg )
8436 struct sendmsg_info *info = arg;
8437 SetLastError( 0xdeadbeef );
8438 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
8439 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT ||
8440 broken(GetLastError() == 0), /* win9x */
8441 "unexpected error %d\n", GetLastError());
8445 static void wait_for_thread( HANDLE thread )
8447 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
8450 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
8454 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8456 if (message == WM_USER) Sleep(200);
8457 return MsgCheckProcA( hwnd, message, wParam, lParam );
8460 static void test_SendMessageTimeout(void)
8463 struct sendmsg_info info;
8467 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8468 100, 100, 200, 200, 0, 0, 0, NULL);
8472 info.timeout = 1000;
8473 info.ret = 0xdeadbeef;
8474 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8475 wait_for_thread( thread );
8476 CloseHandle( thread );
8477 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8478 ok_sequence( WmUser, "WmUser", FALSE );
8481 info.ret = 0xdeadbeef;
8482 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8483 Sleep(100); /* SendMessageTimeout should time out here */
8484 wait_for_thread( thread );
8485 CloseHandle( thread );
8486 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8487 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8489 /* 0 means infinite timeout (but not on win9x) */
8491 info.ret = 0xdeadbeef;
8492 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8494 wait_for_thread( thread );
8495 CloseHandle( thread );
8496 is_win9x = !info.ret;
8497 if (is_win9x) ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8498 else ok_sequence( WmUser, "WmUser", FALSE );
8500 /* timeout is treated as signed despite the prototype (but not on win9x) */
8501 info.timeout = 0x7fffffff;
8502 info.ret = 0xdeadbeef;
8503 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8505 wait_for_thread( thread );
8506 CloseHandle( thread );
8507 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8508 ok_sequence( WmUser, "WmUser", FALSE );
8510 info.timeout = 0x80000000;
8511 info.ret = 0xdeadbeef;
8512 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8514 wait_for_thread( thread );
8515 CloseHandle( thread );
8518 ok( info.ret == 1, "SendMessageTimeout failed\n" );
8519 ok_sequence( WmUser, "WmUser", FALSE );
8523 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
8524 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
8527 /* now check for timeout during message processing */
8528 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
8530 info.ret = 0xdeadbeef;
8531 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
8532 wait_for_thread( thread );
8533 CloseHandle( thread );
8534 /* we should time out but still get the message */
8535 ok( info.ret == 0, "SendMessageTimeout failed\n" );
8536 ok_sequence( WmUser, "WmUser", FALSE );
8538 DestroyWindow( info.hwnd );
8542 /****************** edit message test *************************/
8543 #define ID_EDIT 0x1234
8544 static const struct message sl_edit_setfocus[] =
8546 { HCBT_SETFOCUS, hook },
8547 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8548 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8549 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8550 { WM_SETFOCUS, sent|wparam, 0 },
8551 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8552 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
8553 { WM_CTLCOLOREDIT, sent|parent },
8554 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8555 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8556 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8557 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8560 static const struct message ml_edit_setfocus[] =
8562 { HCBT_SETFOCUS, hook },
8563 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
8564 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8565 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8566 { WM_SETFOCUS, sent|wparam, 0 },
8567 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8568 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8569 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8570 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8571 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8574 static const struct message sl_edit_killfocus[] =
8576 { HCBT_SETFOCUS, hook },
8577 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8578 { WM_KILLFOCUS, sent|wparam, 0 },
8579 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8580 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8581 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
8582 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
8583 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
8586 static const struct message sl_edit_lbutton_dblclk[] =
8588 { WM_LBUTTONDBLCLK, sent },
8589 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8592 static const struct message sl_edit_lbutton_down[] =
8594 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8595 { HCBT_SETFOCUS, hook },
8596 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8597 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8598 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8599 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8600 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8601 { WM_CTLCOLOREDIT, sent|parent },
8602 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8603 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8604 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8605 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8606 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8607 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8608 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8609 { WM_CTLCOLOREDIT, sent|parent|optional },
8610 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8611 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8612 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8615 static const struct message ml_edit_lbutton_down[] =
8617 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
8618 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
8619 { HCBT_SETFOCUS, hook },
8620 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
8621 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
8622 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
8623 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
8624 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
8625 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
8626 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8627 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8628 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
8631 static const struct message sl_edit_lbutton_up[] =
8633 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8634 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8635 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8636 { WM_CAPTURECHANGED, sent|defwinproc },
8637 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
8640 static const struct message ml_edit_lbutton_up[] =
8642 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
8643 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
8644 { WM_CAPTURECHANGED, sent|defwinproc },
8648 static WNDPROC old_edit_proc;
8650 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
8652 static long defwndproc_counter = 0;
8654 struct recvd_message msg;
8656 if (message == WM_GETICON || message == WM_GETOBJECT) return 0; /* ignore them */
8659 msg.message = message;
8660 msg.flags = sent|wparam|lparam;
8661 if (defwndproc_counter) msg.flags |= defwinproc;
8662 msg.wParam = wParam;
8663 msg.lParam = lParam;
8667 defwndproc_counter++;
8668 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
8669 defwndproc_counter--;
8674 static void subclass_edit(void)
8678 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
8680 old_edit_proc = cls.lpfnWndProc;
8682 cls.hInstance = GetModuleHandle(0);
8683 cls.lpfnWndProc = edit_hook_proc;
8684 cls.lpszClassName = "my_edit_class";
8685 UnregisterClass(cls.lpszClassName, cls.hInstance);
8686 if (!RegisterClassA(&cls)) assert(0);
8689 static void test_edit_messages(void)
8695 log_all_parent_messages++;
8697 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
8698 100, 100, 200, 200, 0, 0, 0, NULL);
8699 ok (parent != 0, "Failed to create parent window\n");
8701 /* test single line edit */
8702 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
8703 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8704 ok(hwnd != 0, "Failed to create edit window\n");
8706 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8707 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
8709 ShowWindow(hwnd, SW_SHOW);
8715 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
8718 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
8724 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8725 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
8731 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8732 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
8734 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8735 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
8737 DestroyWindow(hwnd);
8739 /* test multiline edit */
8740 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
8741 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
8742 ok(hwnd != 0, "Failed to create edit window\n");
8744 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
8745 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
8746 "wrong dlg_code %08x\n", dlg_code);
8748 ShowWindow(hwnd, SW_SHOW);
8754 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
8757 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
8763 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
8764 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
8770 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
8771 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
8773 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
8774 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
8776 DestroyWindow(hwnd);
8777 DestroyWindow(parent);
8779 log_all_parent_messages--;
8782 /**************************** End of Edit test ******************************/
8784 static const struct message WmKeyDownSkippedSeq[] =
8786 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
8789 static const struct message WmKeyDownWasDownSkippedSeq[] =
8791 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x40000001 }, /* XP */
8794 static const struct message WmKeyUpSkippedSeq[] =
8796 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
8799 static const struct message WmUserKeyUpSkippedSeq[] =
8802 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
8807 #define EV_SENDMSG 1
8813 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
8816 static DWORD CALLBACK send_msg_thread_2(void *param)
8819 struct peekmsg_info *info = param;
8821 trace("thread: looping\n");
8822 SetEvent(info->hevent[EV_ACK]);
8826 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
8830 case WAIT_OBJECT_0 + EV_STOP:
8831 trace("thread: exiting\n");
8834 case WAIT_OBJECT_0 + EV_SENDMSG:
8835 trace("thread: sending message\n");
8836 ok( SendNotifyMessageA(info->hwnd, WM_USER, 0, 0),
8837 "SendNotifyMessageA failed error %u\n", GetLastError());
8838 SetEvent(info->hevent[EV_ACK]);
8842 trace("unexpected return: %04x\n", ret);
8850 static void test_PeekMessage(void)
8855 UINT qs_all_input = QS_ALLINPUT;
8856 UINT qs_input = QS_INPUT;
8858 struct peekmsg_info info;
8860 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8861 100, 100, 200, 200, 0, 0, 0, NULL);
8863 ShowWindow(info.hwnd, SW_SHOW);
8864 UpdateWindow(info.hwnd);
8865 SetFocus(info.hwnd);
8867 info.hevent[EV_STOP] = CreateEventA(NULL, 0, 0, NULL);
8868 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
8869 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
8871 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
8872 WaitForSingleObject(info.hevent[EV_ACK], 10000);
8877 SetLastError(0xdeadbeef);
8878 qstatus = GetQueueStatus(qs_all_input);
8879 if (GetLastError() == ERROR_INVALID_FLAGS)
8881 trace("QS_RAWINPUT not supported on this platform\n");
8882 qs_all_input &= ~QS_RAWINPUT;
8883 qs_input &= ~QS_RAWINPUT;
8885 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8887 trace("signalling to send message\n");
8888 SetEvent(info.hevent[EV_SENDMSG]);
8889 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8891 /* pass invalid QS_xxxx flags */
8892 SetLastError(0xdeadbeef);
8893 qstatus = GetQueueStatus(0xffffffff);
8894 ok(qstatus == 0 || broken(qstatus) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus);
8897 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
8898 qstatus = GetQueueStatus(qs_all_input);
8900 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
8901 "wrong qstatus %08x\n", qstatus);
8904 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
8906 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8908 ok_sequence(WmUser, "WmUser", FALSE);
8910 qstatus = GetQueueStatus(qs_all_input);
8911 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
8913 keybd_event('N', 0, 0, 0);
8914 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
8915 qstatus = GetQueueStatus(qs_all_input);
8916 ok(qstatus == MAKELONG(QS_KEY, QS_KEY),
8917 "wrong qstatus %08x\n", qstatus);
8919 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
8920 qstatus = GetQueueStatus(qs_all_input);
8921 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
8922 "wrong qstatus %08x\n", qstatus);
8924 InvalidateRect(info.hwnd, NULL, FALSE);
8925 qstatus = GetQueueStatus(qs_all_input);
8926 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8927 "wrong qstatus %08x\n", qstatus);
8929 trace("signalling to send message\n");
8930 SetEvent(info.hevent[EV_SENDMSG]);
8931 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8933 qstatus = GetQueueStatus(qs_all_input);
8934 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8935 "wrong qstatus %08x\n", qstatus);
8938 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
8939 if (ret && msg.message == WM_CHAR)
8941 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
8945 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8947 if (!sequence_cnt) /* nt4 doesn't fetch anything with PM_QS_* flags */
8949 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
8952 ok_sequence(WmUser, "WmUser", FALSE);
8954 qstatus = GetQueueStatus(qs_all_input);
8955 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8956 "wrong qstatus %08x\n", qstatus);
8958 trace("signalling to send message\n");
8959 SetEvent(info.hevent[EV_SENDMSG]);
8960 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
8962 qstatus = GetQueueStatus(qs_all_input);
8963 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8964 "wrong qstatus %08x\n", qstatus);
8967 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE );
8969 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8971 ok_sequence(WmUser, "WmUser", FALSE);
8973 qstatus = GetQueueStatus(qs_all_input);
8974 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
8975 "wrong qstatus %08x\n", qstatus);
8978 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8979 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
8980 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
8981 ret, msg.message, msg.wParam);
8982 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8984 qstatus = GetQueueStatus(qs_all_input);
8985 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8986 "wrong qstatus %08x\n", qstatus);
8989 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
8991 "PeekMessageA should have returned FALSE instead of msg %04x\n",
8993 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
8995 qstatus = GetQueueStatus(qs_all_input);
8996 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
8997 "wrong qstatus %08x\n", qstatus);
9000 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
9001 ok(ret && msg.message == WM_PAINT,
9002 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
9003 DispatchMessageA(&msg);
9004 ok_sequence(WmPaint, "WmPaint", FALSE);
9006 qstatus = GetQueueStatus(qs_all_input);
9007 ok(qstatus == MAKELONG(0, QS_KEY),
9008 "wrong qstatus %08x\n", qstatus);
9011 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
9013 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9015 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9017 qstatus = GetQueueStatus(qs_all_input);
9018 ok(qstatus == MAKELONG(0, QS_KEY),
9019 "wrong qstatus %08x\n", qstatus);
9021 trace("signalling to send message\n");
9022 SetEvent(info.hevent[EV_SENDMSG]);
9023 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9025 qstatus = GetQueueStatus(qs_all_input);
9026 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
9027 "wrong qstatus %08x\n", qstatus);
9029 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9031 qstatus = GetQueueStatus(qs_all_input);
9032 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9033 "wrong qstatus %08x\n", qstatus);
9036 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
9037 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9038 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9039 ret, msg.message, msg.wParam);
9040 ok_sequence(WmUser, "WmUser", FALSE);
9042 qstatus = GetQueueStatus(qs_all_input);
9043 ok(qstatus == MAKELONG(0, QS_KEY),
9044 "wrong qstatus %08x\n", qstatus);
9047 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
9049 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9051 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9053 qstatus = GetQueueStatus(qs_all_input);
9054 ok(qstatus == MAKELONG(0, QS_KEY),
9055 "wrong qstatus %08x\n", qstatus);
9057 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9059 qstatus = GetQueueStatus(qs_all_input);
9060 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
9061 "wrong qstatus %08x\n", qstatus);
9063 trace("signalling to send message\n");
9064 SetEvent(info.hevent[EV_SENDMSG]);
9065 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9067 qstatus = GetQueueStatus(qs_all_input);
9068 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9069 "wrong qstatus %08x\n", qstatus);
9072 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
9074 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9076 ok_sequence(WmUser, "WmUser", FALSE);
9078 qstatus = GetQueueStatus(qs_all_input);
9079 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
9080 "wrong qstatus %08x\n", qstatus);
9083 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
9084 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
9085 else /* workaround for a missing QS_RAWINPUT support */
9086 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
9087 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9088 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9089 ret, msg.message, msg.wParam);
9090 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
9092 qstatus = GetQueueStatus(qs_all_input);
9093 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
9094 "wrong qstatus %08x\n", qstatus);
9097 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
9098 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
9099 else /* workaround for a missing QS_RAWINPUT support */
9100 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
9101 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
9102 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9103 ret, msg.message, msg.wParam);
9104 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
9106 qstatus = GetQueueStatus(qs_all_input);
9107 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9108 "wrong qstatus %08x\n", qstatus);
9111 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
9113 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9115 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9117 qstatus = GetQueueStatus(qs_all_input);
9118 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9119 "wrong qstatus %08x\n", qstatus);
9122 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9123 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9124 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9125 ret, msg.message, msg.wParam);
9126 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9128 qstatus = GetQueueStatus(qs_all_input);
9130 "wrong qstatus %08x\n", qstatus);
9133 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9135 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9137 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9139 qstatus = GetQueueStatus(qs_all_input);
9141 "wrong qstatus %08x\n", qstatus);
9143 /* test whether presence of the quit flag in the queue affects
9146 PostQuitMessage(0x1234abcd);
9148 qstatus = GetQueueStatus(qs_all_input);
9149 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9150 "wrong qstatus %08x\n", qstatus);
9152 PostMessageA(info.hwnd, WM_USER, 0, 0);
9154 qstatus = GetQueueStatus(qs_all_input);
9155 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9156 "wrong qstatus %08x\n", qstatus);
9159 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9160 ok(ret && msg.message == WM_USER,
9161 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
9162 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9164 qstatus = GetQueueStatus(qs_all_input);
9165 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9166 "wrong qstatus %08x\n", qstatus);
9169 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9170 ok(ret && msg.message == WM_QUIT,
9171 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
9172 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
9173 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
9174 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9176 qstatus = GetQueueStatus(qs_all_input);
9178 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9179 "wrong qstatus %08x\n", qstatus);
9183 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9185 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9187 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9189 qstatus = GetQueueStatus(qs_all_input);
9191 "wrong qstatus %08x\n", qstatus);
9193 /* some GetMessage tests */
9195 keybd_event('N', 0, 0, 0);
9196 qstatus = GetQueueStatus(qs_all_input);
9197 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9199 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9200 qstatus = GetQueueStatus(qs_all_input);
9201 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9205 ret = GetMessageA( &msg, 0, 0, 0 );
9206 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9207 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9208 ret, msg.message, msg.wParam);
9209 qstatus = GetQueueStatus(qs_all_input);
9210 ok(qstatus == MAKELONG(0, QS_KEY), "wrong qstatus %08x\n", qstatus);
9215 ret = GetMessageA( &msg, 0, 0, 0 );
9216 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9217 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9218 ret, msg.message, msg.wParam);
9219 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
9220 qstatus = GetQueueStatus(qs_all_input);
9221 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9224 keybd_event('N', 0, 0, 0);
9225 qstatus = GetQueueStatus(qs_all_input);
9226 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9228 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9229 qstatus = GetQueueStatus(qs_all_input);
9230 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9232 if (qstatus & (QS_KEY << 16))
9234 ret = GetMessageA( &msg, 0, WM_KEYDOWN, WM_KEYUP );
9235 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9236 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9237 ret, msg.message, msg.wParam);
9238 ok_sequence(WmKeyDownWasDownSkippedSeq, "WmKeyDownWasDownSkippedSeq", FALSE);
9239 qstatus = GetQueueStatus(qs_all_input);
9240 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), "wrong qstatus %08x\n", qstatus);
9245 ret = GetMessageA( &msg, 0, WM_CHAR, WM_CHAR );
9246 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9247 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9248 ret, msg.message, msg.wParam);
9249 qstatus = GetQueueStatus(qs_all_input);
9250 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9253 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
9254 qstatus = GetQueueStatus(qs_all_input);
9255 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9257 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9258 qstatus = GetQueueStatus(qs_all_input);
9259 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9261 trace("signalling to send message\n");
9262 SetEvent(info.hevent[EV_SENDMSG]);
9263 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9264 qstatus = GetQueueStatus(qs_all_input);
9265 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9266 "wrong qstatus %08x\n", qstatus);
9268 if (qstatus & (QS_KEY << 16))
9270 ret = GetMessageA( &msg, 0, WM_KEYDOWN, WM_KEYUP );
9271 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
9272 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9273 ret, msg.message, msg.wParam);
9274 ok_sequence(WmUserKeyUpSkippedSeq, "WmUserKeyUpSkippedSeq", FALSE);
9275 qstatus = GetQueueStatus(qs_all_input);
9276 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), "wrong qstatus %08x\n", qstatus);
9281 ret = GetMessageA( &msg, 0, WM_CHAR, WM_CHAR );
9282 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9283 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9284 ret, msg.message, msg.wParam);
9285 qstatus = GetQueueStatus(qs_all_input);
9286 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9289 trace("signalling to exit\n");
9290 SetEvent(info.hevent[EV_STOP]);
9292 WaitForSingleObject(hthread, INFINITE);
9294 CloseHandle(hthread);
9295 CloseHandle(info.hevent[0]);
9296 CloseHandle(info.hevent[1]);
9297 CloseHandle(info.hevent[2]);
9299 DestroyWindow(info.hwnd);
9302 static void wait_move_event(HWND hwnd, int x, int y)
9309 time = GetTickCount();
9310 while (GetTickCount() - time < 200 && !go) {
9311 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9312 go = ret && msg.pt.x > x && msg.pt.y > y;
9313 if (ret && !go) PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE);
9318 static void test_PeekMessage2(void)
9324 DWORD time1, time2, time3;
9325 int x1, y1, x2, y2, x3, y3;
9328 time1 = time2 = time3 = 0;
9329 x1 = y1 = x2 = y2 = x3 = y3 = 0;
9331 /* Initialise window and make sure it is ready for events */
9332 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
9333 10, 10, 800, 800, NULL, NULL, NULL, NULL);
9335 trace("Window for test_PeekMessage2 %p\n", hwnd);
9336 ShowWindow(hwnd, SW_SHOW);
9340 SetCursorPos(100, 100);
9341 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
9344 /* Do initial mousemove, wait until we can see it
9345 and then do our test peek with PM_NOREMOVE. */
9346 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9347 wait_move_event(hwnd, 80, 80);
9349 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9350 ok(ret, "no message available\n");
9352 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9353 message = msg.message;
9357 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9358 PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE);
9361 /* Allow time to advance a bit, and then simulate the user moving their
9362 * mouse around. After that we peek again with PM_NOREMOVE.
9363 * Although the previous mousemove message was never removed, the
9364 * mousemove we now peek should reflect the recent mouse movements
9365 * because the input queue will merge the move events. */
9367 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9368 wait_move_event(hwnd, x1, y1);
9370 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9371 ok(ret, "no message available\n");
9373 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9374 message = msg.message;
9378 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9379 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
9380 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
9381 PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE);
9384 /* Have another go, to drive the point home */
9386 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
9387 wait_move_event(hwnd, x2, y2);
9389 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9390 ok(ret, "no message available\n");
9392 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
9393 message = msg.message;
9397 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
9398 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
9399 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
9402 DestroyWindow(hwnd);
9403 SetCursorPos(pos.x, pos.y);
9407 static void test_quit_message(void)
9412 /* test using PostQuitMessage */
9414 PostQuitMessage(0xbeef);
9416 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9417 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9418 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9419 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9421 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9422 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9424 ret = GetMessage(&msg, NULL, 0, 0);
9425 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9426 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9428 /* note: WM_QUIT message received after WM_USER message */
9429 ret = GetMessage(&msg, NULL, 0, 0);
9430 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9431 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9432 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
9434 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
9435 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
9437 /* now test with PostThreadMessage - different behaviour! */
9438 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
9440 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
9441 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
9442 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9443 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9445 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
9446 ok(ret, "PostMessage failed with error %d\n", GetLastError());
9448 /* note: we receive the WM_QUIT message first this time */
9449 ret = GetMessage(&msg, NULL, 0, 0);
9450 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
9451 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
9452 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
9454 ret = GetMessage(&msg, NULL, 0, 0);
9455 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
9456 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
9459 static const struct message WmMouseHoverSeq[] = {
9460 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
9461 { WM_MOUSEACTIVATE, sent|optional },
9462 { WM_TIMER, sent|optional }, /* XP sends it */
9463 { WM_SYSTIMER, sent },
9464 { WM_MOUSEHOVER, sent|wparam, 0 },
9468 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
9471 DWORD start_ticks, end_ticks;
9473 start_ticks = GetTickCount();
9474 /* add some deviation (50%) to cover not expected delays */
9475 start_ticks += timeout / 2;
9479 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
9481 /* Timer proc messages are not dispatched to the window proc,
9482 * and therefore not logged.
9484 if (msg.message == WM_TIMER || msg.message == WM_SYSTIMER)
9486 struct recvd_message s_msg;
9488 s_msg.hwnd = msg.hwnd;
9489 s_msg.message = msg.message;
9490 s_msg.flags = sent|wparam|lparam;
9491 s_msg.wParam = msg.wParam;
9492 s_msg.lParam = msg.lParam;
9493 s_msg.descr = "msg_loop";
9494 add_message(&s_msg);
9496 DispatchMessage(&msg);
9499 end_ticks = GetTickCount();
9501 /* inject WM_MOUSEMOVE to see how it changes tracking */
9502 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
9504 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9505 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9507 inject_mouse_move = FALSE;
9509 } while (start_ticks + timeout >= end_ticks);
9512 static void test_TrackMouseEvent(void)
9514 TRACKMOUSEEVENT tme;
9517 RECT rc_parent, rc_child;
9518 UINT default_hover_time, hover_width = 0, hover_height = 0;
9520 #define track_hover(track_hwnd, track_hover_time) \
9521 tme.cbSize = sizeof(tme); \
9522 tme.dwFlags = TME_HOVER; \
9523 tme.hwndTrack = track_hwnd; \
9524 tme.dwHoverTime = track_hover_time; \
9525 SetLastError(0xdeadbeef); \
9526 ret = pTrackMouseEvent(&tme); \
9527 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
9529 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
9530 tme.cbSize = sizeof(tme); \
9531 tme.dwFlags = TME_QUERY; \
9532 tme.hwndTrack = (HWND)0xdeadbeef; \
9533 tme.dwHoverTime = 0xdeadbeef; \
9534 SetLastError(0xdeadbeef); \
9535 ret = pTrackMouseEvent(&tme); \
9536 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
9537 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
9538 ok(tme.dwFlags == (expected_track_flags), \
9539 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
9540 ok(tme.hwndTrack == (expected_track_hwnd), \
9541 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
9542 ok(tme.dwHoverTime == (expected_hover_time), \
9543 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
9545 #define track_hover_cancel(track_hwnd) \
9546 tme.cbSize = sizeof(tme); \
9547 tme.dwFlags = TME_HOVER | TME_CANCEL; \
9548 tme.hwndTrack = track_hwnd; \
9549 tme.dwHoverTime = 0xdeadbeef; \
9550 SetLastError(0xdeadbeef); \
9551 ret = pTrackMouseEvent(&tme); \
9552 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
9554 default_hover_time = 0xdeadbeef;
9555 SetLastError(0xdeadbeef);
9556 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
9557 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
9558 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
9559 if (!ret) default_hover_time = 400;
9560 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
9562 SetLastError(0xdeadbeef);
9563 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
9564 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
9565 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
9566 if (!ret) hover_width = 4;
9567 SetLastError(0xdeadbeef);
9568 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
9569 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
9570 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
9571 if (!ret) hover_height = 4;
9572 trace("hover rect is %u x %d\n", hover_width, hover_height);
9574 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
9575 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9576 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
9580 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
9581 WS_CHILD | WS_BORDER | WS_VISIBLE,
9582 50, 50, 200, 200, hwnd,
9586 SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
9591 tme.dwFlags = TME_QUERY;
9592 tme.hwndTrack = (HWND)0xdeadbeef;
9593 tme.dwHoverTime = 0xdeadbeef;
9594 SetLastError(0xdeadbeef);
9595 ret = pTrackMouseEvent(&tme);
9596 ok(!ret, "TrackMouseEvent should fail\n");
9597 ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef),
9598 "not expected error %u\n", GetLastError());
9600 tme.cbSize = sizeof(tme);
9601 tme.dwFlags = TME_HOVER;
9602 tme.hwndTrack = (HWND)0xdeadbeef;
9603 tme.dwHoverTime = 0xdeadbeef;
9604 SetLastError(0xdeadbeef);
9605 ret = pTrackMouseEvent(&tme);
9606 ok(!ret, "TrackMouseEvent should fail\n");
9607 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
9608 "not expected error %u\n", GetLastError());
9610 tme.cbSize = sizeof(tme);
9611 tme.dwFlags = TME_HOVER | TME_CANCEL;
9612 tme.hwndTrack = (HWND)0xdeadbeef;
9613 tme.dwHoverTime = 0xdeadbeef;
9614 SetLastError(0xdeadbeef);
9615 ret = pTrackMouseEvent(&tme);
9616 ok(!ret, "TrackMouseEvent should fail\n");
9617 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
9618 "not expected error %u\n", GetLastError());
9620 GetWindowRect(hwnd, &rc_parent);
9621 GetWindowRect(hchild, &rc_child);
9622 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
9624 /* Process messages so that the system updates its internal current
9625 * window and hittest, otherwise TrackMouseEvent calls don't have any
9631 track_query(0, NULL, 0);
9632 track_hover(hchild, 0);
9633 track_query(0, NULL, 0);
9638 track_hover(hwnd, 0);
9639 track_query(TME_HOVER, hwnd, default_hover_time);
9641 pump_msg_loop_timeout(default_hover_time, FALSE);
9642 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9644 track_query(0, NULL, 0);
9646 track_hover(hwnd, HOVER_DEFAULT);
9647 track_query(TME_HOVER, hwnd, default_hover_time);
9649 Sleep(default_hover_time / 2);
9650 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
9651 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
9653 track_query(TME_HOVER, hwnd, default_hover_time);
9655 pump_msg_loop_timeout(default_hover_time / 2, FALSE);
9656 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9658 track_query(0, NULL, 0);
9660 track_hover(hwnd, HOVER_DEFAULT);
9661 track_query(TME_HOVER, hwnd, default_hover_time);
9663 pump_msg_loop_timeout(default_hover_time, TRUE);
9664 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
9666 track_query(0, NULL, 0);
9668 track_hover(hwnd, HOVER_DEFAULT);
9669 track_query(TME_HOVER, hwnd, default_hover_time);
9670 track_hover_cancel(hwnd);
9672 DestroyWindow(hwnd);
9676 #undef track_hover_cancel
9680 static const struct message WmSetWindowRgn[] = {
9681 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9682 { WM_NCCALCSIZE, sent|wparam, 1 },
9683 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
9684 { WM_GETTEXT, sent|defwinproc|optional },
9685 { WM_ERASEBKGND, sent|optional },
9686 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9687 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9691 static const struct message WmSetWindowRgn_no_redraw[] = {
9692 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9693 { WM_NCCALCSIZE, sent|wparam, 1 },
9694 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
9695 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9699 static const struct message WmSetWindowRgn_clear[] = {
9700 { WM_WINDOWPOSCHANGING, sent/*|wparam*/, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
9701 { WM_NCCALCSIZE, sent|wparam, 1 },
9702 { WM_NCPAINT, sent|optional },
9703 { WM_GETTEXT, sent|defwinproc|optional },
9704 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
9705 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9706 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
9707 { WM_NCPAINT, sent|optional },
9708 { WM_GETTEXT, sent|defwinproc|optional },
9709 { WM_ERASEBKGND, sent|optional },
9710 { WM_WINDOWPOSCHANGING, sent|optional },
9711 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
9712 { WM_NCPAINT, sent|optional },
9713 { WM_GETTEXT, sent|defwinproc|optional },
9714 { WM_ERASEBKGND, sent|optional },
9715 { WM_WINDOWPOSCHANGED, sent|optional|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
9716 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
9717 { WM_NCPAINT, sent|optional },
9718 { WM_GETTEXT, sent|defwinproc|optional },
9719 { WM_ERASEBKGND, sent|optional },
9720 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9721 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
9725 static void test_SetWindowRgn(void)
9728 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
9729 100, 100, 200, 200, 0, 0, 0, NULL);
9730 ok( hwnd != 0, "Failed to create overlapped window\n" );
9732 ShowWindow( hwnd, SW_SHOW );
9733 UpdateWindow( hwnd );
9737 trace("testing SetWindowRgn\n");
9738 hrgn = CreateRectRgn( 0, 0, 150, 150 );
9739 SetWindowRgn( hwnd, hrgn, TRUE );
9740 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
9742 hrgn = CreateRectRgn( 30, 30, 160, 160 );
9743 SetWindowRgn( hwnd, hrgn, FALSE );
9744 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
9746 hrgn = CreateRectRgn( 0, 0, 180, 180 );
9747 SetWindowRgn( hwnd, hrgn, TRUE );
9748 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
9750 SetWindowRgn( hwnd, 0, TRUE );
9751 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
9753 DestroyWindow( hwnd );
9756 /*************************** ShowWindow() test ******************************/
9757 static const struct message WmShowNormal[] = {
9758 { WM_SHOWWINDOW, sent|wparam, 1 },
9759 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9760 { HCBT_ACTIVATE, hook },
9761 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9762 { HCBT_SETFOCUS, hook },
9763 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9766 static const struct message WmShow[] = {
9767 { WM_SHOWWINDOW, sent|wparam, 1 },
9768 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9769 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9770 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9771 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9772 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9775 static const struct message WmShowNoActivate_1[] = {
9776 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9777 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9778 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9779 { WM_MOVE, sent|defwinproc|optional },
9780 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9783 static const struct message WmShowNoActivate_2[] = {
9784 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
9785 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9786 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9787 { WM_MOVE, sent|defwinproc },
9788 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9789 { HCBT_SETFOCUS, hook|optional },
9790 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9791 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9792 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9795 static const struct message WmShowNA_1[] = {
9796 { WM_SHOWWINDOW, sent|wparam, 1 },
9797 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9798 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9801 static const struct message WmShowNA_2[] = {
9802 { WM_SHOWWINDOW, sent|wparam, 1 },
9803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9804 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9807 static const struct message WmRestore_1[] = {
9808 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9809 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9810 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9811 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9812 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9813 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9814 { WM_MOVE, sent|defwinproc },
9815 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9816 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9819 static const struct message WmRestore_2[] = {
9820 { WM_SHOWWINDOW, sent|wparam, 1 },
9821 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9822 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9823 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9824 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9825 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9828 static const struct message WmRestore_3[] = {
9829 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9830 { WM_GETMINMAXINFO, sent },
9831 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9832 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
9833 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
9834 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
9835 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9836 { WM_MOVE, sent|defwinproc },
9837 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9838 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9841 static const struct message WmRestore_4[] = {
9842 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
9843 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9844 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9845 { WM_MOVE, sent|defwinproc|optional },
9846 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9849 static const struct message WmRestore_5[] = {
9850 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
9851 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9852 { HCBT_ACTIVATE, hook|optional },
9853 { HCBT_SETFOCUS, hook|optional },
9854 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9855 { WM_MOVE, sent|defwinproc|optional },
9856 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
9859 static const struct message WmHide_1[] = {
9860 { WM_SHOWWINDOW, sent|wparam, 0 },
9861 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9862 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9863 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
9866 static const struct message WmHide_2[] = {
9867 { WM_SHOWWINDOW, sent|wparam, 0 },
9868 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9869 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
9872 static const struct message WmHide_3[] = {
9873 { WM_SHOWWINDOW, sent|wparam, 0 },
9874 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
9875 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9876 { HCBT_SETFOCUS, hook|optional },
9877 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9880 static const struct message WmShowMinimized_1[] = {
9881 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9882 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9883 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9884 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9885 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9886 { WM_MOVE, sent|defwinproc },
9887 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9890 static const struct message WmMinimize_1[] = {
9891 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9892 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9893 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9894 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9895 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9896 { WM_MOVE, sent|defwinproc },
9897 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9900 static const struct message WmMinimize_2[] = {
9901 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9902 { HCBT_SETFOCUS, hook|optional },
9903 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9904 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9905 { WM_MOVE, sent|defwinproc },
9906 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9909 static const struct message WmMinimize_3[] = {
9910 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9911 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9912 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9913 { WM_MOVE, sent|defwinproc },
9914 { WM_SIZE, sent|wparam|defwinproc, SIZE_MINIMIZED },
9917 static const struct message WmShowMinNoActivate[] = {
9918 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9919 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
9920 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9923 static const struct message WmMinMax_1[] = {
9924 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
9927 static const struct message WmMinMax_2[] = {
9928 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9929 { WM_GETMINMAXINFO, sent|optional },
9930 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED },
9931 { HCBT_ACTIVATE, hook|optional },
9932 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
9933 { HCBT_SETFOCUS, hook|optional },
9934 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
9935 { WM_MOVE, sent|defwinproc|optional },
9936 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_MAXIMIZED },
9937 { HCBT_SETFOCUS, hook|optional },
9940 static const struct message WmMinMax_3[] = {
9941 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
9944 static const struct message WmMinMax_4[] = {
9945 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
9948 static const struct message WmShowMaximized_1[] = {
9949 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9950 { WM_GETMINMAXINFO, sent },
9951 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9952 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9953 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9954 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9955 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9956 { WM_MOVE, sent|defwinproc },
9957 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9958 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
9961 static const struct message WmShowMaximized_2[] = {
9962 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9963 { WM_GETMINMAXINFO, sent },
9964 { WM_WINDOWPOSCHANGING, sent|optional },
9965 { HCBT_ACTIVATE, hook|optional },
9966 { WM_WINDOWPOSCHANGED, sent|optional },
9967 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
9968 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
9969 { WM_WINDOWPOSCHANGING, sent },
9970 { HCBT_SETFOCUS, hook|optional },
9971 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
9972 { WM_MOVE, sent|defwinproc },
9973 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9974 { HCBT_SETFOCUS, hook|optional },
9977 static const struct message WmShowMaximized_3[] = {
9978 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
9979 { WM_GETMINMAXINFO, sent },
9980 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9981 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
9982 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
9983 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
9984 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
9985 { WM_MOVE, sent|defwinproc|optional },
9986 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
9990 static void test_ShowWindow(void)
9992 /* ShowWindow commands in random order */
9995 INT cmd; /* ShowWindow command */
9996 LPARAM ret; /* ShowWindow return value */
9997 DWORD style; /* window style after the command */
9998 const struct message *msg; /* message sequence the command produces */
9999 BOOL todo_msg; /* message sequence doesn't match what Wine does */
10002 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal, FALSE },
10003 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10004 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
10005 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
10006 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1, FALSE },
10007 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1, FALSE },
10008 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1, FALSE },
10009 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
10010 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1, FALSE },
10011 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
10012 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1, FALSE },
10013 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq, FALSE },
10014 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1, FALSE },
10015 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10016 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2, FALSE },
10017 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
10018 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow, FALSE },
10019 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10020 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
10021 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
10022 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
10023 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate, TRUE },
10024 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4, FALSE },
10025 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
10026 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
10027 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1, FALSE },
10028 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2, FALSE },
10029 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
10030 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq, FALSE },
10031 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1, FALSE },
10032 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10033 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3, FALSE },
10034 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
10035 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE }, /* what does this mean?! */
10036 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, FALSE },
10037 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
10038 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2, FALSE },
10039 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10040 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10041 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2, FALSE },
10042 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
10043 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2, TRUE },
10044 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2, FALSE },
10045 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1, FALSE },
10046 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3, FALSE },
10047 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3, FALSE },
10048 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4, FALSE },
10049 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3, FALSE },
10050 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq, FALSE },
10051 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5, FALSE },
10052 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq, FALSE },
10053 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1, FALSE },
10054 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq, FALSE },
10055 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3, FALSE },
10056 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2, FALSE },
10057 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2, FALSE },
10058 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq, FALSE }
10065 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
10066 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
10071 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
10072 ok(style == 0, "expected style 0, got %08x\n", style);
10077 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
10079 static const char * const sw_cmd_name[13] =
10081 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
10082 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
10083 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
10084 "SW_NORMALNA" /* 0xCC */
10087 INT idx; /* index into the above array of names */
10089 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
10091 style = GetWindowLong(hwnd, GWL_STYLE);
10092 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
10093 ret = ShowWindow(hwnd, sw[i].cmd);
10094 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
10095 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
10096 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
10098 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
10099 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
10105 DestroyWindow(hwnd);
10108 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
10110 struct recvd_message msg;
10116 return 0; /* ignore them */
10120 msg.message = message;
10121 msg.flags = sent|wparam|lparam;
10122 msg.wParam = wParam;
10123 msg.lParam = lParam;
10124 msg.descr = "dialog";
10127 /* calling DefDlgProc leads to a recursion under XP */
10131 case WM_INITDIALOG:
10132 case WM_GETDLGCODE:
10138 static const struct message WmDefDlgSetFocus_1[] = {
10139 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
10140 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
10141 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
10142 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
10143 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10144 { HCBT_SETFOCUS, hook },
10145 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
10146 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10147 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10148 { WM_SETFOCUS, sent|wparam, 0 },
10149 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
10150 { WM_CTLCOLOREDIT, sent },
10151 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
10152 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
10153 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
10154 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
10155 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
10158 static const struct message WmDefDlgSetFocus_2[] = {
10159 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
10160 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
10161 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
10162 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
10163 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
10164 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
10165 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
10166 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
10169 /* Creation of a dialog */
10170 static const struct message WmCreateDialogParamSeq_1[] = {
10171 { HCBT_CREATEWND, hook },
10172 { WM_NCCREATE, sent },
10173 { WM_NCCALCSIZE, sent|wparam, 0 },
10174 { WM_CREATE, sent },
10175 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
10176 { WM_SIZE, sent|wparam, SIZE_RESTORED },
10178 { WM_SETFONT, sent },
10179 { WM_INITDIALOG, sent },
10180 { WM_CHANGEUISTATE, sent|optional },
10183 /* Creation of a dialog */
10184 static const struct message WmCreateDialogParamSeq_2[] = {
10185 { HCBT_CREATEWND, hook },
10186 { WM_NCCREATE, sent },
10187 { WM_NCCALCSIZE, sent|wparam, 0 },
10188 { WM_CREATE, sent },
10189 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
10190 { WM_SIZE, sent|wparam, SIZE_RESTORED },
10192 { WM_CHANGEUISTATE, sent|optional },
10196 static void test_dialog_messages(void)
10199 HWND hdlg, hedit1, hedit2, hfocus;
10202 #define set_selection(hctl, start, end) \
10203 ret = SendMessage(hctl, EM_SETSEL, start, end); \
10204 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
10206 #define check_selection(hctl, start, end) \
10207 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
10208 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
10212 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
10213 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
10214 0, 0, 100, 100, 0, 0, 0, NULL);
10215 ok(hdlg != 0, "Failed to create custom dialog window\n");
10217 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
10218 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
10219 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
10220 ok(hedit1 != 0, "Failed to create edit control\n");
10221 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
10222 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
10223 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
10224 ok(hedit2 != 0, "Failed to create edit control\n");
10226 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
10227 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
10229 hfocus = GetFocus();
10230 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
10233 hfocus = GetFocus();
10234 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
10236 check_selection(hedit1, 0, 0);
10237 check_selection(hedit2, 0, 0);
10239 set_selection(hedit2, 0, -1);
10240 check_selection(hedit2, 0, 3);
10243 hfocus = GetFocus();
10244 ok(hfocus == 0, "wrong focus %p\n", hfocus);
10247 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
10248 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
10249 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
10251 hfocus = GetFocus();
10252 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
10254 check_selection(hedit1, 0, 5);
10255 check_selection(hedit2, 0, 3);
10258 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
10259 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
10260 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
10262 hfocus = GetFocus();
10263 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
10265 check_selection(hedit1, 0, 5);
10266 check_selection(hedit2, 0, 3);
10268 EndDialog(hdlg, 0);
10269 DestroyWindow(hedit1);
10270 DestroyWindow(hedit2);
10271 DestroyWindow(hdlg);
10274 #undef set_selection
10275 #undef check_selection
10277 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
10278 cls.lpszClassName = "MyDialogClass";
10279 cls.hInstance = GetModuleHandle(0);
10280 /* need a cast since a dlgproc is used as a wndproc */
10281 cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
10282 if (!RegisterClass(&cls)) assert(0);
10284 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
10285 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
10286 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
10287 EndDialog(hdlg, 0);
10288 DestroyWindow(hdlg);
10291 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
10292 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
10293 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
10294 EndDialog(hdlg, 0);
10295 DestroyWindow(hdlg);
10298 UnregisterClass(cls.lpszClassName, cls.hInstance);
10301 static void test_nullCallback(void)
10305 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
10306 100, 100, 200, 200, 0, 0, 0, NULL);
10307 ok (hwnd != 0, "Failed to create overlapped window\n");
10309 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
10311 DestroyWindow(hwnd);
10314 /* SetActiveWindow( 0 ) hwnd visible */
10315 static const struct message SetActiveWindowSeq0[] =
10317 { HCBT_ACTIVATE, hook },
10318 { WM_NCACTIVATE, sent|wparam, 0 },
10319 { WM_GETTEXT, sent|defwinproc|optional },
10320 { WM_ACTIVATE, sent|wparam, 0 },
10321 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
10322 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10323 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10324 { WM_NCACTIVATE, sent|wparam, 1 },
10325 { WM_GETTEXT, sent|defwinproc|optional },
10326 { WM_ACTIVATE, sent|wparam, 1 },
10327 { HCBT_SETFOCUS, hook },
10328 { WM_KILLFOCUS, sent|defwinproc },
10329 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
10330 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10331 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
10332 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10333 { WM_SETFOCUS, sent|defwinproc },
10334 { WM_GETTEXT, sent|optional },
10337 /* SetActiveWindow( hwnd ) hwnd visible */
10338 static const struct message SetActiveWindowSeq1[] =
10340 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
10343 /* SetActiveWindow( popup ) hwnd visible, popup visible */
10344 static const struct message SetActiveWindowSeq2[] =
10346 { HCBT_ACTIVATE, hook },
10347 { WM_NCACTIVATE, sent|wparam, 0 },
10348 { WM_GETTEXT, sent|defwinproc|optional },
10349 { WM_ACTIVATE, sent|wparam, 0 },
10350 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
10351 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
10352 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10353 { WM_NCPAINT, sent|optional },
10354 { WM_GETTEXT, sent|defwinproc|optional },
10355 { WM_ERASEBKGND, sent|optional },
10356 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10357 { WM_NCACTIVATE, sent|wparam, 1 },
10358 { WM_GETTEXT, sent|defwinproc|optional },
10359 { WM_ACTIVATE, sent|wparam, 1 },
10360 { HCBT_SETFOCUS, hook },
10361 { WM_KILLFOCUS, sent|defwinproc },
10362 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
10363 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10364 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
10365 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10366 { WM_SETFOCUS, sent|defwinproc },
10367 { WM_GETTEXT, sent|optional },
10371 /* SetActiveWindow( hwnd ) hwnd not visible */
10372 static const struct message SetActiveWindowSeq3[] =
10374 { HCBT_ACTIVATE, hook },
10375 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
10376 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10377 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10378 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10379 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10380 { WM_ACTIVATEAPP, sent|wparam, 1 },
10381 { WM_ACTIVATEAPP, sent|wparam, 1 },
10382 { WM_NCACTIVATE, sent|wparam, 1 },
10383 { WM_ACTIVATE, sent|wparam, 1 },
10384 { HCBT_SETFOCUS, hook },
10385 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10386 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10387 { WM_SETFOCUS, sent|defwinproc },
10390 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
10391 static const struct message SetActiveWindowSeq4[] =
10393 { HCBT_ACTIVATE, hook },
10394 { WM_NCACTIVATE, sent|wparam, 0 },
10395 { WM_GETTEXT, sent|defwinproc|optional },
10396 { WM_ACTIVATE, sent|wparam, 0 },
10397 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
10398 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
10399 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
10400 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10401 { WM_NCACTIVATE, sent|wparam, 1 },
10402 { WM_GETTEXT, sent|defwinproc|optional },
10403 { WM_ACTIVATE, sent|wparam, 1 },
10404 { HCBT_SETFOCUS, hook },
10405 { WM_KILLFOCUS, sent|defwinproc },
10406 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
10407 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10408 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
10409 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
10410 { WM_SETFOCUS, sent|defwinproc },
10415 static void test_SetActiveWindow(void)
10417 HWND hwnd, popup, ret;
10419 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10420 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10421 100, 100, 200, 200, 0, 0, 0, NULL);
10423 popup = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
10424 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_POPUP,
10425 100, 100, 200, 200, hwnd, 0, 0, NULL);
10427 ok(hwnd != 0, "Failed to create overlapped window\n");
10428 ok(popup != 0, "Failed to create popup window\n");
10429 SetForegroundWindow( popup );
10432 trace("SetActiveWindow(0)\n");
10433 ret = SetActiveWindow(0);
10434 ok( ret == popup, "Failed to SetActiveWindow(0)\n");
10435 ok_sequence(SetActiveWindowSeq0, "SetActiveWindow(0)", TRUE);
10438 trace("SetActiveWindow(hwnd), hwnd visible\n");
10439 ret = SetActiveWindow(hwnd);
10442 ok( ret == hwnd, "Failed to SetActiveWindow(hwnd), hwnd visible\n");
10444 ok_sequence(SetActiveWindowSeq1, "SetActiveWindow(hwnd), hwnd visible", TRUE);
10447 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
10448 ret = SetActiveWindow(popup);
10449 ok( ret == hwnd, "Failed to SetActiveWindow(popup), popup visible\n");
10450 ok_sequence(SetActiveWindowSeq2, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE);
10453 ShowWindow(hwnd, SW_HIDE);
10454 ShowWindow(popup, SW_HIDE);
10457 trace("SetActiveWindow(hwnd), hwnd not visible\n");
10458 ret = SetActiveWindow(hwnd);
10459 ok( ret == NULL, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret );
10460 ok_sequence(SetActiveWindowSeq3, "SetActiveWindow(hwnd), hwnd not visible", TRUE);
10463 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
10464 ret = SetActiveWindow(popup);
10465 ok( ret == hwnd, "Failed to SetActiveWindow(popup)\n");
10466 ok_sequence(SetActiveWindowSeq4, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE);
10471 DestroyWindow(hwnd);
10474 static const struct message SetForegroundWindowSeq[] =
10476 { WM_NCACTIVATE, sent|wparam, 0 },
10477 { WM_GETTEXT, sent|defwinproc|optional },
10478 { WM_ACTIVATE, sent|wparam, 0 },
10479 { WM_ACTIVATEAPP, sent|wparam, 0 },
10480 { WM_KILLFOCUS, sent },
10481 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
10482 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
10486 static void test_SetForegroundWindow(void)
10490 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
10491 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10492 100, 100, 200, 200, 0, 0, 0, NULL);
10493 ok (hwnd != 0, "Failed to create overlapped window\n");
10496 trace("SetForegroundWindow( 0 )\n");
10497 SetForegroundWindow( 0 );
10498 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
10499 trace("SetForegroundWindow( GetDesktopWindow() )\n");
10500 SetForegroundWindow( GetDesktopWindow() );
10501 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
10502 "foreground top level window", FALSE);
10505 DestroyWindow(hwnd);
10508 static void test_dbcs_wm_char(void)
10511 WCHAR wch, bad_wch;
10519 struct message wmCharSeq[2];
10521 if (!pGetCPInfoExA)
10523 skip("GetCPInfoExA is not available\n");
10527 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
10528 if (cpinfo.MaxCharSize != 2)
10530 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
10534 dbch[0] = dbch[1] = 0;
10536 bad_wch = cpinfo.UnicodeDefaultChar;
10537 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
10538 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
10539 for (k = 128; k <= 255; k++)
10545 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
10546 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
10547 (BYTE)str[0] == j && (BYTE)str[1] == k &&
10548 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
10559 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
10562 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
10563 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
10565 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
10566 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10567 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
10568 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
10569 ok (hwnd != 0, "Failed to create overlapped window\n");
10570 ok (hwnd2 != 0, "Failed to create overlapped window\n");
10573 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
10574 wmCharSeq[0].message = WM_CHAR;
10575 wmCharSeq[0].flags = sent|wparam;
10576 wmCharSeq[0].wParam = wch;
10578 /* posted message */
10579 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10580 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10581 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10582 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10583 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10584 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10585 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10587 /* posted thread message */
10588 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
10589 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10590 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10591 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10592 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10593 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10594 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10598 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10599 ok_sequence( WmEmptySeq, "no messages", FALSE );
10600 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10601 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10602 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10604 /* sent message with timeout */
10606 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10607 ok_sequence( WmEmptySeq, "no messages", FALSE );
10608 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10609 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10610 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10612 /* sent message with timeout and callback */
10614 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
10615 ok_sequence( WmEmptySeq, "no messages", FALSE );
10616 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10617 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10618 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10620 /* sent message with callback */
10622 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10623 ok_sequence( WmEmptySeq, "no messages", FALSE );
10624 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
10625 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10626 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10628 /* direct window proc call */
10630 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10631 ok_sequence( WmEmptySeq, "no messages", FALSE );
10632 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10633 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10635 /* dispatch message */
10637 msg.message = WM_CHAR;
10638 msg.wParam = dbch[0];
10640 DispatchMessageA( &msg );
10641 ok_sequence( WmEmptySeq, "no messages", FALSE );
10642 msg.wParam = dbch[1];
10643 DispatchMessageA( &msg );
10644 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10646 /* window handle is irrelevant */
10648 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10649 ok_sequence( WmEmptySeq, "no messages", FALSE );
10650 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10651 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10652 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10654 /* interleaved post and send */
10656 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10657 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
10658 ok_sequence( WmEmptySeq, "no messages", FALSE );
10659 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10660 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10661 ok_sequence( WmEmptySeq, "no messages", FALSE );
10662 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10663 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10664 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
10665 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10666 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10667 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10668 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10670 /* interleaved sent message and winproc */
10672 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10673 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10674 ok_sequence( WmEmptySeq, "no messages", FALSE );
10675 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10676 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10677 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10678 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10680 /* interleaved winproc and dispatch */
10682 msg.message = WM_CHAR;
10683 msg.wParam = dbch[0];
10685 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
10686 DispatchMessageA( &msg );
10687 ok_sequence( WmEmptySeq, "no messages", FALSE );
10688 msg.wParam = dbch[1];
10689 DispatchMessageA( &msg );
10690 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10691 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
10692 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10694 /* interleaved sends */
10696 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
10697 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
10698 ok_sequence( WmEmptySeq, "no messages", FALSE );
10699 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
10700 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10701 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
10702 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10706 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
10707 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
10708 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10710 /* other char messages are not magic */
10711 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
10712 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10713 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
10714 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10715 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10716 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
10717 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10718 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
10719 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
10720 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10722 /* test retrieving messages */
10724 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10725 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10726 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10727 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10728 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10729 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10730 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10731 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10732 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10733 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10735 /* message filters */
10736 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10737 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
10738 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10739 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10740 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10741 /* message id is filtered, hwnd is not */
10742 ok( !PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ), "no message\n" );
10743 ok( PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE ), "no message\n" );
10744 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10745 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10746 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10747 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10749 /* mixing GetMessage and PostMessage */
10750 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
10751 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
10752 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10753 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10754 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10755 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10758 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
10759 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10760 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10761 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10762 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10763 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
10764 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
10765 ok( msg.pt.x == pt.x && msg.pt.y == pt.y, "bad point %u,%u/%u,%u\n", msg.pt.x, msg.pt.y, pt.x, pt.y );
10766 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10768 /* without PM_REMOVE */
10769 PostMessageW( hwnd, WM_CHAR, wch, 0 );
10770 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10771 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10772 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10773 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10774 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10775 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10776 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10777 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10778 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
10779 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10780 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10781 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10782 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
10783 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
10784 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
10785 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
10786 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
10788 DestroyWindow(hwnd);
10791 #define ID_LISTBOX 0x000f
10793 static const struct message wm_lb_setcursel_0[] =
10795 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
10796 { WM_CTLCOLORLISTBOX, sent|parent },
10797 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10798 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10799 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10802 static const struct message wm_lb_setcursel_1[] =
10804 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
10805 { WM_CTLCOLORLISTBOX, sent|parent },
10806 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
10807 { WM_CTLCOLORLISTBOX, sent|parent },
10808 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
10809 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10810 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
10813 static const struct message wm_lb_setcursel_2[] =
10815 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
10816 { WM_CTLCOLORLISTBOX, sent|parent },
10817 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
10818 { WM_CTLCOLORLISTBOX, sent|parent },
10819 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
10820 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10821 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10824 static const struct message wm_lb_click_0[] =
10826 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
10827 { HCBT_SETFOCUS, hook },
10828 { WM_KILLFOCUS, sent|parent },
10829 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
10830 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
10831 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10832 { WM_SETFOCUS, sent|defwinproc },
10834 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
10835 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
10836 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
10837 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
10838 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
10840 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
10841 { WM_CTLCOLORLISTBOX, sent|parent },
10842 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
10843 { WM_CTLCOLORLISTBOX, sent|parent },
10844 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
10845 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
10847 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10848 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
10850 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
10851 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
10852 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
10853 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
10857 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
10859 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
10861 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10863 static long defwndproc_counter = 0;
10865 struct recvd_message msg;
10867 /* do not log painting messages */
10868 if (message != WM_PAINT &&
10869 message != WM_NCPAINT &&
10870 message != WM_SYNCPAINT &&
10871 message != WM_ERASEBKGND &&
10872 message != WM_NCHITTEST &&
10873 message != WM_GETTEXT &&
10874 message != WM_GETOBJECT &&
10875 message != WM_GETICON &&
10876 message != WM_DEVICECHANGE)
10879 msg.message = message;
10880 msg.flags = sent|wparam|lparam;
10881 if (defwndproc_counter) msg.flags |= defwinproc;
10884 msg.descr = "listbox";
10888 defwndproc_counter++;
10889 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
10890 defwndproc_counter--;
10895 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
10896 int caret_index, int top_index, int line)
10900 /* calling an orig proc helps to avoid unnecessary message logging */
10901 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
10902 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
10903 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
10904 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
10905 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
10906 ok_(__FILE__, line)(ret == caret_index, "expected caret index %d, got %ld\n", caret_index, ret);
10907 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
10908 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
10911 static void test_listbox_messages(void)
10913 HWND parent, listbox;
10916 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10917 100, 100, 200, 200, 0, 0, 0, NULL);
10918 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
10919 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
10920 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
10921 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
10923 check_lb_state(listbox, 0, LB_ERR, 0, 0);
10925 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
10926 ok(ret == 0, "expected 0, got %ld\n", ret);
10927 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
10928 ok(ret == 1, "expected 1, got %ld\n", ret);
10929 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
10930 ok(ret == 2, "expected 2, got %ld\n", ret);
10932 check_lb_state(listbox, 3, LB_ERR, 0, 0);
10936 log_all_parent_messages++;
10938 trace("selecting item 0\n");
10939 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
10940 ok(ret == 0, "expected 0, got %ld\n", ret);
10941 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
10942 check_lb_state(listbox, 3, 0, 0, 0);
10945 trace("selecting item 1\n");
10946 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
10947 ok(ret == 1, "expected 1, got %ld\n", ret);
10948 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
10949 check_lb_state(listbox, 3, 1, 1, 0);
10951 trace("selecting item 2\n");
10952 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
10953 ok(ret == 2, "expected 2, got %ld\n", ret);
10954 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
10955 check_lb_state(listbox, 3, 2, 2, 0);
10957 trace("clicking on item 0\n");
10958 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
10959 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10960 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
10961 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
10962 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
10963 check_lb_state(listbox, 3, 0, 0, 0);
10966 log_all_parent_messages--;
10968 DestroyWindow(listbox);
10969 DestroyWindow(parent);
10972 /*************************** Menu test ******************************/
10973 static const struct message wm_popup_menu_1[] =
10975 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
10976 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
10977 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0x20000001 },
10978 { WM_SYSKEYDOWN, sent|wparam|lparam, 'E', 0x20000001 },
10979 { WM_SYSCHAR, sent|wparam|lparam, 'e', 0x20000001 },
10980 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'e' },
10981 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
10982 { WM_INITMENU, sent|lparam, 0, 0 },
10983 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(1,MF_HILITE|MF_POPUP) },
10984 { WM_INITMENUPOPUP, sent|lparam, 0, 1 },
10985 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't create a window */
10986 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(200,MF_HILITE) },
10987 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0xf0000001 },
10988 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
10989 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
10990 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't create a window */
10991 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
10992 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
10993 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
10994 { WM_MENUCOMMAND, sent }, /* |wparam, 200 - Win9x */
10995 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
10996 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
10999 static const struct message wm_popup_menu_2[] =
11001 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
11002 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
11003 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
11004 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
11005 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
11006 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
11007 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
11008 { WM_INITMENU, sent|lparam, 0, 0 },
11009 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
11010 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
11011 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
11012 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
11013 { HCBT_CREATEWND, hook },
11014 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11015 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11016 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
11017 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
11018 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
11019 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
11020 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
11021 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
11022 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
11023 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
11024 { HCBT_DESTROYWND, hook },
11025 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11026 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
11027 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11028 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
11029 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
11030 { WM_MENUCOMMAND, sent }, /* |wparam, 100 - Win9x */
11031 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
11032 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
11035 static const struct message wm_popup_menu_3[] =
11037 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
11038 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
11039 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
11040 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
11041 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
11042 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
11043 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
11044 { WM_INITMENU, sent|lparam, 0, 0 },
11045 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
11046 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
11047 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
11048 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
11049 { HCBT_CREATEWND, hook },
11050 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11051 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11052 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
11053 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
11054 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
11055 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
11056 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
11057 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
11058 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
11059 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
11060 { HCBT_DESTROYWND, hook },
11061 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11062 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
11063 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11064 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
11065 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
11066 { WM_COMMAND, sent|wparam|lparam, 100, 0 },
11067 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
11068 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
11072 static LRESULT WINAPI parent_menu_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
11074 if (message == WM_ENTERIDLE ||
11075 message == WM_INITMENU ||
11076 message == WM_INITMENUPOPUP ||
11077 message == WM_MENUSELECT ||
11078 message == WM_PARENTNOTIFY ||
11079 message == WM_ENTERMENULOOP ||
11080 message == WM_EXITMENULOOP ||
11081 message == WM_UNINITMENUPOPUP ||
11082 message == WM_KEYDOWN ||
11083 message == WM_KEYUP ||
11084 message == WM_CHAR ||
11085 message == WM_SYSKEYDOWN ||
11086 message == WM_SYSKEYUP ||
11087 message == WM_SYSCHAR ||
11088 message == WM_COMMAND ||
11089 message == WM_MENUCOMMAND)
11091 struct recvd_message msg;
11094 msg.message = message;
11095 msg.flags = sent|wparam|lparam;
11098 msg.descr = "parent_menu_proc";
11102 return DefWindowProcA(hwnd, message, wp, lp);
11105 static void set_menu_style(HMENU hmenu, DWORD style)
11110 mi.cbSize = sizeof(mi);
11111 mi.fMask = MIM_STYLE;
11112 mi.dwStyle = style;
11113 SetLastError(0xdeadbeef);
11114 ret = pSetMenuInfo(hmenu, &mi);
11115 ok(ret, "SetMenuInfo error %u\n", GetLastError());
11118 static DWORD get_menu_style(HMENU hmenu)
11123 mi.cbSize = sizeof(mi);
11124 mi.fMask = MIM_STYLE;
11126 SetLastError(0xdeadbeef);
11127 ret = pGetMenuInfo(hmenu, &mi);
11128 ok(ret, "GetMenuInfo error %u\n", GetLastError());
11133 static void test_menu_messages(void)
11137 HMENU hmenu, hmenu_popup;
11141 if (!pGetMenuInfo || !pSetMenuInfo)
11143 skip("GetMenuInfo and/or SetMenuInfo are not available\n");
11147 cls.lpfnWndProc = parent_menu_proc;
11148 cls.cbClsExtra = 0;
11149 cls.cbWndExtra = 0;
11150 cls.hInstance = GetModuleHandleA(0);
11152 cls.hCursor = LoadCursorA(0, IDC_ARROW);
11153 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
11154 cls.lpszMenuName = NULL;
11155 cls.lpszClassName = "TestMenuClass";
11156 UnregisterClass(cls.lpszClassName, cls.hInstance);
11157 if (!RegisterClassA(&cls)) assert(0);
11159 SetLastError(0xdeadbeef);
11160 hwnd = CreateWindowExA(0, "TestMenuClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11161 100, 100, 200, 200, 0, 0, 0, NULL);
11162 ok(hwnd != 0, "LoadMenuA error %u\n", GetLastError());
11164 SetLastError(0xdeadbeef);
11165 hmenu = LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
11166 ok(hmenu != 0, "LoadMenuA error %u\n", GetLastError());
11168 SetMenu(hwnd, hmenu);
11169 SetForegroundWindow( hwnd );
11171 set_menu_style(hmenu, MNS_NOTIFYBYPOS);
11172 style = get_menu_style(hmenu);
11173 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
11175 hmenu_popup = GetSubMenu(hmenu, 0);
11176 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
11177 style = get_menu_style(hmenu_popup);
11178 ok(style == 0, "expected 0, got %u\n", style);
11180 hmenu_popup = GetSubMenu(hmenu_popup, 0);
11181 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
11182 style = get_menu_style(hmenu_popup);
11183 ok(style == 0, "expected 0, got %u\n", style);
11186 trace("testing a popup menu command\n");
11188 keybd_event(VK_MENU, 0, 0, 0);
11189 keybd_event('E', 0, 0, 0);
11190 keybd_event('E', 0, KEYEVENTF_KEYUP, 0);
11191 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
11192 keybd_event(VK_RETURN, 0, 0, 0);
11193 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
11194 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
11196 TranslateMessage(&msg);
11197 DispatchMessage(&msg);
11199 ok_sequence(wm_popup_menu_1, "popup menu command", FALSE);
11201 /* Alt+F, Right, Enter */
11202 trace("testing submenu of a popup menu command\n");
11204 keybd_event(VK_MENU, 0, 0, 0);
11205 keybd_event('F', 0, 0, 0);
11206 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
11207 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
11208 keybd_event(VK_RIGHT, 0, 0, 0);
11209 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
11210 keybd_event(VK_RETURN, 0, 0, 0);
11211 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
11212 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
11214 TranslateMessage(&msg);
11215 DispatchMessage(&msg);
11217 ok_sequence(wm_popup_menu_2, "submenu of a popup menu command", FALSE);
11219 set_menu_style(hmenu, 0);
11220 style = get_menu_style(hmenu);
11221 ok(style == 0, "expected 0, got %u\n", style);
11223 hmenu_popup = GetSubMenu(hmenu, 0);
11224 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
11225 set_menu_style(hmenu_popup, MNS_NOTIFYBYPOS);
11226 style = get_menu_style(hmenu_popup);
11227 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
11229 hmenu_popup = GetSubMenu(hmenu_popup, 0);
11230 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
11231 style = get_menu_style(hmenu_popup);
11232 ok(style == 0, "expected 0, got %u\n", style);
11234 /* Alt+F, Right, Enter */
11235 trace("testing submenu of a popup menu command\n");
11237 keybd_event(VK_MENU, 0, 0, 0);
11238 keybd_event('F', 0, 0, 0);
11239 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
11240 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
11241 keybd_event(VK_RIGHT, 0, 0, 0);
11242 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
11243 keybd_event(VK_RETURN, 0, 0, 0);
11244 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
11245 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
11247 TranslateMessage(&msg);
11248 DispatchMessage(&msg);
11250 ok_sequence(wm_popup_menu_3, "submenu of a popup menu command", FALSE);
11252 DestroyWindow(hwnd);
11253 DestroyMenu(hmenu);
11257 static void test_paintingloop(void)
11261 paint_loop_done = 0;
11262 hwnd = CreateWindowExA(0x0,"PaintLoopWindowClass",
11263 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW,
11264 100, 100, 100, 100, 0, 0, 0, NULL );
11265 ok(hwnd != 0, "PaintLoop window error %u\n", GetLastError());
11266 ShowWindow(hwnd,SW_NORMAL);
11269 while (!paint_loop_done)
11272 if (PeekMessageA(&msg, 0, 0, 0, 1))
11274 TranslateMessage(&msg);
11275 DispatchMessage(&msg);
11278 DestroyWindow(hwnd);
11284 FARPROC pIsWinEventHookInstalled = 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
11288 if (!RegisterWindowClasses()) assert(0);
11290 if (pSetWinEventHook)
11292 hEvent_hook = (HWINEVENTHOOK)pSetWinEventHook(EVENT_MIN, EVENT_MAX,
11293 GetModuleHandleA(0),
11296 GetCurrentThreadId(),
11297 WINEVENT_INCONTEXT);
11298 assert(hEvent_hook);
11300 if (pIsWinEventHookInstalled)
11303 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
11304 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
11308 cbt_hook_thread_id = GetCurrentThreadId();
11309 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
11310 if (!hCBT_hook) skip( "cannot set global hook, will skip hook tests\n" );
11314 /* Fix message sequences before removing 4 lines below */
11316 if (pUnhookWinEvent && hEvent_hook)
11318 ret = pUnhookWinEvent(hEvent_hook);
11319 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
11320 pUnhookWinEvent = 0;
11326 test_PeekMessage();
11327 test_PeekMessage2();
11328 test_scrollwindowex();
11330 test_setwindowpos();
11332 invisible_parent_tests();
11333 test_mdi_messages();
11334 test_button_messages();
11335 test_static_messages();
11336 test_listbox_messages();
11337 test_combobox_messages();
11338 test_wmime_keydown_message();
11339 test_paint_messages();
11340 test_interthread_messages();
11341 test_message_conversion();
11342 test_accelerators();
11344 test_timers_no_wnd();
11346 test_DestroyWindow();
11347 test_DispatchMessage();
11348 test_SendMessageTimeout();
11349 test_edit_messages();
11350 test_quit_message();
11351 test_SetActiveWindow();
11353 if (!pTrackMouseEvent)
11354 skip("TrackMouseEvent is not available\n");
11356 test_TrackMouseEvent();
11358 test_SetWindowRgn();
11360 test_dialog_messages();
11361 test_nullCallback();
11362 test_dbcs_wm_char();
11363 test_menu_messages();
11364 test_paintingloop();
11365 /* keep it the last test, under Windows it tends to break the tests
11366 * which rely on active/foreground windows being correct.
11368 test_SetForegroundWindow();
11370 UnhookWindowsHookEx(hCBT_hook);
11371 if (pUnhookWinEvent)
11373 ret = pUnhookWinEvent(hEvent_hook);
11374 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
11375 SetLastError(0xdeadbeef);
11376 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
11377 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
11378 GetLastError() == 0xdeadbeef, /* Win9x */
11379 "unexpected error %d\n", GetLastError());
11382 skip("UnhookWinEvent is not available\n");