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 0x0600 /* For WM_CHANGEUISTATE,QS_RAWINPUT,WM_DWMxxxx */
24 #define WINVER 0x0600 /* for WM_GETTITLEBARINFOEX */
36 #include "wine/test.h"
38 #define MDI_FIRST_CHILD_ID 2004
40 /* undocumented SWP flags - from SDK 3.1 */
41 #define SWP_NOCLIENTSIZE 0x0800
42 #define SWP_NOCLIENTMOVE 0x1000
43 #define SWP_STATECHANGED 0x8000
45 #define SW_NORMALNA 0xCC /* undoc. flag in MinMaximize */
48 #define WM_KEYF1 0x004d
52 #define WM_SYSTIMER 0x0118
55 #define WND_PARENT_ID 1
56 #define WND_POPUP_ID 2
57 #define WND_CHILD_ID 3
59 #ifndef WM_LBTRACKPOINT
60 #define WM_LBTRACKPOINT 0x0131
63 /* encoded DRAWITEMSTRUCT into an LPARAM */
70 UINT type : 4; /* ODT_* flags */
71 UINT ctl_id : 4; /* Control ID */
72 UINT item_id : 4; /* Menu item ID */
73 UINT action : 4; /* ODA_* flags */
74 UINT state : 16; /* ODS_* flags */
80 static BOOL test_DestroyWindow_flag;
81 static HWINEVENTHOOK hEvent_hook;
82 static HHOOK hKBD_hook;
83 static HHOOK hCBT_hook;
84 static DWORD cbt_hook_thread_id;
86 static const WCHAR testWindowClassW[] =
87 { 'T','e','s','t','W','i','n','d','o','w','C','l','a','s','s','W',0 };
90 FIXME: add tests for these
91 Window Edge Styles (Win31/Win95/98 look), in order of precedence:
92 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
93 WS_THICKFRAME: thick border
94 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
95 WS_BORDER (default for overlapped windows): single black border
96 none (default for child (and popup?) windows): no border
114 UINT message; /* the WM_* code */
115 msg_flags_t flags; /* message props */
116 WPARAM wParam; /* expected value of wParam */
117 LPARAM lParam; /* expected value of lParam */
118 WPARAM wp_mask; /* mask for wParam checks */
119 LPARAM lp_mask; /* mask for lParam checks */
122 struct recvd_message {
123 UINT message; /* the WM_* code */
124 msg_flags_t flags; /* message props */
125 HWND hwnd; /* window that received the message */
126 WPARAM wParam; /* expected value of wParam */
127 LPARAM lParam; /* expected value of lParam */
128 int line; /* source line where logged */
129 const char *descr; /* description for trace output */
130 char output[512]; /* trace output */
133 /* Empty message sequence */
134 static const struct message WmEmptySeq[] =
138 /* CreateWindow (for overlapped window, not initially visible) (16/32) */
139 static const struct message WmCreateOverlappedSeq[] = {
140 { HCBT_CREATEWND, hook },
141 { WM_GETMINMAXINFO, sent },
142 { WM_NCCREATE, sent },
143 { WM_NCCALCSIZE, sent|wparam, 0 },
144 { 0x0093, sent|defwinproc|optional },
145 { 0x0094, sent|defwinproc|optional },
146 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
148 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
151 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
152 * for a not visible overlapped window.
154 static const struct message WmSWP_ShowOverlappedSeq[] = {
155 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
156 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
157 { WM_NCPAINT, sent|wparam|optional, 1 },
158 { WM_GETTEXT, sent|defwinproc|optional },
159 { WM_ERASEBKGND, sent|optional },
160 { HCBT_ACTIVATE, hook },
161 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
162 { WM_NOTIFYFORMAT, sent|optional },
163 { WM_QUERYUISTATE, sent|optional },
164 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
165 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x: SWP_NOSENDCHANGING */
166 { WM_ACTIVATEAPP, sent|wparam, 1 },
167 { WM_NCACTIVATE, sent },
168 { WM_GETTEXT, sent|defwinproc|optional },
169 { WM_ACTIVATE, sent|wparam, 1 },
170 { HCBT_SETFOCUS, hook },
171 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
172 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
173 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
174 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
175 { WM_GETTEXT, sent|optional },
176 { WM_NCPAINT, sent|wparam|optional, 1 },
177 { WM_GETTEXT, sent|defwinproc|optional },
178 { WM_ERASEBKGND, sent|optional },
179 /* Win9x adds SWP_NOZORDER below */
180 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
181 { WM_GETTEXT, sent|optional },
182 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
183 { WM_NCPAINT, sent|wparam|optional, 1 },
184 { WM_ERASEBKGND, sent|optional },
185 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
186 { WM_SYNCPAINT, sent|optional },
187 { WM_GETTITLEBARINFOEX, sent|optional },
188 { WM_PAINT, sent|optional },
189 { WM_NCPAINT, sent|beginpaint|optional },
190 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
191 { WM_ERASEBKGND, sent|beginpaint|optional },
194 /* SetWindowPos(SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE)
195 * for a visible overlapped window.
197 static const struct message WmSWP_HideOverlappedSeq[] = {
198 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
199 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
200 { HCBT_ACTIVATE, hook|optional },
201 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
202 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
203 { WM_NCACTIVATE, sent|optional },
204 { WM_ACTIVATE, sent|optional },
205 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
209 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
210 * for a visible overlapped window.
212 static const struct message WmSWP_ResizeSeq[] = {
213 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
214 { WM_GETMINMAXINFO, sent|defwinproc },
215 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
216 { WM_NCPAINT, sent|optional },
217 { WM_GETTEXT, sent|defwinproc|optional },
218 { WM_ERASEBKGND, sent|optional },
219 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
220 { WM_SIZE, sent|defwinproc|optional },
221 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
222 { WM_NCPAINT, sent|optional },
223 { WM_GETTEXT, sent|defwinproc|optional },
224 { WM_ERASEBKGND, sent|optional },
225 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
226 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
230 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE)
231 * for a visible popup window.
233 static const struct message WmSWP_ResizePopupSeq[] = {
234 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE },
235 { WM_GETMINMAXINFO, sent|defwinproc|optional }, /* Win9x */
236 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
237 { WM_NCPAINT, sent|optional },
238 { WM_GETTEXT, sent|defwinproc|optional },
239 { WM_ERASEBKGND, sent|optional },
240 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
241 { WM_SIZE, sent|defwinproc|wparam|optional, SIZE_RESTORED },
242 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
243 { WM_NCPAINT, sent|optional },
244 { WM_GETTEXT, sent|defwinproc|optional },
245 { WM_ERASEBKGND, sent|optional },
246 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
250 /* SetWindowPos(SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE)
251 * for a visible overlapped window.
253 static const struct message WmSWP_MoveSeq[] = {
254 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE },
255 { WM_NCPAINT, sent|optional },
256 { WM_GETTEXT, sent|defwinproc|optional },
257 { WM_ERASEBKGND, sent|optional },
258 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
259 { WM_MOVE, sent|defwinproc|wparam, 0 },
260 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
263 /* Resize with SetWindowPos(SWP_NOZORDER)
264 * for a visible overlapped window
265 * SWP_NOZORDER is stripped by the logging code
267 static const struct message WmSWP_ResizeNoZOrder[] = {
268 { WM_WINDOWPOSCHANGING, sent|wparam, /*SWP_NOZORDER|*/SWP_NOACTIVATE },
269 { WM_GETMINMAXINFO, sent|defwinproc },
270 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
271 { WM_NCPAINT, sent|optional },
272 { WM_GETTEXT, sent|defwinproc|optional },
273 { WM_ERASEBKGND, sent|optional },
274 { WM_WINDOWPOSCHANGED, sent|wparam|optional, /*SWP_NOZORDER|*/SWP_NOACTIVATE, 0,
275 SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE },
276 { WM_MOVE, sent|defwinproc|optional },
277 { WM_SIZE, sent|defwinproc|optional },
278 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
279 { WM_NCPAINT, sent|optional }, /* Win9x doesn't send it */
280 { WM_GETTEXT, sent|defwinproc|optional }, /* Win9x doesn't send it */
281 { WM_ERASEBKGND, sent|optional }, /* Win9x doesn't send it */
282 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
283 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
287 /* Switch visible mdi children */
288 static const struct message WmSwitchChild[] = {
289 /* Switch MDI child */
290 { WM_MDIACTIVATE, sent },/* in the MDI client */
291 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 1st MDI child */
292 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
293 { WM_CHILDACTIVATE, sent },/* in the 1st MDI child */
294 /* Deactivate 2nd MDI child */
295 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
296 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
297 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
298 /* Preparing for maximize and maximize the 1st MDI child */
299 { WM_GETMINMAXINFO, sent|defwinproc }, /* in the 1st MDI child */
300 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED }, /* in the 1st MDI child */
301 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
302 { WM_CHILDACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
303 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 1st MDI child */
304 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED }, /* in the 1st MDI child */
305 /* Lock redraw 2nd MDI child */
306 { WM_SETREDRAW, sent|wparam|defwinproc, 0 }, /* in the 2nd MDI child */
307 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
308 /* Restore 2nd MDI child */
309 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },/* in the 2nd MDI child */
310 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
311 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
312 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED }, /* in the 2nd MDI child */
313 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, /* in the 2nd MDI child */
314 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 2nd MDI child */
315 /* Redraw 2nd MDI child */
316 { WM_SETREDRAW, sent|wparam|defwinproc, 1 },/* in the 2nd MDI child */
317 /* Redraw MDI frame */
318 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },/* in MDI frame */
319 { WM_NCCALCSIZE, sent|wparam, 1 },/* in MDI frame */
320 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in MDI frame */
321 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in MDI frame */
322 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
323 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
324 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 1st MDI child */
325 { HCBT_SETFOCUS, hook },
326 { WM_KILLFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
327 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },/* in the 1st MDI child */
328 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
329 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
330 { WM_SETFOCUS, sent },/* in the MDI client */
331 { HCBT_SETFOCUS, hook },
332 { WM_KILLFOCUS, sent },/* in the MDI client */
333 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
334 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, /* in the 1st MDI child */
335 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
336 { WM_SETFOCUS, sent|defwinproc }, /* in the 1st MDI child */
337 { WM_MDIACTIVATE, sent|defwinproc },/* in the 1st MDI child */
338 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, /* in the 1st MDI child */
342 /* Switch visible not maximized mdi children */
343 static const struct message WmSwitchNotMaximizedChild[] = {
344 /* Switch not maximized MDI child */
345 { WM_MDIACTIVATE, sent },/* in the MDI client */
346 { WM_WINDOWPOSCHANGING, sent|wparam,SWP_NOSIZE|SWP_NOMOVE },/* in the 2nd MDI child */
347 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
348 { WM_CHILDACTIVATE, sent },/* in the 2nd MDI child */
349 /* Deactivate 1st MDI child */
350 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
351 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
352 /* Activate 2nd MDI child */
353 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE}, /* in the 2nd MDI child */
354 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 }, /* in the 2nd MDI child */
355 { HCBT_SETFOCUS, hook }, /* in the 1st MDI child */
356 { WM_KILLFOCUS, sent|defwinproc }, /* in the 1st MDI child */
357 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
358 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
359 { WM_SETFOCUS, sent, 0 }, /* in the MDI client */
360 { HCBT_SETFOCUS, hook },
361 { WM_KILLFOCUS, sent }, /* in the MDI client */
362 { WM_IME_SETCONTEXT, sent|optional }, /* in the MDI client */
363 { WM_IME_SETCONTEXT, sent|defwinproc|optional }, /* in the 1st MDI child */
364 { WM_SETFOCUS, sent|defwinproc }, /* in the 2nd MDI child */
365 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 2nd MDI child */
366 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE}, /* in the 2nd MDI child */
371 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
372 SWP_NOZORDER|SWP_FRAMECHANGED)
373 * for a visible overlapped window with WS_CLIPCHILDREN style set.
375 static const struct message WmSWP_FrameChanged_clip[] = {
376 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
377 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
378 { WM_NCPAINT, sent|parent|optional }, /* wparam != 1 */
379 { WM_GETTEXT, sent|parent|defwinproc|optional },
380 { WM_ERASEBKGND, sent|parent|optional }, /* FIXME: remove optional once Wine is fixed */
381 { WM_NCPAINT, sent }, /* wparam != 1 */
382 { WM_ERASEBKGND, sent },
383 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
384 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
388 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|
389 SWP_NOZORDER|SWP_FRAMECHANGED)
390 * for a visible overlapped window.
392 static const struct message WmSWP_FrameChangedDeferErase[] = {
393 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
394 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
395 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_DEFERERASE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
396 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
397 { WM_PAINT, sent|parent|optional },
398 { WM_NCPAINT, sent|beginpaint|parent|optional }, /* wparam != 1 */
399 { WM_GETTEXT, sent|beginpaint|parent|defwinproc|optional },
401 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
402 { WM_ERASEBKGND, sent|beginpaint|optional },
406 /* SetWindowPos(SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
407 SWP_NOZORDER|SWP_FRAMECHANGED)
408 * for a visible overlapped window without WS_CLIPCHILDREN style set.
410 static const struct message WmSWP_FrameChanged_noclip[] = {
411 { WM_WINDOWPOSCHANGING, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED },
412 { WM_NCCALCSIZE, sent|wparam|parent, 1 },
413 { WM_NCPAINT, sent|parent|optional }, /* wparam != 1 */
414 { WM_GETTEXT, sent|parent|defwinproc|optional },
415 { WM_ERASEBKGND, sent|parent|optional },
416 { WM_WINDOWPOSCHANGED, sent|wparam|parent, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
417 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
419 { WM_NCPAINT, sent|beginpaint }, /* wparam != 1 */
420 { WM_ERASEBKGND, sent|beginpaint|optional },
424 /* ShowWindow(SW_SHOW) for a not visible overlapped window */
425 static const struct message WmShowOverlappedSeq[] = {
426 { WM_SHOWWINDOW, sent|wparam, 1 },
427 { WM_NCPAINT, sent|wparam|optional, 1 },
428 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
429 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
430 { WM_NCPAINT, sent|wparam|optional, 1 },
431 { WM_GETTEXT, sent|defwinproc|optional },
432 { WM_ERASEBKGND, sent|optional },
433 { HCBT_ACTIVATE, hook },
434 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
435 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
436 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
437 { WM_NCPAINT, sent|wparam|optional, 1 },
438 { WM_ACTIVATEAPP, sent|wparam, 1 },
439 { WM_NCACTIVATE, sent|wparam, 1 },
440 { WM_GETTEXT, sent|defwinproc|optional },
441 { WM_ACTIVATE, sent|wparam, 1 },
442 { HCBT_SETFOCUS, hook },
443 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
444 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
445 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
446 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
447 { WM_GETTEXT, sent|optional },
448 { WM_NCPAINT, sent|wparam|optional, 1 },
449 { WM_GETTEXT, sent|defwinproc|optional },
450 { WM_ERASEBKGND, sent|optional },
451 /* Win9x adds SWP_NOZORDER below */
452 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
453 { WM_NCCALCSIZE, sent|optional },
454 { WM_GETTEXT, sent|optional },
455 { WM_NCPAINT, sent|optional },
456 { WM_ERASEBKGND, sent|optional },
457 { WM_SYNCPAINT, sent|optional },
458 #if 0 /* CreateWindow/ShowWindow(SW_SHOW) also generates WM_SIZE/WM_MOVE
459 * messages. Does that mean that CreateWindow doesn't set initial
460 * window dimensions for overlapped windows?
465 { WM_PAINT, sent|optional },
466 { WM_NCPAINT, sent|beginpaint|optional },
469 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible overlapped window */
470 static const struct message WmShowMaxOverlappedSeq[] = {
471 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
472 { WM_GETMINMAXINFO, sent },
473 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
474 { WM_GETMINMAXINFO, sent|defwinproc },
475 { WM_NCCALCSIZE, sent|wparam, TRUE },
476 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
477 { HCBT_ACTIVATE, hook },
478 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
479 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
480 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
481 { WM_ACTIVATEAPP, sent|wparam, 1 },
482 { WM_NCACTIVATE, sent|wparam, 1 },
483 { WM_GETTEXT, sent|defwinproc|optional },
484 { WM_ACTIVATE, sent|wparam, 1 },
485 { HCBT_SETFOCUS, hook },
486 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
487 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
488 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
489 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
490 { WM_GETTEXT, sent|optional },
491 { WM_NCPAINT, sent|wparam|optional, 1 },
492 { WM_GETTEXT, sent|defwinproc|optional },
493 { WM_ERASEBKGND, sent|optional },
494 /* Win9x adds SWP_NOZORDER below */
495 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
496 { WM_MOVE, sent|defwinproc },
497 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
498 { WM_GETTEXT, sent|optional },
499 { WM_NCCALCSIZE, sent|optional },
500 { WM_NCPAINT, sent|optional },
501 { WM_ERASEBKGND, sent|optional },
502 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
503 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
504 { WM_SYNCPAINT, sent|optional },
505 { WM_GETTITLEBARINFOEX, sent|optional },
506 { WM_PAINT, sent|optional },
507 { WM_NCPAINT, sent|beginpaint|optional },
508 { WM_ERASEBKGND, sent|beginpaint|optional },
511 /* ShowWindow(SW_RESTORE) for a not visible maximized overlapped window */
512 static const struct message WmShowRestoreMaxOverlappedSeq[] = {
513 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
514 { WM_GETTEXT, sent|optional },
515 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
516 { WM_GETMINMAXINFO, sent|defwinproc },
517 { WM_NCCALCSIZE, sent|wparam, TRUE },
518 { WM_NCPAINT, sent|optional },
519 { WM_GETTEXT, sent|defwinproc|optional },
520 { WM_ERASEBKGND, sent|optional },
521 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
522 { WM_MOVE, sent|defwinproc|optional },
523 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
524 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
525 { WM_NCPAINT, sent|optional },
526 { WM_ERASEBKGND, sent|optional },
527 { WM_PAINT, sent|optional },
528 { WM_GETTITLEBARINFOEX, sent|optional },
529 { WM_NCPAINT, sent|beginpaint|optional },
530 { WM_ERASEBKGND, sent|beginpaint|optional },
533 /* ShowWindow(SW_RESTORE) for a not visible minimized overlapped window */
534 static const struct message WmShowRestoreMinOverlappedSeq[] = {
535 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
536 { WM_QUERYOPEN, sent|optional },
537 { WM_GETTEXT, sent|optional },
538 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED|SWP_NOCOPYBITS },
539 { WM_GETMINMAXINFO, sent|defwinproc },
540 { WM_NCCALCSIZE, sent|wparam, TRUE },
541 { HCBT_ACTIVATE, hook },
542 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
543 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
544 { WM_ACTIVATEAPP, sent|wparam, 1 },
545 { WM_NCACTIVATE, sent|wparam, 1 },
546 { WM_GETTEXT, sent|defwinproc|optional },
547 { WM_ACTIVATE, sent|wparam, 1 },
548 { HCBT_SETFOCUS, hook },
549 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
550 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
551 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
552 { WM_GETTEXT, sent|optional },
553 { WM_NCPAINT, sent|wparam|optional, 1 },
554 { WM_GETTEXT, sent|defwinproc|optional },
555 { WM_ERASEBKGND, sent },
556 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_STATECHANGED|SWP_FRAMECHANGED|SWP_NOCOPYBITS },
557 { WM_MOVE, sent|defwinproc },
558 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
559 { WM_NCCALCSIZE, sent|wparam|optional, TRUE },
560 { WM_NCPAINT, sent|wparam|optional, 1 },
561 { WM_ERASEBKGND, sent|optional },
562 { WM_ACTIVATE, sent|wparam, 1 },
563 { WM_GETTEXT, sent|optional },
564 { WM_PAINT, sent|optional },
565 { WM_GETTITLEBARINFOEX, sent|optional },
566 { WM_NCPAINT, sent|beginpaint|optional },
567 { WM_ERASEBKGND, sent|beginpaint|optional },
570 /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */
571 static const struct message WmShowMinOverlappedSeq[] = {
572 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
573 { HCBT_SETFOCUS, hook },
574 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
575 { WM_KILLFOCUS, sent },
576 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
577 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
578 { WM_GETTEXT, sent|optional },
579 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
580 { WM_GETMINMAXINFO, sent|defwinproc },
581 { WM_NCCALCSIZE, sent|wparam, TRUE },
582 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
583 { WM_NCPAINT, sent|optional },
584 { WM_GETTEXT, sent|defwinproc|optional },
585 { WM_WINDOWPOSCHANGED, sent },
586 { WM_MOVE, sent|defwinproc },
587 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
588 { WM_NCCALCSIZE, sent|optional },
589 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
590 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
591 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
592 { WM_NCACTIVATE, sent|wparam, 0 },
593 { WM_GETTEXT, sent|defwinproc|optional },
594 { WM_ACTIVATE, sent },
595 { WM_ACTIVATEAPP, sent|wparam, 0 },
597 /* Vista sometimes restores the window right away... */
598 { WM_SYSCOMMAND, sent|optional|wparam, SC_RESTORE },
599 { HCBT_SYSCOMMAND, hook|optional|wparam, SC_RESTORE },
600 { HCBT_MINMAX, hook|optional|lparam, 0, SW_RESTORE },
601 { WM_QUERYOPEN, sent|optional },
602 { WM_WINDOWPOSCHANGING, sent|optional|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
603 { WM_GETMINMAXINFO, sent|optional|defwinproc },
604 { WM_NCCALCSIZE, sent|optional|wparam, TRUE },
605 { HCBT_ACTIVATE, hook|optional },
606 { WM_ACTIVATEAPP, sent|optional|wparam, 1 },
607 { WM_NCACTIVATE, sent|optional },
608 { WM_GETTEXT, sent|optional },
609 { WM_ACTIVATE, sent|optional|wparam, 1 },
610 { HCBT_SETFOCUS, hook|optional },
611 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
612 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
613 { WM_SETFOCUS, sent|optional },
614 { WM_NCPAINT, sent|optional },
615 { WM_GETTEXT, sent|defwinproc|optional },
616 { WM_ERASEBKGND, sent|optional },
617 { WM_WINDOWPOSCHANGED, sent|optional|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
618 { WM_MOVE, sent|defwinproc|optional },
619 { WM_SIZE, sent|defwinproc|optional|wparam, SIZE_RESTORED },
620 { WM_ACTIVATE, sent|optional|wparam, 1 },
621 { WM_SYSCOMMAND, sent|optional|wparam, SC_RESTORE },
622 { HCBT_SYSCOMMAND, hook|optional|wparam, SC_RESTORE },
624 { WM_PAINT, sent|optional },
625 { WM_NCPAINT, sent|beginpaint|optional },
626 { WM_ERASEBKGND, sent|beginpaint|optional },
629 /* ShowWindow(SW_HIDE) for a visible overlapped window */
630 static const struct message WmHideOverlappedSeq[] = {
631 { WM_SHOWWINDOW, sent|wparam, 0 },
632 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
633 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
634 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
635 { WM_SIZE, sent|optional }, /* XP doesn't send it */
636 { WM_MOVE, sent|optional }, /* XP doesn't send it */
637 { WM_NCACTIVATE, sent|wparam|optional, 0 },
638 { WM_ACTIVATE, sent|wparam|optional, 0 },
639 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
640 { HCBT_SETFOCUS, hook|optional },
641 { WM_KILLFOCUS, sent|wparam, 0 },
642 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
643 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
646 /* DestroyWindow for a visible overlapped window */
647 static const struct message WmDestroyOverlappedSeq[] = {
648 { HCBT_DESTROYWND, hook },
649 { 0x0090, sent|optional },
650 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
651 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
652 { 0x0090, sent|optional },
653 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
654 { WM_NCACTIVATE, sent|optional|wparam, 0 },
655 { WM_ACTIVATE, sent|optional },
656 { WM_ACTIVATEAPP, sent|optional|wparam, 0 },
657 { WM_KILLFOCUS, sent|optional|wparam, 0 },
658 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
659 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
660 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
661 { WM_DESTROY, sent },
662 { WM_NCDESTROY, sent },
665 /* CreateWindow(WS_MAXIMIZE|WS_VISIBLE) for popup window */
666 static const struct message WmCreateMaxPopupSeq[] = {
667 { HCBT_CREATEWND, hook },
668 { WM_NCCREATE, sent },
669 { WM_NCCALCSIZE, sent|wparam, 0 },
671 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
672 { WM_SIZE, sent|wparam, SIZE_RESTORED },
674 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
675 { WM_GETMINMAXINFO, sent },
676 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
677 { WM_NCCALCSIZE, sent|wparam, TRUE },
678 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
679 { WM_MOVE, sent|defwinproc },
680 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
681 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
682 { WM_SHOWWINDOW, sent|wparam, 1 },
683 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
684 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
685 { HCBT_ACTIVATE, hook },
686 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
687 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
688 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
689 { WM_NCPAINT, sent|wparam|optional, 1 },
690 { WM_ERASEBKGND, sent|optional },
691 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_NOMOVE|SWP_NOSIZE },
692 { WM_ACTIVATEAPP, sent|wparam, 1 },
693 { WM_NCACTIVATE, sent },
694 { WM_ACTIVATE, sent|wparam, 1 },
695 { HCBT_SETFOCUS, hook },
696 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
697 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
698 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
699 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
700 { WM_GETTEXT, sent|optional },
701 { WM_SYNCPAINT, sent|wparam|optional, 4 },
702 { WM_NCPAINT, sent|wparam|optional, 1 },
703 { WM_ERASEBKGND, sent|optional },
704 { WM_NCPAINT, sent|wparam|defwinproc|optional, 1 },
705 { WM_ERASEBKGND, sent|defwinproc|optional },
706 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
709 /* CreateWindow(WS_MAXIMIZE) for popup window, not initially visible */
710 static const struct message WmCreateInvisibleMaxPopupSeq[] = {
711 { HCBT_CREATEWND, hook },
712 { WM_NCCREATE, sent },
713 { WM_NCCALCSIZE, sent|wparam, 0 },
715 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
716 { WM_SIZE, sent|wparam, SIZE_RESTORED },
718 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
719 { WM_GETMINMAXINFO, sent },
720 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED },
721 { WM_NCCALCSIZE, sent|wparam, TRUE },
722 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
723 { WM_MOVE, sent|defwinproc },
724 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
725 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
728 /* ShowWindow(SW_SHOWMAXIMIZED) for a resized not visible popup window */
729 static const struct message WmShowMaxPopupResizedSeq[] = {
730 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
731 { WM_GETMINMAXINFO, sent },
732 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
733 { WM_NCCALCSIZE, sent|wparam, TRUE },
734 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
735 { HCBT_ACTIVATE, hook },
736 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
737 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
738 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
739 { WM_NCPAINT, sent|wparam|optional, 1 },
740 { WM_ERASEBKGND, sent|optional },
741 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
742 { WM_ACTIVATEAPP, sent|wparam, 1 },
743 { WM_NCACTIVATE, sent },
744 { WM_ACTIVATE, sent|wparam, 1 },
745 { HCBT_SETFOCUS, hook },
746 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
747 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
748 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
749 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
750 { WM_GETTEXT, sent|optional },
751 { WM_NCPAINT, sent|wparam|optional, 1 },
752 { WM_ERASEBKGND, sent|optional },
753 { WM_WINDOWPOSCHANGED, sent },
754 /* WinNT4.0 sends WM_MOVE */
755 { WM_MOVE, sent|defwinproc|optional },
756 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
757 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
760 /* ShowWindow(SW_SHOWMAXIMIZED) for a not visible popup window */
761 static const struct message WmShowMaxPopupSeq[] = {
762 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
763 { WM_GETMINMAXINFO, sent },
764 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
765 { WM_NCCALCSIZE, sent|wparam, TRUE },
766 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
767 { HCBT_ACTIVATE, hook },
768 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
769 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
770 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
771 { WM_ACTIVATEAPP, sent|wparam, 1 },
772 { WM_NCACTIVATE, sent },
773 { WM_ACTIVATE, sent|wparam, 1 },
774 { HCBT_SETFOCUS, hook },
775 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
776 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
777 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
778 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
779 { WM_GETTEXT, sent|optional },
780 { WM_SYNCPAINT, sent|wparam|optional, 4 },
781 { WM_NCPAINT, sent|wparam|optional, 1 },
782 { WM_ERASEBKGND, sent|optional },
783 { WM_NCPAINT, sent|wparam|defwinproc|optional, 1 },
784 { WM_ERASEBKGND, sent|defwinproc|optional },
785 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE },
786 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
789 /* CreateWindow(WS_VISIBLE) for popup window */
790 static const struct message WmCreatePopupSeq[] = {
791 { HCBT_CREATEWND, hook },
792 { WM_NCCREATE, sent },
793 { WM_NCCALCSIZE, sent|wparam, 0 },
795 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
796 { WM_SIZE, sent|wparam, SIZE_RESTORED },
798 { WM_SHOWWINDOW, sent|wparam, 1 },
799 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
800 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
801 { HCBT_ACTIVATE, hook },
802 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
803 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
804 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
805 { WM_NCPAINT, sent|wparam|optional, 1 },
806 { WM_ERASEBKGND, sent|optional },
807 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
808 { WM_ACTIVATEAPP, sent|wparam, 1 },
809 { WM_NCACTIVATE, sent },
810 { WM_ACTIVATE, sent|wparam, 1 },
811 { HCBT_SETFOCUS, hook },
812 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
813 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
814 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
815 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
816 { WM_GETTEXT, sent|optional },
817 { WM_SYNCPAINT, sent|wparam|optional, 4 },
818 { WM_NCPAINT, sent|wparam|optional, 1 },
819 { WM_ERASEBKGND, sent|optional },
820 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE },
823 /* ShowWindow(SW_SHOWMAXIMIZED) for a visible popup window */
824 static const struct message WmShowVisMaxPopupSeq[] = {
825 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
826 { WM_GETMINMAXINFO, sent },
827 { WM_GETTEXT, sent|optional },
828 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
829 { WM_GETTEXT, sent|optional },
830 { WM_NCCALCSIZE, sent|wparam, TRUE },
831 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
832 { WM_NCPAINT, sent|wparam|optional, 1 },
833 { WM_ERASEBKGND, sent|optional },
834 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
835 { WM_MOVE, sent|defwinproc },
836 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
837 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
840 /* CreateWindow (for a child popup window, not initially visible) */
841 static const struct message WmCreateChildPopupSeq[] = {
842 { HCBT_CREATEWND, hook },
843 { WM_NCCREATE, sent },
844 { WM_NCCALCSIZE, sent|wparam, 0 },
846 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
847 { WM_SIZE, sent|wparam, SIZE_RESTORED },
851 /* CreateWindow (for a popup window, not initially visible,
852 * which sets WS_VISIBLE in WM_CREATE handler)
854 static const struct message WmCreateInvisiblePopupSeq[] = {
855 { HCBT_CREATEWND, hook },
856 { WM_NCCREATE, sent },
857 { WM_NCCALCSIZE, sent|wparam, 0 },
859 { WM_STYLECHANGING, sent },
860 { WM_STYLECHANGED, sent },
861 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
862 { WM_SIZE, sent|wparam, SIZE_RESTORED },
866 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER)
867 * for a popup window with WS_VISIBLE style set
869 static const struct message WmShowVisiblePopupSeq_2[] = {
870 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
873 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
874 * for a popup window with WS_VISIBLE style set
876 static const struct message WmShowVisiblePopupSeq_3[] = {
877 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
878 { HCBT_ACTIVATE, hook },
879 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
880 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
881 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
882 { WM_NCACTIVATE, sent },
883 { WM_ACTIVATE, sent|wparam, 1 },
884 { HCBT_SETFOCUS, hook },
885 { WM_KILLFOCUS, sent|parent },
886 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
887 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
888 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
889 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
890 { WM_SETFOCUS, sent|defwinproc },
891 { WM_GETTEXT, sent|optional },
892 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_SHOWWINDOW },
895 /* CreateWindow (for child window, not initially visible) */
896 static const struct message WmCreateChildSeq[] = {
897 { HCBT_CREATEWND, hook },
898 { WM_NCCREATE, sent },
899 /* child is inserted into parent's child list after WM_NCCREATE returns */
900 { WM_NCCALCSIZE, sent|wparam, 0 },
902 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
903 { WM_SIZE, sent|wparam, SIZE_RESTORED },
905 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
908 /* CreateWindow (for maximized child window, not initially visible) */
909 static const struct message WmCreateMaximizedChildSeq[] = {
910 { HCBT_CREATEWND, hook },
911 { WM_NCCREATE, sent },
912 { WM_NCCALCSIZE, sent|wparam, 0 },
914 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
915 { WM_SIZE, sent|wparam, SIZE_RESTORED },
917 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
918 { WM_GETMINMAXINFO, sent },
919 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
920 { WM_NCCALCSIZE, sent|wparam, 1 },
921 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
922 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
923 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
924 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
927 /* CreateWindow (for a child window, initially visible) */
928 static const struct message WmCreateVisibleChildSeq[] = {
929 { HCBT_CREATEWND, hook },
930 { WM_NCCREATE, sent },
931 /* child is inserted into parent's child list after WM_NCCREATE returns */
932 { WM_NCCALCSIZE, sent|wparam, 0 },
933 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
935 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
936 { WM_SIZE, sent|wparam, SIZE_RESTORED },
938 { WM_PARENTNOTIFY, sent|parent|wparam, WM_CREATE },
939 { WM_SHOWWINDOW, sent|wparam, 1 },
940 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
941 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
942 { WM_ERASEBKGND, sent|parent|optional },
943 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
944 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* WinXP */
945 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
948 /* ShowWindow(SW_SHOW) for a not visible child window */
949 static const struct message WmShowChildSeq[] = {
950 { WM_SHOWWINDOW, sent|wparam, 1 },
951 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
952 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
953 { WM_ERASEBKGND, sent|parent|optional },
954 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
957 /* ShowWindow(SW_HIDE) for a visible child window */
958 static const struct message WmHideChildSeq[] = {
959 { WM_SHOWWINDOW, sent|wparam, 0 },
960 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
961 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
962 { WM_ERASEBKGND, sent|parent|optional },
963 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
966 /* ShowWindow(SW_HIDE) for a visible child window checking all parent events*/
967 static const struct message WmHideChildSeq2[] = {
968 { WM_SHOWWINDOW, sent|wparam, 0 },
969 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
970 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
971 { WM_ERASEBKGND, sent|parent|optional },
972 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
975 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
976 * for a not visible child window
978 static const struct message WmShowChildSeq_2[] = {
979 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
980 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
981 { WM_CHILDACTIVATE, sent },
982 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
985 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE)
986 * for a not visible child window
988 static const struct message WmShowChildSeq_3[] = {
989 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
990 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
991 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
994 /* SetWindowPos(SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE)
995 * for a visible child window with a caption
997 static const struct message WmShowChildSeq_4[] = {
998 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
999 { WM_CHILDACTIVATE, sent },
1002 /* ShowWindow(SW_MINIMIZE) for child with invisible parent */
1003 static const struct message WmShowChildInvisibleParentSeq_1[] = {
1004 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
1005 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE },
1006 { WM_NCCALCSIZE, sent|wparam, 1 },
1007 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1008 { WM_CHILDACTIVATE, sent|optional },
1009 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE },
1010 { WM_MOVE, sent|defwinproc },
1011 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
1012 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1013 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1014 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1015 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1016 { WM_GETTEXT, sent|optional },
1019 /* repeated ShowWindow(SW_MINIMIZE) for child with invisible parent */
1020 static const struct message WmShowChildInvisibleParentSeq_1r[] = {
1021 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
1024 /* ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1025 static const struct message WmShowChildInvisibleParentSeq_2[] = {
1026 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1027 { WM_GETMINMAXINFO, sent },
1028 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
1029 { WM_NCCALCSIZE, sent|wparam, 1 },
1030 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1031 { WM_CHILDACTIVATE, sent },
1032 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
1033 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
1034 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1037 /* repeated ShowWindow(SW_MAXIMIZE) for child with invisible parent */
1038 static const struct message WmShowChildInvisibleParentSeq_2r[] = {
1039 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
1042 /* ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1043 static const struct message WmShowChildInvisibleParentSeq_3[] = {
1044 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
1045 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
1046 { WM_NCCALCSIZE, sent|wparam, 1 },
1047 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1048 { WM_CHILDACTIVATE, sent },
1049 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
1050 { WM_MOVE, sent|defwinproc },
1051 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
1052 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1053 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1054 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1055 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1056 { WM_GETTEXT, sent|optional },
1059 /* repeated ShowWindow(SW_SHOWMINIMIZED) for child with invisible parent */
1060 static const struct message WmShowChildInvisibleParentSeq_3r[] = {
1061 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
1064 /* ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1065 static const struct message WmShowChildInvisibleParentSeq_4[] = {
1066 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
1067 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
1068 { WM_NCCALCSIZE, sent|wparam, 1 },
1069 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1070 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCOPYBITS|SWP_STATECHANGED },
1071 { WM_MOVE, sent|defwinproc },
1072 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
1073 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1074 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 },
1075 /* FIXME: Wine creates an icon/title window while Windows doesn't */
1076 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE },
1077 { WM_GETTEXT, sent|optional },
1080 /* repeated ShowWindow(SW_SHOWMINNOACTIVE) for child with invisible parent */
1081 static const struct message WmShowChildInvisibleParentSeq_4r[] = {
1082 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
1085 /* ShowWindow(SW_SHOW) for child with invisible parent */
1086 static const struct message WmShowChildInvisibleParentSeq_5[] = {
1087 { WM_SHOWWINDOW, sent|wparam, 1 },
1090 /* ShowWindow(SW_HIDE) for child with invisible parent */
1091 static const struct message WmHideChildInvisibleParentSeq[] = {
1092 { WM_SHOWWINDOW, sent|wparam, 0 },
1095 /* SetWindowPos(SWP_SHOWWINDOW) for child with invisible parent */
1096 static const struct message WmShowChildInvisibleParentSeq_6[] = {
1097 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1098 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1099 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1102 /* SetWindowPos(SWP_HIDEWINDOW) for child with invisible parent */
1103 static const struct message WmHideChildInvisibleParentSeq_2[] = {
1104 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1105 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1106 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1109 /* DestroyWindow for a visible child window */
1110 static const struct message WmDestroyChildSeq[] = {
1111 { HCBT_DESTROYWND, hook },
1112 { 0x0090, sent|optional },
1113 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1114 { WM_SHOWWINDOW, sent|wparam, 0 },
1115 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1116 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1117 { WM_ERASEBKGND, sent|parent|optional },
1118 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1119 { HCBT_SETFOCUS, hook }, /* set focus to a parent */
1120 { WM_KILLFOCUS, sent },
1121 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1122 { WM_IME_SETCONTEXT, sent|wparam|parent|optional, 1 },
1123 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1124 { WM_SETFOCUS, sent|parent },
1125 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1126 { WM_DESTROY, sent },
1127 { WM_DESTROY, sent|optional }, /* some other (IME?) window */
1128 { WM_NCDESTROY, sent|optional }, /* some other (IME?) window */
1129 { WM_NCDESTROY, sent },
1132 /* visible child window destroyed by thread exit */
1133 static const struct message WmExitThreadSeq[] = {
1134 { WM_NCDESTROY, sent }, /* actually in grandchild */
1135 { WM_PAINT, sent|parent },
1136 { WM_ERASEBKGND, sent|parent|beginpaint },
1139 /* DestroyWindow for a visible child window with invisible parent */
1140 static const struct message WmDestroyInvisibleChildSeq[] = {
1141 { HCBT_DESTROYWND, hook },
1142 { 0x0090, sent|optional },
1143 { WM_PARENTNOTIFY, sent|parent|wparam, WM_DESTROY },
1144 { WM_SHOWWINDOW, sent|wparam, 0 },
1145 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1146 { WM_DESTROY, sent },
1147 { WM_NCDESTROY, sent },
1150 /* Moving the mouse in nonclient area */
1151 static const struct message WmMouseMoveInNonClientAreaSeq[] = { /* FIXME: add */
1152 { WM_NCHITTEST, sent },
1153 { WM_SETCURSOR, sent },
1154 { WM_NCMOUSEMOVE, posted },
1157 /* Moving the mouse in client area */
1158 static const struct message WmMouseMoveInClientAreaSeq[] = { /* FIXME: add */
1159 { WM_NCHITTEST, sent },
1160 { WM_SETCURSOR, sent },
1161 { WM_MOUSEMOVE, posted },
1164 /* Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1165 static const struct message WmDragTitleBarSeq[] = { /* FIXME: add */
1166 { WM_NCLBUTTONDOWN, sent|wparam, HTCAPTION },
1167 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_MOVE+2 },
1168 { WM_GETMINMAXINFO, sent|defwinproc },
1169 { WM_ENTERSIZEMOVE, sent|defwinproc },
1170 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1171 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1172 { WM_MOVE, sent|defwinproc },
1173 { WM_EXITSIZEMOVE, sent|defwinproc },
1176 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
1177 static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
1178 { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
1179 { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
1180 { WM_GETMINMAXINFO, sent|defwinproc },
1181 { WM_ENTERSIZEMOVE, sent|defwinproc },
1182 { WM_SIZING, sent|defwinproc|wparam, 4}, /* one for each mouse movement */
1183 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, 0 },
1184 { WM_GETMINMAXINFO, sent|defwinproc },
1185 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
1186 { WM_NCPAINT, sent|defwinproc|wparam, 1 },
1187 { WM_GETTEXT, sent|defwinproc },
1188 { WM_ERASEBKGND, sent|defwinproc },
1189 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, 0 },
1190 { WM_MOVE, sent|defwinproc },
1191 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1192 { WM_EXITSIZEMOVE, sent|defwinproc },
1195 /* Resizing child window with MoveWindow (32) */
1196 static const struct message WmResizingChildWithMoveWindowSeq[] = {
1197 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
1198 { WM_NCCALCSIZE, sent|wparam, 1 },
1199 { WM_ERASEBKGND, sent|parent|optional },
1200 { WM_ERASEBKGND, sent|optional },
1201 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE },
1202 { WM_MOVE, sent|defwinproc },
1203 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1204 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1207 /* Clicking on inactive button */
1208 static const struct message WmClickInactiveButtonSeq[] = { /* FIXME: add */
1209 { WM_NCHITTEST, sent },
1210 { WM_PARENTNOTIFY, sent|parent|wparam, WM_LBUTTONDOWN },
1211 { WM_MOUSEACTIVATE, sent },
1212 { WM_MOUSEACTIVATE, sent|parent|defwinproc },
1213 { WM_SETCURSOR, sent },
1214 { WM_SETCURSOR, sent|parent|defwinproc },
1215 { WM_LBUTTONDOWN, posted },
1216 { WM_KILLFOCUS, posted|parent },
1217 { WM_SETFOCUS, posted },
1218 { WM_CTLCOLORBTN, posted|parent },
1219 { BM_SETSTATE, posted },
1220 { WM_CTLCOLORBTN, posted|parent },
1221 { WM_LBUTTONUP, posted },
1222 { BM_SETSTATE, posted },
1223 { WM_CTLCOLORBTN, posted|parent },
1224 { WM_COMMAND, posted|parent },
1227 /* Reparenting a button (16/32) */
1228 /* The last child (button) reparented gets topmost for its new parent. */
1229 static const struct message WmReparentButtonSeq[] = { /* FIXME: add */
1230 { WM_SHOWWINDOW, sent|wparam, 0 },
1231 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1232 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1233 { WM_ERASEBKGND, sent|parent },
1234 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1235 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
1236 { WM_CHILDACTIVATE, sent },
1237 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW },
1238 { WM_MOVE, sent|defwinproc },
1239 { WM_SHOWWINDOW, sent|wparam, 1 },
1242 /* Creation of a custom dialog (32) */
1243 static const struct message WmCreateCustomDialogSeq[] = {
1244 { HCBT_CREATEWND, hook },
1245 { WM_GETMINMAXINFO, sent },
1246 { WM_NCCREATE, sent },
1247 { WM_NCCALCSIZE, sent|wparam, 0 },
1248 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1249 { WM_CREATE, sent },
1250 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1251 { WM_NOTIFYFORMAT, sent|optional },
1252 { WM_QUERYUISTATE, sent|optional },
1253 { WM_WINDOWPOSCHANGING, sent|optional },
1254 { WM_GETMINMAXINFO, sent|optional },
1255 { WM_NCCALCSIZE, sent|optional },
1256 { WM_WINDOWPOSCHANGED, sent|optional },
1257 { WM_SHOWWINDOW, sent|wparam, 1 },
1258 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1259 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1260 { HCBT_ACTIVATE, hook },
1261 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1264 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1266 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
1268 { WM_NCACTIVATE, sent },
1269 { WM_GETTEXT, sent|optional|defwinproc },
1270 { WM_GETTEXT, sent|optional|defwinproc },
1271 { WM_GETTEXT, sent|optional|defwinproc },
1272 { EVENT_OBJECT_DEFACTIONCHANGE, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
1273 { WM_ACTIVATE, sent|wparam, 1 },
1274 { WM_GETTEXT, sent|optional },
1275 { WM_KILLFOCUS, sent|parent },
1276 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1277 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1278 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1279 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1280 { WM_SETFOCUS, sent },
1281 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1282 { WM_NCPAINT, sent|wparam, 1 },
1283 { WM_GETTEXT, sent|optional|defwinproc },
1284 { WM_GETTEXT, sent|optional|defwinproc },
1285 { WM_ERASEBKGND, sent },
1286 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1287 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1288 { WM_GETTEXT, sent|optional },
1289 { WM_GETTEXT, sent|optional },
1290 { WM_NCCALCSIZE, sent|optional },
1291 { WM_NCPAINT, sent|optional },
1292 { WM_GETTEXT, sent|optional|defwinproc },
1293 { WM_GETTEXT, sent|optional|defwinproc },
1294 { WM_ERASEBKGND, sent|optional },
1295 { WM_CTLCOLORDLG, sent|optional|defwinproc },
1296 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1297 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1301 /* Calling EndDialog for a custom dialog (32) */
1302 static const struct message WmEndCustomDialogSeq[] = {
1303 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1304 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1305 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1306 { WM_GETTEXT, sent|optional },
1307 { HCBT_ACTIVATE, hook },
1308 { WM_NCACTIVATE, sent|wparam, 0 },
1309 { WM_GETTEXT, sent|optional|defwinproc },
1310 { WM_GETTEXT, sent|optional|defwinproc },
1311 { WM_ACTIVATE, sent|wparam, 0 },
1312 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1313 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1314 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1315 { WM_GETTEXT, sent|optional|defwinproc },
1316 { WM_GETTEXT, sent|optional|defwinproc },
1317 { HCBT_SETFOCUS, hook },
1318 { WM_KILLFOCUS, sent },
1319 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
1320 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1321 { WM_IME_NOTIFY, sent|wparam|optional, 1 },
1322 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1323 { WM_SETFOCUS, sent|parent|defwinproc },
1326 /* ShowWindow(SW_SHOW) for a custom dialog (initially invisible) */
1327 static const struct message WmShowCustomDialogSeq[] = {
1328 { WM_SHOWWINDOW, sent|wparam, 1 },
1329 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
1330 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1331 { HCBT_ACTIVATE, hook },
1332 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1334 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1336 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
1337 { WM_ACTIVATEAPP, sent|wparam|optional, 1 },
1338 { WM_NCACTIVATE, sent },
1339 { WM_ACTIVATE, sent|wparam, 1 },
1340 { WM_GETTEXT, sent|optional },
1342 { WM_KILLFOCUS, sent|parent },
1343 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1344 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
1345 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
1346 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1347 { WM_SETFOCUS, sent },
1348 { WM_GETDLGCODE, sent|defwinproc|wparam, 0 },
1349 { WM_NCPAINT, sent|wparam, 1 },
1350 { WM_ERASEBKGND, sent },
1351 { WM_CTLCOLORDLG, sent|defwinproc },
1352 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1355 /* Creation and destruction of a modal dialog (32) */
1356 static const struct message WmModalDialogSeq[] = {
1357 { WM_CANCELMODE, sent|parent },
1358 { HCBT_SETFOCUS, hook },
1359 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1360 { WM_KILLFOCUS, sent|parent },
1361 { WM_IME_SETCONTEXT, sent|parent|wparam|optional, 0 },
1362 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1363 { WM_ENABLE, sent|parent|wparam, 0 },
1364 { HCBT_CREATEWND, hook },
1365 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1366 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
1367 { WM_SETFONT, sent },
1368 { WM_INITDIALOG, sent },
1369 { WM_CHANGEUISTATE, sent|optional },
1370 { WM_UPDATEUISTATE, sent|optional },
1371 { WM_SHOWWINDOW, sent },
1372 { HCBT_ACTIVATE, hook },
1373 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1374 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
1375 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
1376 { WM_NCACTIVATE, sent },
1377 { WM_GETTEXT, sent|optional },
1378 { WM_ACTIVATE, sent|wparam, 1 },
1379 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1380 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1381 { WM_NCPAINT, sent|optional },
1382 { WM_GETTEXT, sent|optional },
1383 { WM_ERASEBKGND, sent|optional },
1384 { WM_CTLCOLORDLG, sent|optional },
1385 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1386 { WM_GETTEXT, sent|optional },
1387 { WM_NCCALCSIZE, sent|optional },
1388 { WM_NCPAINT, sent|optional },
1389 { WM_GETTEXT, sent|optional },
1390 { WM_ERASEBKGND, sent|optional },
1391 { WM_CTLCOLORDLG, sent|optional },
1392 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1393 { WM_PAINT, sent|optional },
1394 { WM_CTLCOLORBTN, sent|optional },
1395 { WM_GETTITLEBARINFOEX, sent|optional },
1396 { WM_ENTERIDLE, sent|parent|optional },
1397 { WM_ENTERIDLE, sent|parent|optional },
1398 { WM_ENTERIDLE, sent|parent|optional },
1399 { WM_ENTERIDLE, sent|parent|optional },
1400 { WM_ENTERIDLE, sent|parent|optional },
1401 { WM_ENTERIDLE, sent|parent|optional },
1402 { WM_ENTERIDLE, sent|parent|optional },
1403 { WM_ENTERIDLE, sent|parent|optional },
1404 { WM_ENTERIDLE, sent|parent|optional },
1405 { WM_ENTERIDLE, sent|parent|optional },
1406 { WM_ENTERIDLE, sent|parent|optional },
1407 { WM_ENTERIDLE, sent|parent|optional },
1408 { WM_ENTERIDLE, sent|parent|optional },
1409 { WM_ENTERIDLE, sent|parent|optional },
1410 { WM_ENTERIDLE, sent|parent|optional },
1411 { WM_ENTERIDLE, sent|parent|optional },
1412 { WM_ENTERIDLE, sent|parent|optional },
1413 { WM_ENTERIDLE, sent|parent|optional },
1414 { WM_ENTERIDLE, sent|parent|optional },
1415 { WM_ENTERIDLE, sent|parent|optional },
1417 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1418 { WM_ENABLE, sent|parent|wparam, 1 },
1419 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1420 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
1421 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1422 { WM_GETTEXT, sent|optional },
1423 { HCBT_ACTIVATE, hook },
1424 { WM_NCACTIVATE, sent|wparam, 0 },
1425 { WM_GETTEXT, sent|optional },
1426 { WM_ACTIVATE, sent|wparam, 0 },
1427 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
1428 { WM_WINDOWPOSCHANGING, sent|optional },
1429 { WM_WINDOWPOSCHANGED, sent|optional },
1430 { HCBT_SETFOCUS, hook },
1431 { WM_IME_SETCONTEXT, sent|parent|wparam|defwinproc|optional, 1 },
1432 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
1433 { WM_SETFOCUS, sent|parent|defwinproc },
1434 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, 0, 0 },
1435 { HCBT_DESTROYWND, hook },
1436 { 0x0090, sent|optional },
1437 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
1438 { WM_DESTROY, sent },
1439 { WM_NCDESTROY, sent },
1442 /* Creation of a modal dialog that is resized inside WM_INITDIALOG (32) */
1443 static const struct message WmCreateModalDialogResizeSeq[] = { /* FIXME: add */
1444 /* (inside dialog proc, handling WM_INITDIALOG) */
1445 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1446 { WM_NCCALCSIZE, sent },
1447 { WM_NCACTIVATE, sent|parent|wparam, 0 },
1448 { WM_GETTEXT, sent|defwinproc },
1449 { WM_ACTIVATE, sent|parent|wparam, 0 },
1450 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1451 { WM_WINDOWPOSCHANGING, sent|parent },
1452 { WM_NCACTIVATE, sent|wparam, 1 },
1453 { WM_ACTIVATE, sent|wparam, 1 },
1454 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1455 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1456 /* (setting focus) */
1457 { WM_SHOWWINDOW, sent|wparam, 1 },
1458 { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
1459 { WM_NCPAINT, sent },
1460 { WM_GETTEXT, sent|defwinproc },
1461 { WM_ERASEBKGND, sent },
1462 { WM_CTLCOLORDLG, sent|defwinproc },
1463 { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
1465 /* (bunch of WM_CTLCOLOR* for each control) */
1466 { WM_PAINT, sent|parent },
1467 { WM_ENTERIDLE, sent|parent|wparam, 0 },
1468 { WM_SETCURSOR, sent|parent },
1471 /* SetMenu for NonVisible windows with size change*/
1472 static const struct message WmSetMenuNonVisibleSizeChangeSeq[] = {
1473 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1474 { WM_NCCALCSIZE, sent|wparam, 1 },
1475 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1476 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
1477 { WM_MOVE, sent|defwinproc },
1478 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1479 { WM_NCCALCSIZE,sent|wparam|optional, 1 }, /* XP */
1480 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1481 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1482 { WM_GETTEXT, sent|optional },
1483 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1486 /* SetMenu for NonVisible windows with no size change */
1487 static const struct message WmSetMenuNonVisibleNoSizeChangeSeq[] = {
1488 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1489 { WM_NCCALCSIZE, sent|wparam, 1 },
1490 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1491 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1494 /* SetMenu for Visible windows with size change */
1495 static const struct message WmSetMenuVisibleSizeChangeSeq[] = {
1496 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1497 { WM_NCCALCSIZE, sent|wparam, 1 },
1498 { 0x0093, sent|defwinproc|optional },
1499 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1500 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1501 { 0x0093, sent|defwinproc|optional },
1502 { 0x0093, sent|defwinproc|optional },
1503 { 0x0091, sent|defwinproc|optional },
1504 { 0x0092, sent|defwinproc|optional },
1505 { WM_GETTEXT, sent|defwinproc|optional },
1506 { WM_ERASEBKGND, sent|optional },
1507 { WM_ACTIVATE, sent|optional },
1508 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1509 { WM_MOVE, sent|defwinproc },
1510 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
1511 { 0x0093, sent|optional },
1512 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1513 { 0x0093, sent|defwinproc|optional },
1514 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1515 { 0x0093, sent|defwinproc|optional },
1516 { 0x0093, sent|defwinproc|optional },
1517 { 0x0091, sent|defwinproc|optional },
1518 { 0x0092, sent|defwinproc|optional },
1519 { WM_ERASEBKGND, sent|optional },
1520 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1521 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP sends a duplicate */
1524 /* SetMenu for Visible windows with no size change */
1525 static const struct message WmSetMenuVisibleNoSizeChangeSeq[] = {
1526 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1527 { WM_NCCALCSIZE, sent|wparam, 1 },
1528 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1529 { WM_GETTEXT, sent|defwinproc|optional },
1530 { WM_ERASEBKGND, sent|optional },
1531 { WM_ACTIVATE, sent|optional },
1532 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1533 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1536 /* DrawMenuBar for a visible window */
1537 static const struct message WmDrawMenuBarSeq[] =
1539 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1540 { WM_NCCALCSIZE, sent|wparam, 1 },
1541 { 0x0093, sent|defwinproc|optional },
1542 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
1543 { 0x0093, sent|defwinproc|optional },
1544 { 0x0093, sent|defwinproc|optional },
1545 { 0x0091, sent|defwinproc|optional },
1546 { 0x0092, sent|defwinproc|optional },
1547 { WM_GETTEXT, sent|defwinproc|optional },
1548 { WM_ERASEBKGND, sent|optional },
1549 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1550 { 0x0093, sent|optional },
1551 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1555 static const struct message WmSetRedrawFalseSeq[] =
1557 { WM_SETREDRAW, sent|wparam, 0 },
1561 static const struct message WmSetRedrawTrueSeq[] =
1563 { WM_SETREDRAW, sent|wparam, 1 },
1567 static const struct message WmEnableWindowSeq_1[] =
1569 { WM_CANCELMODE, sent|wparam|lparam, 0, 0 },
1570 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1571 { HCBT_SETFOCUS, hook|optional },
1572 { WM_KILLFOCUS, sent|optional },
1573 { WM_ENABLE, sent|wparam|lparam, FALSE, 0 },
1577 static const struct message WmEnableWindowSeq_2[] =
1579 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, 0, 0 },
1580 { WM_ENABLE, sent|wparam|lparam, TRUE, 0 },
1584 static const struct message WmGetScrollRangeSeq[] =
1586 { SBM_GETRANGE, sent },
1589 static const struct message WmGetScrollInfoSeq[] =
1591 { SBM_GETSCROLLINFO, sent },
1594 static const struct message WmSetScrollRangeSeq[] =
1596 /* MSDN claims that Windows sends SBM_SETRANGE message, but win2k SP4
1597 sends SBM_SETSCROLLINFO.
1599 { SBM_SETSCROLLINFO, sent },
1602 /* SetScrollRange for a window without a non-client area */
1603 static const struct message WmSetScrollRangeHSeq_empty[] =
1605 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_HSCROLL, 0 },
1608 static const struct message WmSetScrollRangeVSeq_empty[] =
1610 { EVENT_OBJECT_VALUECHANGE, winevent_hook|wparam|lparam, OBJID_VSCROLL, 0 },
1613 static const struct message WmSetScrollRangeHVSeq[] =
1615 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1616 { WM_NCCALCSIZE, sent|wparam, 1 },
1617 { WM_GETTEXT, sent|defwinproc|optional },
1618 { WM_ERASEBKGND, sent|optional },
1619 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1620 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1621 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1624 /* SetScrollRange for a window with a non-client area */
1625 static const struct message WmSetScrollRangeHV_NC_Seq[] =
1627 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE },
1628 { WM_NCCALCSIZE, sent|wparam, 1 },
1629 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
1630 { WM_NCPAINT, sent|optional },
1631 { WM_STYLECHANGING, sent|defwinproc|optional },
1632 { WM_STYLECHANGED, sent|defwinproc|optional },
1633 { WM_STYLECHANGING, sent|defwinproc|optional },
1634 { WM_STYLECHANGED, sent|defwinproc|optional },
1635 { WM_STYLECHANGING, sent|defwinproc|optional },
1636 { WM_STYLECHANGED, sent|defwinproc|optional },
1637 { WM_STYLECHANGING, sent|defwinproc|optional },
1638 { WM_STYLECHANGED, sent|defwinproc|optional },
1639 { WM_GETTEXT, sent|defwinproc|optional },
1640 { WM_GETTEXT, sent|defwinproc|optional },
1641 { WM_ERASEBKGND, sent|optional },
1642 { WM_CTLCOLORDLG, sent|defwinproc|optional }, /* sent to a parent of the dialog */
1643 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOCLIENTSIZE },
1644 { WM_SIZE, sent|defwinproc|optional },
1645 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1646 { EVENT_OBJECT_VALUECHANGE, winevent_hook|lparam|optional, 0/*OBJID_HSCROLL or OBJID_VSCROLL*/, 0 },
1647 { WM_GETTEXT, sent|optional },
1648 { WM_GETTEXT, sent|optional },
1649 { WM_GETTEXT, sent|optional },
1650 { WM_GETTEXT, sent|optional },
1653 /* test if we receive the right sequence of messages */
1654 /* after calling ShowWindow( SW_SHOWNA) */
1655 static const struct message WmSHOWNAChildInvisParInvis[] = {
1656 { WM_SHOWWINDOW, sent|wparam, 1 },
1659 static const struct message WmSHOWNAChildVisParInvis[] = {
1660 { WM_SHOWWINDOW, sent|wparam, 1 },
1663 static const struct message WmSHOWNAChildVisParVis[] = {
1664 { WM_SHOWWINDOW, sent|wparam, 1 },
1665 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1668 static const struct message WmSHOWNAChildInvisParVis[] = {
1669 { WM_SHOWWINDOW, sent|wparam, 1 },
1670 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1671 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1672 { WM_ERASEBKGND, sent|optional },
1673 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOACTIVATE|SWP_NOCLIENTMOVE },
1676 static const struct message WmSHOWNATopVisible[] = {
1677 { WM_SHOWWINDOW, sent|wparam, 1 },
1678 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
1679 { WM_NCPAINT, sent|wparam|optional, 1 },
1680 { WM_GETTEXT, sent|defwinproc|optional },
1681 { WM_ERASEBKGND, sent|optional },
1682 { WM_WINDOWPOSCHANGED, sent|optional },
1685 static const struct message WmSHOWNATopInvisible[] = {
1686 { WM_NOTIFYFORMAT, sent|optional },
1687 { WM_QUERYUISTATE, sent|optional },
1688 { WM_WINDOWPOSCHANGING, sent|optional },
1689 { WM_GETMINMAXINFO, sent|optional },
1690 { WM_NCCALCSIZE, sent|optional },
1691 { WM_WINDOWPOSCHANGED, sent|optional },
1692 { WM_SHOWWINDOW, sent|wparam, 1 },
1693 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
1694 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
1695 { WM_NCPAINT, sent|wparam|optional, 1 },
1696 { WM_GETTEXT, sent|defwinproc|optional },
1697 { WM_ERASEBKGND, sent|optional },
1698 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
1699 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
1700 { WM_NCPAINT, sent|wparam|optional, 1 },
1701 { WM_ERASEBKGND, sent|optional },
1702 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
1703 { WM_SIZE, sent|wparam, SIZE_RESTORED },
1708 static int after_end_dialog, test_def_id;
1709 static int sequence_cnt, sequence_size;
1710 static struct recvd_message* sequence;
1711 static int log_all_parent_messages;
1712 static int paint_loop_done;
1714 /* user32 functions */
1715 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
1716 static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
1717 static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
1718 static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
1719 static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
1720 static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
1721 static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
1722 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
1723 static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
1724 static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
1725 /* kernel32 functions */
1726 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1728 static void init_procs(void)
1730 HMODULE user32 = GetModuleHandleA("user32.dll");
1731 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1733 #define GET_PROC(dll, func) \
1734 p ## func = (void*)GetProcAddress(dll, #func); \
1736 trace("GetProcAddress(%s) failed\n", #func); \
1739 GET_PROC(user32, GetAncestor)
1740 GET_PROC(user32, GetMenuInfo)
1741 GET_PROC(user32, NotifyWinEvent)
1742 GET_PROC(user32, SetMenuInfo)
1743 GET_PROC(user32, SetWinEventHook)
1744 GET_PROC(user32, TrackMouseEvent)
1745 GET_PROC(user32, UnhookWinEvent)
1746 GET_PROC(user32, GetMonitorInfoA)
1747 GET_PROC(user32, MonitorFromPoint)
1748 GET_PROC(user32, UpdateLayeredWindow)
1750 GET_PROC(kernel32, GetCPInfoExA)
1755 static const char *get_winpos_flags(UINT flags)
1757 static char buffer[300];
1760 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1761 DUMP( SWP_SHOWWINDOW );
1762 DUMP( SWP_HIDEWINDOW );
1763 DUMP( SWP_NOACTIVATE );
1764 DUMP( SWP_FRAMECHANGED );
1765 DUMP( SWP_NOCOPYBITS );
1766 DUMP( SWP_NOOWNERZORDER );
1767 DUMP( SWP_NOSENDCHANGING );
1768 DUMP( SWP_DEFERERASE );
1769 DUMP( SWP_ASYNCWINDOWPOS );
1770 DUMP( SWP_NOZORDER );
1771 DUMP( SWP_NOREDRAW );
1774 DUMP( SWP_NOCLIENTSIZE );
1775 DUMP( SWP_NOCLIENTMOVE );
1776 if (flags) sprintf(buffer + strlen(buffer),"|0x%04x", flags);
1781 static BOOL ignore_message( UINT message )
1783 /* these are always ignored */
1784 return (message >= 0xc000 ||
1785 message == WM_GETICON ||
1786 message == WM_GETOBJECT ||
1787 message == WM_TIMECHANGE ||
1788 message == WM_DISPLAYCHANGE ||
1789 message == WM_DEVICECHANGE ||
1790 message == WM_DWMNCRENDERINGCHANGED);
1794 #define add_message(msg) add_message_(__LINE__,msg);
1795 static void add_message_(int line, const struct recvd_message *msg)
1797 struct recvd_message *seq;
1802 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
1804 if (sequence_cnt == sequence_size)
1807 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof(*sequence) );
1811 seq = &sequence[sequence_cnt];
1812 seq->hwnd = msg->hwnd;
1813 seq->message = msg->message;
1814 seq->flags = msg->flags;
1815 seq->wParam = msg->wParam;
1816 seq->lParam = msg->lParam;
1818 seq->descr = msg->descr;
1823 if (msg->flags & hook)
1825 static const char * const CBT_code_name[10] =
1833 "HCBT_CLICKSKIPPED",
1838 const char *code_name = (msg->message <= HCBT_SETFOCUS) ? CBT_code_name[msg->message] : "Unknown";
1840 sprintf( seq->output, "%s: hook %d (%s) wp %08lx lp %08lx",
1841 msg->descr, msg->message, code_name, msg->wParam, msg->lParam );
1843 else if (msg->flags & winevent_hook)
1845 sprintf( seq->output, "%s: winevent %p %08x %08lx %08lx",
1846 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
1850 switch (msg->message)
1852 case WM_WINDOWPOSCHANGING:
1853 case WM_WINDOWPOSCHANGED:
1855 WINDOWPOS *winpos = (WINDOWPOS *)msg->lParam;
1857 sprintf( seq->output, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1858 msg->descr, msg->hwnd,
1859 (msg->message == WM_WINDOWPOSCHANGING) ? "CHANGING" : "CHANGED",
1860 msg->wParam, msg->lParam, winpos->hwndInsertAfter,
1861 winpos->x, winpos->y, winpos->cx, winpos->cy,
1862 get_winpos_flags(winpos->flags) );
1864 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1865 * in the high word for internal purposes
1867 seq->wParam = winpos->flags & 0xffff;
1868 /* We are not interested in the flags that don't match under XP and Win9x */
1869 seq->wParam &= ~SWP_NOZORDER;
1875 DRAW_ITEM_STRUCT di;
1876 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)msg->lParam;
1878 sprintf( seq->output, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1879 msg->descr, msg->hwnd, dis->CtlType, dis->CtlID,
1880 dis->itemID, dis->itemAction, dis->itemState);
1883 di.u.item.type = dis->CtlType;
1884 di.u.item.ctl_id = dis->CtlID;
1885 if (dis->CtlType == ODT_LISTBOX ||
1886 dis->CtlType == ODT_COMBOBOX ||
1887 dis->CtlType == ODT_MENU)
1888 di.u.item.item_id = dis->itemID;
1889 di.u.item.action = dis->itemAction;
1890 di.u.item.state = dis->itemState;
1892 seq->lParam = di.u.lp;
1896 if (msg->message >= 0xc000) return; /* ignore registered messages */
1897 sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
1898 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
1900 if (msg->flags & (sent|posted|parent|defwinproc|beginpaint))
1901 sprintf( seq->output + strlen(seq->output), " (flags %x)", msg->flags );
1908 /* try to make sure pending X events have been processed before continuing */
1909 static void flush_events(void)
1913 int min_timeout = 100;
1914 DWORD time = GetTickCount() + diff;
1918 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1919 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1920 diff = time - GetTickCount();
1924 static void flush_sequence(void)
1926 HeapFree(GetProcessHeap(), 0, sequence);
1928 sequence_cnt = sequence_size = 0;
1931 static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
1933 const struct recvd_message *actual = sequence;
1934 unsigned int count = 0;
1936 trace_(file, line)("Failed sequence %s:\n", context );
1937 while (expected->message && actual->message)
1939 if (actual->output[0])
1941 if (expected->flags & hook)
1943 trace_(file, line)( " %u: expected: hook %04x - actual: %s\n",
1944 count, expected->message, actual->output );
1946 else if (expected->flags & winevent_hook)
1948 trace_(file, line)( " %u: expected: winevent %04x - actual: %s\n",
1949 count, expected->message, actual->output );
1951 else if (expected->flags & kbd_hook)
1953 trace_(file, line)( " %u: expected: kbd %04x - actual: %s\n",
1954 count, expected->message, actual->output );
1958 trace_(file, line)( " %u: expected: msg %04x - actual: %s\n",
1959 count, expected->message, actual->output );
1963 if (expected->message == actual->message)
1965 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) &&
1966 (expected->flags & optional))
1968 /* don't match messages if their defwinproc status differs */
1977 /* silently drop winevent messages if there is no support for them */
1978 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1988 /* optional trailing messages */
1989 while (expected->message && ((expected->flags & optional) ||
1990 ((expected->flags & winevent_hook) && !hEvent_hook)))
1992 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
1997 if (expected->message)
1999 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
2003 while (actual->message && actual->output[0])
2005 trace_(file, line)( " %u: expected: nothing - actual: %s\n", count, actual->output );
2011 #define ok_sequence( exp, contx, todo) \
2012 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2015 static void ok_sequence_(const struct message *expected_list, const char *context, int todo,
2016 const char *file, int line)
2018 static const struct recvd_message end_of_sequence;
2019 const struct message *expected = expected_list;
2020 const struct recvd_message *actual;
2021 int failcount = 0, dump = 0;
2022 unsigned int count = 0;
2024 add_message(&end_of_sequence);
2028 while (expected->message && actual->message)
2030 if (expected->message == actual->message &&
2031 !((expected->flags ^ actual->flags) & (hook|winevent_hook|kbd_hook)))
2033 if (expected->flags & wparam)
2035 if (((expected->wParam ^ actual->wParam) & ~expected->wp_mask) && todo)
2039 if (strcmp(winetest_platform, "wine")) dump++;
2040 ok_( file, line) (FALSE,
2041 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2042 context, count, expected->message, expected->wParam, actual->wParam);
2047 ok_( file, line)( ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) == 0,
2048 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2049 context, count, expected->message, expected->wParam, actual->wParam);
2050 if ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) dump++;
2054 if (expected->flags & lparam)
2056 if (((expected->lParam ^ actual->lParam) & ~expected->lp_mask) && todo)
2060 if (strcmp(winetest_platform, "wine")) dump++;
2061 ok_( file, line) (FALSE,
2062 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2063 context, count, expected->message, expected->lParam, actual->lParam);
2068 ok_( file, line)(((expected->lParam ^ actual->lParam) & ~expected->lp_mask) == 0,
2069 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2070 context, count, expected->message, expected->lParam, actual->lParam);
2071 if ((expected->lParam ^ actual->lParam) & ~expected->lp_mask) dump++;
2074 if ((expected->flags & optional) &&
2075 ((expected->flags ^ actual->flags) & (defwinproc|parent)))
2077 /* don't match optional messages if their defwinproc or parent status differs */
2082 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
2086 if (strcmp(winetest_platform, "wine")) dump++;
2087 ok_( file, line) (FALSE,
2088 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2089 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
2094 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
2095 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2096 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
2097 if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
2100 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
2101 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2102 context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
2103 if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++;
2105 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
2106 "%s: %u: the msg 0x%04x should have been %s\n",
2107 context, count, expected->message, (expected->flags & posted) ? "posted" : "sent");
2108 if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
2110 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
2111 "%s: %u: the msg 0x%04x was expected in %s\n",
2112 context, count, expected->message, (expected->flags & parent) ? "parent" : "child");
2113 if ((expected->flags & parent) != (actual->flags & parent)) dump++;
2115 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
2116 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2117 context, count, expected->message);
2118 if ((expected->flags & hook) != (actual->flags & hook)) dump++;
2120 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
2121 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2122 context, count, expected->message);
2123 if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++;
2125 ok_( file, line) ((expected->flags & kbd_hook) == (actual->flags & kbd_hook),
2126 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2127 context, count, expected->message);
2128 if ((expected->flags & kbd_hook) != (actual->flags & kbd_hook)) dump++;
2133 /* silently drop hook messages if there is no support for them */
2134 else if ((expected->flags & optional) ||
2135 ((expected->flags & hook) && !hCBT_hook) ||
2136 ((expected->flags & winevent_hook) && !hEvent_hook) ||
2137 ((expected->flags & kbd_hook) && !hKBD_hook))
2143 if (strcmp(winetest_platform, "wine")) dump++;
2144 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2145 context, count, expected->message, actual->message);
2151 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2152 context, count, expected->message, actual->message);
2160 /* skip all optional trailing messages */
2161 while (expected->message && ((expected->flags & optional) ||
2162 ((expected->flags & hook) && !hCBT_hook) ||
2163 ((expected->flags & winevent_hook) && !hEvent_hook)))
2169 if (expected->message || actual->message) {
2171 if (strcmp(winetest_platform, "wine")) dump++;
2172 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2173 context, count, expected->message, actual->message);
2179 if (expected->message || actual->message)
2182 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2183 context, count, expected->message, actual->message);
2186 if( todo && !failcount) /* succeeded yet marked todo */
2188 if (!strcmp(winetest_platform, "wine")) dump++;
2189 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
2193 if (dump) dump_sequence(expected_list, context, file, line);
2197 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2199 /******************************** MDI test **********************************/
2201 /* CreateWindow for MDI frame window, initially visible */
2202 static const struct message WmCreateMDIframeSeq[] = {
2203 { HCBT_CREATEWND, hook },
2204 { WM_GETMINMAXINFO, sent },
2205 { WM_NCCREATE, sent },
2206 { WM_NCCALCSIZE, sent|wparam, 0 },
2207 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2208 { WM_CREATE, sent },
2209 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2210 { WM_NOTIFYFORMAT, sent|optional },
2211 { WM_QUERYUISTATE, sent|optional },
2212 { WM_WINDOWPOSCHANGING, sent|optional },
2213 { WM_GETMINMAXINFO, sent|optional },
2214 { WM_NCCALCSIZE, sent|optional },
2215 { WM_WINDOWPOSCHANGED, sent|optional },
2216 { WM_SHOWWINDOW, sent|wparam, 1 },
2217 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2218 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2219 { HCBT_ACTIVATE, hook },
2220 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
2221 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
2222 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
2223 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
2224 { WM_NCACTIVATE, sent },
2225 { WM_GETTEXT, sent|defwinproc|optional },
2226 { WM_ACTIVATE, sent|wparam, 1 },
2227 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
2228 { HCBT_SETFOCUS, hook },
2229 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2230 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2231 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2232 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
2233 /* Win9x adds SWP_NOZORDER below */
2234 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2235 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2236 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2237 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2241 /* DestroyWindow for MDI frame window, initially visible */
2242 static const struct message WmDestroyMDIframeSeq[] = {
2243 { HCBT_DESTROYWND, hook },
2244 { 0x0090, sent|optional },
2245 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2246 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2247 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2248 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2249 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
2250 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2251 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
2252 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
2253 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2254 { WM_DESTROY, sent },
2255 { WM_NCDESTROY, sent },
2258 /* CreateWindow for MDI client window, initially visible */
2259 static const struct message WmCreateMDIclientSeq[] = {
2260 { HCBT_CREATEWND, hook },
2261 { WM_NCCREATE, sent },
2262 { WM_NCCALCSIZE, sent|wparam, 0 },
2263 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2264 { WM_CREATE, sent },
2265 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2266 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2267 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2269 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
2270 { WM_SHOWWINDOW, sent|wparam, 1 },
2271 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2272 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2273 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2276 /* ShowWindow(SW_SHOW) for MDI client window */
2277 static const struct message WmShowMDIclientSeq[] = {
2278 { WM_SHOWWINDOW, sent|wparam, 1 },
2279 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2280 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2281 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2284 /* ShowWindow(SW_HIDE) for MDI client window */
2285 static const struct message WmHideMDIclientSeq[] = {
2286 { WM_SHOWWINDOW, sent|wparam, 0 },
2287 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2288 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
2289 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
2290 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2293 /* DestroyWindow for MDI client window, initially visible */
2294 static const struct message WmDestroyMDIclientSeq[] = {
2295 { HCBT_DESTROYWND, hook },
2296 { 0x0090, sent|optional },
2297 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
2298 { WM_SHOWWINDOW, sent|wparam, 0 },
2299 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2300 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2301 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2302 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2303 { WM_DESTROY, sent },
2304 { WM_NCDESTROY, sent },
2307 /* CreateWindow for MDI child window, initially visible */
2308 static const struct message WmCreateMDIchildVisibleSeq[] = {
2309 { HCBT_CREATEWND, hook },
2310 { WM_NCCREATE, sent },
2311 { WM_NCCALCSIZE, sent|wparam, 0 },
2312 { WM_CREATE, sent },
2313 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2314 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2316 /* Win2k sends wparam set to
2317 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2318 * while Win9x doesn't bother to set child window id according to
2319 * CLIENTCREATESTRUCT.idFirstChild
2321 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2322 { WM_SHOWWINDOW, sent|wparam, 1 },
2323 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2324 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2325 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2326 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2327 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2328 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2329 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2331 /* Win9x: message sequence terminates here. */
2333 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2334 { HCBT_SETFOCUS, hook }, /* in MDI client */
2335 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2336 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2337 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2338 { WM_SETFOCUS, sent }, /* in MDI client */
2339 { HCBT_SETFOCUS, hook },
2340 { WM_KILLFOCUS, sent }, /* in MDI client */
2341 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2342 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2343 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2344 { WM_SETFOCUS, sent|defwinproc },
2345 { WM_MDIACTIVATE, sent|defwinproc },
2348 /* CreateWindow for MDI child window with invisible parent */
2349 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
2350 { HCBT_CREATEWND, hook },
2351 { WM_GETMINMAXINFO, sent },
2352 { WM_NCCREATE, sent },
2353 { WM_NCCALCSIZE, sent|wparam, 0 },
2354 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2355 { WM_CREATE, sent },
2356 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2357 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2359 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2360 { WM_SHOWWINDOW, sent|wparam, 1 },
2361 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2362 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2363 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2364 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2366 /* Win9x: message sequence terminates here. */
2368 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2369 { HCBT_SETFOCUS, hook }, /* in MDI client */
2370 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2371 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2372 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2373 { WM_SETFOCUS, sent }, /* in MDI client */
2374 { HCBT_SETFOCUS, hook },
2375 { WM_KILLFOCUS, sent }, /* in MDI client */
2376 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2377 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2378 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2379 { WM_SETFOCUS, sent|defwinproc },
2380 { WM_MDIACTIVATE, sent|defwinproc },
2383 /* DestroyWindow for MDI child window, initially visible */
2384 static const struct message WmDestroyMDIchildVisibleSeq[] = {
2385 { HCBT_DESTROYWND, hook },
2386 /* Win2k sends wparam set to
2387 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2388 * while Win9x doesn't bother to set child window id according to
2389 * CLIENTCREATESTRUCT.idFirstChild
2391 { 0x0090, sent|optional },
2392 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2393 { WM_SHOWWINDOW, sent|wparam, 0 },
2394 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2395 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2396 { WM_ERASEBKGND, sent|parent|optional },
2397 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2399 /* { WM_DESTROY, sent }
2400 * Win9x: message sequence terminates here.
2403 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2404 { WM_KILLFOCUS, sent },
2405 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2406 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2407 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2408 { WM_SETFOCUS, sent }, /* in MDI client */
2410 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2411 { WM_KILLFOCUS, sent }, /* in MDI client */
2412 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2413 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2414 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2415 { WM_SETFOCUS, sent }, /* in MDI client */
2417 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2419 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2420 { WM_KILLFOCUS, sent },
2421 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2422 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2423 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2424 { WM_SETFOCUS, sent }, /* in MDI client */
2426 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2427 { WM_KILLFOCUS, sent }, /* in MDI client */
2428 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2429 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2430 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2431 { WM_SETFOCUS, sent }, /* in MDI client */
2433 { WM_DESTROY, sent },
2435 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2436 { WM_KILLFOCUS, sent },
2437 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2438 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2439 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2440 { WM_SETFOCUS, sent }, /* in MDI client */
2442 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2443 { WM_KILLFOCUS, sent }, /* in MDI client */
2444 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2445 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2446 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2447 { WM_SETFOCUS, sent }, /* in MDI client */
2449 { WM_NCDESTROY, sent },
2452 /* CreateWindow for MDI child window, initially invisible */
2453 static const struct message WmCreateMDIchildInvisibleSeq[] = {
2454 { HCBT_CREATEWND, hook },
2455 { WM_NCCREATE, sent },
2456 { WM_NCCALCSIZE, sent|wparam, 0 },
2457 { WM_CREATE, sent },
2458 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2459 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2461 /* Win2k sends wparam set to
2462 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2463 * while Win9x doesn't bother to set child window id according to
2464 * CLIENTCREATESTRUCT.idFirstChild
2466 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2469 /* DestroyWindow for MDI child window, initially invisible */
2470 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
2471 { HCBT_DESTROYWND, hook },
2472 /* Win2k sends wparam set to
2473 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2474 * while Win9x doesn't bother to set child window id according to
2475 * CLIENTCREATESTRUCT.idFirstChild
2477 { 0x0090, sent|optional },
2478 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2479 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2480 { WM_DESTROY, sent },
2481 { WM_NCDESTROY, sent },
2482 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2483 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
2486 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2487 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
2488 { HCBT_CREATEWND, hook },
2489 { WM_NCCREATE, sent },
2490 { WM_NCCALCSIZE, sent|wparam, 0 },
2491 { WM_CREATE, sent },
2492 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2493 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2495 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2496 { WM_GETMINMAXINFO, sent },
2497 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2498 { WM_NCCALCSIZE, sent|wparam, 1 },
2499 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2500 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2502 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2503 { WM_NCCALCSIZE, sent|wparam, 1 },
2504 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2505 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2506 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2507 /* Win2k sends wparam set to
2508 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2509 * while Win9x doesn't bother to set child window id according to
2510 * CLIENTCREATESTRUCT.idFirstChild
2512 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2513 { WM_SHOWWINDOW, sent|wparam, 1 },
2514 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2515 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2516 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2517 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2518 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2519 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2520 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_FRAMECHANGED },
2522 /* Win9x: message sequence terminates here. */
2524 { WM_NCACTIVATE, sent|wparam|defwinproc|optional, 1 },
2525 { HCBT_SETFOCUS, hook|optional }, /* in MDI client */
2526 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2527 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2528 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2529 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2530 { HCBT_SETFOCUS, hook|optional },
2531 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
2532 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2533 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2534 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2535 { WM_SETFOCUS, sent|defwinproc|optional },
2536 { WM_MDIACTIVATE, sent|defwinproc|optional },
2538 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2539 { WM_NCCALCSIZE, sent|wparam, 1 },
2540 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2541 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2544 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2545 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2546 /* restore the 1st MDI child */
2547 { WM_SETREDRAW, sent|wparam, 0 },
2548 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2549 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2550 { WM_NCCALCSIZE, sent|wparam, 1 },
2551 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2552 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2553 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2555 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2556 { WM_NCCALCSIZE, sent|wparam, 1 },
2557 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2558 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2559 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2560 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2561 /* create the 2nd MDI child */
2562 { HCBT_CREATEWND, hook },
2563 { WM_NCCREATE, sent },
2564 { WM_NCCALCSIZE, sent|wparam, 0 },
2565 { WM_CREATE, sent },
2566 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2567 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2569 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2570 { WM_GETMINMAXINFO, sent },
2571 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2572 { WM_NCCALCSIZE, sent|wparam, 1 },
2573 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2574 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2575 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2577 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2578 { WM_NCCALCSIZE, sent|wparam, 1 },
2579 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2580 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2581 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2582 /* Win2k sends wparam set to
2583 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2584 * while Win9x doesn't bother to set child window id according to
2585 * CLIENTCREATESTRUCT.idFirstChild
2587 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2588 { WM_SHOWWINDOW, sent|wparam, 1 },
2589 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2590 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2591 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2592 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2593 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2594 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2596 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2597 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2599 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2601 /* Win9x: message sequence terminates here. */
2603 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2604 { HCBT_SETFOCUS, hook },
2605 { WM_KILLFOCUS, sent|defwinproc|optional }, /* in the 1st MDI child */
2606 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2607 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2608 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2609 { WM_SETFOCUS, sent }, /* in MDI client */
2610 { HCBT_SETFOCUS, hook },
2611 { WM_KILLFOCUS, sent }, /* in MDI client */
2612 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2613 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2614 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2615 { WM_SETFOCUS, sent|defwinproc },
2617 { WM_MDIACTIVATE, sent|defwinproc },
2619 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2620 { WM_NCCALCSIZE, sent|wparam, 1 },
2621 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2622 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2625 /* WM_MDICREATE MDI child window, initially visible and maximized */
2626 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2627 { WM_MDICREATE, sent },
2628 { HCBT_CREATEWND, hook },
2629 { WM_NCCREATE, sent },
2630 { WM_NCCALCSIZE, sent|wparam, 0 },
2631 { WM_CREATE, sent },
2632 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2633 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2635 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2636 { WM_GETMINMAXINFO, sent },
2637 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2638 { WM_NCCALCSIZE, sent|wparam, 1 },
2639 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2640 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2643 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2644 { WM_NCCALCSIZE, sent|wparam, 1 },
2645 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2646 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2647 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2649 /* Win2k sends wparam set to
2650 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2651 * while Win9x doesn't bother to set child window id according to
2652 * CLIENTCREATESTRUCT.idFirstChild
2654 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2655 { WM_SHOWWINDOW, sent|wparam, 1 },
2656 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2658 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2660 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2661 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2662 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2664 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2665 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2667 /* Win9x: message sequence terminates here. */
2669 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2670 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2671 { HCBT_SETFOCUS, hook }, /* in MDI client */
2672 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2673 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2674 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2675 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2676 { HCBT_SETFOCUS, hook|optional },
2677 { WM_KILLFOCUS, sent }, /* in MDI client */
2678 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2679 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2680 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2681 { WM_SETFOCUS, sent|defwinproc },
2683 { WM_MDIACTIVATE, sent|defwinproc },
2686 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2687 { WM_NCCALCSIZE, sent|wparam, 1 },
2688 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2689 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2692 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2693 { WM_NCCALCSIZE, sent|wparam, 1 },
2694 { 0x0093, sent|defwinproc|optional },
2695 { 0x0093, sent|defwinproc|optional },
2696 { 0x0093, sent|defwinproc|optional },
2697 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2698 { WM_MOVE, sent|defwinproc },
2699 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2702 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2703 { WM_NCCALCSIZE, sent|wparam, 1 },
2704 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2705 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2708 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2709 { WM_NCCALCSIZE, sent|wparam, 1 },
2710 { 0x0093, sent|optional },
2711 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2712 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2714 { 0x0093, sent|optional },
2715 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2716 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2717 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2718 { 0x0093, sent|defwinproc|optional },
2719 { 0x0093, sent|defwinproc|optional },
2720 { 0x0093, sent|defwinproc|optional },
2721 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2722 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2726 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2727 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2728 { HCBT_CREATEWND, hook },
2729 { WM_GETMINMAXINFO, sent },
2730 { WM_NCCREATE, sent },
2731 { WM_NCCALCSIZE, sent|wparam, 0 },
2732 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2733 { WM_CREATE, sent },
2734 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2735 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2736 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_NOZORDER }, /* MDI frame */
2737 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI frame */
2738 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOZORDER }, /* MDI frame */
2740 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2741 { WM_GETMINMAXINFO, sent },
2742 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2743 { WM_GETMINMAXINFO, sent|defwinproc },
2744 { WM_NCCALCSIZE, sent|wparam, 1 },
2745 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_STATECHANGED },
2746 { WM_MOVE, sent|defwinproc },
2747 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2749 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2750 { WM_NCCALCSIZE, sent|wparam, 1 },
2751 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2752 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2753 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2754 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2755 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2756 /* Win2k sends wparam set to
2757 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2758 * while Win9x doesn't bother to set child window id according to
2759 * CLIENTCREATESTRUCT.idFirstChild
2761 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2764 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2765 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2766 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2767 { HCBT_SYSCOMMAND, hook },
2768 { WM_CLOSE, sent|defwinproc },
2769 { WM_MDIDESTROY, sent }, /* in MDI client */
2771 /* bring the 1st MDI child to top */
2772 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2773 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2775 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2777 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2778 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2779 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2781 /* maximize the 1st MDI child */
2782 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2783 { WM_GETMINMAXINFO, sent|defwinproc },
2784 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED },
2785 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2786 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2787 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2788 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2790 /* restore the 2nd MDI child */
2791 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2792 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2793 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2794 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2796 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2798 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2799 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2801 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2803 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2805 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2806 { WM_NCCALCSIZE, sent|wparam, 1 },
2807 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2808 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2809 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2811 /* bring the 1st MDI child to top */
2812 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2813 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2814 { HCBT_SETFOCUS, hook },
2815 { WM_KILLFOCUS, sent|defwinproc },
2816 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2817 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2818 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2819 { WM_SETFOCUS, sent }, /* in MDI client */
2820 { HCBT_SETFOCUS, hook },
2821 { WM_KILLFOCUS, sent }, /* in MDI client */
2822 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2823 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2824 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2825 { WM_SETFOCUS, sent|defwinproc },
2826 { WM_MDIACTIVATE, sent|defwinproc },
2827 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2829 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2830 { WM_SHOWWINDOW, sent|wparam, 1 },
2831 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2832 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2833 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2834 { WM_MDIREFRESHMENU, sent },
2836 { HCBT_DESTROYWND, hook },
2837 /* Win2k sends wparam set to
2838 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2839 * while Win9x doesn't bother to set child window id according to
2840 * CLIENTCREATESTRUCT.idFirstChild
2842 { 0x0090, sent|defwinproc|optional },
2843 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2844 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2845 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2846 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2847 { WM_ERASEBKGND, sent|parent|optional },
2848 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2850 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2851 { WM_DESTROY, sent|defwinproc },
2852 { WM_NCDESTROY, sent|defwinproc },
2855 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2856 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2857 { WM_MDIDESTROY, sent }, /* in MDI client */
2858 { WM_SHOWWINDOW, sent|wparam, 0 },
2859 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2860 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2861 { WM_ERASEBKGND, sent|parent|optional },
2862 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2864 { HCBT_SETFOCUS, hook },
2865 { WM_KILLFOCUS, sent },
2866 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2867 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2868 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2869 { WM_SETFOCUS, sent }, /* in MDI client */
2870 { HCBT_SETFOCUS, hook },
2871 { WM_KILLFOCUS, sent }, /* in MDI client */
2872 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2873 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2874 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2875 { WM_SETFOCUS, sent },
2878 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2879 { WM_NCCALCSIZE, sent|wparam, 1 },
2880 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2881 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2884 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2885 { WM_NCCALCSIZE, sent|wparam, 1 },
2886 { 0x0093, sent|defwinproc|optional },
2887 { 0x0093, sent|defwinproc|optional },
2888 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2889 { WM_MOVE, sent|defwinproc },
2890 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2893 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2894 { WM_NCCALCSIZE, sent|wparam, 1 },
2895 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2896 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2899 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2900 { WM_NCCALCSIZE, sent|wparam, 1 },
2901 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2902 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2905 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2906 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2907 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2908 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2911 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2912 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2913 { 0x0093, sent|defwinproc|optional },
2914 { 0x0093, sent|defwinproc|optional },
2915 { 0x0093, sent|defwinproc|optional },
2916 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2917 { WM_MOVE, sent|defwinproc },
2918 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2921 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2922 { WM_NCCALCSIZE, sent|wparam, 1 },
2923 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2924 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2927 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2928 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2929 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2930 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2931 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2932 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2934 { 0x0093, sent|defwinproc|optional },
2935 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2936 { 0x0093, sent|defwinproc|optional },
2937 { 0x0093, sent|defwinproc|optional },
2938 { 0x0093, sent|defwinproc|optional },
2939 { 0x0093, sent|optional },
2941 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2942 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2943 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2944 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2945 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2948 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2949 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2950 { 0x0093, sent|defwinproc|optional },
2951 { 0x0093, sent|defwinproc|optional },
2952 { 0x0093, sent|defwinproc|optional },
2953 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2954 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2955 { 0x0093, sent|optional },
2957 { WM_NCACTIVATE, sent|wparam, 0 },
2958 { WM_MDIACTIVATE, sent },
2960 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2961 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2962 { WM_NCCALCSIZE, sent|wparam, 1 },
2964 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2966 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2967 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2968 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2971 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2972 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2973 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2974 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2977 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2978 { WM_NCCALCSIZE, sent|wparam, 1 },
2979 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2980 { WM_MOVE, sent|defwinproc },
2981 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2984 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2985 { WM_NCCALCSIZE, sent|wparam, 1 },
2986 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2987 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2988 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2989 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2990 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2991 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2992 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2994 { HCBT_SETFOCUS, hook },
2995 { WM_KILLFOCUS, sent },
2996 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2997 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2998 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2999 { WM_SETFOCUS, sent }, /* in MDI client */
3001 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
3003 { HCBT_DESTROYWND, hook },
3004 /* Win2k sends wparam set to
3005 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3006 * while Win9x doesn't bother to set child window id according to
3007 * CLIENTCREATESTRUCT.idFirstChild
3009 { 0x0090, sent|optional },
3010 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
3012 { WM_SHOWWINDOW, sent|wparam, 0 },
3013 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3014 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
3015 { WM_ERASEBKGND, sent|parent|optional },
3016 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3018 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
3019 { WM_DESTROY, sent },
3020 { WM_NCDESTROY, sent },
3023 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3024 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
3025 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3026 { WM_GETMINMAXINFO, sent },
3027 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
3028 { WM_NCCALCSIZE, sent|wparam, 1 },
3029 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3030 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3032 { WM_WINDOWPOSCHANGING, sent|wparam|optional|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3033 { WM_NCACTIVATE, sent|wparam|optional|defwinproc, 1 },
3034 { HCBT_SETFOCUS, hook|optional },
3035 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
3036 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3037 { WM_SETFOCUS, sent|optional }, /* in MDI client */
3038 { HCBT_SETFOCUS, hook|optional },
3039 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
3040 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
3041 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3042 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3043 { WM_SETFOCUS, sent|optional|defwinproc },
3044 { WM_MDIACTIVATE, sent|optional|defwinproc },
3045 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3046 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3048 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3049 { WM_NCCALCSIZE, sent|wparam, 1 },
3050 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3051 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3052 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3055 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3056 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
3057 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3058 { WM_GETMINMAXINFO, sent },
3059 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
3060 { WM_GETMINMAXINFO, sent|defwinproc },
3061 { WM_NCCALCSIZE, sent|wparam, 1 },
3062 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3063 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3065 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3066 { WM_NCACTIVATE, sent|wparam|defwinproc|optional, 1 },
3067 { HCBT_SETFOCUS, hook|optional },
3068 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
3069 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3070 { WM_SETFOCUS, sent|optional }, /* in MDI client */
3071 { HCBT_SETFOCUS, hook|optional },
3072 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
3073 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
3074 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3075 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3076 { WM_SETFOCUS, sent|defwinproc|optional },
3077 { WM_MDIACTIVATE, sent|defwinproc|optional },
3078 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3079 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3082 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3083 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
3084 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
3085 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3086 { WM_GETMINMAXINFO, sent },
3087 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3088 { WM_GETMINMAXINFO, sent|defwinproc },
3089 { WM_NCCALCSIZE, sent|wparam, 1 },
3090 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
3091 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3092 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
3093 { WM_MOVE, sent|defwinproc },
3094 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3096 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3097 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
3098 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3099 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
3100 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3101 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
3103 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3104 { WM_NCCALCSIZE, sent|wparam, 1 },
3105 { 0x0093, sent|defwinproc|optional },
3106 { 0x0094, sent|defwinproc|optional },
3107 { 0x0094, sent|defwinproc|optional },
3108 { 0x0094, sent|defwinproc|optional },
3109 { 0x0094, sent|defwinproc|optional },
3110 { 0x0093, sent|defwinproc|optional },
3111 { 0x0093, sent|defwinproc|optional },
3112 { 0x0091, sent|defwinproc|optional },
3113 { 0x0092, sent|defwinproc|optional },
3114 { 0x0092, sent|defwinproc|optional },
3115 { 0x0092, sent|defwinproc|optional },
3116 { 0x0092, sent|defwinproc|optional },
3117 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3118 { WM_MOVE, sent|defwinproc },
3119 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3120 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
3122 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
3123 { WM_NCCALCSIZE, sent|wparam, 1 },
3124 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
3125 { WM_SIZE, sent|wparam, SIZE_RESTORED },
3127 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
3128 { WM_GETMINMAXINFO, sent|defwinproc },
3129 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
3130 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
3131 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3132 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
3133 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
3134 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3135 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3136 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
3138 { 0x0093, sent|optional },
3139 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
3140 { 0x0093, sent|defwinproc|optional },
3141 { 0x0093, sent|defwinproc|optional },
3142 { 0x0093, sent|defwinproc|optional },
3143 { 0x0091, sent|defwinproc|optional },
3144 { 0x0092, sent|defwinproc|optional },
3145 { 0x0092, sent|defwinproc|optional },
3146 { 0x0092, sent|defwinproc|optional },
3147 { 0x0092, sent|defwinproc|optional },
3148 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
3149 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
3150 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3153 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3154 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
3155 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3156 { WM_GETMINMAXINFO, sent },
3157 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3158 { WM_NCCALCSIZE, sent|wparam, 1 },
3159 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3160 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3161 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3163 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3164 { WM_NCCALCSIZE, sent|wparam, 1 },
3165 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3166 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3167 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3170 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3171 static const struct message WmRestoreMDIchildVisibleSeq[] = {
3172 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3173 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3174 { WM_NCCALCSIZE, sent|wparam, 1 },
3175 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3176 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3177 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3179 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3180 { WM_NCCALCSIZE, sent|wparam, 1 },
3181 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3182 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3183 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3186 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3187 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
3188 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3189 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
3190 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
3191 { WM_NCCALCSIZE, sent|wparam, 1 },
3192 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3193 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
3194 { WM_MOVE, sent|defwinproc },
3195 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3196 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3197 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3198 { HCBT_SETFOCUS, hook },
3199 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3200 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
3201 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3202 { WM_SETFOCUS, sent },
3205 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3206 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
3207 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
3208 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
3209 { WM_NCCALCSIZE, sent|wparam, 1 },
3210 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
3211 { WM_MOVE, sent|defwinproc },
3212 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
3213 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
3214 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3215 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3216 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3217 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
3220 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3221 static const struct message WmRestoreMDIchildInisibleSeq[] = {
3222 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3223 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
3224 { WM_NCCALCSIZE, sent|wparam, 1 },
3225 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3226 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3227 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3228 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3230 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3231 { WM_NCCALCSIZE, sent|wparam, 1 },
3232 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3233 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3234 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3238 static HWND mdi_client;
3239 static WNDPROC old_mdi_client_proc;
3241 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3243 struct recvd_message msg;
3245 /* do not log painting messages */
3246 if (message != WM_PAINT &&
3247 message != WM_NCPAINT &&
3248 message != WM_SYNCPAINT &&
3249 message != WM_ERASEBKGND &&
3250 message != WM_NCHITTEST &&
3251 message != WM_GETTEXT &&
3252 message != WM_MDIGETACTIVE &&
3253 !ignore_message( message ))
3256 msg.message = message;
3257 msg.flags = sent|wparam|lparam;
3258 msg.wParam = wParam;
3259 msg.lParam = lParam;
3260 msg.descr = "mdi client";
3264 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
3267 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3269 static LONG defwndproc_counter = 0;
3271 struct recvd_message msg;
3273 /* do not log painting messages */
3274 if (message != WM_PAINT &&
3275 message != WM_NCPAINT &&
3276 message != WM_SYNCPAINT &&
3277 message != WM_ERASEBKGND &&
3278 message != WM_NCHITTEST &&
3279 message != WM_GETTEXT &&
3280 !ignore_message( message ))
3284 case WM_MDIACTIVATE:
3286 HWND active, client = GetParent(hwnd);
3288 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
3290 if (hwnd == (HWND)lParam) /* if we are being activated */
3291 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
3293 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
3299 msg.message = message;
3300 msg.flags = sent|wparam|lparam;
3301 if (defwndproc_counter) msg.flags |= defwinproc;
3302 msg.wParam = wParam;
3303 msg.lParam = lParam;
3304 msg.descr = "mdi child";
3308 defwndproc_counter++;
3309 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
3310 defwndproc_counter--;
3315 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3317 static LONG defwndproc_counter = 0;
3319 struct recvd_message msg;
3321 /* do not log painting messages */
3322 if (message != WM_PAINT &&
3323 message != WM_NCPAINT &&
3324 message != WM_SYNCPAINT &&
3325 message != WM_ERASEBKGND &&
3326 message != WM_NCHITTEST &&
3327 message != WM_GETTEXT &&
3328 !ignore_message( message ))
3331 msg.message = message;
3332 msg.flags = sent|wparam|lparam;
3333 if (defwndproc_counter) msg.flags |= defwinproc;
3334 msg.wParam = wParam;
3335 msg.lParam = lParam;
3336 msg.descr = "mdi frame";
3340 defwndproc_counter++;
3341 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
3342 defwndproc_counter--;
3347 static BOOL mdi_RegisterWindowClasses(void)
3352 cls.lpfnWndProc = mdi_frame_wnd_proc;
3355 cls.hInstance = GetModuleHandleA(0);
3357 cls.hCursor = LoadCursorA(0, IDC_ARROW);
3358 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
3359 cls.lpszMenuName = NULL;
3360 cls.lpszClassName = "MDI_frame_class";
3361 if (!RegisterClassA(&cls)) return FALSE;
3363 cls.lpfnWndProc = mdi_child_wnd_proc;
3364 cls.lpszClassName = "MDI_child_class";
3365 if (!RegisterClassA(&cls)) return FALSE;
3367 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
3368 old_mdi_client_proc = cls.lpfnWndProc;
3369 cls.hInstance = GetModuleHandleA(0);
3370 cls.lpfnWndProc = mdi_client_hook_proc;
3371 cls.lpszClassName = "MDI_client_class";
3372 if (!RegisterClassA(&cls)) assert(0);
3377 static void test_mdi_messages(void)
3379 MDICREATESTRUCTA mdi_cs;
3380 CLIENTCREATESTRUCT client_cs;
3381 HWND mdi_frame, mdi_child, mdi_child2, active_child;
3384 HMENU hMenu = CreateMenu();
3386 if (!mdi_RegisterWindowClasses()) assert(0);
3390 trace("creating MDI frame window\n");
3391 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3392 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
3393 WS_MAXIMIZEBOX | WS_VISIBLE,
3394 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
3395 GetDesktopWindow(), hMenu,
3396 GetModuleHandleA(0), NULL);
3398 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
3400 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3401 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
3403 trace("creating MDI client window\n");
3404 GetClientRect(mdi_frame, &rc);
3405 client_cs.hWindowMenu = 0;
3406 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
3407 mdi_client = CreateWindowExA(0, "MDI_client_class",
3409 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
3410 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
3411 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3413 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
3415 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3416 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
3418 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3419 ok(!active_child, "wrong active MDI child %p\n", active_child);
3420 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3425 trace("creating invisible MDI child window\n");
3426 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3428 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3429 mdi_client, 0, GetModuleHandleA(0), NULL);
3433 ShowWindow(mdi_child, SW_SHOWNORMAL);
3434 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3436 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3437 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3439 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3440 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3442 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3443 ok(!active_child, "wrong active MDI child %p\n", active_child);
3444 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3446 ShowWindow(mdi_child, SW_HIDE);
3447 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3450 ShowWindow(mdi_child, SW_SHOW);
3451 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3453 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3454 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3456 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3457 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3459 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3460 ok(!active_child, "wrong active MDI child %p\n", active_child);
3461 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3463 DestroyWindow(mdi_child);
3466 trace("creating visible MDI child window\n");
3467 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3468 WS_CHILD | WS_VISIBLE,
3469 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3470 mdi_client, 0, GetModuleHandleA(0), NULL);
3472 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3474 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3475 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3477 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3478 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3480 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3481 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3482 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3485 DestroyWindow(mdi_child);
3486 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3488 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3489 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3491 /* Win2k: MDI client still returns a just destroyed child as active
3492 * Win9x: MDI client returns 0
3494 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3495 ok(active_child == mdi_child || /* win2k */
3496 !active_child, /* win9x */
3497 "wrong active MDI child %p\n", active_child);
3498 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3502 trace("creating invisible MDI child window\n");
3503 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3505 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3506 mdi_client, 0, GetModuleHandleA(0), NULL);
3508 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3510 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3511 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3513 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3514 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3516 /* Win2k: MDI client still returns a just destroyed child as active
3517 * Win9x: MDI client returns mdi_child2
3519 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3520 ok(active_child == mdi_child || /* win2k */
3521 active_child == mdi_child2, /* win9x */
3522 "wrong active MDI child %p\n", active_child);
3523 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3526 ShowWindow(mdi_child2, SW_MAXIMIZE);
3527 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3529 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3530 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3532 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3533 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3534 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3537 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3538 ok(GetFocus() == mdi_child2 || /* win2k */
3539 GetFocus() == 0, /* win9x */
3540 "wrong focus window %p\n", GetFocus());
3545 ShowWindow(mdi_child2, SW_HIDE);
3546 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3548 ShowWindow(mdi_child2, SW_RESTORE);
3549 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3552 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3553 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3555 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3556 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3557 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3563 ShowWindow(mdi_child2, SW_HIDE);
3564 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3566 ShowWindow(mdi_child2, SW_SHOW);
3567 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3569 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3570 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3572 ShowWindow(mdi_child2, SW_MAXIMIZE);
3573 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3575 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3576 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3578 ShowWindow(mdi_child2, SW_RESTORE);
3579 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3581 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3582 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3584 ShowWindow(mdi_child2, SW_MINIMIZE);
3585 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3587 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3588 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3590 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3591 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3592 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3595 ShowWindow(mdi_child2, SW_RESTORE);
3596 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE);
3598 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3599 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3601 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3602 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3603 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3609 ShowWindow(mdi_child2, SW_HIDE);
3610 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3612 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3613 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3615 DestroyWindow(mdi_child2);
3616 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3618 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3619 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3621 /* test for maximized MDI children */
3622 trace("creating maximized visible MDI child window 1\n");
3623 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3624 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3625 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3626 mdi_client, 0, GetModuleHandleA(0), NULL);
3628 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3629 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3631 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3632 ok(GetFocus() == mdi_child || /* win2k */
3633 GetFocus() == 0, /* win9x */
3634 "wrong focus window %p\n", GetFocus());
3636 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3637 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3638 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3641 trace("creating maximized visible MDI child window 2\n");
3642 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3643 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3644 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3645 mdi_client, 0, GetModuleHandleA(0), NULL);
3647 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3648 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3649 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3651 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3652 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3654 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3655 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3656 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3659 trace("destroying maximized visible MDI child window 2\n");
3660 DestroyWindow(mdi_child2);
3661 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3663 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3665 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3666 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3668 /* Win2k: MDI client still returns a just destroyed child as active
3669 * Win9x: MDI client returns 0
3671 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3672 ok(active_child == mdi_child2 || /* win2k */
3673 !active_child, /* win9x */
3674 "wrong active MDI child %p\n", active_child);
3677 ShowWindow(mdi_child, SW_MAXIMIZE);
3678 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3681 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3682 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3684 trace("re-creating maximized visible MDI child window 2\n");
3685 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3686 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3687 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3688 mdi_client, 0, GetModuleHandleA(0), NULL);
3690 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3691 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3692 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3694 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3695 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3697 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3698 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3699 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3702 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3703 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3704 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3706 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3707 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3708 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3710 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3711 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3712 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3715 DestroyWindow(mdi_child);
3716 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3718 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3719 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3721 /* Win2k: MDI client still returns a just destroyed child as active
3722 * Win9x: MDI client returns 0
3724 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3725 ok(active_child == mdi_child || /* win2k */
3726 !active_child, /* win9x */
3727 "wrong active MDI child %p\n", active_child);
3730 trace("creating maximized invisible MDI child window\n");
3731 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3732 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3733 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3734 mdi_client, 0, GetModuleHandleA(0), NULL);
3736 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", FALSE);
3737 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3738 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3739 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3741 /* Win2k: MDI client still returns a just destroyed child as active
3742 * Win9x: MDI client returns 0
3744 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3745 ok(active_child == mdi_child || /* win2k */
3746 !active_child || active_child == mdi_child2, /* win9x */
3747 "wrong active MDI child %p\n", active_child);
3750 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3751 ShowWindow(mdi_child2, SW_MAXIMIZE);
3752 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3753 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3754 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3755 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3757 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3758 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3759 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3762 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3765 /* end of test for maximized MDI children */
3768 trace("creating maximized visible MDI child window 1(Switch test)\n");
3769 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3770 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3771 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3772 mdi_client, 0, GetModuleHandleA(0), NULL);
3774 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3775 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3777 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3778 ok(GetFocus() == mdi_child || /* win2k */
3779 GetFocus() == 0, /* win9x */
3780 "wrong focus window %p(Switch test)\n", GetFocus());
3782 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3783 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3784 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3787 trace("creating maximized visible MDI child window 2(Switch test)\n");
3788 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3789 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3790 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3791 mdi_client, 0, GetModuleHandleA(0), NULL);
3793 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3795 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3796 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3798 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3799 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3801 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3802 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3803 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3806 trace("Switch child window.\n");
3807 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3808 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3809 trace("end of test for switch maximized MDI children\n");
3812 /* Prepare for switching test of not maximized MDI children */
3813 ShowWindow( mdi_child, SW_NORMAL );
3814 ok(!IsZoomed(mdi_child), "wrong zoomed state for %p(Switch test)\n", mdi_child);
3815 ok(!IsZoomed(mdi_child2), "wrong zoomed state for %p(Switch test)\n", mdi_child2);
3816 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
3817 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3820 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child2, 0);
3821 ok_sequence(WmSwitchNotMaximizedChild, "Not maximized child did not switch correctly", FALSE);
3822 trace("end of test for switch not maximized MDI children\n");
3825 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3828 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3833 /* end of tests for switch maximized/not maximized MDI children */
3835 mdi_cs.szClass = "MDI_child_Class";
3836 mdi_cs.szTitle = "MDI child";
3837 mdi_cs.hOwner = GetModuleHandleA(0);
3840 mdi_cs.cx = CW_USEDEFAULT;
3841 mdi_cs.cy = CW_USEDEFAULT;
3842 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3844 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3845 ok(mdi_child != 0, "MDI child creation failed\n");
3846 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3848 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3850 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3851 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3853 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3854 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3855 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3857 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3858 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3859 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3862 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3863 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3865 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3866 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3867 ok(!active_child, "wrong active MDI child %p\n", active_child);
3872 DestroyWindow(mdi_client);
3873 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3875 /* test maximization of MDI child with invisible parent */
3876 client_cs.hWindowMenu = 0;
3877 mdi_client = CreateWindow("MDI_client_class",
3879 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3881 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3882 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3884 ShowWindow(mdi_client, SW_HIDE);
3885 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3887 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3888 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3890 mdi_client, 0, GetModuleHandleA(0), NULL);
3891 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3893 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3894 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3895 zoomed = IsZoomed(mdi_child);
3896 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3898 ShowWindow(mdi_client, SW_SHOW);
3899 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3901 DestroyWindow(mdi_child);
3902 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3904 /* end of test for maximization of MDI child with invisible parent */
3906 DestroyWindow(mdi_client);
3907 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3909 DestroyWindow(mdi_frame);
3910 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3912 /************************* End of MDI test **********************************/
3914 static void test_WM_SETREDRAW(HWND hwnd)
3916 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3921 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3922 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3924 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3925 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3928 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3929 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3931 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3932 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3934 /* restore original WS_VISIBLE state */
3935 SetWindowLongA(hwnd, GWL_STYLE, style);
3941 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3943 struct recvd_message msg;
3945 if (ignore_message( message )) return 0;
3951 case WM_NCMOUSEMOVE:
3952 case WM_NCMOUSELEAVE:
3960 msg.message = message;
3961 msg.flags = sent|wparam|lparam;
3962 msg.wParam = wParam;
3963 msg.lParam = lParam;
3964 msg.descr = "dialog";
3967 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3968 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3972 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3974 DWORD style, exstyle;
3978 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3979 style = GetWindowLongA(hwnd, GWL_STYLE);
3980 /* do not be confused by WS_DLGFRAME set */
3981 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3983 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3984 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3986 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3987 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3988 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3989 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3991 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3993 style = GetWindowLongA(hwnd, GWL_STYLE);
3994 if (set) ok(style & set, "style %08x should be set\n", set);
3995 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3997 /* a subsequent call should do nothing */
3998 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3999 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
4000 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
4004 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
4005 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
4006 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
4007 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
4008 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
4011 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
4013 DWORD style, exstyle;
4017 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
4018 style = GetWindowLongA(hwnd, GWL_STYLE);
4019 /* do not be confused by WS_DLGFRAME set */
4020 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
4022 if (clear) ok(style & clear, "style %08x should be set\n", clear);
4023 if (set) ok(!(style & set), "style %08x should not be set\n", set);
4025 si.cbSize = sizeof(si);
4026 si.fMask = SIF_RANGE;
4029 SetScrollInfo(hwnd, ctl, &si, TRUE);
4030 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
4031 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
4033 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
4035 style = GetWindowLongA(hwnd, GWL_STYLE);
4036 if (set) ok(style & set, "style %08x should be set\n", set);
4037 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
4039 /* a subsequent call should do nothing */
4040 SetScrollInfo(hwnd, ctl, &si, TRUE);
4041 if (style & WS_HSCROLL)
4042 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4043 else if (style & WS_VSCROLL)
4044 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4046 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4048 si.fMask = SIF_PAGE;
4050 SetScrollInfo(hwnd, ctl, &si, FALSE);
4051 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4055 SetScrollInfo(hwnd, ctl, &si, FALSE);
4056 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4058 si.fMask = SIF_RANGE;
4059 si.nMin = 0xdeadbeef;
4060 si.nMax = 0xdeadbeef;
4061 ret = GetScrollInfo(hwnd, ctl, &si);
4062 ok( ret, "GetScrollInfo error %d\n", GetLastError());
4063 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
4064 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
4065 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
4068 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4069 static void test_scroll_messages(HWND hwnd)
4080 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
4081 ok( ret, "GetScrollRange error %d\n", GetLastError());
4082 if (sequence->message != WmGetScrollRangeSeq[0].message)
4083 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
4084 /* values of min and max are undefined */
4087 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
4088 ok( ret, "SetScrollRange error %d\n", GetLastError());
4089 if (sequence->message != WmSetScrollRangeSeq[0].message)
4090 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
4095 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
4096 ok( ret, "GetScrollRange error %d\n", GetLastError());
4097 if (sequence->message != WmGetScrollRangeSeq[0].message)
4098 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
4099 /* values of min and max are undefined */
4102 si.cbSize = sizeof(si);
4103 si.fMask = SIF_RANGE;
4106 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4107 if (sequence->message != WmSetScrollRangeSeq[0].message)
4108 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4111 si.fMask = SIF_PAGE;
4113 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4114 if (sequence->message != WmSetScrollRangeSeq[0].message)
4115 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4120 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4121 if (sequence->message != WmSetScrollRangeSeq[0].message)
4122 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4125 si.fMask = SIF_RANGE;
4126 si.nMin = 0xdeadbeef;
4127 si.nMax = 0xdeadbeef;
4128 ret = GetScrollInfo(hwnd, SB_CTL, &si);
4129 ok( ret, "GetScrollInfo error %d\n", GetLastError());
4130 if (sequence->message != WmGetScrollInfoSeq[0].message)
4131 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4132 /* values of min and max are undefined */
4135 /* set WS_HSCROLL */
4136 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
4137 /* clear WS_HSCROLL */
4138 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
4140 /* set WS_HSCROLL */
4141 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
4142 /* clear WS_HSCROLL */
4143 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
4145 /* set WS_VSCROLL */
4146 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
4147 /* clear WS_VSCROLL */
4148 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
4150 /* set WS_VSCROLL */
4151 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
4152 /* clear WS_VSCROLL */
4153 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
4156 static void test_showwindow(void)
4161 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4162 100, 100, 200, 200, 0, 0, 0, NULL);
4163 ok (hwnd != 0, "Failed to create overlapped window\n");
4164 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4165 0, 0, 10, 10, hwnd, 0, 0, NULL);
4166 ok (hchild != 0, "Failed to create child\n");
4169 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4170 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4171 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4172 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE);
4174 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4175 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4176 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4177 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
4178 /* back to invisible */
4179 ShowWindow(hchild, SW_HIDE);
4180 ShowWindow(hwnd, SW_HIDE);
4182 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4183 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4184 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4185 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
4186 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4187 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
4189 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4190 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4191 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
4192 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4193 ShowWindow( hwnd, SW_SHOW);
4195 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4196 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4197 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
4199 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4200 ShowWindow( hchild, SW_HIDE);
4202 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4203 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4204 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
4207 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
4208 DestroyWindow(hchild);
4209 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4211 DestroyWindow(hwnd);
4216 * 1. Create invisible maximized popup window.
4217 * 2. Move and resize it.
4218 * 3. Show it maximized.
4220 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4221 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
4222 100, 100, 200, 200, 0, 0, 0, NULL);
4223 ok (hwnd != 0, "Failed to create popup window\n");
4224 ok(IsZoomed(hwnd), "window should be maximized\n");
4225 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4227 GetWindowRect(hwnd, &rc);
4228 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
4229 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
4230 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4231 rc.left, rc.top, rc.right, rc.bottom);
4232 /* Reset window's size & position */
4233 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
4234 ok(IsZoomed(hwnd), "window should be maximized\n");
4237 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4238 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4239 ok(IsZoomed(hwnd), "window should be maximized\n");
4240 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
4242 GetWindowRect(hwnd, &rc);
4243 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
4244 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
4245 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4246 rc.left, rc.top, rc.right, rc.bottom);
4247 DestroyWindow(hwnd);
4251 * 1. Create invisible maximized popup window.
4252 * 2. Show it maximized.
4254 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4255 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
4256 100, 100, 200, 200, 0, 0, 0, NULL);
4257 ok (hwnd != 0, "Failed to create popup window\n");
4258 ok(IsZoomed(hwnd), "window should be maximized\n");
4259 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4261 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4262 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4263 ok(IsZoomed(hwnd), "window should be maximized\n");
4264 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
4265 DestroyWindow(hwnd);
4269 * 1. Create visible maximized popup window.
4271 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4272 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4273 100, 100, 200, 200, 0, 0, 0, NULL);
4274 ok (hwnd != 0, "Failed to create popup window\n");
4275 ok(IsZoomed(hwnd), "window should be maximized\n");
4276 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4277 DestroyWindow(hwnd);
4281 * 1. Create visible popup window.
4284 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4285 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
4286 100, 100, 200, 200, 0, 0, 0, NULL);
4287 ok (hwnd != 0, "Failed to create popup window\n");
4288 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
4289 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
4291 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4292 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4293 ok(IsZoomed(hwnd), "window should be maximized\n");
4294 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
4295 DestroyWindow(hwnd);
4299 static void test_sys_menu(void)
4305 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4306 100, 100, 200, 200, 0, 0, 0, NULL);
4307 ok (hwnd != 0, "Failed to create overlapped window\n");
4311 /* test existing window without CS_NOCLOSE style */
4312 hmenu = GetSystemMenu(hwnd, FALSE);
4313 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4315 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4316 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4317 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4319 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
4320 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4322 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4323 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4324 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
4326 EnableMenuItem(hmenu, SC_CLOSE, 0);
4327 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4329 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4330 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4331 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4333 /* test whether removing WS_SYSMENU destroys a system menu */
4334 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
4335 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4337 hmenu = GetSystemMenu(hwnd, FALSE);
4338 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4340 DestroyWindow(hwnd);
4342 /* test new window with CS_NOCLOSE style */
4343 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4344 100, 100, 200, 200, 0, 0, 0, NULL);
4345 ok (hwnd != 0, "Failed to create overlapped window\n");
4347 hmenu = GetSystemMenu(hwnd, FALSE);
4348 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4350 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4351 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4353 DestroyWindow(hwnd);
4355 /* test new window without WS_SYSMENU style */
4356 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
4357 100, 100, 200, 200, 0, 0, 0, NULL);
4358 ok(hwnd != 0, "Failed to create overlapped window\n");
4360 hmenu = GetSystemMenu(hwnd, FALSE);
4361 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
4363 DestroyWindow(hwnd);
4366 /* For shown WS_OVERLAPPEDWINDOW */
4367 static const struct message WmSetIcon_1[] = {
4368 { WM_SETICON, sent },
4369 { 0x00AE, sent|defwinproc|optional }, /* XP */
4370 { WM_GETTEXT, sent|defwinproc|optional },
4371 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
4375 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4376 static const struct message WmSetIcon_2[] = {
4377 { WM_SETICON, sent },
4381 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4382 static const struct message WmInitEndSession[] = {
4384 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4388 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4389 static const struct message WmInitEndSession_2[] = {
4391 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4395 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4396 static const struct message WmInitEndSession_3[] = {
4398 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4402 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4403 static const struct message WmInitEndSession_4[] = {
4405 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4409 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4410 static const struct message WmInitEndSession_5[] = {
4412 { WM_ENDSESSION, sent|defwinproc/*|wparam*/|lparam, 1, ENDSESSION_LOGOFF },
4416 static const struct message WmOptionalPaint[] = {
4417 { WM_PAINT, sent|optional },
4418 { WM_NCPAINT, sent|beginpaint|optional },
4419 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4420 { WM_ERASEBKGND, sent|beginpaint|optional },
4424 static const struct message WmZOrder[] = {
4425 { WM_WINDOWPOSCHANGING, sent|wparam, 0, 0 },
4426 { WM_GETMINMAXINFO, sent|defwinproc|wparam, 0, 0 },
4427 { HCBT_ACTIVATE, hook },
4428 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
4429 { WM_WINDOWPOSCHANGING, sent|wparam, 3, 0 },
4430 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0 },
4431 { WM_GETTEXT, sent|optional },
4432 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
4433 { WM_ACTIVATEAPP, sent|wparam, 1, 0 },
4434 { WM_NCACTIVATE, sent|lparam, 1, 0 },
4435 { WM_GETTEXT, sent|defwinproc|optional },
4436 { WM_GETTEXT, sent|defwinproc|optional },
4437 { WM_ACTIVATE, sent|wparam|lparam, 1, 0 },
4438 { HCBT_SETFOCUS, hook },
4439 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4440 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4441 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4442 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
4443 { WM_GETTEXT, sent|optional },
4444 { WM_NCCALCSIZE, sent|optional },
4448 static void test_MsgWaitForMultipleObjects(HWND hwnd)
4453 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4454 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4456 PostMessageA(hwnd, WM_USER, 0, 0);
4458 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4459 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4461 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4462 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4464 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4465 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4467 PostMessageA(hwnd, WM_USER, 0, 0);
4469 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4470 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4472 ok(PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4473 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4475 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4476 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4477 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4479 PostMessageA(hwnd, WM_USER, 0, 0);
4481 /* new incoming message causes it to become signaled again */
4482 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4483 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4485 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4486 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4487 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4488 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4491 /* test if we receive the right sequence of messages */
4492 static void test_messages(void)
4494 HWND hwnd, hparent, hchild;
4495 HWND hchild2, hbutton;
4502 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4503 100, 100, 200, 200, 0, 0, 0, NULL);
4504 ok (hwnd != 0, "Failed to create overlapped window\n");
4505 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4507 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4508 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4509 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4511 /* test WM_SETREDRAW on a not visible top level window */
4512 test_WM_SETREDRAW(hwnd);
4514 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4516 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4517 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4519 ok(GetActiveWindow() == hwnd, "window should be active\n");
4520 ok(GetFocus() == hwnd, "window should have input focus\n");
4521 ShowWindow(hwnd, SW_HIDE);
4523 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4525 ShowWindow(hwnd, SW_SHOW);
4527 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4529 ShowWindow(hwnd, SW_HIDE);
4531 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4533 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4535 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4538 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MAXIMIZE)
4540 ShowWindow(hwnd, SW_RESTORE);
4542 ok_sequence(WmShowRestoreMaxOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", TRUE);
4546 ShowWindow(hwnd, SW_MINIMIZE);
4548 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4551 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MINIMIZE)
4553 ShowWindow(hwnd, SW_RESTORE);
4555 ok_sequence(WmShowRestoreMinOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", TRUE);
4559 ShowWindow(hwnd, SW_SHOW);
4561 ok_sequence(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4563 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4564 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4565 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4566 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4568 /* test WM_SETREDRAW on a visible top level window */
4569 ShowWindow(hwnd, SW_SHOW);
4571 test_WM_SETREDRAW(hwnd);
4573 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4574 test_scroll_messages(hwnd);
4576 /* test resizing and moving */
4577 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4578 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4581 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4582 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4585 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER|SWP_NOACTIVATE );
4586 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4590 /* popups don't get WM_GETMINMAXINFO */
4591 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4592 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4594 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4595 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4597 DestroyWindow(hwnd);
4598 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4600 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4601 100, 100, 200, 200, 0, 0, 0, NULL);
4602 ok (hparent != 0, "Failed to create parent window\n");
4605 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4606 0, 0, 10, 10, hparent, 0, 0, NULL);
4607 ok (hchild != 0, "Failed to create child window\n");
4608 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4609 DestroyWindow(hchild);
4612 /* visible child window with a caption */
4613 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4614 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4615 0, 0, 10, 10, hparent, 0, 0, NULL);
4616 ok (hchild != 0, "Failed to create child window\n");
4617 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4619 trace("testing scroll APIs on a visible child window %p\n", hchild);
4620 test_scroll_messages(hchild);
4622 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4623 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4625 DestroyWindow(hchild);
4628 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4629 0, 0, 10, 10, hparent, 0, 0, NULL);
4630 ok (hchild != 0, "Failed to create child window\n");
4631 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4633 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4634 100, 100, 50, 50, hparent, 0, 0, NULL);
4635 ok (hchild2 != 0, "Failed to create child2 window\n");
4638 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4639 0, 100, 50, 50, hchild, 0, 0, NULL);
4640 ok (hbutton != 0, "Failed to create button window\n");
4642 /* test WM_SETREDRAW on a not visible child window */
4643 test_WM_SETREDRAW(hchild);
4645 ShowWindow(hchild, SW_SHOW);
4646 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4648 /* check parent messages too */
4649 log_all_parent_messages++;
4650 ShowWindow(hchild, SW_HIDE);
4651 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4652 log_all_parent_messages--;
4654 ShowWindow(hchild, SW_SHOW);
4655 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4657 ShowWindow(hchild, SW_HIDE);
4658 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4660 ShowWindow(hchild, SW_SHOW);
4661 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4663 /* test WM_SETREDRAW on a visible child window */
4664 test_WM_SETREDRAW(hchild);
4666 log_all_parent_messages++;
4667 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4668 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4669 log_all_parent_messages--;
4671 ShowWindow(hchild, SW_HIDE);
4673 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4674 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4676 ShowWindow(hchild, SW_HIDE);
4678 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4679 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4681 /* DestroyWindow sequence below expects that a child has focus */
4685 DestroyWindow(hchild);
4686 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4687 DestroyWindow(hchild2);
4688 DestroyWindow(hbutton);
4691 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4692 0, 0, 100, 100, hparent, 0, 0, NULL);
4693 ok (hchild != 0, "Failed to create child popup window\n");
4694 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4695 DestroyWindow(hchild);
4697 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4699 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4700 0, 0, 100, 100, hparent, 0, 0, NULL);
4701 ok (hchild != 0, "Failed to create popup window\n");
4702 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4703 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4704 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4706 ShowWindow(hchild, SW_SHOW);
4707 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4709 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4710 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4712 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4713 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
4714 DestroyWindow(hchild);
4716 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4717 * changes nothing in message sequences.
4720 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4721 0, 0, 100, 100, hparent, 0, 0, NULL);
4722 ok (hchild != 0, "Failed to create popup window\n");
4723 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4724 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4725 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4727 ShowWindow(hchild, SW_SHOW);
4728 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4730 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4731 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4732 DestroyWindow(hchild);
4735 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4736 0, 0, 100, 100, hparent, 0, 0, NULL);
4737 ok(hwnd != 0, "Failed to create custom dialog window\n");
4738 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4741 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4742 test_scroll_messages(hwnd);
4748 SendMessage(hwnd, WM_NULL, 0, 0);
4751 after_end_dialog = 1;
4752 EndDialog( hwnd, 0 );
4753 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4755 DestroyWindow(hwnd);
4756 after_end_dialog = 0;
4759 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4760 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4761 ok(hwnd != 0, "Failed to create custom dialog window\n");
4763 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4764 ShowWindow(hwnd, SW_SHOW);
4765 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4766 DestroyWindow(hwnd);
4769 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4770 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4772 DestroyWindow(hparent);
4775 /* Message sequence for SetMenu */
4776 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4777 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4779 hmenu = CreateMenu();
4780 ok (hmenu != 0, "Failed to create menu\n");
4781 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4782 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4783 100, 100, 200, 200, 0, hmenu, 0, NULL);
4784 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4785 ok (SetMenu(hwnd, 0), "SetMenu\n");
4786 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4787 ok (SetMenu(hwnd, 0), "SetMenu\n");
4788 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4789 ShowWindow(hwnd, SW_SHOW);
4790 UpdateWindow( hwnd );
4793 ok (SetMenu(hwnd, 0), "SetMenu\n");
4794 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4795 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4796 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4798 UpdateWindow( hwnd );
4801 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4803 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4805 DestroyWindow(hwnd);
4808 /* Message sequence for EnableWindow */
4809 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4810 100, 100, 200, 200, 0, 0, 0, NULL);
4811 ok (hparent != 0, "Failed to create parent window\n");
4812 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4813 0, 0, 10, 10, hparent, 0, 0, NULL);
4814 ok (hchild != 0, "Failed to create child window\n");
4820 EnableWindow(hparent, FALSE);
4821 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4823 EnableWindow(hparent, TRUE);
4824 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4829 test_MsgWaitForMultipleObjects(hparent);
4831 /* the following test causes an exception in user.exe under win9x */
4832 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4834 DestroyWindow(hparent);
4838 PostMessageW( hparent, WM_USER+1, 0, 0 );
4839 /* PeekMessage(NULL) fails, but still removes the message */
4840 SetLastError(0xdeadbeef);
4841 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4842 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4843 GetLastError() == 0xdeadbeef, /* NT4 */
4844 "last error is %d\n", GetLastError() );
4845 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4846 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4848 DestroyWindow(hchild);
4849 DestroyWindow(hparent);
4852 /* Message sequences for WM_SETICON */
4853 trace("testing WM_SETICON\n");
4854 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4855 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4857 ShowWindow(hwnd, SW_SHOW);
4861 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4862 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4864 ShowWindow(hwnd, SW_HIDE);
4867 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4868 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4869 DestroyWindow(hwnd);
4872 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4873 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4875 ShowWindow(hwnd, SW_SHOW);
4879 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4880 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4882 ShowWindow(hwnd, SW_HIDE);
4885 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4886 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4889 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4892 todo_wine win_skip( "Message 0x3b not supported\n" );
4895 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4896 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4897 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4898 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4899 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4900 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4901 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4902 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4905 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4906 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4907 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4908 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4909 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4910 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4912 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4913 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4914 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4916 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4917 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4918 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4921 DestroyWindow(hwnd);
4925 static void test_setwindowpos(void)
4930 const INT winX = 100;
4931 const INT winY = 100;
4932 const INT sysX = GetSystemMetrics(SM_CXMINTRACK);
4934 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0,
4935 0, 0, winX, winY, 0,
4938 GetWindowRect(hwnd, &rc);
4939 expect(sysX, rc.right);
4940 expect(winY, rc.bottom);
4944 res = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, winX, winY, 0);
4945 ok_sequence(WmZOrder, "Z-Order", TRUE);
4946 ok(res == TRUE, "SetWindowPos expected TRUE, got %ld\n", res);
4948 GetWindowRect(hwnd, &rc);
4949 expect(sysX, rc.right);
4950 expect(winY, rc.bottom);
4951 DestroyWindow(hwnd);
4954 static void invisible_parent_tests(void)
4956 HWND hparent, hchild;
4958 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4959 100, 100, 200, 200, 0, 0, 0, NULL);
4960 ok (hparent != 0, "Failed to create parent window\n");
4963 /* test showing child with hidden parent */
4965 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4966 0, 0, 10, 10, hparent, 0, 0, NULL);
4967 ok (hchild != 0, "Failed to create child window\n");
4968 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4970 ShowWindow( hchild, SW_MINIMIZE );
4971 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4972 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4973 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4978 ShowWindow( hchild, SW_MINIMIZE );
4979 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4981 DestroyWindow(hchild);
4982 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4983 0, 0, 10, 10, hparent, 0, 0, NULL);
4986 ShowWindow( hchild, SW_MAXIMIZE );
4987 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4988 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4989 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4994 ShowWindow( hchild, SW_MAXIMIZE );
4995 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4997 DestroyWindow(hchild);
4998 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4999 0, 0, 10, 10, hparent, 0, 0, NULL);
5002 ShowWindow( hchild, SW_RESTORE );
5003 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
5004 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5005 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5007 DestroyWindow(hchild);
5008 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5009 0, 0, 10, 10, hparent, 0, 0, NULL);
5012 ShowWindow( hchild, SW_SHOWMINIMIZED );
5013 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
5014 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5015 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5020 ShowWindow( hchild, SW_SHOWMINIMIZED );
5021 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
5023 DestroyWindow(hchild);
5024 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5025 0, 0, 10, 10, hparent, 0, 0, NULL);
5028 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5029 ShowWindow( hchild, SW_SHOWMAXIMIZED );
5030 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
5031 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5032 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5034 DestroyWindow(hchild);
5035 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5036 0, 0, 10, 10, hparent, 0, 0, NULL);
5039 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
5040 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
5041 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5042 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5047 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
5048 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
5050 DestroyWindow(hchild);
5051 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5052 0, 0, 10, 10, hparent, 0, 0, NULL);
5055 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5056 ShowWindow( hchild, SW_FORCEMINIMIZE );
5057 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
5059 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
5061 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5063 DestroyWindow(hchild);
5064 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5065 0, 0, 10, 10, hparent, 0, 0, NULL);
5068 ShowWindow( hchild, SW_SHOWNA );
5069 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
5070 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5071 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5076 ShowWindow( hchild, SW_SHOWNA );
5077 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
5079 DestroyWindow(hchild);
5080 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5081 0, 0, 10, 10, hparent, 0, 0, NULL);
5084 ShowWindow( hchild, SW_SHOW );
5085 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
5086 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5087 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5092 ShowWindow( hchild, SW_SHOW );
5093 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
5095 ShowWindow( hchild, SW_HIDE );
5096 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
5097 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
5098 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5100 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
5101 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
5102 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5103 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5105 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
5106 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
5107 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
5108 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5110 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
5112 DestroyWindow(hchild);
5113 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
5115 DestroyWindow(hparent);
5119 /****************** button message test *************************/
5120 #define ID_BUTTON 0x000e
5122 static const struct message WmSetFocusButtonSeq[] =
5124 { HCBT_SETFOCUS, hook },
5125 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5126 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5127 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5128 { WM_SETFOCUS, sent|wparam, 0 },
5129 { WM_CTLCOLORBTN, sent|parent },
5130 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
5131 { WM_APP, sent|wparam|lparam, 0, 0 },
5134 static const struct message WmKillFocusButtonSeq[] =
5136 { HCBT_SETFOCUS, hook },
5137 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5138 { WM_KILLFOCUS, sent|wparam, 0 },
5139 { WM_CTLCOLORBTN, sent|parent },
5140 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_KILLFOCUS) },
5141 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5142 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5143 { WM_APP, sent|wparam|lparam, 0, 0 },
5145 { WM_CTLCOLORBTN, sent|parent },
5148 static const struct message WmSetFocusStaticSeq[] =
5150 { HCBT_SETFOCUS, hook },
5151 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5152 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5153 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5154 { WM_SETFOCUS, sent|wparam, 0 },
5155 { WM_CTLCOLORSTATIC, sent|parent },
5156 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
5157 { WM_COMMAND, sent|wparam|parent|optional, MAKEWPARAM(ID_BUTTON, BN_CLICKED) }, /* radio button */
5158 { WM_APP, sent|wparam|lparam, 0, 0 },
5161 static const struct message WmKillFocusStaticSeq[] =
5163 { HCBT_SETFOCUS, hook },
5164 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5165 { WM_KILLFOCUS, sent|wparam, 0 },
5166 { WM_CTLCOLORSTATIC, sent|parent },
5167 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_KILLFOCUS) },
5168 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5169 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5170 { WM_APP, sent|wparam|lparam, 0, 0 },
5172 { WM_CTLCOLORSTATIC, sent|parent },
5175 static const struct message WmSetFocusOwnerdrawSeq[] =
5177 { HCBT_SETFOCUS, hook },
5178 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5179 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5180 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5181 { WM_SETFOCUS, sent|wparam, 0 },
5182 { WM_CTLCOLORBTN, sent|parent },
5183 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x001040e4 },
5184 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
5185 { WM_APP, sent|wparam|lparam, 0, 0 },
5188 static const struct message WmKillFocusOwnerdrawSeq[] =
5190 { HCBT_SETFOCUS, hook },
5191 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5192 { WM_KILLFOCUS, sent|wparam, 0 },
5193 { WM_CTLCOLORBTN, sent|parent },
5194 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000040e4 },
5195 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_KILLFOCUS) },
5196 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5197 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5198 { WM_APP, sent|wparam|lparam, 0, 0 },
5200 { WM_CTLCOLORBTN, sent|parent },
5201 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000010e4 },
5204 static const struct message WmLButtonDownSeq[] =
5206 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
5207 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5208 { HCBT_SETFOCUS, hook },
5209 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
5210 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5211 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5212 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
5213 { WM_CTLCOLORBTN, sent|defwinproc },
5214 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
5215 { WM_CTLCOLORBTN, sent|defwinproc },
5216 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5219 static const struct message WmLButtonUpSeq[] =
5221 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
5222 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
5223 { WM_CTLCOLORBTN, sent|defwinproc },
5224 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5225 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
5226 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
5229 static const struct message WmSetFontButtonSeq[] =
5231 { WM_SETFONT, sent },
5233 { WM_ERASEBKGND, sent|defwinproc|optional },
5234 { WM_CTLCOLORBTN, sent|defwinproc },
5237 static const struct message WmSetStyleButtonSeq[] =
5239 { BM_SETSTYLE, sent },
5240 { WM_APP, sent|wparam|lparam, 0, 0 },
5242 { WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
5243 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5244 { WM_CTLCOLORBTN, sent|parent },
5247 static const struct message WmSetStyleStaticSeq[] =
5249 { BM_SETSTYLE, sent },
5250 { WM_APP, sent|wparam|lparam, 0, 0 },
5252 { WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
5253 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5254 { WM_CTLCOLORSTATIC, sent|parent },
5257 static const struct message WmSetStyleUserSeq[] =
5259 { BM_SETSTYLE, sent },
5260 { WM_APP, sent|wparam|lparam, 0, 0 },
5262 { WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
5263 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5264 { WM_CTLCOLORBTN, sent|parent },
5265 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_PAINT) },
5268 static const struct message WmSetStyleOwnerdrawSeq[] =
5270 { BM_SETSTYLE, sent },
5271 { WM_APP, sent|wparam|lparam, 0, 0 },
5273 { WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
5274 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5275 { WM_CTLCOLORBTN, sent|parent },
5276 { WM_CTLCOLORBTN, sent|parent|optional }, /* Win9x doesn't send it */
5277 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000010e4 },
5280 static const struct message WmSetStateButtonSeq[] =
5282 { BM_SETSTATE, sent },
5283 { WM_CTLCOLORBTN, sent|parent },
5284 { WM_APP, sent|wparam|lparam, 0, 0 },
5287 static const struct message WmSetStateStaticSeq[] =
5289 { BM_SETSTATE, sent },
5290 { WM_CTLCOLORSTATIC, sent|parent },
5291 { WM_APP, sent|wparam|lparam, 0, 0 },
5294 static const struct message WmSetStateUserSeq[] =
5296 { BM_SETSTATE, sent },
5297 { WM_CTLCOLORBTN, sent|parent },
5298 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_HILITE) },
5299 { WM_APP, sent|wparam|lparam, 0, 0 },
5302 static const struct message WmSetStateOwnerdrawSeq[] =
5304 { BM_SETSTATE, sent },
5305 { WM_CTLCOLORBTN, sent|parent },
5306 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000120e4 },
5307 { WM_APP, sent|wparam|lparam, 0, 0 },
5310 static const struct message WmClearStateButtonSeq[] =
5312 { BM_SETSTATE, sent },
5313 { WM_CTLCOLORBTN, sent|parent },
5314 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_UNHILITE) },
5315 { WM_APP, sent|wparam|lparam, 0, 0 },
5318 static const struct message WmClearStateOwnerdrawSeq[] =
5320 { BM_SETSTATE, sent },
5321 { WM_CTLCOLORBTN, sent|parent },
5322 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000020e4 },
5323 { WM_APP, sent|wparam|lparam, 0, 0 },
5326 static const struct message WmSetCheckIgnoredSeq[] =
5328 { BM_SETCHECK, sent },
5329 { WM_APP, sent|wparam|lparam, 0, 0 },
5332 static const struct message WmSetCheckStaticSeq[] =
5334 { BM_SETCHECK, sent },
5335 { WM_CTLCOLORSTATIC, sent|parent },
5336 { WM_APP, sent|wparam|lparam, 0, 0 },
5340 static WNDPROC old_button_proc;
5342 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5344 static LONG defwndproc_counter = 0;
5346 struct recvd_message msg;
5348 if (ignore_message( message )) return 0;
5356 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
5360 msg.message = message;
5361 msg.flags = sent|wparam|lparam;
5362 if (defwndproc_counter) msg.flags |= defwinproc;
5363 msg.wParam = wParam;
5364 msg.lParam = lParam;
5365 msg.descr = "button";
5369 defwndproc_counter++;
5370 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
5371 defwndproc_counter--;
5376 static void subclass_button(void)
5380 if (!GetClassInfoA(0, "button", &cls)) assert(0);
5382 old_button_proc = cls.lpfnWndProc;
5384 cls.hInstance = GetModuleHandle(0);
5385 cls.lpfnWndProc = button_hook_proc;
5386 cls.lpszClassName = "my_button_class";
5387 UnregisterClass(cls.lpszClassName, cls.hInstance);
5388 if (!RegisterClassA(&cls)) assert(0);
5391 static void test_button_messages(void)
5397 const struct message *setfocus;
5398 const struct message *killfocus;
5399 const struct message *setstyle;
5400 const struct message *setstate;
5401 const struct message *clearstate;
5402 const struct message *setcheck;
5404 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
5405 WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleButtonSeq,
5406 WmSetStateButtonSeq, WmSetStateButtonSeq, WmSetCheckIgnoredSeq },
5407 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
5408 WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleButtonSeq,
5409 WmSetStateButtonSeq, WmSetStateButtonSeq, WmSetCheckIgnoredSeq },
5410 { BS_CHECKBOX, DLGC_BUTTON,
5411 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5412 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5413 { BS_AUTOCHECKBOX, DLGC_BUTTON,
5414 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5415 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5416 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
5417 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5418 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5419 { BS_3STATE, DLGC_BUTTON,
5420 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5421 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5422 { BS_AUTO3STATE, DLGC_BUTTON,
5423 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5424 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5425 { BS_GROUPBOX, DLGC_STATIC,
5426 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5427 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckIgnoredSeq },
5428 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
5429 WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleUserSeq,
5430 WmSetStateUserSeq, WmClearStateButtonSeq, WmSetCheckIgnoredSeq },
5431 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
5432 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5433 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5434 { BS_OWNERDRAW, DLGC_BUTTON,
5435 WmSetFocusOwnerdrawSeq, WmKillFocusOwnerdrawSeq, WmSetStyleOwnerdrawSeq,
5436 WmSetStateOwnerdrawSeq, WmClearStateOwnerdrawSeq, WmSetCheckIgnoredSeq },
5443 /* selection with VK_SPACE should capture button window */
5444 hwnd = CreateWindowExA(0, "button", "test", BS_CHECKBOX | WS_VISIBLE | WS_POPUP,
5445 0, 0, 50, 14, 0, 0, 0, NULL);
5446 ok(hwnd != 0, "Failed to create button window\n");
5449 SendMessageA(hwnd, WM_KEYDOWN, VK_SPACE, 0);
5450 ok(GetCapture() == hwnd, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5451 SendMessageA(hwnd, WM_KEYUP, VK_SPACE, 0);
5452 DestroyWindow(hwnd);
5456 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5457 100, 100, 200, 200, 0, 0, 0, NULL);
5458 ok(parent != 0, "Failed to create parent window\n");
5460 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
5465 trace("button style %08x\n", button[i].style);
5467 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_CHILD | BS_NOTIFY,
5468 0, 0, 50, 14, parent, (HMENU)ID_BUTTON, 0, NULL);
5469 ok(hwnd != 0, "Failed to create button window\n");
5471 style = GetWindowLongA(hwnd, GWL_STYLE);
5472 style &= ~(WS_CHILD | BS_NOTIFY);
5473 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5474 if (button[i].style == BS_USERBUTTON)
5475 ok(style == BS_PUSHBUTTON, "expected style BS_PUSHBUTTON got %x\n", style);
5477 ok(style == button[i].style, "expected style %x got %x\n", button[i].style, style);
5479 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5480 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5482 ShowWindow(hwnd, SW_SHOW);
5489 log_all_parent_messages++;
5491 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5493 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5494 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5495 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
5498 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5499 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5500 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
5502 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5504 SendMessage(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
5505 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5506 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5507 ok_sequence(button[i].setstyle, "BM_SETSTYLE on a button", FALSE);
5509 style = GetWindowLongA(hwnd, GWL_STYLE);
5510 style &= ~(WS_VISIBLE | WS_CHILD | BS_NOTIFY);
5511 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
5512 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5514 state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
5515 ok(state == 0, "expected state 0, got %04x\n", state);
5519 SendMessage(hwnd, BM_SETSTATE, TRUE, 0);
5520 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5521 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5522 ok_sequence(button[i].setstate, "BM_SETSTATE/TRUE on a button", FALSE);
5524 state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
5525 ok(state == 0x0004, "expected state 0x0004, got %04x\n", state);
5527 style = GetWindowLongA(hwnd, GWL_STYLE);
5528 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5529 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5533 SendMessage(hwnd, BM_SETSTATE, FALSE, 0);
5534 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5535 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5536 ok_sequence(button[i].clearstate, "BM_SETSTATE/FALSE on a button", FALSE);
5538 state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
5539 ok(state == 0, "expected state 0, got %04x\n", state);
5541 style = GetWindowLongA(hwnd, GWL_STYLE);
5542 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5543 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5545 state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
5546 ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state);
5550 SendMessage(hwnd, BM_SETCHECK, BST_UNCHECKED, 0);
5551 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5552 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5553 ok_sequence(WmSetCheckIgnoredSeq, "BM_SETCHECK on a button", FALSE);
5555 state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
5556 ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state);
5558 style = GetWindowLongA(hwnd, GWL_STYLE);
5559 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5560 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5564 SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0);
5565 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5566 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5567 ok_sequence(button[i].setcheck, "BM_SETCHECK on a button", FALSE);
5569 state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
5570 if (button[i].style == BS_PUSHBUTTON ||
5571 button[i].style == BS_DEFPUSHBUTTON ||
5572 button[i].style == BS_GROUPBOX ||
5573 button[i].style == BS_USERBUTTON ||
5574 button[i].style == BS_OWNERDRAW)
5575 ok(state == BST_UNCHECKED, "expected check 0, got %04x\n", state);
5577 ok(state == BST_CHECKED, "expected check 1, got %04x\n", state);
5579 style = GetWindowLongA(hwnd, GWL_STYLE);
5580 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5581 if (button[i].style == BS_RADIOBUTTON ||
5582 button[i].style == BS_AUTORADIOBUTTON)
5583 ok(style == (button[i].style | WS_TABSTOP), "expected style %04x | WS_TABSTOP got %04x\n", button[i].style, style);
5585 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5587 log_all_parent_messages--;
5589 DestroyWindow(hwnd);
5592 DestroyWindow(parent);
5594 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
5595 0, 0, 50, 14, 0, 0, 0, NULL);
5596 ok(hwnd != 0, "Failed to create button window\n");
5598 SetForegroundWindow(hwnd);
5601 SetActiveWindow(hwnd);
5605 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
5606 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
5608 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
5609 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
5612 zfont = GetStockObject(SYSTEM_FONT);
5613 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
5615 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
5617 DestroyWindow(hwnd);
5620 /****************** static message test *************************/
5621 static const struct message WmSetFontStaticSeq[] =
5623 { WM_SETFONT, sent },
5624 { WM_PAINT, sent|defwinproc|optional },
5625 { WM_ERASEBKGND, sent|defwinproc|optional },
5626 { WM_CTLCOLORSTATIC, sent|defwinproc|optional },
5630 static WNDPROC old_static_proc;
5632 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5634 static LONG defwndproc_counter = 0;
5636 struct recvd_message msg;
5638 if (ignore_message( message )) return 0;
5641 msg.message = message;
5642 msg.flags = sent|wparam|lparam;
5643 if (defwndproc_counter) msg.flags |= defwinproc;
5644 msg.wParam = wParam;
5645 msg.lParam = lParam;
5646 msg.descr = "static";
5649 defwndproc_counter++;
5650 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
5651 defwndproc_counter--;
5656 static void subclass_static(void)
5660 if (!GetClassInfoA(0, "static", &cls)) assert(0);
5662 old_static_proc = cls.lpfnWndProc;
5664 cls.hInstance = GetModuleHandle(0);
5665 cls.lpfnWndProc = static_hook_proc;
5666 cls.lpszClassName = "my_static_class";
5667 UnregisterClass(cls.lpszClassName, cls.hInstance);
5668 if (!RegisterClassA(&cls)) assert(0);
5671 static void test_static_messages(void)
5673 /* FIXME: make as comprehensive as the button message test */
5678 const struct message *setfont;
5680 { SS_LEFT, DLGC_STATIC,
5681 WmSetFontStaticSeq }
5689 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
5691 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
5692 0, 0, 50, 14, 0, 0, 0, NULL);
5693 ok(hwnd != 0, "Failed to create static window\n");
5695 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5696 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5698 ShowWindow(hwnd, SW_SHOW);
5703 trace("static style %08x\n", static_ctrl[i].style);
5704 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
5705 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
5707 DestroyWindow(hwnd);
5711 /****************** ComboBox message test *************************/
5712 #define ID_COMBOBOX 0x000f
5714 static const struct message WmKeyDownComboSeq[] =
5716 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
5717 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
5718 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
5719 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
5720 { WM_CTLCOLOREDIT, sent|parent },
5721 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
5725 static const struct message WmSetPosComboSeq[] =
5727 { WM_WINDOWPOSCHANGING, sent },
5728 { WM_NCCALCSIZE, sent|wparam, TRUE },
5729 { WM_CHILDACTIVATE, sent },
5730 { WM_WINDOWPOSCHANGED, sent },
5731 { WM_MOVE, sent|defwinproc },
5732 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
5733 { WM_WINDOWPOSCHANGING, sent|defwinproc },
5734 { WM_NCCALCSIZE, sent|defwinproc|wparam, TRUE },
5735 { WM_WINDOWPOSCHANGED, sent|defwinproc },
5736 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
5740 static WNDPROC old_combobox_proc;
5742 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5744 static LONG defwndproc_counter = 0;
5746 struct recvd_message msg;
5748 /* do not log painting messages */
5749 if (message != WM_PAINT &&
5750 message != WM_NCPAINT &&
5751 message != WM_SYNCPAINT &&
5752 message != WM_ERASEBKGND &&
5753 message != WM_NCHITTEST &&
5754 message != WM_GETTEXT &&
5755 !ignore_message( message ))
5758 msg.message = message;
5759 msg.flags = sent|wparam|lparam;
5760 if (defwndproc_counter) msg.flags |= defwinproc;
5761 msg.wParam = wParam;
5762 msg.lParam = lParam;
5763 msg.descr = "combo";
5767 defwndproc_counter++;
5768 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
5769 defwndproc_counter--;
5774 static void subclass_combobox(void)
5778 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
5780 old_combobox_proc = cls.lpfnWndProc;
5782 cls.hInstance = GetModuleHandle(0);
5783 cls.lpfnWndProc = combobox_hook_proc;
5784 cls.lpszClassName = "my_combobox_class";
5785 UnregisterClass(cls.lpszClassName, cls.hInstance);
5786 if (!RegisterClassA(&cls)) assert(0);
5789 static void test_combobox_messages(void)
5794 subclass_combobox();
5796 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5797 100, 100, 200, 200, 0, 0, 0, NULL);
5798 ok(parent != 0, "Failed to create parent window\n");
5801 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
5802 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
5803 ok(combo != 0, "Failed to create combobox window\n");
5805 UpdateWindow(combo);
5807 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5808 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5810 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5811 ok(ret == 0, "expected 0, got %ld\n", ret);
5812 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5813 ok(ret == 1, "expected 1, got %ld\n", ret);
5814 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5815 ok(ret == 2, "expected 2, got %ld\n", ret);
5817 SendMessage(combo, CB_SETCURSEL, 0, 0);
5821 log_all_parent_messages++;
5822 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5823 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5824 log_all_parent_messages--;
5825 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5828 SetWindowPos(combo, 0, 10, 10, 120, 130, SWP_NOZORDER);
5829 ok_sequence(WmSetPosComboSeq, "repositioning messages on a ComboBox", FALSE);
5831 DestroyWindow(combo);
5832 DestroyWindow(parent);
5835 /****************** WM_IME_KEYDOWN message test *******************/
5837 static const struct message WmImeKeydownMsgSeq_0[] =
5839 { WM_IME_KEYDOWN, wparam, VK_RETURN },
5840 { WM_CHAR, wparam, 'A' },
5844 static const struct message WmImeKeydownMsgSeq_1[] =
5846 { WM_KEYDOWN, optional|wparam, VK_RETURN },
5847 { WM_CHAR, optional|wparam, VK_RETURN },
5851 static LRESULT WINAPI wmime_keydown_procA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5853 struct recvd_message msg;
5856 msg.message = message;
5857 msg.flags = wparam|lparam;
5858 msg.wParam = wParam;
5859 msg.lParam = lParam;
5860 msg.descr = "wmime_keydown";
5863 return DefWindowProcA(hwnd, message, wParam, lParam);
5866 static void register_wmime_keydown_class(void)
5870 ZeroMemory(&cls, sizeof(WNDCLASSA));
5871 cls.lpfnWndProc = wmime_keydown_procA;
5872 cls.hInstance = GetModuleHandleA(0);
5873 cls.lpszClassName = "wmime_keydown_class";
5874 if (!RegisterClassA(&cls)) assert(0);
5877 static void test_wmime_keydown_message(void)
5882 trace("Message sequences by WM_IME_KEYDOWN\n");
5884 register_wmime_keydown_class();
5885 hwnd = CreateWindowExA(0, "wmime_keydown_class", NULL, WS_OVERLAPPEDWINDOW,
5886 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5891 SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
5892 SendMessage(hwnd, WM_CHAR, 'A', 1);
5893 ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
5895 while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
5897 TranslateMessage(&msg);
5898 DispatchMessage(&msg);
5900 ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
5902 DestroyWindow(hwnd);
5905 /************* painting message test ********************/
5907 void dump_region(HRGN hrgn)
5910 RGNDATA *data = NULL;
5915 printf( "null region\n" );
5918 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5919 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5920 GetRegionData( hrgn, size, data );
5921 printf("%d rects:", data->rdh.nCount );
5922 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5923 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5925 HeapFree( GetProcessHeap(), 0, data );
5928 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5932 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5933 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5935 ret = GetUpdateRgn( hwnd, update, FALSE );
5936 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5937 if (ret == NULLREGION)
5939 ok( !hrgn, "Update region shouldn't be empty\n" );
5943 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5945 ok( 0, "Regions are different\n" );
5946 if (winetest_debug > 0)
5948 printf( "Update region: " );
5949 dump_region( update );
5950 printf( "Wanted region: " );
5951 dump_region( hrgn );
5955 GetRgnBox( update, &r1 );
5956 GetUpdateRect( hwnd, &r2, FALSE );
5957 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5958 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5959 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5961 DeleteObject( tmp );
5962 DeleteObject( update );
5965 static const struct message WmInvalidateRgn[] = {
5966 { WM_NCPAINT, sent },
5967 { WM_GETTEXT, sent|defwinproc|optional },
5971 static const struct message WmGetUpdateRect[] = {
5972 { WM_NCPAINT, sent },
5973 { WM_GETTEXT, sent|defwinproc|optional },
5978 static const struct message WmInvalidateFull[] = {
5979 { WM_NCPAINT, sent|wparam, 1 },
5980 { WM_GETTEXT, sent|defwinproc|optional },
5984 static const struct message WmInvalidateErase[] = {
5985 { WM_NCPAINT, sent|wparam, 1 },
5986 { WM_GETTEXT, sent|defwinproc|optional },
5987 { WM_ERASEBKGND, sent },
5991 static const struct message WmInvalidatePaint[] = {
5993 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5994 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5998 static const struct message WmInvalidateErasePaint[] = {
6000 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
6001 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6002 { WM_ERASEBKGND, sent|beginpaint|optional },
6006 static const struct message WmInvalidateErasePaint2[] = {
6008 { WM_NCPAINT, sent|beginpaint },
6009 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6010 { WM_ERASEBKGND, sent|beginpaint|optional },
6014 static const struct message WmErase[] = {
6015 { WM_ERASEBKGND, sent },
6019 static const struct message WmPaint[] = {
6024 static const struct message WmParentOnlyPaint[] = {
6025 { WM_PAINT, sent|parent },
6029 static const struct message WmInvalidateParent[] = {
6030 { WM_NCPAINT, sent|parent },
6031 { WM_GETTEXT, sent|defwinproc|parent|optional },
6032 { WM_ERASEBKGND, sent|parent },
6036 static const struct message WmInvalidateParentChild[] = {
6037 { WM_NCPAINT, sent|parent },
6038 { WM_GETTEXT, sent|defwinproc|parent|optional },
6039 { WM_ERASEBKGND, sent|parent },
6040 { WM_NCPAINT, sent },
6041 { WM_GETTEXT, sent|defwinproc|optional },
6042 { WM_ERASEBKGND, sent },
6046 static const struct message WmInvalidateParentChild2[] = {
6047 { WM_ERASEBKGND, sent|parent },
6048 { WM_NCPAINT, sent },
6049 { WM_GETTEXT, sent|defwinproc|optional },
6050 { WM_ERASEBKGND, sent },
6054 static const struct message WmParentPaint[] = {
6055 { WM_PAINT, sent|parent },
6060 static const struct message WmParentPaintNc[] = {
6061 { WM_PAINT, sent|parent },
6063 { WM_NCPAINT, sent|beginpaint },
6064 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6065 { WM_ERASEBKGND, sent|beginpaint|optional },
6069 static const struct message WmChildPaintNc[] = {
6071 { WM_NCPAINT, sent|beginpaint },
6072 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6073 { WM_ERASEBKGND, sent|beginpaint|optional },
6077 static const struct message WmParentErasePaint[] = {
6078 { WM_PAINT, sent|parent },
6079 { WM_NCPAINT, sent|parent|beginpaint },
6080 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
6081 { WM_ERASEBKGND, sent|parent|beginpaint|optional },
6083 { WM_NCPAINT, sent|beginpaint },
6084 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6085 { WM_ERASEBKGND, sent|beginpaint|optional },
6089 static const struct message WmParentOnlyNcPaint[] = {
6090 { WM_PAINT, sent|parent },
6091 { WM_NCPAINT, sent|parent|beginpaint },
6092 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
6096 static const struct message WmSetParentStyle[] = {
6097 { WM_STYLECHANGING, sent|parent },
6098 { WM_STYLECHANGED, sent|parent },
6102 static void test_paint_messages(void)
6108 HWND hparent, hchild;
6109 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
6110 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
6111 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
6112 100, 100, 200, 200, 0, 0, 0, NULL);
6113 ok (hwnd != 0, "Failed to create overlapped window\n");
6115 ShowWindow( hwnd, SW_SHOW );
6116 UpdateWindow( hwnd );
6120 check_update_rgn( hwnd, 0 );
6121 SetRectRgn( hrgn, 10, 10, 20, 20 );
6122 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
6123 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6124 check_update_rgn( hwnd, hrgn );
6125 SetRectRgn( hrgn2, 20, 20, 30, 30 );
6126 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
6127 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6128 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
6129 check_update_rgn( hwnd, hrgn );
6130 /* validate everything */
6131 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
6132 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6133 check_update_rgn( hwnd, 0 );
6135 /* test empty region */
6136 SetRectRgn( hrgn, 10, 10, 10, 15 );
6137 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
6138 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6139 check_update_rgn( hwnd, 0 );
6140 /* test empty rect */
6141 SetRect( &rect, 10, 10, 10, 15 );
6142 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
6143 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6144 check_update_rgn( hwnd, 0 );
6146 /* flush pending messages */
6150 GetClientRect( hwnd, &rect );
6151 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
6152 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
6153 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6155 trace("testing InvalidateRect(0, NULL, FALSE)\n");
6156 SetRectEmpty( &rect );
6157 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
6158 check_update_rgn( hwnd, hrgn );
6159 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
6161 ok_sequence( WmPaint, "Paint", FALSE );
6162 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
6163 check_update_rgn( hwnd, 0 );
6165 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
6166 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6168 trace("testing ValidateRect(0, NULL)\n");
6169 SetRectEmpty( &rect );
6170 if (ValidateRect(0, &rect)) /* not supported on Win9x */
6172 check_update_rgn( hwnd, hrgn );
6173 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
6175 ok_sequence( WmPaint, "Paint", FALSE );
6176 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
6177 check_update_rgn( hwnd, 0 );
6180 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
6181 SetLastError(0xdeadbeef);
6182 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
6183 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
6184 "wrong error code %d\n", GetLastError());
6185 check_update_rgn( hwnd, 0 );
6187 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6189 trace("testing ValidateRgn(0, NULL)\n");
6190 SetLastError(0xdeadbeef);
6191 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
6192 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
6193 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6194 "wrong error code %d\n", GetLastError());
6195 check_update_rgn( hwnd, 0 );
6197 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6199 trace("testing UpdateWindow(NULL)\n");
6200 SetLastError(0xdeadbeef);
6201 ok(!UpdateWindow(NULL), "UpdateWindow(NULL) should fail\n");
6202 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
6203 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6204 "wrong error code %d\n", GetLastError());
6205 check_update_rgn( hwnd, 0 );
6207 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6209 /* now with frame */
6210 SetRectRgn( hrgn, -5, -5, 20, 20 );
6212 /* flush pending messages */
6215 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6216 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
6218 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
6219 check_update_rgn( hwnd, hrgn );
6222 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
6223 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
6226 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
6227 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
6229 GetClientRect( hwnd, &rect );
6230 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
6231 check_update_rgn( hwnd, hrgn );
6234 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
6235 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
6238 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
6239 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
6240 check_update_rgn( hwnd, 0 );
6243 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
6244 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
6245 check_update_rgn( hwnd, 0 );
6248 SetRectRgn( hrgn, 0, 0, 100, 100 );
6249 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
6250 SetRectRgn( hrgn, 0, 0, 50, 100 );
6251 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
6252 SetRectRgn( hrgn, 50, 0, 100, 100 );
6253 check_update_rgn( hwnd, hrgn );
6254 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
6255 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
6256 check_update_rgn( hwnd, 0 );
6259 SetRectRgn( hrgn, 0, 0, 100, 100 );
6260 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
6261 SetRectRgn( hrgn, 0, 0, 100, 50 );
6262 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
6263 ok_sequence( WmErase, "Erase", FALSE );
6264 SetRectRgn( hrgn, 0, 50, 100, 100 );
6265 check_update_rgn( hwnd, hrgn );
6268 SetRectRgn( hrgn, 0, 0, 100, 100 );
6269 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
6270 SetRectRgn( hrgn, 0, 0, 50, 50 );
6271 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
6272 ok_sequence( WmPaint, "Paint", FALSE );
6275 SetRectRgn( hrgn, -4, -4, -2, -2 );
6276 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6277 SetRectRgn( hrgn, -200, -200, -198, -198 );
6278 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
6279 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
6282 SetRectRgn( hrgn, -4, -4, -2, -2 );
6283 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6284 SetRectRgn( hrgn, -4, -4, -3, -3 );
6285 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
6286 SetRectRgn( hrgn, 0, 0, 1, 1 );
6287 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
6288 ok_sequence( WmPaint, "Paint", FALSE );
6291 SetRectRgn( hrgn, -4, -4, -1, -1 );
6292 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6293 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
6294 /* make sure no WM_PAINT was generated */
6296 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
6299 SetRectRgn( hrgn, -4, -4, -1, -1 );
6300 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6301 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6303 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
6305 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6306 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
6307 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
6308 ret = GetUpdateRect( hwnd, &rect, FALSE );
6309 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
6310 /* this will send WM_NCPAINT and validate the non client area */
6311 ret = GetUpdateRect( hwnd, &rect, TRUE );
6312 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
6314 DispatchMessage( &msg );
6316 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
6318 DestroyWindow( hwnd );
6320 /* now test with a child window */
6322 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
6323 100, 100, 200, 200, 0, 0, 0, NULL);
6324 ok (hparent != 0, "Failed to create parent window\n");
6326 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
6327 10, 10, 100, 100, hparent, 0, 0, NULL);
6328 ok (hchild != 0, "Failed to create child window\n");
6330 ShowWindow( hparent, SW_SHOW );
6331 UpdateWindow( hparent );
6332 UpdateWindow( hchild );
6335 log_all_parent_messages++;
6337 SetRect( &rect, 0, 0, 50, 50 );
6338 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6339 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
6340 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
6342 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6344 MapWindowPoints( hchild, hparent, &pt, 1 );
6345 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
6346 check_update_rgn( hchild, hrgn );
6347 SetRectRgn( hrgn, 0, 0, 50, 50 );
6348 check_update_rgn( hparent, hrgn );
6349 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6350 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
6351 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
6352 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
6355 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
6357 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
6358 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6359 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
6360 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
6361 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
6363 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6364 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
6365 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
6367 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
6369 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
6370 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6371 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
6373 /* flush all paint messages */
6377 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6378 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
6379 SetRectRgn( hrgn, 0, 0, 50, 50 );
6380 check_update_rgn( hparent, hrgn );
6381 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
6382 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6383 SetRectRgn( hrgn, 0, 0, 50, 50 );
6384 check_update_rgn( hparent, hrgn );
6386 /* flush all paint messages */
6388 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
6391 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6392 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6393 SetRectRgn( hrgn, 0, 0, 50, 50 );
6394 check_update_rgn( hparent, hrgn );
6395 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
6396 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6397 SetRectRgn( hrgn2, 10, 10, 50, 50 );
6398 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
6399 check_update_rgn( hparent, hrgn );
6400 /* flush all paint messages */
6404 /* same as above but parent gets completely validated */
6405 SetRect( &rect, 20, 20, 30, 30 );
6406 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6407 SetRectRgn( hrgn, 20, 20, 30, 30 );
6408 check_update_rgn( hparent, hrgn );
6409 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
6410 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6411 check_update_rgn( hparent, 0 ); /* no update region */
6413 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
6415 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6417 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6418 SetRectRgn( hrgn, 20, 20, 30, 30 );
6419 check_update_rgn( hparent, hrgn );
6420 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
6421 SetRectRgn( hrgn, 20, 20, 30, 30 );
6422 check_update_rgn( hparent, hrgn );
6424 /* same as above but normal WM_PAINT doesn't validate parent */
6426 SetRect( &rect, 20, 20, 30, 30 );
6427 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6428 SetRectRgn( hrgn, 20, 20, 30, 30 );
6429 check_update_rgn( hparent, hrgn );
6430 /* no WM_PAINT in child while parent still pending */
6431 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6432 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6433 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6434 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
6437 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6438 /* no WM_PAINT in child while parent still pending */
6439 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6440 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6441 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
6442 /* now that parent is valid child should get WM_PAINT */
6443 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6444 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6445 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6446 ok_sequence( WmEmptySeq, "No other message", FALSE );
6448 /* same thing with WS_CLIPCHILDREN in parent */
6450 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
6451 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
6452 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6453 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
6454 ok_sequence( WmEmptySeq, "No message", FALSE );
6455 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
6456 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
6459 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
6460 SetRectRgn( hrgn, 20, 20, 30, 30 );
6461 check_update_rgn( hparent, hrgn );
6462 /* no WM_PAINT in child while parent still pending */
6463 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6464 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6465 /* WM_PAINT in parent first */
6466 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6467 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
6469 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6471 SetRect( &rect, 0, 0, 30, 30 );
6472 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
6473 SetRectRgn( hrgn, 0, 0, 30, 30 );
6474 check_update_rgn( hparent, hrgn );
6476 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
6478 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6480 SetRect( &rect, -10, 0, 30, 30 );
6481 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
6482 SetRect( &rect, 0, 0, 20, 20 );
6483 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
6484 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
6485 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
6487 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6489 SetRect( &rect, -10, 0, 30, 30 );
6490 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
6491 SetRect( &rect, 0, 0, 100, 100 );
6492 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
6493 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
6494 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
6495 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6496 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
6498 /* test RDW_INTERNALPAINT behavior */
6501 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
6503 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
6505 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
6507 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
6509 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
6511 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
6513 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
6514 UpdateWindow( hparent );
6517 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6518 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6519 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
6520 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6522 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
6524 UpdateWindow( hparent );
6527 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6528 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6529 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
6530 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6532 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
6534 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
6535 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
6536 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
6538 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
6540 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
6541 UpdateWindow( hparent );
6544 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6545 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6546 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
6547 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6549 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
6551 UpdateWindow( hparent );
6554 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6555 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6556 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
6557 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6559 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
6561 ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
6562 ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
6564 UpdateWindow( hparent );
6567 trace("testing SetWindowPos(-10000, -10000) on child\n");
6568 SetWindowPos( hchild, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
6569 check_update_rgn( hchild, 0 );
6572 #if 0 /* this one doesn't pass under Wine yet */
6573 UpdateWindow( hparent );
6576 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6577 ShowWindow( hchild, SW_MINIMIZE );
6578 check_update_rgn( hchild, 0 );
6582 UpdateWindow( hparent );
6585 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6586 SetWindowPos( hparent, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
6587 check_update_rgn( hparent, 0 );
6590 log_all_parent_messages--;
6591 DestroyWindow( hparent );
6592 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6594 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6596 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP | WS_VISIBLE,
6597 100, 100, 200, 200, 0, 0, 0, NULL);
6598 ok (hparent != 0, "Failed to create parent window\n");
6600 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
6601 10, 10, 100, 100, hparent, 0, 0, NULL);
6602 ok (hchild != 0, "Failed to create child window\n");
6604 ShowWindow( hparent, SW_SHOW );
6605 UpdateWindow( hparent );
6606 UpdateWindow( hchild );
6610 /* moving child outside of parent boundaries changes update region */
6611 SetRect( &rect, 0, 0, 40, 40 );
6612 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6613 SetRectRgn( hrgn, 0, 0, 40, 40 );
6614 check_update_rgn( hchild, hrgn );
6615 MoveWindow( hchild, -10, 10, 100, 100, FALSE );
6616 SetRectRgn( hrgn, 10, 0, 40, 40 );
6617 check_update_rgn( hchild, hrgn );
6618 MoveWindow( hchild, -10, -10, 100, 100, FALSE );
6619 SetRectRgn( hrgn, 10, 10, 40, 40 );
6620 check_update_rgn( hchild, hrgn );
6622 /* moving parent off-screen does too */
6623 SetRect( &rect, 0, 0, 100, 100 );
6624 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
6625 SetRectRgn( hrgn, 0, 0, 100, 100 );
6626 check_update_rgn( hparent, hrgn );
6627 SetRectRgn( hrgn, 10, 10, 40, 40 );
6628 check_update_rgn( hchild, hrgn );
6629 MoveWindow( hparent, -20, -20, 200, 200, FALSE );
6630 SetRectRgn( hrgn, 20, 20, 100, 100 );
6631 check_update_rgn( hparent, hrgn );
6632 SetRectRgn( hrgn, 30, 30, 40, 40 );
6633 check_update_rgn( hchild, hrgn );
6635 /* invalidated region is cropped by the parent rects */
6636 SetRect( &rect, 0, 0, 50, 50 );
6637 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6638 SetRectRgn( hrgn, 30, 30, 50, 50 );
6639 check_update_rgn( hchild, hrgn );
6641 DestroyWindow( hparent );
6642 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6645 DeleteObject( hrgn );
6646 DeleteObject( hrgn2 );
6657 static DWORD WINAPI thread_proc(void *param)
6660 struct wnd_event *wnd_event = param;
6662 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
6663 100, 100, 200, 200, 0, 0, 0, NULL);
6664 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
6666 SetEvent(wnd_event->start_event);
6668 while (GetMessage(&msg, 0, 0, 0))
6670 TranslateMessage(&msg);
6671 DispatchMessage(&msg);
6674 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
6679 static DWORD CALLBACK create_grand_child_thread( void *param )
6681 struct wnd_event *wnd_event = param;
6685 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
6686 WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, wnd_event->hwnd, 0, 0, NULL);
6687 ok (hchild != 0, "Failed to create child window\n");
6690 SetEvent( wnd_event->start_event );
6694 MsgWaitForMultipleObjects(0, NULL, FALSE, 1000, QS_ALLINPUT);
6695 if (!IsWindow( hchild )) break; /* will be destroyed when parent thread exits */
6696 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
6701 static DWORD CALLBACK create_child_thread( void *param )
6703 struct wnd_event *wnd_event = param;
6704 struct wnd_event child_event;
6708 child_event.hwnd = CreateWindowExA(0, "TestWindowClass", "Test child",
6709 WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, wnd_event->hwnd, 0, 0, NULL);
6710 ok (child_event.hwnd != 0, "Failed to create child window\n");
6711 SetFocus( child_event.hwnd );
6714 child_event.start_event = wnd_event->start_event;
6715 wnd_event->grand_child = CreateThread(NULL, 0, create_grand_child_thread, &child_event, 0, &tid);
6718 DWORD ret = MsgWaitForMultipleObjects(1, &child_event.start_event, FALSE, 1000, QS_SENDMESSAGE);
6719 if (ret != 1) break;
6720 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
6722 ret = WaitForSingleObject( wnd_event->stop_event, 5000 );
6723 ok( !ret, "WaitForSingleObject failed %x\n", ret );
6727 static void test_interthread_messages(void)
6734 int len, expected_len;
6735 struct wnd_event wnd_event;
6738 wnd_event.start_event = CreateEventW(NULL, 0, 0, NULL);
6739 if (!wnd_event.start_event)
6741 win_skip("skipping interthread message test under win9x\n");
6745 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
6746 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
6748 ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6750 CloseHandle(wnd_event.start_event);
6752 SetLastError(0xdeadbeef);
6753 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeeded\n");
6754 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
6755 "wrong error code %d\n", GetLastError());
6757 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6758 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6760 expected_len = lstrlenA("window caption text");
6761 memset(buf, 0, sizeof(buf));
6762 SetLastError(0xdeadbeef);
6763 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
6764 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
6765 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
6767 msg.hwnd = wnd_event.hwnd;
6768 msg.message = WM_GETTEXT;
6769 msg.wParam = sizeof(buf);
6770 msg.lParam = (LPARAM)buf;
6771 memset(buf, 0, sizeof(buf));
6772 SetLastError(0xdeadbeef);
6773 len = DispatchMessageA(&msg);
6774 ok((!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY) || broken(len), /* nt4 */
6775 "DispatchMessageA(WM_GETTEXT) succeeded on another thread window: ret %d, error %d\n", len, GetLastError());
6777 /* the following test causes an exception in user.exe under win9x */
6778 msg.hwnd = wnd_event.hwnd;
6779 msg.message = WM_TIMER;
6781 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6782 SetLastError(0xdeadbeef);
6783 len = DispatchMessageA(&msg);
6784 ok(!len && GetLastError() == 0xdeadbeef,
6785 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
6787 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
6788 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6790 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6791 CloseHandle(hThread);
6793 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
6795 wnd_event.hwnd = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6796 100, 100, 200, 200, 0, 0, 0, NULL);
6797 ok (wnd_event.hwnd != 0, "Failed to create parent window\n");
6800 log_all_parent_messages++;
6801 wnd_event.start_event = CreateEventA( NULL, TRUE, FALSE, NULL );
6802 wnd_event.stop_event = CreateEventA( NULL, TRUE, FALSE, NULL );
6803 hThread = CreateThread( NULL, 0, create_child_thread, &wnd_event, 0, &tid );
6806 ret = MsgWaitForMultipleObjects(1, &wnd_event.start_event, FALSE, 1000, QS_SENDMESSAGE);
6807 if (ret != 1) break;
6808 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
6810 ok( !ret, "MsgWaitForMultipleObjects failed %x\n", ret );
6811 /* now wait for the thread without processing messages; this shouldn't deadlock */
6812 SetEvent( wnd_event.stop_event );
6813 ret = WaitForSingleObject( hThread, 5000 );
6814 ok( !ret, "WaitForSingleObject failed %x\n", ret );
6815 CloseHandle( hThread );
6817 ret = WaitForSingleObject( wnd_event.grand_child, 5000 );
6818 ok( !ret, "WaitForSingleObject failed %x\n", ret );
6819 CloseHandle( wnd_event.grand_child );
6821 CloseHandle( wnd_event.start_event );
6822 CloseHandle( wnd_event.stop_event );
6824 ok_sequence(WmExitThreadSeq, "destroy child on thread exit", FALSE);
6825 log_all_parent_messages--;
6826 DestroyWindow( wnd_event.hwnd );
6830 static const struct message WmVkN[] = {
6831 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6832 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6833 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6834 { WM_CHAR, wparam|lparam, 'n', 1 },
6835 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
6836 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6837 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6838 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6841 static const struct message WmShiftVkN[] = {
6842 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6843 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6844 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6845 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6846 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6847 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6848 { WM_CHAR, wparam|lparam, 'N', 1 },
6849 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
6850 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6851 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6852 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6853 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6854 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6855 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6858 static const struct message WmCtrlVkN[] = {
6859 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6860 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6861 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6862 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6863 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6864 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6865 { WM_CHAR, wparam|lparam, 0x000e, 1 },
6866 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6867 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6868 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6869 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6870 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6871 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6872 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6875 static const struct message WmCtrlVkN_2[] = {
6876 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6877 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6878 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6879 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6880 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6881 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6882 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6883 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6884 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6885 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6886 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6887 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6890 static const struct message WmAltVkN[] = {
6891 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6892 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6893 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6894 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6895 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6896 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6897 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
6898 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
6899 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
6900 { HCBT_SYSCOMMAND, hook },
6901 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6902 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6903 { 0x00AE, sent|defwinproc|optional }, /* XP */
6904 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
6905 { WM_INITMENU, sent|defwinproc },
6906 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6907 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
6908 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6909 { WM_CAPTURECHANGED, sent|defwinproc },
6910 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
6911 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6912 { WM_EXITMENULOOP, sent|defwinproc },
6913 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6914 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
6915 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6916 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6917 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6918 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6919 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6920 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6923 static const struct message WmAltVkN_2[] = {
6924 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6925 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6926 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6927 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6928 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6929 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
6930 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6931 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6932 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6933 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6934 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6935 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6938 static const struct message WmCtrlAltVkN[] = {
6939 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6940 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6941 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6942 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6943 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6944 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6945 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6946 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6947 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6948 { WM_CHAR, optional },
6949 { WM_CHAR, sent|optional },
6950 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6951 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6952 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6953 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6954 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6955 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6956 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6957 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6958 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6961 static const struct message WmCtrlShiftVkN[] = {
6962 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6963 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6964 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6965 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6966 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6967 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6968 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6969 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6970 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
6971 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6972 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6973 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6974 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6975 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6976 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6977 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6978 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6979 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6982 static const struct message WmCtrlAltShiftVkN[] = {
6983 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6984 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6985 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6986 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6987 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6988 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6989 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
6990 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
6991 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
6992 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6993 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6994 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
6995 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6996 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6997 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6998 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
6999 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
7000 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
7001 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
7002 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
7003 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
7004 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
7005 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
7006 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
7009 static const struct message WmAltPressRelease[] = {
7010 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
7011 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
7012 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
7013 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
7014 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
7015 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
7016 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
7017 { HCBT_SYSCOMMAND, hook },
7018 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7019 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7020 { WM_INITMENU, sent|defwinproc },
7021 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7022 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
7023 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7025 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
7027 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7028 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
7029 { WM_CAPTURECHANGED, sent|defwinproc },
7030 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
7031 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7032 { WM_EXITMENULOOP, sent|defwinproc },
7033 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
7034 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
7035 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
7038 static const struct message WmShiftMouseButton[] = {
7039 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
7040 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
7041 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
7042 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
7043 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
7044 { WM_LBUTTONDOWN, wparam, MK_LBUTTON|MK_SHIFT, 0 },
7045 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON|MK_SHIFT, 0 },
7046 { WM_LBUTTONUP, wparam, MK_SHIFT, 0 },
7047 { WM_LBUTTONUP, sent|wparam, MK_SHIFT, 0 },
7048 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
7049 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
7050 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
7053 static const struct message WmF1Seq[] = {
7054 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
7055 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
7056 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
7057 { WM_KEYF1, wparam|lparam, 0, 0 },
7058 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
7059 { WM_HELP, sent|defwinproc },
7060 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
7061 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
7062 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
7065 static const struct message WmVkAppsSeq[] = {
7066 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
7067 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
7068 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
7069 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
7070 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
7071 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
7072 { WM_CONTEXTMENU, lparam, /*hwnd*/0, -1 },
7073 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, -1 },
7076 static const struct message WmVkF10Seq[] = {
7077 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 1 }, /* XP */
7078 { WM_SYSKEYDOWN, wparam|lparam, VK_F10, 1 },
7079 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_F10, 0x00000001 },
7080 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0xc0000001 }, /* XP */
7081 { WM_SYSKEYUP, wparam|lparam, VK_F10, 0xc0000001 },
7082 { WM_SYSKEYUP, sent|wparam|lparam, VK_F10, 0xc0000001 },
7083 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_KEYMENU },
7084 { HCBT_SYSCOMMAND, hook },
7085 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7086 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7087 { WM_INITMENU, sent|defwinproc },
7088 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7089 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
7090 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7092 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0x10000001 }, /* XP */
7094 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 1 }, /* XP */
7095 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7096 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
7097 { WM_CAPTURECHANGED, sent|defwinproc },
7098 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
7099 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7100 { WM_EXITMENULOOP, sent|defwinproc },
7101 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0xc0000001 }, /* XP */
7102 { WM_SYSKEYUP, wparam|lparam, VK_F10, 0xc0000001 },
7103 { WM_SYSKEYUP, sent|wparam|lparam, VK_F10, 0xc0000001 },
7106 static const struct message WmShiftF10Seq[] = {
7107 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
7108 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
7109 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x00000001 },
7110 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 1 }, /* XP */
7111 { WM_SYSKEYDOWN, wparam|lparam, VK_F10, 1 },
7112 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_F10, 0x00000001 },
7113 { WM_CONTEXTMENU, sent|defwinproc|lparam, /*hwnd*/0, -1 },
7114 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0xc0000001 }, /* XP */
7115 { WM_SYSKEYUP, wparam|lparam, VK_F10, 0xc0000001 },
7116 { WM_SYSKEYUP, sent|wparam|lparam, VK_F10, 0xc0000001 },
7117 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_KEYMENU },
7118 { HCBT_SYSCOMMAND, hook },
7119 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7120 { WM_INITMENU, sent|defwinproc },
7121 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
7122 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xd0000001 }, /* XP */
7123 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 0x10000001 }, /* XP */
7124 { WM_CAPTURECHANGED, sent|defwinproc|wparam|lparam, 0, 0 },
7125 { WM_MENUSELECT, sent|defwinproc|wparam|lparam, 0xffff0000, 0 },
7126 { WM_EXITMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7127 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 0xc0000001 }, /* XP */
7128 { WM_KEYUP, wparam|lparam, VK_ESCAPE, 0xc0000001 },
7129 { WM_KEYUP, sent|wparam|lparam, VK_ESCAPE, 0xc0000001 },
7133 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
7137 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
7139 struct recvd_message log_msg;
7141 /* ignore some unwanted messages */
7142 if (msg.message == WM_MOUSEMOVE ||
7143 msg.message == WM_TIMER ||
7144 ignore_message( msg.message ))
7147 log_msg.hwnd = msg.hwnd;
7148 log_msg.message = msg.message;
7149 log_msg.flags = wparam|lparam;
7150 log_msg.wParam = msg.wParam;
7151 log_msg.lParam = msg.lParam;
7152 log_msg.descr = "accel";
7153 add_message(&log_msg);
7155 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
7157 TranslateMessage(&msg);
7158 DispatchMessage(&msg);
7163 static void test_accelerators(void)
7169 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
7170 100, 100, 200, 200, 0, 0, 0, NULL);
7179 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
7181 state = GetKeyState(VK_SHIFT);
7182 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
7183 state = GetKeyState(VK_CAPITAL);
7184 ok(state == 0, "wrong CapsLock state %04x\n", state);
7186 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
7187 assert(hAccel != 0);
7190 pump_msg_loop(hwnd, 0);
7193 trace("testing VK_N press/release\n");
7195 keybd_event('N', 0, 0, 0);
7196 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7197 pump_msg_loop(hwnd, hAccel);
7198 if (!sequence_cnt) /* we didn't get any message */
7200 skip( "queuing key events not supported\n" );
7203 ok_sequence(WmVkN, "VK_N press/release", FALSE);
7205 trace("testing Shift+VK_N press/release\n");
7207 keybd_event(VK_SHIFT, 0, 0, 0);
7208 keybd_event('N', 0, 0, 0);
7209 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7210 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7211 pump_msg_loop(hwnd, hAccel);
7212 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
7214 trace("testing Ctrl+VK_N press/release\n");
7216 keybd_event(VK_CONTROL, 0, 0, 0);
7217 keybd_event('N', 0, 0, 0);
7218 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7219 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7220 pump_msg_loop(hwnd, hAccel);
7221 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
7223 trace("testing Alt+VK_N press/release\n");
7225 keybd_event(VK_MENU, 0, 0, 0);
7226 keybd_event('N', 0, 0, 0);
7227 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7228 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7229 pump_msg_loop(hwnd, hAccel);
7230 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
7232 trace("testing Ctrl+Alt+VK_N press/release 1\n");
7234 keybd_event(VK_CONTROL, 0, 0, 0);
7235 keybd_event(VK_MENU, 0, 0, 0);
7236 keybd_event('N', 0, 0, 0);
7237 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7238 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7239 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7240 pump_msg_loop(hwnd, hAccel);
7241 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
7243 ret = DestroyAcceleratorTable(hAccel);
7244 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
7246 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
7247 assert(hAccel != 0);
7249 trace("testing VK_N press/release\n");
7251 keybd_event('N', 0, 0, 0);
7252 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7253 pump_msg_loop(hwnd, hAccel);
7254 ok_sequence(WmVkN, "VK_N press/release", FALSE);
7256 trace("testing Shift+VK_N press/release\n");
7258 keybd_event(VK_SHIFT, 0, 0, 0);
7259 keybd_event('N', 0, 0, 0);
7260 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7261 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7262 pump_msg_loop(hwnd, hAccel);
7263 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
7265 trace("testing Ctrl+VK_N press/release 2\n");
7267 keybd_event(VK_CONTROL, 0, 0, 0);
7268 keybd_event('N', 0, 0, 0);
7269 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7270 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7271 pump_msg_loop(hwnd, hAccel);
7272 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
7274 trace("testing Alt+VK_N press/release 2\n");
7276 keybd_event(VK_MENU, 0, 0, 0);
7277 keybd_event('N', 0, 0, 0);
7278 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7279 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7280 pump_msg_loop(hwnd, hAccel);
7281 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
7283 trace("testing Ctrl+Alt+VK_N press/release 2\n");
7285 keybd_event(VK_CONTROL, 0, 0, 0);
7286 keybd_event(VK_MENU, 0, 0, 0);
7287 keybd_event('N', 0, 0, 0);
7288 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7289 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7290 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7291 pump_msg_loop(hwnd, hAccel);
7292 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
7294 trace("testing Ctrl+Shift+VK_N press/release\n");
7296 keybd_event(VK_CONTROL, 0, 0, 0);
7297 keybd_event(VK_SHIFT, 0, 0, 0);
7298 keybd_event('N', 0, 0, 0);
7299 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7300 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7301 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7302 pump_msg_loop(hwnd, hAccel);
7303 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
7305 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
7307 keybd_event(VK_CONTROL, 0, 0, 0);
7308 keybd_event(VK_MENU, 0, 0, 0);
7309 keybd_event(VK_SHIFT, 0, 0, 0);
7310 keybd_event('N', 0, 0, 0);
7311 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7312 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7313 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7314 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7315 pump_msg_loop(hwnd, hAccel);
7316 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
7318 ret = DestroyAcceleratorTable(hAccel);
7319 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
7322 trace("testing Alt press/release\n");
7324 keybd_event(VK_MENU, 0, 0, 0);
7325 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7326 keybd_event(VK_MENU, 0, 0, 0);
7327 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7328 pump_msg_loop(hwnd, 0);
7329 /* this test doesn't pass in Wine for managed windows */
7330 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
7332 trace("testing VK_F1 press/release\n");
7333 keybd_event(VK_F1, 0, 0, 0);
7334 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
7335 pump_msg_loop(hwnd, 0);
7336 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
7338 trace("testing VK_APPS press/release\n");
7339 keybd_event(VK_APPS, 0, 0, 0);
7340 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
7341 pump_msg_loop(hwnd, 0);
7342 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
7344 trace("testing VK_F10 press/release\n");
7345 keybd_event(VK_F10, 0, 0, 0);
7346 keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
7347 keybd_event(VK_F10, 0, 0, 0);
7348 keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
7349 pump_msg_loop(hwnd, 0);
7350 ok_sequence(WmVkF10Seq, "VK_F10 press/release", TRUE);
7352 trace("testing SHIFT+F10 press/release\n");
7353 keybd_event(VK_SHIFT, 0, 0, 0);
7354 keybd_event(VK_F10, 0, 0, 0);
7355 keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
7356 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7357 keybd_event(VK_ESCAPE, 0, 0, 0);
7358 keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
7359 pump_msg_loop(hwnd, 0);
7360 ok_sequence(WmShiftF10Seq, "SHIFT+F10 press/release", TRUE);
7362 trace("testing Shift+MouseButton press/release\n");
7363 /* first, move mouse pointer inside of the window client area */
7364 GetClientRect(hwnd, &rc);
7365 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
7366 rc.left += (rc.right - rc.left)/2;
7367 rc.top += (rc.bottom - rc.top)/2;
7368 SetCursorPos(rc.left, rc.top);
7369 SetActiveWindow(hwnd);
7374 if (pt.x == rc.left && pt.y == rc.top)
7377 keybd_event(VK_SHIFT, 0, 0, 0);
7378 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
7379 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7380 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7381 pump_msg_loop(hwnd, 0);
7382 for (i = 0; i < sequence_cnt; i++) if (sequence[i].message == WM_LBUTTONDOWN) break;
7383 if (i < sequence_cnt)
7384 ok_sequence(WmShiftMouseButton, "Shift+MouseButton press/release", FALSE);
7386 skip( "Shift+MouseButton event didn't get to the window\n" );
7390 if (hAccel) DestroyAcceleratorTable(hAccel);
7391 DestroyWindow(hwnd);
7394 /************* window procedures ********************/
7396 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
7397 WPARAM wParam, LPARAM lParam)
7399 static LONG defwndproc_counter = 0;
7400 static LONG beginpaint_counter = 0;
7402 struct recvd_message msg;
7404 if (ignore_message( message )) return 0;
7410 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
7411 ok((BOOL)wParam == !(style & WS_DISABLED),
7412 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
7416 case WM_CAPTURECHANGED:
7417 if (test_DestroyWindow_flag)
7419 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
7420 if (style & WS_CHILD)
7421 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
7422 else if (style & WS_POPUP)
7423 lParam = WND_POPUP_ID;
7425 lParam = WND_PARENT_ID;
7433 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
7434 capture = GetCapture();
7437 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
7438 trace("current capture %p, releasing...\n", capture);
7445 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
7446 if (test_DestroyWindow_flag)
7448 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
7449 if (style & WS_CHILD)
7450 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
7451 else if (style & WS_POPUP)
7452 lParam = WND_POPUP_ID;
7454 lParam = WND_PARENT_ID;
7458 /* test_accelerators() depends on this */
7464 case WM_MOUSEACTIVATE:
7465 case WM_NCMOUSEMOVE:
7472 msg.message = message;
7473 msg.flags = sent|wparam|lparam;
7474 if (defwndproc_counter) msg.flags |= defwinproc;
7475 if (beginpaint_counter) msg.flags |= beginpaint;
7476 msg.wParam = wParam;
7477 msg.lParam = lParam;
7478 msg.descr = "MsgCheckProc";
7481 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
7483 HWND parent = GetParent(hwnd);
7485 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
7487 GetClientRect(parent, &rc);
7488 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
7489 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7490 minmax->ptReserved.x, minmax->ptReserved.y,
7491 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
7492 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
7493 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
7494 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
7496 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
7497 minmax->ptMaxSize.x, rc.right);
7498 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
7499 minmax->ptMaxSize.y, rc.bottom);
7502 if (message == WM_PAINT)
7505 beginpaint_counter++;
7506 BeginPaint( hwnd, &ps );
7507 beginpaint_counter--;
7508 EndPaint( hwnd, &ps );
7512 defwndproc_counter++;
7513 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
7514 : DefWindowProcA(hwnd, message, wParam, lParam);
7515 defwndproc_counter--;
7520 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7522 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
7525 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7527 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
7530 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7532 static LONG defwndproc_counter = 0;
7534 struct recvd_message msg;
7536 if (ignore_message( message )) return 0;
7540 case WM_QUERYENDSESSION:
7542 lParam &= ~0x01; /* Vista adds a 0x01 flag */
7547 msg.message = message;
7548 msg.flags = sent|wparam|lparam;
7549 if (defwndproc_counter) msg.flags |= defwinproc;
7550 msg.wParam = wParam;
7551 msg.lParam = lParam;
7552 msg.descr = "popup";
7555 if (message == WM_CREATE)
7557 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
7558 SetWindowLongA(hwnd, GWL_STYLE, style);
7561 defwndproc_counter++;
7562 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7563 defwndproc_counter--;
7568 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7570 static LONG defwndproc_counter = 0;
7571 static LONG beginpaint_counter = 0;
7573 struct recvd_message msg;
7575 if (ignore_message( message )) return 0;
7577 if (log_all_parent_messages ||
7578 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
7579 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
7580 message == WM_ENABLE || message == WM_ENTERIDLE ||
7581 message == WM_DRAWITEM || message == WM_COMMAND ||
7582 message == WM_IME_SETCONTEXT)
7591 case WM_NCMOUSEMOVE:
7597 INT ret = GetClipBox((HDC)wParam, &rc);
7599 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7600 ret, rc.left, rc.top, rc.right, rc.bottom);
7606 msg.message = message;
7607 msg.flags = sent|parent|wparam|lparam;
7608 if (defwndproc_counter) msg.flags |= defwinproc;
7609 if (beginpaint_counter) msg.flags |= beginpaint;
7610 msg.wParam = wParam;
7611 msg.lParam = lParam;
7612 msg.descr = "parent";
7616 if (message == WM_PAINT)
7619 beginpaint_counter++;
7620 BeginPaint( hwnd, &ps );
7621 beginpaint_counter--;
7622 EndPaint( hwnd, &ps );
7626 defwndproc_counter++;
7627 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7628 defwndproc_counter--;
7633 static INT_PTR CALLBACK StopQuitMsgCheckProcA(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
7635 if (message == WM_CREATE)
7636 PostMessage(hwnd, WM_CLOSE, 0, 0);
7637 else if (message == WM_CLOSE)
7639 /* Only the first WM_QUIT will survive the window destruction */
7640 PostMessage(hwnd, WM_USER, 0x1234, 0x5678);
7641 PostMessage(hwnd, WM_QUIT, 0x1234, 0x5678);
7642 PostMessage(hwnd, WM_QUIT, 0x4321, 0x8765);
7645 return DefWindowProcA(hwnd, message, wp, lp);
7648 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7650 static LONG defwndproc_counter = 0;
7652 struct recvd_message msg;
7654 if (ignore_message( message )) return 0;
7658 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
7659 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
7660 if (after_end_dialog)
7661 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
7663 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
7667 msg.message = message;
7668 msg.flags = sent|wparam|lparam;
7669 if (defwndproc_counter) msg.flags |= defwinproc;
7670 msg.wParam = wParam;
7671 msg.lParam = lParam;
7672 msg.descr = "dialog";
7675 defwndproc_counter++;
7676 ret = DefDlgProcA(hwnd, message, wParam, lParam);
7677 defwndproc_counter--;
7682 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7684 static LONG defwndproc_counter = 0;
7686 struct recvd_message msg;
7688 /* log only specific messages we are interested in */
7691 #if 0 /* probably log these as well */
7699 case WM_GETMINMAXINFO:
7700 case WM_WINDOWPOSCHANGING:
7701 case WM_WINDOWPOSCHANGED:
7704 default: /* ignore */
7705 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7706 return DefWindowProcA(hwnd, message, wParam, lParam);
7710 msg.message = message;
7711 msg.flags = sent|wparam|lparam;
7712 if (defwndproc_counter) msg.flags |= defwinproc;
7713 msg.wParam = wParam;
7714 msg.lParam = lParam;
7718 defwndproc_counter++;
7719 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7720 defwndproc_counter--;
7725 static LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
7729 case WM_CREATE: return 0;
7738 if (PeekMessageA(&msg2, 0, 0, 0, 1))
7740 TranslateMessage(&msg2);
7741 DispatchMessage(&msg2);
7745 else ok(broken(1), "infinite loop\n");
7747 paint_loop_done = 1;
7748 return DefWindowProcA(hWnd,msg,wParam,lParam);
7751 return DefWindowProcA(hWnd,msg,wParam,lParam);
7754 static LRESULT WINAPI HotkeyMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7756 static LONG defwndproc_counter = 0;
7758 struct recvd_message msg;
7761 if (ignore_message( message )) return 0;
7763 if ((message >= WM_KEYFIRST && message <= WM_KEYLAST) ||
7764 message == WM_HOTKEY || message >= WM_APP)
7767 msg.message = message;
7768 msg.flags = sent|wparam|lparam;
7769 if (defwndproc_counter) msg.flags |= defwinproc;
7770 msg.wParam = wParam;
7771 msg.lParam = lParam;
7772 msg.descr = "HotkeyMsgCheckProcA";
7776 defwndproc_counter++;
7777 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7778 defwndproc_counter--;
7780 if (message == WM_APP)
7782 queue_status = GetQueueStatus(QS_HOTKEY);
7783 ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
7784 queue_status = GetQueueStatus(QS_POSTMESSAGE);
7785 ok((queue_status & (QS_POSTMESSAGE << 16)) == QS_POSTMESSAGE << 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status);
7786 PostMessageA(hwnd, WM_APP+1, 0, 0);
7788 else if (message == WM_APP+1)
7790 queue_status = GetQueueStatus(QS_HOTKEY);
7791 ok((queue_status & (QS_HOTKEY << 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status);
7797 static BOOL RegisterWindowClasses(void)
7803 cls.lpfnWndProc = MsgCheckProcA;
7806 cls.hInstance = GetModuleHandleA(0);
7808 cls.hCursor = LoadCursorA(0, IDC_ARROW);
7809 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
7810 cls.lpszMenuName = NULL;
7811 cls.lpszClassName = "TestWindowClass";
7812 if(!RegisterClassA(&cls)) return FALSE;
7814 cls.lpfnWndProc = HotkeyMsgCheckProcA;
7815 cls.lpszClassName = "HotkeyWindowClass";
7816 if(!RegisterClassA(&cls)) return FALSE;
7818 cls.lpfnWndProc = ShowWindowProcA;
7819 cls.lpszClassName = "ShowWindowClass";
7820 if(!RegisterClassA(&cls)) return FALSE;
7822 cls.lpfnWndProc = PopupMsgCheckProcA;
7823 cls.lpszClassName = "TestPopupClass";
7824 if(!RegisterClassA(&cls)) return FALSE;
7826 cls.lpfnWndProc = ParentMsgCheckProcA;
7827 cls.lpszClassName = "TestParentClass";
7828 if(!RegisterClassA(&cls)) return FALSE;
7830 cls.lpfnWndProc = StopQuitMsgCheckProcA;
7831 cls.lpszClassName = "StopQuitClass";
7832 if(!RegisterClassA(&cls)) return FALSE;
7834 cls.lpfnWndProc = DefWindowProcA;
7835 cls.lpszClassName = "SimpleWindowClass";
7836 if(!RegisterClassA(&cls)) return FALSE;
7838 cls.lpfnWndProc = PaintLoopProcA;
7839 cls.lpszClassName = "PaintLoopWindowClass";
7840 if(!RegisterClassA(&cls)) return FALSE;
7842 cls.style = CS_NOCLOSE;
7843 cls.lpszClassName = "NoCloseWindowClass";
7844 if(!RegisterClassA(&cls)) return FALSE;
7846 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
7848 cls.hInstance = GetModuleHandleA(0);
7849 cls.hbrBackground = 0;
7850 cls.lpfnWndProc = TestDlgProcA;
7851 cls.lpszClassName = "TestDialogClass";
7852 if(!RegisterClassA(&cls)) return FALSE;
7855 clsW.lpfnWndProc = MsgCheckProcW;
7856 clsW.cbClsExtra = 0;
7857 clsW.cbWndExtra = 0;
7858 clsW.hInstance = GetModuleHandleW(0);
7860 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
7861 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
7862 clsW.lpszMenuName = NULL;
7863 clsW.lpszClassName = testWindowClassW;
7864 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
7869 static BOOL is_our_logged_class(HWND hwnd)
7873 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7875 if (!lstrcmpiA(buf, "TestWindowClass") ||
7876 !lstrcmpiA(buf, "ShowWindowClass") ||
7877 !lstrcmpiA(buf, "TestParentClass") ||
7878 !lstrcmpiA(buf, "TestPopupClass") ||
7879 !lstrcmpiA(buf, "SimpleWindowClass") ||
7880 !lstrcmpiA(buf, "TestDialogClass") ||
7881 !lstrcmpiA(buf, "MDI_frame_class") ||
7882 !lstrcmpiA(buf, "MDI_client_class") ||
7883 !lstrcmpiA(buf, "MDI_child_class") ||
7884 !lstrcmpiA(buf, "my_button_class") ||
7885 !lstrcmpiA(buf, "my_edit_class") ||
7886 !lstrcmpiA(buf, "static") ||
7887 !lstrcmpiA(buf, "ListBox") ||
7888 !lstrcmpiA(buf, "ComboBox") ||
7889 !lstrcmpiA(buf, "MyDialogClass") ||
7890 !lstrcmpiA(buf, "#32770") ||
7891 !lstrcmpiA(buf, "#32768"))
7897 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7901 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7903 if (nCode == HCBT_CLICKSKIPPED)
7905 /* ignore this event, XP sends it a lot when switching focus between windows */
7906 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7909 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
7911 struct recvd_message msg;
7914 msg.message = nCode;
7915 msg.flags = hook|wparam|lparam;
7916 msg.wParam = wParam;
7917 msg.lParam = lParam;
7921 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7924 if (nCode == HCBT_DESTROYWND)
7926 if (test_DestroyWindow_flag)
7928 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
7929 if (style & WS_CHILD)
7930 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
7931 else if (style & WS_POPUP)
7932 lParam = WND_POPUP_ID;
7934 lParam = WND_PARENT_ID;
7938 /* Log also SetFocus(0) calls */
7939 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7941 if (is_our_logged_class(hwnd))
7943 struct recvd_message msg;
7946 msg.message = nCode;
7947 msg.flags = hook|wparam|lparam;
7948 msg.wParam = wParam;
7949 msg.lParam = lParam;
7953 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7956 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
7964 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7966 /* ignore mouse cursor events */
7967 if (object_id == OBJID_CURSOR) return;
7969 if (!hwnd || is_our_logged_class(hwnd))
7971 struct recvd_message msg;
7974 msg.message = event;
7975 msg.flags = winevent_hook|wparam|lparam;
7976 msg.wParam = object_id;
7977 msg.lParam = child_id;
7983 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
7984 static const WCHAR wszAnsi[] = {'U',0};
7986 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
7990 case CB_FINDSTRINGEXACT:
7991 trace("String: %p\n", (LPCWSTR)lParam);
7992 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
7994 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
7998 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
8001 static const struct message WmGetTextLengthAfromW[] = {
8002 { WM_GETTEXTLENGTH, sent },
8003 { WM_GETTEXT, sent|optional },
8007 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
8009 /* dummy window proc for WM_GETTEXTLENGTH test */
8010 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
8014 case WM_GETTEXTLENGTH:
8015 return lstrlenW(dummy_window_text) + 37; /* some random length */
8017 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
8018 return lstrlenW( (LPWSTR)lp );
8020 return DefWindowProcW( hwnd, msg, wp, lp );
8024 static void test_message_conversion(void)
8026 static const WCHAR wszMsgConversionClass[] =
8027 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
8031 WNDPROC wndproc, newproc;
8035 cls.lpfnWndProc = MsgConversionProcW;
8038 cls.hInstance = GetModuleHandleW(NULL);
8040 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
8041 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
8042 cls.lpszMenuName = NULL;
8043 cls.lpszClassName = wszMsgConversionClass;
8044 /* this call will fail on Win9x, but that doesn't matter as this test is
8045 * meaningless on those platforms */
8046 if(!RegisterClassW(&cls)) return;
8048 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
8049 100, 100, 200, 200, 0, 0, 0, NULL);
8050 ok(hwnd != NULL, "Window creation failed\n");
8054 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
8055 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8056 ok(lRes == 0, "String should have been converted\n");
8057 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8058 ok(lRes == 1, "String shouldn't have been converted\n");
8062 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
8063 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8064 ok(lRes == 1, "String shouldn't have been converted\n");
8065 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8066 ok(lRes == 1, "String shouldn't have been converted\n");
8068 /* Synchronous messages */
8070 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8071 ok(lRes == 0, "String should have been converted\n");
8072 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8073 ok(lRes == 1, "String shouldn't have been converted\n");
8075 /* Asynchronous messages */
8078 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8079 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8080 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8082 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8083 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8084 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8086 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8087 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8088 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8090 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8091 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8092 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8094 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8095 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8096 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8098 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8099 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8100 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8102 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
8103 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8104 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8106 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
8107 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8108 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8110 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
8112 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
8113 WS_OVERLAPPEDWINDOW,
8114 100, 100, 200, 200, 0, 0, 0, NULL);
8117 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
8118 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
8119 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
8120 "got bad length %ld\n", lRes );
8123 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
8124 hwnd, WM_GETTEXTLENGTH, 0, 0);
8125 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
8126 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
8127 "got bad length %ld\n", lRes );
8129 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
8130 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
8131 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
8132 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
8133 NULL, 0, NULL, NULL ) ||
8134 broken(lRes == lstrlenW(dummy_window_text) + 37),
8135 "got bad length %ld\n", lRes );
8137 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
8138 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
8139 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
8140 NULL, 0, NULL, NULL ) ||
8141 broken(lRes == lstrlenW(dummy_window_text) + 37),
8142 "got bad length %ld\n", lRes );
8144 ret = DestroyWindow(hwnd);
8145 ok( ret, "DestroyWindow() error %d\n", GetLastError());
8155 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
8159 #define TIMER_ID 0x19
8161 static DWORD WINAPI timer_thread_proc(LPVOID x)
8163 struct timer_info *info = x;
8166 r = KillTimer(info->hWnd, 0x19);
8167 ok(r,"KillTimer failed in thread\n");
8168 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
8169 ok(r,"SetTimer failed in thread\n");
8170 ok(r==TIMER_ID,"SetTimer id different\n");
8171 r = SetEvent(info->handles[0]);
8172 ok(r,"SetEvent failed in thread\n");
8176 static void test_timers(void)
8178 struct timer_info info;
8181 info.hWnd = CreateWindow ("TestWindowClass", NULL,
8182 WS_OVERLAPPEDWINDOW ,
8183 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8186 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
8187 ok(info.id, "SetTimer failed\n");
8188 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
8189 info.handles[0] = CreateEvent(NULL,0,0,NULL);
8190 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
8192 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
8194 WaitForSingleObject(info.handles[1], INFINITE);
8196 CloseHandle(info.handles[0]);
8197 CloseHandle(info.handles[1]);
8199 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
8201 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
8204 static int count = 0;
8205 static VOID CALLBACK callback_count(
8215 static void test_timers_no_wnd(void)
8221 id = SetTimer(NULL, 0, 100, callback_count);
8222 ok(id != 0, "did not get id from SetTimer.\n");
8223 id2 = SetTimer(NULL, id, 200, callback_count);
8224 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
8226 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8227 ok(count == 0, "did not get zero count as expected (%i).\n", count);
8229 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8230 ok(count == 1, "did not get one count as expected (%i).\n", count);
8231 KillTimer(NULL, id);
8233 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8234 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
8237 /* Various win events with arbitrary parameters */
8238 static const struct message WmWinEventsSeq[] = {
8239 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
8240 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
8241 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
8242 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
8243 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
8244 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
8245 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
8246 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
8247 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
8248 /* our win event hook ignores OBJID_CURSOR events */
8249 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
8250 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
8251 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
8252 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
8253 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
8254 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
8255 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
8256 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
8257 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
8258 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
8259 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
8260 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
8261 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
8262 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
8265 static const struct message WmWinEventCaretSeq[] = {
8266 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
8267 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
8268 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
8269 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
8272 static const struct message WmWinEventCaretSeq_2[] = {
8273 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
8274 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
8275 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
8278 static const struct message WmWinEventAlertSeq[] = {
8279 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
8282 static const struct message WmWinEventAlertSeq_2[] = {
8283 /* create window in the thread proc */
8284 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
8285 /* our test event */
8286 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
8289 static const struct message WmGlobalHookSeq_1[] = {
8290 /* create window in the thread proc */
8291 { HCBT_CREATEWND, hook|lparam, 0, 2 },
8292 /* our test events */
8293 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
8294 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
8297 static const struct message WmGlobalHookSeq_2[] = {
8298 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
8299 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
8300 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
8301 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
8305 static const struct message WmMouseLLHookSeq[] = {
8306 { WM_MOUSEMOVE, hook },
8307 { WM_LBUTTONUP, hook },
8308 { WM_MOUSEMOVE, hook },
8312 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
8322 if (GetClassNameA(hwnd, buf, sizeof(buf)))
8324 if (!lstrcmpiA(buf, "TestWindowClass") ||
8325 !lstrcmpiA(buf, "static"))
8327 struct recvd_message msg;
8330 msg.message = event;
8331 msg.flags = winevent_hook|wparam|lparam;
8332 msg.wParam = object_id;
8333 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
8334 msg.descr = "WEH_2";
8340 static HHOOK hCBT_global_hook;
8341 static DWORD cbt_global_hook_thread_id;
8343 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
8348 if (nCode == HCBT_SYSCOMMAND)
8350 struct recvd_message msg;
8353 msg.message = nCode;
8354 msg.flags = hook|wparam|lparam;
8355 msg.wParam = wParam;
8356 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
8357 msg.descr = "CBT_2";
8360 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
8362 /* WH_MOUSE_LL hook */
8363 if (nCode == HC_ACTION)
8365 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
8367 /* we can't test for real mouse events */
8368 if (mhll->flags & LLMHF_INJECTED)
8370 struct recvd_message msg;
8372 memset (&msg, 0, sizeof (msg));
8373 msg.message = wParam;
8375 msg.descr = "CBT_2";
8378 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
8381 /* Log also SetFocus(0) calls */
8382 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
8384 if (GetClassNameA(hwnd, buf, sizeof(buf)))
8386 if (!lstrcmpiA(buf, "TestWindowClass") ||
8387 !lstrcmpiA(buf, "static"))
8389 struct recvd_message msg;
8392 msg.message = nCode;
8393 msg.flags = hook|wparam|lparam;
8394 msg.wParam = wParam;
8395 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
8396 msg.descr = "CBT_2";
8400 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
8403 static DWORD WINAPI win_event_global_thread_proc(void *param)
8407 HANDLE hevent = *(HANDLE *)param;
8409 assert(pNotifyWinEvent);
8411 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
8413 trace("created thread window %p\n", hwnd);
8415 *(HWND *)param = hwnd;
8418 /* this event should be received only by our new hook proc,
8419 * an old one does not expect an event from another thread.
8421 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
8424 while (GetMessage(&msg, 0, 0, 0))
8426 TranslateMessage(&msg);
8427 DispatchMessage(&msg);
8432 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
8436 HANDLE hevent = *(HANDLE *)param;
8439 /* these events should be received only by our new hook proc,
8440 * an old one does not expect an event from another thread.
8443 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
8445 trace("created thread window %p\n", hwnd);
8447 *(HWND *)param = hwnd;
8449 /* Windows doesn't like when a thread plays games with the focus,
8450 that leads to all kinds of misbehaviours and failures to activate
8451 a window. So, better keep next lines commented out.
8455 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
8456 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
8460 while (GetMessage(&msg, 0, 0, 0))
8462 TranslateMessage(&msg);
8463 DispatchMessage(&msg);
8468 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
8472 HANDLE hevent = *(HANDLE *)param;
8474 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
8476 trace("created thread window %p\n", hwnd);
8478 *(HWND *)param = hwnd;
8482 /* Windows doesn't like when a thread plays games with the focus,
8483 * that leads to all kinds of misbehaviours and failures to activate
8484 * a window. So, better don't generate a mouse click message below.
8486 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8487 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
8488 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8491 while (GetMessage(&msg, 0, 0, 0))
8493 TranslateMessage(&msg);
8494 DispatchMessage(&msg);
8499 static void test_winevents(void)
8505 HANDLE hthread, hevent;
8507 HWINEVENTHOOK hhook;
8508 const struct message *events = WmWinEventsSeq;
8510 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
8511 WS_OVERLAPPEDWINDOW,
8512 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8516 /****** start of global hook test *************/
8517 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
8518 if (!hCBT_global_hook)
8520 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8521 skip( "cannot set global hook\n" );
8525 hevent = CreateEventA(NULL, 0, 0, NULL);
8529 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
8530 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8532 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8534 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
8537 /* this one should be received only by old hook proc */
8538 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
8539 /* this one should be received only by old hook proc */
8540 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
8542 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
8544 ret = UnhookWindowsHookEx(hCBT_global_hook);
8545 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
8547 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8548 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8549 CloseHandle(hthread);
8550 CloseHandle(hevent);
8551 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8552 /****** end of global hook test *************/
8554 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
8556 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8564 /* this test doesn't pass under Win9x */
8565 /* win2k ignores events with hwnd == 0 */
8566 SetLastError(0xdeadbeef);
8567 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
8568 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
8569 GetLastError() == 0xdeadbeef, /* Win9x */
8570 "unexpected error %d\n", GetLastError());
8571 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
8574 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
8575 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
8577 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
8579 /****** start of event filtering test *************/
8580 hhook = pSetWinEventHook(
8581 EVENT_OBJECT_SHOW, /* 0x8002 */
8582 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
8583 GetModuleHandleA(0), win_event_global_hook_proc,
8584 GetCurrentProcessId(), 0,
8585 WINEVENT_INCONTEXT);
8586 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
8588 hevent = CreateEventA(NULL, 0, 0, NULL);
8592 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
8593 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8595 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8597 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
8600 /* this one should be received only by old hook proc */
8601 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
8602 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
8603 /* this one should be received only by old hook proc */
8604 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
8606 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
8608 ret = pUnhookWinEvent(hhook);
8609 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8611 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8612 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8613 CloseHandle(hthread);
8614 CloseHandle(hevent);
8615 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8616 /****** end of event filtering test *************/
8618 /****** start of out of context event test *************/
8619 hhook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0,
8620 win_event_global_hook_proc, GetCurrentProcessId(), 0,
8621 WINEVENT_OUTOFCONTEXT);
8622 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
8624 hevent = CreateEventA(NULL, 0, 0, NULL);
8630 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
8631 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8633 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8635 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
8636 /* process pending winevent messages */
8637 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
8638 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
8641 /* this one should be received only by old hook proc */
8642 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
8643 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
8644 /* this one should be received only by old hook proc */
8645 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
8647 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
8648 /* process pending winevent messages */
8649 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
8650 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
8652 ret = pUnhookWinEvent(hhook);
8653 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8655 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8656 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8657 CloseHandle(hthread);
8658 CloseHandle(hevent);
8659 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8660 /****** end of out of context event test *************/
8662 /****** start of MOUSE_LL hook test *************/
8663 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
8664 /* WH_MOUSE_LL is not supported on Win9x platforms */
8665 if (!hCBT_global_hook)
8667 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
8668 goto skip_mouse_ll_hook_test;
8671 hevent = CreateEventA(NULL, 0, 0, NULL);
8675 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
8676 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8678 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
8679 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
8681 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
8684 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8685 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
8686 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8688 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
8690 ret = UnhookWindowsHookEx(hCBT_global_hook);
8691 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
8693 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8694 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8695 CloseHandle(hthread);
8696 CloseHandle(hevent);
8697 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8698 /****** end of MOUSE_LL hook test *************/
8699 skip_mouse_ll_hook_test:
8701 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8704 static void test_set_hook(void)
8708 HWINEVENTHOOK hwinevent_hook;
8710 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
8711 ok(hhook != 0, "local hook does not require hModule set to 0\n");
8712 UnhookWindowsHookEx(hhook);
8716 /* this test doesn't pass under Win9x: BUG! */
8717 SetLastError(0xdeadbeef);
8718 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
8719 ok(!hhook, "global hook requires hModule != 0\n");
8720 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
8723 SetLastError(0xdeadbeef);
8724 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
8725 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
8726 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
8727 GetLastError() == 0xdeadbeef, /* Win9x */
8728 "unexpected error %d\n", GetLastError());
8730 SetLastError(0xdeadbeef);
8731 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8732 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
8733 GetLastError() == 0xdeadbeef, /* Win9x */
8734 "unexpected error %d\n", GetLastError());
8736 if (!pSetWinEventHook || !pUnhookWinEvent) return;
8738 /* even process local incontext hooks require hmodule */
8739 SetLastError(0xdeadbeef);
8740 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8741 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
8742 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8743 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8744 GetLastError() == 0xdeadbeef, /* Win9x */
8745 "unexpected error %d\n", GetLastError());
8747 /* even thread local incontext hooks require hmodule */
8748 SetLastError(0xdeadbeef);
8749 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8750 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
8751 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8752 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8753 GetLastError() == 0xdeadbeef, /* Win9x */
8754 "unexpected error %d\n", GetLastError());
8758 /* these 3 tests don't pass under Win9x */
8759 SetLastError(0xdeadbeef);
8760 hwinevent_hook = pSetWinEventHook(1, 0, 0, win_event_proc,
8761 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8762 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8763 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8765 SetLastError(0xdeadbeef);
8766 hwinevent_hook = pSetWinEventHook(-1, 1, 0, win_event_proc,
8767 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8768 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8769 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8771 SetLastError(0xdeadbeef);
8772 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8773 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
8774 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
8775 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
8778 SetLastError(0xdeadbeef);
8779 hwinevent_hook = pSetWinEventHook(0, 0, 0, win_event_proc,
8780 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8781 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8782 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8783 ret = pUnhookWinEvent(hwinevent_hook);
8784 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8787 /* This call succeeds under win2k SP4, but fails under Wine.
8788 Does win2k test/use passed process id? */
8789 SetLastError(0xdeadbeef);
8790 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8791 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
8792 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8793 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8794 ret = pUnhookWinEvent(hwinevent_hook);
8795 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8798 SetLastError(0xdeadbeef);
8799 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
8800 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
8801 GetLastError() == 0xdeadbeef, /* Win9x */
8802 "unexpected error %d\n", GetLastError());
8805 static const struct message ScrollWindowPaint1[] = {
8807 { WM_ERASEBKGND, sent|beginpaint },
8808 { WM_GETTEXTLENGTH, sent|optional },
8809 { WM_PAINT, sent|optional },
8810 { WM_NCPAINT, sent|beginpaint|optional },
8811 { WM_GETTEXT, sent|beginpaint|optional },
8812 { WM_GETTEXT, sent|beginpaint|optional },
8813 { WM_GETTEXT, sent|beginpaint|optional },
8814 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
8815 { WM_ERASEBKGND, sent|beginpaint|optional },
8819 static const struct message ScrollWindowPaint2[] = {
8824 static void test_scrollwindowex(void)
8827 RECT rect={0,0,130,130};
8829 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8830 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
8831 100, 100, 200, 200, 0, 0, 0, NULL);
8832 ok (hwnd != 0, "Failed to create overlapped window\n");
8833 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
8834 WS_VISIBLE|WS_CAPTION|WS_CHILD,
8835 10, 10, 150, 150, hwnd, 0, 0, NULL);
8836 ok (hchild != 0, "Failed to create child\n");
8841 /* scroll without the child window */
8842 trace("start scroll\n");
8843 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8844 SW_ERASE|SW_INVALIDATE);
8845 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8846 trace("end scroll\n");
8849 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8853 /* Now without the SW_ERASE flag */
8854 trace("start scroll\n");
8855 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
8856 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8857 trace("end scroll\n");
8860 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
8864 /* now scroll the child window as well */
8865 trace("start scroll\n");
8866 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8867 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
8868 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8869 /* windows sometimes a WM_MOVE */
8870 ok_sequence(WmEmptySeq, "ScrollWindowEx", TRUE);
8871 trace("end scroll\n");
8874 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8878 /* now scroll with ScrollWindow() */
8879 trace("start scroll with ScrollWindow\n");
8880 ScrollWindow( hwnd, 5, 5, NULL, NULL);
8881 trace("end scroll\n");
8884 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
8886 ok(DestroyWindow(hchild), "failed to destroy window\n");
8887 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8891 static const struct message destroy_window_with_children[] = {
8892 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8893 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
8894 { 0x0090, sent|optional },
8895 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
8896 { 0x0090, sent|optional },
8897 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8898 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8899 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8900 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8901 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
8902 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8903 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8904 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8905 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8906 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8907 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8908 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8909 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8913 static void test_DestroyWindow(void)
8916 HWND parent, child1, child2, child3, child4, test;
8917 UINT_PTR child_id = WND_CHILD_ID + 1;
8919 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8920 100, 100, 200, 200, 0, 0, 0, NULL);
8921 assert(parent != 0);
8922 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8923 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
8924 assert(child1 != 0);
8925 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8926 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
8927 assert(child2 != 0);
8928 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8929 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
8930 assert(child3 != 0);
8931 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
8932 0, 0, 50, 50, parent, 0, 0, NULL);
8933 assert(child4 != 0);
8935 /* test owner/parent of child2 */
8936 test = GetParent(child2);
8937 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8938 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8940 test = pGetAncestor(child2, GA_PARENT);
8941 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8943 test = GetWindow(child2, GW_OWNER);
8944 ok(!test, "wrong owner %p\n", test);
8946 test = SetParent(child2, parent);
8947 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
8949 /* test owner/parent of the parent */
8950 test = GetParent(parent);
8951 ok(!test, "wrong parent %p\n", test);
8952 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
8954 test = pGetAncestor(parent, GA_PARENT);
8955 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8957 test = GetWindow(parent, GW_OWNER);
8958 ok(!test, "wrong owner %p\n", test);
8960 /* test owner/parent of child1 */
8961 test = GetParent(child1);
8962 ok(test == parent, "wrong parent %p\n", test);
8963 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
8965 test = pGetAncestor(child1, GA_PARENT);
8966 ok(test == parent, "wrong parent %p\n", test);
8968 test = GetWindow(child1, GW_OWNER);
8969 ok(!test, "wrong owner %p\n", test);
8971 /* test owner/parent of child2 */
8972 test = GetParent(child2);
8973 ok(test == parent, "wrong parent %p\n", test);
8974 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8976 test = pGetAncestor(child2, GA_PARENT);
8977 ok(test == parent, "wrong parent %p\n", test);
8979 test = GetWindow(child2, GW_OWNER);
8980 ok(!test, "wrong owner %p\n", test);
8982 /* test owner/parent of child3 */
8983 test = GetParent(child3);
8984 ok(test == child1, "wrong parent %p\n", test);
8985 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
8987 test = pGetAncestor(child3, GA_PARENT);
8988 ok(test == child1, "wrong parent %p\n", test);
8990 test = GetWindow(child3, GW_OWNER);
8991 ok(!test, "wrong owner %p\n", test);
8993 /* test owner/parent of child4 */
8994 test = GetParent(child4);
8995 ok(test == parent, "wrong parent %p\n", test);
8996 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
8998 test = pGetAncestor(child4, GA_PARENT);
8999 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
9001 test = GetWindow(child4, GW_OWNER);
9002 ok(test == parent, "wrong owner %p\n", test);
9006 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
9007 parent, child1, child2, child3, child4);
9010 test = GetCapture();
9011 ok(test == child4, "wrong capture window %p\n", test);
9013 test_DestroyWindow_flag = TRUE;
9014 ret = DestroyWindow(parent);
9015 ok( ret, "DestroyWindow() error %d\n", GetLastError());
9016 test_DestroyWindow_flag = FALSE;
9017 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
9019 ok(!IsWindow(parent), "parent still exists\n");
9020 ok(!IsWindow(child1), "child1 still exists\n");
9021 ok(!IsWindow(child2), "child2 still exists\n");
9022 ok(!IsWindow(child3), "child3 still exists\n");
9023 ok(!IsWindow(child4), "child4 still exists\n");
9025 test = GetCapture();
9026 ok(!test, "wrong capture window %p\n", test);
9030 static const struct message WmDispatchPaint[] = {
9031 { WM_NCPAINT, sent },
9032 { WM_GETTEXT, sent|defwinproc|optional },
9033 { WM_GETTEXT, sent|defwinproc|optional },
9034 { WM_ERASEBKGND, sent },
9038 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9040 if (message == WM_PAINT) return 0;
9041 return MsgCheckProcA( hwnd, message, wParam, lParam );
9044 static void test_DispatchMessage(void)
9049 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
9050 100, 100, 200, 200, 0, 0, 0, NULL);
9051 ShowWindow( hwnd, SW_SHOW );
9052 UpdateWindow( hwnd );
9055 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
9057 SetRect( &rect, -5, -5, 5, 5 );
9058 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
9060 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
9062 if (msg.message != WM_PAINT) DispatchMessage( &msg );
9066 DispatchMessage( &msg );
9067 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
9068 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
9069 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
9070 if (++count > 10) break;
9073 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
9075 trace("now without DispatchMessage\n");
9077 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
9079 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
9081 if (msg.message != WM_PAINT) DispatchMessage( &msg );
9084 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
9086 /* this will send WM_NCCPAINT just like DispatchMessage does */
9087 GetUpdateRgn( hwnd, hrgn, TRUE );
9088 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
9089 DeleteObject( hrgn );
9090 GetClientRect( hwnd, &rect );
9091 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
9092 ok( !count, "Got multiple WM_PAINTs\n" );
9093 if (++count > 10) break;
9096 DestroyWindow(hwnd);
9100 static const struct message WmUser[] = {
9112 static DWORD CALLBACK send_msg_thread( LPVOID arg )
9114 struct sendmsg_info *info = arg;
9115 SetLastError( 0xdeadbeef );
9116 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
9117 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT ||
9118 broken(GetLastError() == 0), /* win9x */
9119 "unexpected error %d\n", GetLastError());
9123 static void wait_for_thread( HANDLE thread )
9125 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
9128 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
9132 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9134 if (message == WM_USER) Sleep(200);
9135 return MsgCheckProcA( hwnd, message, wParam, lParam );
9138 static void test_SendMessageTimeout(void)
9141 struct sendmsg_info info;
9145 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
9146 100, 100, 200, 200, 0, 0, 0, NULL);
9150 info.timeout = 1000;
9151 info.ret = 0xdeadbeef;
9152 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9153 wait_for_thread( thread );
9154 CloseHandle( thread );
9155 ok( info.ret == 1, "SendMessageTimeout failed\n" );
9156 ok_sequence( WmUser, "WmUser", FALSE );
9159 info.ret = 0xdeadbeef;
9160 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9161 Sleep(100); /* SendMessageTimeout should time out here */
9162 wait_for_thread( thread );
9163 CloseHandle( thread );
9164 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
9165 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
9167 /* 0 means infinite timeout (but not on win9x) */
9169 info.ret = 0xdeadbeef;
9170 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9172 wait_for_thread( thread );
9173 CloseHandle( thread );
9174 is_win9x = !info.ret;
9175 if (is_win9x) ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
9176 else ok_sequence( WmUser, "WmUser", FALSE );
9178 /* timeout is treated as signed despite the prototype (but not on win9x) */
9179 info.timeout = 0x7fffffff;
9180 info.ret = 0xdeadbeef;
9181 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9183 wait_for_thread( thread );
9184 CloseHandle( thread );
9185 ok( info.ret == 1, "SendMessageTimeout failed\n" );
9186 ok_sequence( WmUser, "WmUser", FALSE );
9188 info.timeout = 0x80000000;
9189 info.ret = 0xdeadbeef;
9190 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9192 wait_for_thread( thread );
9193 CloseHandle( thread );
9196 ok( info.ret == 1, "SendMessageTimeout failed\n" );
9197 ok_sequence( WmUser, "WmUser", FALSE );
9201 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
9202 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
9205 /* now check for timeout during message processing */
9206 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
9208 info.ret = 0xdeadbeef;
9209 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9210 wait_for_thread( thread );
9211 CloseHandle( thread );
9212 /* we should time out but still get the message */
9213 ok( info.ret == 0, "SendMessageTimeout failed\n" );
9214 ok_sequence( WmUser, "WmUser", FALSE );
9216 DestroyWindow( info.hwnd );
9220 /****************** edit message test *************************/
9221 #define ID_EDIT 0x1234
9222 static const struct message sl_edit_setfocus[] =
9224 { HCBT_SETFOCUS, hook },
9225 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9226 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9227 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9228 { WM_SETFOCUS, sent|wparam, 0 },
9229 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9230 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
9231 { WM_CTLCOLOREDIT, sent|parent },
9232 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9233 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9234 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9235 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9238 static const struct message ml_edit_setfocus[] =
9240 { HCBT_SETFOCUS, hook },
9241 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9242 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9243 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9244 { WM_SETFOCUS, sent|wparam, 0 },
9245 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9246 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9247 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9248 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9249 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9252 static const struct message sl_edit_killfocus[] =
9254 { HCBT_SETFOCUS, hook },
9255 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9256 { WM_KILLFOCUS, sent|wparam, 0 },
9257 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9258 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9259 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
9260 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
9261 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
9264 static const struct message sl_edit_lbutton_dblclk[] =
9266 { WM_LBUTTONDBLCLK, sent },
9267 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
9270 static const struct message sl_edit_lbutton_down[] =
9272 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
9273 { HCBT_SETFOCUS, hook },
9274 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
9275 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9276 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9277 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
9278 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9279 { WM_CTLCOLOREDIT, sent|parent },
9280 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9281 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9282 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9283 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9284 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9285 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
9286 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9287 { WM_CTLCOLOREDIT, sent|parent|optional },
9288 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9289 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9290 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9293 static const struct message ml_edit_lbutton_down[] =
9295 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
9296 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
9297 { HCBT_SETFOCUS, hook },
9298 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
9299 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9300 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9301 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
9302 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9303 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9304 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9305 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9306 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9309 static const struct message sl_edit_lbutton_up[] =
9311 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
9312 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9313 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
9314 { WM_CAPTURECHANGED, sent|defwinproc },
9315 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9318 static const struct message ml_edit_lbutton_up[] =
9320 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
9321 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
9322 { WM_CAPTURECHANGED, sent|defwinproc },
9326 static WNDPROC old_edit_proc;
9328 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9330 static LONG defwndproc_counter = 0;
9332 struct recvd_message msg;
9334 if (ignore_message( message )) return 0;
9337 msg.message = message;
9338 msg.flags = sent|wparam|lparam;
9339 if (defwndproc_counter) msg.flags |= defwinproc;
9340 msg.wParam = wParam;
9341 msg.lParam = lParam;
9345 defwndproc_counter++;
9346 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
9347 defwndproc_counter--;
9352 static void subclass_edit(void)
9356 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
9358 old_edit_proc = cls.lpfnWndProc;
9360 cls.hInstance = GetModuleHandle(0);
9361 cls.lpfnWndProc = edit_hook_proc;
9362 cls.lpszClassName = "my_edit_class";
9363 UnregisterClass(cls.lpszClassName, cls.hInstance);
9364 if (!RegisterClassA(&cls)) assert(0);
9367 static void test_edit_messages(void)
9373 log_all_parent_messages++;
9375 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9376 100, 100, 200, 200, 0, 0, 0, NULL);
9377 ok (parent != 0, "Failed to create parent window\n");
9379 /* test single line edit */
9380 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
9381 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
9382 ok(hwnd != 0, "Failed to create edit window\n");
9384 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
9385 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
9387 ShowWindow(hwnd, SW_SHOW);
9393 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
9396 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
9402 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
9403 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
9409 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
9410 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
9412 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
9413 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
9415 DestroyWindow(hwnd);
9417 /* test multiline edit */
9418 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
9419 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
9420 ok(hwnd != 0, "Failed to create edit window\n");
9422 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
9423 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
9424 "wrong dlg_code %08x\n", dlg_code);
9426 ShowWindow(hwnd, SW_SHOW);
9432 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
9435 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
9441 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
9442 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
9448 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
9449 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
9451 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
9452 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
9454 DestroyWindow(hwnd);
9455 DestroyWindow(parent);
9457 log_all_parent_messages--;
9460 /**************************** End of Edit test ******************************/
9462 static const struct message WmKeyDownSkippedSeq[] =
9464 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
9467 static const struct message WmKeyDownWasDownSkippedSeq[] =
9469 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x40000001 }, /* XP */
9472 static const struct message WmKeyUpSkippedSeq[] =
9474 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
9477 static const struct message WmUserKeyUpSkippedSeq[] =
9480 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
9485 #define EV_SENDMSG 1
9491 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9494 static DWORD CALLBACK send_msg_thread_2(void *param)
9497 struct peekmsg_info *info = param;
9499 trace("thread: looping\n");
9500 SetEvent(info->hevent[EV_ACK]);
9504 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
9508 case WAIT_OBJECT_0 + EV_STOP:
9509 trace("thread: exiting\n");
9512 case WAIT_OBJECT_0 + EV_SENDMSG:
9513 trace("thread: sending message\n");
9514 ret = SendNotifyMessageA(info->hwnd, WM_USER, 0, 0);
9515 ok(ret, "SendNotifyMessageA failed error %u\n", GetLastError());
9516 SetEvent(info->hevent[EV_ACK]);
9520 trace("unexpected return: %04x\n", ret);
9528 static void test_PeekMessage(void)
9533 UINT qs_all_input = QS_ALLINPUT;
9534 UINT qs_input = QS_INPUT;
9536 struct peekmsg_info info;
9538 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
9539 100, 100, 200, 200, 0, 0, 0, NULL);
9541 ShowWindow(info.hwnd, SW_SHOW);
9542 UpdateWindow(info.hwnd);
9543 SetFocus(info.hwnd);
9545 info.hevent[EV_STOP] = CreateEventA(NULL, 0, 0, NULL);
9546 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
9547 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
9549 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
9550 WaitForSingleObject(info.hevent[EV_ACK], 10000);
9555 SetLastError(0xdeadbeef);
9556 qstatus = GetQueueStatus(qs_all_input);
9557 if (GetLastError() == ERROR_INVALID_FLAGS)
9559 trace("QS_RAWINPUT not supported on this platform\n");
9560 qs_all_input &= ~QS_RAWINPUT;
9561 qs_input &= ~QS_RAWINPUT;
9563 if (qstatus & QS_POSTMESSAGE)
9565 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) /* nothing */ ;
9566 qstatus = GetQueueStatus(qs_all_input);
9568 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9570 trace("signalling to send message\n");
9571 SetEvent(info.hevent[EV_SENDMSG]);
9572 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9574 /* pass invalid QS_xxxx flags */
9575 SetLastError(0xdeadbeef);
9576 qstatus = GetQueueStatus(0xffffffff);
9577 ok(qstatus == 0 || broken(qstatus) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus);
9580 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
9581 qstatus = GetQueueStatus(qs_all_input);
9583 qstatus &= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
9584 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
9585 "wrong qstatus %08x\n", qstatus);
9588 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9590 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9592 ok_sequence(WmUser, "WmUser", FALSE);
9594 qstatus = GetQueueStatus(qs_all_input);
9595 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9597 keybd_event('N', 0, 0, 0);
9598 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
9599 qstatus = GetQueueStatus(qs_all_input);
9600 if (!(qstatus & MAKELONG(QS_KEY, QS_KEY)))
9602 skip( "queuing key events not supported\n" );
9605 ok(qstatus == MAKELONG(QS_KEY, QS_KEY) ||
9606 /* keybd_event seems to trigger a sent message on NT4 */
9607 qstatus == MAKELONG(QS_KEY|QS_SENDMESSAGE, QS_KEY|QS_SENDMESSAGE),
9608 "wrong qstatus %08x\n", qstatus);
9610 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9611 qstatus = GetQueueStatus(qs_all_input);
9612 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY) ||
9613 qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY|QS_SENDMESSAGE),
9614 "wrong qstatus %08x\n", qstatus);
9616 InvalidateRect(info.hwnd, NULL, FALSE);
9617 qstatus = GetQueueStatus(qs_all_input);
9618 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY) ||
9619 qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY|QS_SENDMESSAGE),
9620 "wrong qstatus %08x\n", qstatus);
9622 trace("signalling to send message\n");
9623 SetEvent(info.hevent[EV_SENDMSG]);
9624 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9626 qstatus = GetQueueStatus(qs_all_input);
9627 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9628 "wrong qstatus %08x\n", qstatus);
9631 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
9632 if (ret && msg.message == WM_CHAR)
9634 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9638 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9640 if (!sequence_cnt) /* nt4 doesn't fetch anything with PM_QS_* flags */
9642 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9645 ok_sequence(WmUser, "WmUser", FALSE);
9647 qstatus = GetQueueStatus(qs_all_input);
9648 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9649 "wrong qstatus %08x\n", qstatus);
9651 trace("signalling to send message\n");
9652 SetEvent(info.hevent[EV_SENDMSG]);
9653 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9655 qstatus = GetQueueStatus(qs_all_input);
9656 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9657 "wrong qstatus %08x\n", qstatus);
9660 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE );
9662 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9664 ok_sequence(WmUser, "WmUser", FALSE);
9666 qstatus = GetQueueStatus(qs_all_input);
9667 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9668 "wrong qstatus %08x\n", qstatus);
9671 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
9672 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9673 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9674 ret, msg.message, msg.wParam);
9675 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9677 qstatus = GetQueueStatus(qs_all_input);
9678 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
9679 "wrong qstatus %08x\n", qstatus);
9682 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
9684 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9686 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9688 qstatus = GetQueueStatus(qs_all_input);
9689 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
9690 "wrong qstatus %08x\n", qstatus);
9693 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
9694 ok(ret && msg.message == WM_PAINT,
9695 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
9696 DispatchMessageA(&msg);
9697 ok_sequence(WmPaint, "WmPaint", FALSE);
9699 qstatus = GetQueueStatus(qs_all_input);
9700 ok(qstatus == MAKELONG(0, QS_KEY),
9701 "wrong qstatus %08x\n", qstatus);
9704 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
9706 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9708 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9710 qstatus = GetQueueStatus(qs_all_input);
9711 ok(qstatus == MAKELONG(0, QS_KEY),
9712 "wrong qstatus %08x\n", qstatus);
9714 trace("signalling to send message\n");
9715 SetEvent(info.hevent[EV_SENDMSG]);
9716 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9718 qstatus = GetQueueStatus(qs_all_input);
9719 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
9720 "wrong qstatus %08x\n", qstatus);
9722 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9724 qstatus = GetQueueStatus(qs_all_input);
9725 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9726 "wrong qstatus %08x\n", qstatus);
9729 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
9730 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9731 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9732 ret, msg.message, msg.wParam);
9733 ok_sequence(WmUser, "WmUser", FALSE);
9735 qstatus = GetQueueStatus(qs_all_input);
9736 ok(qstatus == MAKELONG(0, QS_KEY),
9737 "wrong qstatus %08x\n", qstatus);
9740 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
9742 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9744 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9746 qstatus = GetQueueStatus(qs_all_input);
9747 ok(qstatus == MAKELONG(0, QS_KEY),
9748 "wrong qstatus %08x\n", qstatus);
9750 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9752 qstatus = GetQueueStatus(qs_all_input);
9753 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
9754 "wrong qstatus %08x\n", qstatus);
9756 trace("signalling to send message\n");
9757 SetEvent(info.hevent[EV_SENDMSG]);
9758 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9760 qstatus = GetQueueStatus(qs_all_input);
9761 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9762 "wrong qstatus %08x\n", qstatus);
9765 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
9767 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9769 ok_sequence(WmUser, "WmUser", FALSE);
9771 qstatus = GetQueueStatus(qs_all_input);
9772 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
9773 "wrong qstatus %08x\n", qstatus);
9776 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
9777 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
9778 else /* workaround for a missing QS_RAWINPUT support */
9779 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
9780 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9781 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9782 ret, msg.message, msg.wParam);
9783 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
9785 qstatus = GetQueueStatus(qs_all_input);
9786 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
9787 "wrong qstatus %08x\n", qstatus);
9790 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
9791 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
9792 else /* workaround for a missing QS_RAWINPUT support */
9793 ret = PeekMessageA(&msg, 0, WM_KEYUP, WM_KEYUP, PM_REMOVE);
9794 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
9795 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9796 ret, msg.message, msg.wParam);
9797 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
9799 qstatus = GetQueueStatus(qs_all_input);
9800 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9801 "wrong qstatus %08x\n", qstatus);
9804 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
9806 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9808 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9810 qstatus = GetQueueStatus(qs_all_input);
9811 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9812 "wrong qstatus %08x\n", qstatus);
9815 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9816 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9817 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9818 ret, msg.message, msg.wParam);
9819 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9821 qstatus = GetQueueStatus(qs_all_input);
9823 "wrong qstatus %08x\n", qstatus);
9826 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9828 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9830 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9832 qstatus = GetQueueStatus(qs_all_input);
9834 "wrong qstatus %08x\n", qstatus);
9836 /* test whether presence of the quit flag in the queue affects
9839 PostQuitMessage(0x1234abcd);
9841 qstatus = GetQueueStatus(qs_all_input);
9842 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9843 "wrong qstatus %08x\n", qstatus);
9845 PostMessageA(info.hwnd, WM_USER, 0, 0);
9847 qstatus = GetQueueStatus(qs_all_input);
9848 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9849 "wrong qstatus %08x\n", qstatus);
9852 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9853 ok(ret && msg.message == WM_USER,
9854 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
9855 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9857 qstatus = GetQueueStatus(qs_all_input);
9858 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9859 "wrong qstatus %08x\n", qstatus);
9862 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9863 ok(ret && msg.message == WM_QUIT,
9864 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
9865 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
9866 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
9867 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9869 qstatus = GetQueueStatus(qs_all_input);
9871 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9872 "wrong qstatus %08x\n", qstatus);
9876 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9878 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9880 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9882 qstatus = GetQueueStatus(qs_all_input);
9884 "wrong qstatus %08x\n", qstatus);
9886 /* some GetMessage tests */
9888 keybd_event('N', 0, 0, 0);
9889 qstatus = GetQueueStatus(qs_all_input);
9890 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9892 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9893 qstatus = GetQueueStatus(qs_all_input);
9894 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9898 ret = GetMessageA( &msg, 0, 0, 0 );
9899 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9900 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9901 ret, msg.message, msg.wParam);
9902 qstatus = GetQueueStatus(qs_all_input);
9903 ok(qstatus == MAKELONG(0, QS_KEY), "wrong qstatus %08x\n", qstatus);
9908 ret = GetMessageA( &msg, 0, 0, 0 );
9909 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9910 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9911 ret, msg.message, msg.wParam);
9912 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
9913 qstatus = GetQueueStatus(qs_all_input);
9914 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9917 keybd_event('N', 0, 0, 0);
9918 qstatus = GetQueueStatus(qs_all_input);
9919 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9921 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9922 qstatus = GetQueueStatus(qs_all_input);
9923 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9925 if (qstatus & (QS_KEY << 16))
9927 ret = GetMessageA( &msg, 0, WM_KEYDOWN, WM_KEYUP );
9928 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9929 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9930 ret, msg.message, msg.wParam);
9931 ok_sequence(WmKeyDownWasDownSkippedSeq, "WmKeyDownWasDownSkippedSeq", FALSE);
9932 qstatus = GetQueueStatus(qs_all_input);
9933 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), "wrong qstatus %08x\n", qstatus);
9938 ret = GetMessageA( &msg, 0, WM_CHAR, WM_CHAR );
9939 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9940 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9941 ret, msg.message, msg.wParam);
9942 qstatus = GetQueueStatus(qs_all_input);
9943 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9946 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
9947 qstatus = GetQueueStatus(qs_all_input);
9948 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9950 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9951 qstatus = GetQueueStatus(qs_all_input);
9952 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9954 trace("signalling to send message\n");
9955 SetEvent(info.hevent[EV_SENDMSG]);
9956 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9957 qstatus = GetQueueStatus(qs_all_input);
9958 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9959 "wrong qstatus %08x\n", qstatus);
9961 if (qstatus & (QS_KEY << 16))
9963 ret = GetMessageA( &msg, 0, WM_KEYDOWN, WM_KEYUP );
9964 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
9965 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9966 ret, msg.message, msg.wParam);
9967 ok_sequence(WmUserKeyUpSkippedSeq, "WmUserKeyUpSkippedSeq", FALSE);
9968 qstatus = GetQueueStatus(qs_all_input);
9969 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), "wrong qstatus %08x\n", qstatus);
9974 ret = GetMessageA( &msg, 0, WM_CHAR, WM_CHAR );
9975 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9976 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9977 ret, msg.message, msg.wParam);
9978 qstatus = GetQueueStatus(qs_all_input);
9979 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9982 trace("signalling to exit\n");
9983 SetEvent(info.hevent[EV_STOP]);
9985 WaitForSingleObject(hthread, INFINITE);
9987 CloseHandle(hthread);
9988 CloseHandle(info.hevent[0]);
9989 CloseHandle(info.hevent[1]);
9990 CloseHandle(info.hevent[2]);
9992 DestroyWindow(info.hwnd);
9995 static void wait_move_event(HWND hwnd, int x, int y)
10002 time = GetTickCount();
10003 while (GetTickCount() - time < 200 && !go) {
10004 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10005 go = ret && msg.pt.x > x && msg.pt.y > y;
10006 if (!ret) MsgWaitForMultipleObjects( 0, NULL, FALSE, GetTickCount() - time, QS_ALLINPUT );
10011 static void test_PeekMessage2(void)
10017 DWORD time1, time2, time3;
10018 int x1, y1, x2, y2, x3, y3;
10021 time1 = time2 = time3 = 0;
10022 x1 = y1 = x2 = y2 = x3 = y3 = 0;
10024 /* Initialise window and make sure it is ready for events */
10025 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
10026 10, 10, 800, 800, NULL, NULL, NULL, NULL);
10028 trace("Window for test_PeekMessage2 %p\n", hwnd);
10029 ShowWindow(hwnd, SW_SHOW);
10030 UpdateWindow(hwnd);
10032 GetCursorPos(&pos);
10033 SetCursorPos(100, 100);
10034 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
10037 /* Do initial mousemove, wait until we can see it
10038 and then do our test peek with PM_NOREMOVE. */
10039 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
10040 wait_move_event(hwnd, 100-STEP, 100-STEP);
10042 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10045 skip( "queuing mouse events not supported\n" );
10050 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
10051 message = msg.message;
10055 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
10058 /* Allow time to advance a bit, and then simulate the user moving their
10059 * mouse around. After that we peek again with PM_NOREMOVE.
10060 * Although the previous mousemove message was never removed, the
10061 * mousemove we now peek should reflect the recent mouse movements
10062 * because the input queue will merge the move events. */
10064 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
10065 wait_move_event(hwnd, x1, y1);
10067 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10068 ok(ret, "no message available\n");
10070 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
10071 message = msg.message;
10075 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
10076 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
10077 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
10080 /* Have another go, to drive the point home */
10082 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
10083 wait_move_event(hwnd, x2, y2);
10085 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10086 ok(ret, "no message available\n");
10088 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
10089 message = msg.message;
10093 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
10094 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
10095 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
10099 DestroyWindow(hwnd);
10100 SetCursorPos(pos.x, pos.y);
10104 static INT_PTR CALLBACK wm_quit_dlg_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10106 struct recvd_message msg;
10108 if (ignore_message( message )) return 0;
10111 msg.message = message;
10112 msg.flags = sent|wparam|lparam;
10115 msg.descr = "dialog";
10120 case WM_INITDIALOG:
10121 PostMessage(hwnd, WM_QUIT, 0x1234, 0x5678);
10122 PostMessage(hwnd, WM_USER, 0xdead, 0xbeef);
10125 case WM_GETDLGCODE:
10129 EndDialog(hwnd, 0);
10136 static const struct message WmQuitDialogSeq[] = {
10137 { HCBT_CREATEWND, hook },
10138 { WM_SETFONT, sent },
10139 { WM_INITDIALOG, sent },
10140 { WM_CHANGEUISTATE, sent|optional },
10141 { HCBT_DESTROYWND, hook },
10142 { 0x0090, sent|optional }, /* Vista */
10143 { WM_DESTROY, sent },
10144 { WM_NCDESTROY, sent },
10148 static const struct message WmStopQuitSeq[] = {
10149 { WM_DWMNCRENDERINGCHANGED, posted|optional },
10150 { WM_CLOSE, posted },
10151 { WM_QUIT, posted|wparam|lparam, 0x1234, 0 },
10155 static void test_quit_message(void)
10160 /* test using PostQuitMessage */
10162 PostQuitMessage(0xbeef);
10164 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
10165 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
10166 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10167 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
10169 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
10170 ok(ret, "PostMessage failed with error %d\n", GetLastError());
10172 ret = GetMessage(&msg, NULL, 0, 0);
10173 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
10174 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
10176 /* note: WM_QUIT message received after WM_USER message */
10177 ret = GetMessage(&msg, NULL, 0, 0);
10178 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
10179 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10180 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
10182 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
10183 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
10185 /* now test with PostThreadMessage - different behaviour! */
10186 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
10188 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
10189 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
10190 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10191 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
10193 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
10194 ok(ret, "PostMessage failed with error %d\n", GetLastError());
10196 /* note: we receive the WM_QUIT message first this time */
10197 ret = GetMessage(&msg, NULL, 0, 0);
10198 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
10199 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10200 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
10202 ret = GetMessage(&msg, NULL, 0, 0);
10203 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
10204 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
10208 ret = DialogBoxParam(GetModuleHandle(0), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc, 0);
10209 ok(ret == 1, "expected 1, got %d\n", ret);
10210 ok_sequence(WmQuitDialogSeq, "WmQuitDialogSeq", FALSE);
10211 memset(&msg, 0xab, sizeof(msg));
10212 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
10213 ok(ret, "PeekMessage failed\n");
10214 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10215 ok(msg.wParam == 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg.wParam);
10216 ok(msg.lParam == 0, "lParam was 0x%lx instead of 0\n", msg.lParam);
10218 /* Check what happens to a WM_QUIT message posted to a window that gets
10221 CreateWindowExA(0, "StopQuitClass", "Stop Quit Test", WS_OVERLAPPEDWINDOW,
10222 0, 0, 100, 100, NULL, NULL, NULL, NULL);
10224 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10226 struct recvd_message rmsg;
10227 rmsg.hwnd = msg.hwnd;
10228 rmsg.message = msg.message;
10229 rmsg.flags = posted|wparam|lparam;
10230 rmsg.wParam = msg.wParam;
10231 rmsg.lParam = msg.lParam;
10232 rmsg.descr = "stop/quit";
10233 if (msg.message == WM_QUIT)
10234 /* The hwnd can only be checked here */
10235 ok(!msg.hwnd, "The WM_QUIT hwnd was %p instead of NULL\n", msg.hwnd);
10236 add_message(&rmsg);
10237 DispatchMessage(&msg);
10239 ok_sequence(WmStopQuitSeq, "WmStopQuitSeq", FALSE);
10242 static const struct message WmMouseHoverSeq[] = {
10243 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
10244 { WM_MOUSEACTIVATE, sent|optional },
10245 { WM_TIMER, sent|optional }, /* XP sends it */
10246 { WM_SYSTIMER, sent },
10247 { WM_MOUSEHOVER, sent|wparam, 0 },
10251 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
10254 DWORD start_ticks, end_ticks;
10256 start_ticks = GetTickCount();
10257 /* add some deviation (50%) to cover not expected delays */
10258 start_ticks += timeout / 2;
10262 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10264 /* Timer proc messages are not dispatched to the window proc,
10265 * and therefore not logged.
10267 if ((msg.message == WM_TIMER || msg.message == WM_SYSTIMER) && msg.hwnd)
10269 struct recvd_message s_msg;
10271 s_msg.hwnd = msg.hwnd;
10272 s_msg.message = msg.message;
10273 s_msg.flags = sent|wparam|lparam;
10274 s_msg.wParam = msg.wParam;
10275 s_msg.lParam = msg.lParam;
10276 s_msg.descr = "msg_loop";
10277 add_message(&s_msg);
10279 DispatchMessage(&msg);
10282 end_ticks = GetTickCount();
10284 /* inject WM_MOUSEMOVE to see how it changes tracking */
10285 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
10287 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
10288 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
10290 inject_mouse_move = FALSE;
10292 } while (start_ticks + timeout >= end_ticks);
10295 static void test_TrackMouseEvent(void)
10297 TRACKMOUSEEVENT tme;
10300 RECT rc_parent, rc_child;
10301 UINT default_hover_time, hover_width = 0, hover_height = 0;
10303 #define track_hover(track_hwnd, track_hover_time) \
10304 tme.cbSize = sizeof(tme); \
10305 tme.dwFlags = TME_HOVER; \
10306 tme.hwndTrack = track_hwnd; \
10307 tme.dwHoverTime = track_hover_time; \
10308 SetLastError(0xdeadbeef); \
10309 ret = pTrackMouseEvent(&tme); \
10310 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
10312 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
10313 tme.cbSize = sizeof(tme); \
10314 tme.dwFlags = TME_QUERY; \
10315 tme.hwndTrack = (HWND)0xdeadbeef; \
10316 tme.dwHoverTime = 0xdeadbeef; \
10317 SetLastError(0xdeadbeef); \
10318 ret = pTrackMouseEvent(&tme); \
10319 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
10320 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
10321 ok(tme.dwFlags == (expected_track_flags), \
10322 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
10323 ok(tme.hwndTrack == (expected_track_hwnd), \
10324 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
10325 ok(tme.dwHoverTime == (expected_hover_time), \
10326 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
10328 #define track_hover_cancel(track_hwnd) \
10329 tme.cbSize = sizeof(tme); \
10330 tme.dwFlags = TME_HOVER | TME_CANCEL; \
10331 tme.hwndTrack = track_hwnd; \
10332 tme.dwHoverTime = 0xdeadbeef; \
10333 SetLastError(0xdeadbeef); \
10334 ret = pTrackMouseEvent(&tme); \
10335 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
10337 default_hover_time = 0xdeadbeef;
10338 SetLastError(0xdeadbeef);
10339 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
10340 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
10341 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
10342 if (!ret) default_hover_time = 400;
10343 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
10345 SetLastError(0xdeadbeef);
10346 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
10347 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
10348 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
10349 if (!ret) hover_width = 4;
10350 SetLastError(0xdeadbeef);
10351 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
10352 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
10353 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
10354 if (!ret) hover_height = 4;
10355 trace("hover rect is %u x %d\n", hover_width, hover_height);
10357 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
10358 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10359 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
10363 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
10364 WS_CHILD | WS_BORDER | WS_VISIBLE,
10365 50, 50, 200, 200, hwnd,
10369 SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
10374 tme.dwFlags = TME_QUERY;
10375 tme.hwndTrack = (HWND)0xdeadbeef;
10376 tme.dwHoverTime = 0xdeadbeef;
10377 SetLastError(0xdeadbeef);
10378 ret = pTrackMouseEvent(&tme);
10379 ok(!ret, "TrackMouseEvent should fail\n");
10380 ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef),
10381 "not expected error %u\n", GetLastError());
10383 tme.cbSize = sizeof(tme);
10384 tme.dwFlags = TME_HOVER;
10385 tme.hwndTrack = (HWND)0xdeadbeef;
10386 tme.dwHoverTime = 0xdeadbeef;
10387 SetLastError(0xdeadbeef);
10388 ret = pTrackMouseEvent(&tme);
10389 ok(!ret, "TrackMouseEvent should fail\n");
10390 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
10391 "not expected error %u\n", GetLastError());
10393 tme.cbSize = sizeof(tme);
10394 tme.dwFlags = TME_HOVER | TME_CANCEL;
10395 tme.hwndTrack = (HWND)0xdeadbeef;
10396 tme.dwHoverTime = 0xdeadbeef;
10397 SetLastError(0xdeadbeef);
10398 ret = pTrackMouseEvent(&tme);
10399 ok(!ret, "TrackMouseEvent should fail\n");
10400 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
10401 "not expected error %u\n", GetLastError());
10403 GetWindowRect(hwnd, &rc_parent);
10404 GetWindowRect(hchild, &rc_child);
10405 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
10407 /* Process messages so that the system updates its internal current
10408 * window and hittest, otherwise TrackMouseEvent calls don't have any
10414 track_query(0, NULL, 0);
10415 track_hover(hchild, 0);
10416 track_query(0, NULL, 0);
10421 track_hover(hwnd, 0);
10422 tme.cbSize = sizeof(tme);
10423 tme.dwFlags = TME_QUERY;
10424 tme.hwndTrack = (HWND)0xdeadbeef;
10425 tme.dwHoverTime = 0xdeadbeef;
10426 SetLastError(0xdeadbeef);
10427 ret = pTrackMouseEvent(&tme);
10428 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
10429 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize);
10432 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
10433 DestroyWindow( hwnd );
10436 ok(tme.dwFlags == TME_HOVER, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme.dwFlags);
10437 ok(tme.hwndTrack == hwnd, "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, hwnd);
10438 ok(tme.dwHoverTime == default_hover_time, "wrong tme.dwHoverTime %u, expected %u\n",
10439 tme.dwHoverTime, default_hover_time);
10441 pump_msg_loop_timeout(default_hover_time, FALSE);
10442 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
10444 track_query(0, NULL, 0);
10446 track_hover(hwnd, HOVER_DEFAULT);
10447 track_query(TME_HOVER, hwnd, default_hover_time);
10449 Sleep(default_hover_time / 2);
10450 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
10451 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
10453 track_query(TME_HOVER, hwnd, default_hover_time);
10455 pump_msg_loop_timeout(default_hover_time, FALSE);
10456 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
10458 track_query(0, NULL, 0);
10460 track_hover(hwnd, HOVER_DEFAULT);
10461 track_query(TME_HOVER, hwnd, default_hover_time);
10463 pump_msg_loop_timeout(default_hover_time, TRUE);
10464 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
10466 track_query(0, NULL, 0);
10468 track_hover(hwnd, HOVER_DEFAULT);
10469 track_query(TME_HOVER, hwnd, default_hover_time);
10470 track_hover_cancel(hwnd);
10472 DestroyWindow(hwnd);
10476 #undef track_hover_cancel
10480 static const struct message WmSetWindowRgn[] = {
10481 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10482 { WM_NCCALCSIZE, sent|wparam, 1 },
10483 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
10484 { WM_GETTEXT, sent|defwinproc|optional },
10485 { WM_ERASEBKGND, sent|optional },
10486 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10487 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10491 static const struct message WmSetWindowRgn_no_redraw[] = {
10492 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
10493 { WM_NCCALCSIZE, sent|wparam, 1 },
10494 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
10495 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10499 static const struct message WmSetWindowRgn_clear[] = {
10500 { WM_WINDOWPOSCHANGING, sent/*|wparam*/, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
10501 { WM_NCCALCSIZE, sent|wparam, 1 },
10502 { WM_NCPAINT, sent|optional },
10503 { WM_GETTEXT, sent|defwinproc|optional },
10504 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
10505 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10506 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
10507 { WM_NCPAINT, sent|optional },
10508 { WM_GETTEXT, sent|defwinproc|optional },
10509 { WM_ERASEBKGND, sent|optional },
10510 { WM_WINDOWPOSCHANGING, sent|optional },
10511 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
10512 { WM_NCPAINT, sent|optional },
10513 { WM_GETTEXT, sent|defwinproc|optional },
10514 { WM_ERASEBKGND, sent|optional },
10515 { WM_WINDOWPOSCHANGED, sent|optional|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10516 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
10517 { WM_NCPAINT, sent|optional },
10518 { WM_GETTEXT, sent|defwinproc|optional },
10519 { WM_ERASEBKGND, sent|optional },
10520 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10521 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10525 static void test_SetWindowRgn(void)
10528 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
10529 100, 100, 200, 200, 0, 0, 0, NULL);
10530 ok( hwnd != 0, "Failed to create overlapped window\n" );
10532 ShowWindow( hwnd, SW_SHOW );
10533 UpdateWindow( hwnd );
10537 trace("testing SetWindowRgn\n");
10538 hrgn = CreateRectRgn( 0, 0, 150, 150 );
10539 SetWindowRgn( hwnd, hrgn, TRUE );
10540 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
10542 hrgn = CreateRectRgn( 30, 30, 160, 160 );
10543 SetWindowRgn( hwnd, hrgn, FALSE );
10544 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
10546 hrgn = CreateRectRgn( 0, 0, 180, 180 );
10547 SetWindowRgn( hwnd, hrgn, TRUE );
10548 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
10550 SetWindowRgn( hwnd, 0, TRUE );
10551 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
10553 DestroyWindow( hwnd );
10556 /*************************** ShowWindow() test ******************************/
10557 static const struct message WmShowNormal[] = {
10558 { WM_SHOWWINDOW, sent|wparam, 1 },
10559 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10560 { HCBT_ACTIVATE, hook },
10561 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
10562 { HCBT_SETFOCUS, hook },
10563 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10566 static const struct message WmShow[] = {
10567 { WM_SHOWWINDOW, sent|wparam, 1 },
10568 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10569 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10570 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10571 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10572 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10575 static const struct message WmShowNoActivate_1[] = {
10576 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
10577 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10578 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10579 { WM_MOVE, sent|defwinproc|optional },
10580 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
10583 static const struct message WmShowNoActivate_2[] = {
10584 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
10585 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10586 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10587 { WM_MOVE, sent|defwinproc },
10588 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
10589 { HCBT_SETFOCUS, hook|optional },
10590 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
10591 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
10592 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10593 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
10596 static const struct message WmShowNA_1[] = {
10597 { WM_SHOWWINDOW, sent|wparam, 1 },
10598 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
10599 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10602 static const struct message WmShowNA_2[] = {
10603 { WM_SHOWWINDOW, sent|wparam, 1 },
10604 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
10605 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10608 static const struct message WmRestore_1[] = {
10609 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
10610 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10611 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10612 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10613 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10614 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10615 { WM_MOVE, sent|defwinproc },
10616 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
10617 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
10620 static const struct message WmRestore_2[] = {
10621 { WM_SHOWWINDOW, sent|wparam, 1 },
10622 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10623 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10624 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10625 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10626 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10629 static const struct message WmRestore_3[] = {
10630 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
10631 { WM_GETMINMAXINFO, sent },
10632 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10633 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
10634 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
10635 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
10636 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10637 { WM_MOVE, sent|defwinproc },
10638 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10639 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
10642 static const struct message WmRestore_4[] = {
10643 { HCBT_MINMAX, hook|lparam|optional, 0, SW_RESTORE },
10644 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10645 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10646 { WM_MOVE, sent|defwinproc|optional },
10647 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_RESTORED },
10650 static const struct message WmRestore_5[] = {
10651 { HCBT_MINMAX, hook|lparam|optional, 0, SW_SHOWNORMAL },
10652 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10653 { HCBT_ACTIVATE, hook|optional },
10654 { HCBT_SETFOCUS, hook|optional },
10655 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10656 { WM_MOVE, sent|defwinproc|optional },
10657 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_RESTORED },
10660 static const struct message WmHide_1[] = {
10661 { WM_SHOWWINDOW, sent|wparam, 0 },
10662 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_NOACTIVATE },
10663 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOACTIVATE },
10664 { HCBT_ACTIVATE, hook|optional },
10665 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
10668 static const struct message WmHide_2[] = {
10669 { WM_SHOWWINDOW, sent|wparam, 0 },
10670 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10671 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10672 { HCBT_ACTIVATE, hook|optional },
10675 static const struct message WmHide_3[] = {
10676 { WM_SHOWWINDOW, sent|wparam, 0 },
10677 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10678 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10679 { HCBT_SETFOCUS, hook|optional },
10680 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10683 static const struct message WmShowMinimized_1[] = {
10684 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
10685 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10686 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10687 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10688 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10689 { WM_MOVE, sent|defwinproc },
10690 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10693 static const struct message WmMinimize_1[] = {
10694 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10695 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10696 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10697 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10698 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10699 { WM_MOVE, sent|defwinproc },
10700 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10703 static const struct message WmMinimize_2[] = {
10704 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10705 { HCBT_SETFOCUS, hook|optional },
10706 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10707 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10708 { WM_MOVE, sent|defwinproc },
10709 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10712 static const struct message WmMinimize_3[] = {
10713 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10714 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10715 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10716 { WM_MOVE, sent|defwinproc },
10717 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10720 static const struct message WmShowMinNoActivate[] = {
10721 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
10722 { WM_WINDOWPOSCHANGING, sent },
10723 { WM_WINDOWPOSCHANGED, sent },
10724 { WM_MOVE, sent|defwinproc|optional },
10725 { WM_SIZE, sent|wparam|lparam|defwinproc|optional, SIZE_MINIMIZED, 0 },
10728 static const struct message WmMinMax_1[] = {
10729 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
10732 static const struct message WmMinMax_2[] = {
10733 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10734 { WM_GETMINMAXINFO, sent|optional },
10735 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED },
10736 { HCBT_ACTIVATE, hook|optional },
10737 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
10738 { HCBT_SETFOCUS, hook|optional },
10739 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10740 { WM_MOVE, sent|defwinproc|optional },
10741 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_MAXIMIZED },
10742 { HCBT_SETFOCUS, hook|optional },
10745 static const struct message WmMinMax_3[] = {
10746 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10747 { HCBT_SETFOCUS, hook|optional },
10748 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10749 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10750 { WM_MOVE, sent|defwinproc|optional },
10751 { WM_SIZE, sent|wparam|lparam|defwinproc|optional, SIZE_MINIMIZED, 0 },
10754 static const struct message WmMinMax_4[] = {
10755 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
10758 static const struct message WmShowMaximized_1[] = {
10759 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10760 { WM_GETMINMAXINFO, sent },
10761 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10762 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10763 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10764 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10765 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10766 { WM_MOVE, sent|defwinproc },
10767 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10768 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
10771 static const struct message WmShowMaximized_2[] = {
10772 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10773 { WM_GETMINMAXINFO, sent },
10774 { WM_WINDOWPOSCHANGING, sent|optional },
10775 { HCBT_ACTIVATE, hook|optional },
10776 { WM_WINDOWPOSCHANGED, sent|optional },
10777 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
10778 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
10779 { WM_WINDOWPOSCHANGING, sent|optional },
10780 { HCBT_SETFOCUS, hook|optional },
10781 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10782 { WM_MOVE, sent|defwinproc },
10783 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10784 { HCBT_SETFOCUS, hook|optional },
10787 static const struct message WmShowMaximized_3[] = {
10788 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10789 { WM_GETMINMAXINFO, sent|optional },
10790 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10791 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10792 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10793 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10794 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10795 { WM_MOVE, sent|defwinproc|optional },
10796 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10800 static void test_ShowWindow(void)
10802 /* ShowWindow commands in random order */
10803 static const struct
10805 INT cmd; /* ShowWindow command */
10806 LPARAM ret; /* ShowWindow return value */
10807 DWORD style; /* window style after the command */
10808 const struct message *msg; /* message sequence the command produces */
10809 INT wp_cmd, wp_flags; /* window placement after the command */
10810 POINT wp_min, wp_max; /* window placement after the command */
10811 BOOL todo_msg; /* message sequence doesn't match what Wine does */
10814 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal,
10815 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10816 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq,
10817 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10818 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1,
10819 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10820 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10821 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10822 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1,
10823 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10824 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1,
10825 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10826 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1,
10827 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10828 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq,
10829 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10830 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1,
10831 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10832 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2,
10833 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10834 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1,
10835 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10836 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq,
10837 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10838 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1,
10839 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10840 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq,
10841 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10842 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2,
10843 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10844 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10845 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10846 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow,
10847 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10848 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq,
10849 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10850 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1,
10851 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10852 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3,
10853 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10854 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10855 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10856 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate,
10857 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, TRUE },
10858 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4,
10859 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10860 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10861 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10862 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq,
10863 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10864 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1,
10865 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10866 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2,
10867 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10868 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10869 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10870 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq,
10871 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10872 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1,
10873 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10874 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq,
10875 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10876 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3,
10877 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10878 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10879 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10880 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, /* what does this mean?! */
10881 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10882 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq,
10883 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10884 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10885 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10886 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2,
10887 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10888 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq,
10889 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10890 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq,
10891 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10892 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2,
10893 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10894 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3,
10895 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10896 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2,
10897 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10898 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2,
10899 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10900 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1,
10901 SW_SHOWMINIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10902 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3,
10903 SW_SHOWMINIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10904 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3,
10905 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10906 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4,
10907 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10908 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3,
10909 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10910 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq,
10911 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10912 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5,
10913 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10914 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5,
10915 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10916 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1,
10917 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10918 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10919 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10920 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3,
10921 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10922 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10923 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10924 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2,
10925 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10926 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq,
10927 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE }
10933 WINDOWPLACEMENT wp;
10934 RECT win_rc, work_rc = {0, 0, 0, 0};
10936 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
10937 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
10942 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
10943 ok(style == 0, "expected style 0, got %08x\n", style);
10948 if (pGetMonitorInfoA && pMonitorFromPoint)
10954 SetLastError(0xdeadbeef);
10955 hmon = pMonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
10956 ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
10958 mi.cbSize = sizeof(mi);
10959 SetLastError(0xdeadbeef);
10960 ret = pGetMonitorInfoA(hmon, &mi);
10961 ok(ret, "GetMonitorInfo error %u\n", GetLastError());
10962 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
10963 mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
10964 mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom);
10965 work_rc = mi.rcWork;
10968 GetWindowRect(hwnd, &win_rc);
10969 OffsetRect(&win_rc, -work_rc.left, -work_rc.top);
10971 wp.length = sizeof(wp);
10972 SetLastError(0xdeadbeaf);
10973 ret = GetWindowPlacement(hwnd, &wp);
10974 ok(ret, "GetWindowPlacement error %u\n", GetLastError());
10975 ok(wp.flags == 0, "expected 0, got %#x\n", wp.flags);
10976 ok(wp.showCmd == SW_SHOWNORMAL, "expected SW_SHOWNORMAL, got %d\n", wp.showCmd);
10977 ok(wp.ptMinPosition.x == -1 && wp.ptMinPosition.y == -1,
10978 "expected -1,-1 got %d,%d\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
10979 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
10980 "expected -1,-1 got %d,%d\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
10981 if (work_rc.left || work_rc.top) todo_wine /* FIXME: remove once Wine is fixed */
10982 ok(EqualRect(&win_rc, &wp.rcNormalPosition),
10983 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10984 win_rc.left, win_rc.top, win_rc.right, win_rc.bottom,
10985 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
10986 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
10988 ok(EqualRect(&win_rc, &wp.rcNormalPosition),
10989 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10990 win_rc.left, win_rc.top, win_rc.right, win_rc.bottom,
10991 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
10992 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
10994 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
10996 static const char * const sw_cmd_name[13] =
10998 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
10999 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
11000 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
11001 "SW_NORMALNA" /* 0xCC */
11004 INT idx; /* index into the above array of names */
11006 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
11008 style = GetWindowLong(hwnd, GWL_STYLE);
11009 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
11010 ret = ShowWindow(hwnd, sw[i].cmd);
11011 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
11012 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
11013 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
11015 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
11016 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
11018 wp.length = sizeof(wp);
11019 SetLastError(0xdeadbeaf);
11020 ret = GetWindowPlacement(hwnd, &wp);
11021 ok(ret, "GetWindowPlacement error %u\n", GetLastError());
11022 ok(wp.flags == sw[i].wp_flags, "expected %#x, got %#x\n", sw[i].wp_flags, wp.flags);
11023 ok(wp.showCmd == sw[i].wp_cmd, "expected %d, got %d\n", sw[i].wp_cmd, wp.showCmd);
11025 /* NT moves the minimized window to -32000,-32000, win9x to 3000,3000 */
11026 if ((wp.ptMinPosition.x + work_rc.left == -32000 && wp.ptMinPosition.y + work_rc.top == -32000) ||
11027 (wp.ptMinPosition.x + work_rc.left == 3000 && wp.ptMinPosition.y + work_rc.top == 3000))
11029 ok((wp.ptMinPosition.x + work_rc.left == sw[i].wp_min.x && wp.ptMinPosition.y + work_rc.top == sw[i].wp_min.y) ||
11030 (wp.ptMinPosition.x + work_rc.left == 3000 && wp.ptMinPosition.y + work_rc.top == 3000),
11031 "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
11035 ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y,
11036 "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
11039 if (wp.ptMaxPosition.x != sw[i].wp_max.x || wp.ptMaxPosition.y != sw[i].wp_max.y)
11041 ok(wp.ptMaxPosition.x == sw[i].wp_max.x && wp.ptMaxPosition.y == sw[i].wp_max.y,
11042 "expected %d,%d got %d,%d\n", sw[i].wp_max.x, sw[i].wp_max.y, wp.ptMaxPosition.x, wp.ptMaxPosition.y);
11044 ok(wp.ptMaxPosition.x == sw[i].wp_max.x && wp.ptMaxPosition.y == sw[i].wp_max.y,
11045 "expected %d,%d got %d,%d\n", sw[i].wp_max.x, sw[i].wp_max.y, wp.ptMaxPosition.x, wp.ptMaxPosition.y);
11047 if (0) /* FIXME: Wine behaves completely different here */
11048 ok(EqualRect(&win_rc, &wp.rcNormalPosition),
11049 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11050 win_rc.left, win_rc.top, win_rc.right, win_rc.bottom,
11051 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
11052 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
11058 DestroyWindow(hwnd);
11061 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
11063 struct recvd_message msg;
11065 if (ignore_message( message )) return 0;
11068 msg.message = message;
11069 msg.flags = sent|wparam|lparam;
11070 msg.wParam = wParam;
11071 msg.lParam = lParam;
11072 msg.descr = "dialog";
11075 /* calling DefDlgProc leads to a recursion under XP */
11079 case WM_INITDIALOG:
11080 case WM_GETDLGCODE:
11086 static const struct message WmDefDlgSetFocus_1[] = {
11087 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
11088 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
11089 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
11090 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
11091 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11092 { HCBT_SETFOCUS, hook },
11093 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
11094 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11095 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
11096 { WM_SETFOCUS, sent|wparam, 0 },
11097 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
11098 { WM_CTLCOLOREDIT, sent },
11099 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
11100 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11101 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11102 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11103 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
11106 static const struct message WmDefDlgSetFocus_2[] = {
11107 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
11108 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
11109 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
11110 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
11111 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11112 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11113 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
11114 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11117 /* Creation of a dialog */
11118 static const struct message WmCreateDialogParamSeq_1[] = {
11119 { HCBT_CREATEWND, hook },
11120 { WM_NCCREATE, sent },
11121 { WM_NCCALCSIZE, sent|wparam, 0 },
11122 { WM_CREATE, sent },
11123 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
11124 { WM_SIZE, sent|wparam, SIZE_RESTORED },
11126 { WM_SETFONT, sent },
11127 { WM_INITDIALOG, sent },
11128 { WM_CHANGEUISTATE, sent|optional },
11131 /* Creation of a dialog */
11132 static const struct message WmCreateDialogParamSeq_2[] = {
11133 { HCBT_CREATEWND, hook },
11134 { WM_NCCREATE, sent },
11135 { WM_NCCALCSIZE, sent|wparam, 0 },
11136 { WM_CREATE, sent },
11137 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
11138 { WM_SIZE, sent|wparam, SIZE_RESTORED },
11140 { WM_CHANGEUISTATE, sent|optional },
11144 static void test_dialog_messages(void)
11147 HWND hdlg, hedit1, hedit2, hfocus;
11150 #define set_selection(hctl, start, end) \
11151 ret = SendMessage(hctl, EM_SETSEL, start, end); \
11152 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
11154 #define check_selection(hctl, start, end) \
11155 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
11156 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
11160 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
11161 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
11162 0, 0, 100, 100, 0, 0, 0, NULL);
11163 ok(hdlg != 0, "Failed to create custom dialog window\n");
11165 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
11166 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
11167 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
11168 ok(hedit1 != 0, "Failed to create edit control\n");
11169 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
11170 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
11171 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
11172 ok(hedit2 != 0, "Failed to create edit control\n");
11174 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
11175 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
11177 hfocus = GetFocus();
11178 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
11181 hfocus = GetFocus();
11182 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
11184 check_selection(hedit1, 0, 0);
11185 check_selection(hedit2, 0, 0);
11187 set_selection(hedit2, 0, -1);
11188 check_selection(hedit2, 0, 3);
11191 hfocus = GetFocus();
11192 ok(hfocus == 0, "wrong focus %p\n", hfocus);
11195 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
11196 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
11197 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
11199 hfocus = GetFocus();
11200 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
11202 check_selection(hedit1, 0, 5);
11203 check_selection(hedit2, 0, 3);
11206 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
11207 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
11208 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
11210 hfocus = GetFocus();
11211 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
11213 check_selection(hedit1, 0, 5);
11214 check_selection(hedit2, 0, 3);
11216 EndDialog(hdlg, 0);
11217 DestroyWindow(hedit1);
11218 DestroyWindow(hedit2);
11219 DestroyWindow(hdlg);
11222 #undef set_selection
11223 #undef check_selection
11225 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
11226 cls.lpszClassName = "MyDialogClass";
11227 cls.hInstance = GetModuleHandle(0);
11228 /* need a cast since a dlgproc is used as a wndproc */
11229 cls.lpfnWndProc = test_dlg_proc;
11230 if (!RegisterClass(&cls)) assert(0);
11232 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
11233 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
11234 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
11235 EndDialog(hdlg, 0);
11236 DestroyWindow(hdlg);
11239 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
11240 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
11241 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
11242 EndDialog(hdlg, 0);
11243 DestroyWindow(hdlg);
11246 UnregisterClass(cls.lpszClassName, cls.hInstance);
11249 static void test_EndDialog(void)
11251 HWND hparent, hother, hactive, hdlg;
11254 hparent = CreateWindowExA(0, "TestParentClass", "Test parent",
11255 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_DISABLED,
11256 100, 100, 200, 200, 0, 0, 0, NULL);
11257 ok (hparent != 0, "Failed to create parent window\n");
11259 hother = CreateWindowExA(0, "TestParentClass", "Test parent 2",
11260 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11261 100, 100, 200, 200, 0, 0, 0, NULL);
11262 ok (hother != 0, "Failed to create parent window\n");
11264 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
11265 cls.lpszClassName = "MyDialogClass";
11266 cls.hInstance = GetModuleHandle(0);
11267 cls.lpfnWndProc = test_dlg_proc;
11268 if (!RegisterClass(&cls)) assert(0);
11271 SetForegroundWindow(hother);
11272 hactive = GetForegroundWindow();
11273 ok(hother == hactive, "Wrong window has focus (%p != %p)\n", hother, hactive);
11275 /* create a dialog where the parent is disabled, this parent should still
11276 receive the focus when the dialog exits (even though "normally" a
11277 disabled window should not receive the focus) */
11278 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", hparent, test_dlg_proc, 0);
11279 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
11280 SetForegroundWindow(hdlg);
11281 hactive = GetForegroundWindow();
11282 ok(hdlg == hactive, "Wrong window has focus (%p != %p)\n", hdlg, hactive);
11283 EndDialog(hdlg, 0);
11284 hactive = GetForegroundWindow();
11285 ok(hparent == hactive, "Wrong window has focus (parent != active) (active: %p, parent: %p, dlg: %p, other: %p)\n", hactive, hparent, hdlg, hother);
11286 DestroyWindow(hdlg);
11289 DestroyWindow( hother );
11290 DestroyWindow( hparent );
11291 UnregisterClass(cls.lpszClassName, cls.hInstance);
11294 static void test_nullCallback(void)
11298 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
11299 100, 100, 200, 200, 0, 0, 0, NULL);
11300 ok (hwnd != 0, "Failed to create overlapped window\n");
11302 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
11304 DestroyWindow(hwnd);
11307 /* SetActiveWindow( 0 ) hwnd visible */
11308 static const struct message SetActiveWindowSeq0[] =
11310 { HCBT_ACTIVATE, hook|optional },
11311 { WM_NCACTIVATE, sent|wparam, 0 },
11312 { WM_GETTEXT, sent|defwinproc|optional },
11313 { WM_ACTIVATE, sent|wparam, 0 },
11314 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
11315 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
11316 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11317 { WM_KILLFOCUS, sent|optional },
11318 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11319 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
11320 { WM_NCACTIVATE, sent|wparam|optional, 1 },
11321 { WM_GETTEXT, sent|defwinproc|optional },
11322 { WM_ACTIVATE, sent|wparam|optional, 1 },
11323 { HCBT_SETFOCUS, hook|optional },
11324 { WM_KILLFOCUS, sent|defwinproc|optional },
11325 { WM_IME_SETCONTEXT, sent|defwinproc|optional },
11326 { WM_IME_SETCONTEXT, sent|defwinproc|optional },
11327 { WM_IME_SETCONTEXT, sent|optional },
11328 { WM_IME_SETCONTEXT, sent|optional },
11329 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
11330 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11331 { WM_SETFOCUS, sent|defwinproc|optional },
11332 { WM_GETTEXT, sent|optional },
11335 /* SetActiveWindow( hwnd ) hwnd visible */
11336 static const struct message SetActiveWindowSeq1[] =
11338 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11341 /* SetActiveWindow( popup ) hwnd visible, popup visible */
11342 static const struct message SetActiveWindowSeq2[] =
11344 { HCBT_ACTIVATE, hook },
11345 { WM_NCACTIVATE, sent|wparam, 0 },
11346 { WM_GETTEXT, sent|defwinproc|optional },
11347 { WM_ACTIVATE, sent|wparam, 0 },
11348 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11349 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
11350 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11351 { WM_NCPAINT, sent|optional },
11352 { WM_GETTEXT, sent|defwinproc|optional },
11353 { WM_ERASEBKGND, sent|optional },
11354 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11355 { WM_NCACTIVATE, sent|wparam, 1 },
11356 { WM_GETTEXT, sent|defwinproc|optional },
11357 { WM_ACTIVATE, sent|wparam, 1 },
11358 { HCBT_SETFOCUS, hook },
11359 { WM_KILLFOCUS, sent|defwinproc },
11360 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
11361 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11362 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
11363 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11364 { WM_SETFOCUS, sent|defwinproc },
11365 { WM_GETTEXT, sent|optional },
11369 /* SetActiveWindow( hwnd ) hwnd not visible */
11370 static const struct message SetActiveWindowSeq3[] =
11372 { HCBT_ACTIVATE, hook },
11373 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11374 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11375 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
11376 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11377 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11378 { WM_ACTIVATEAPP, sent|wparam, 1 },
11379 { WM_ACTIVATEAPP, sent|wparam, 1 },
11380 { WM_NCACTIVATE, sent|wparam, 1 },
11381 { WM_ACTIVATE, sent|wparam, 1 },
11382 { HCBT_SETFOCUS, hook },
11383 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11384 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11385 { WM_SETFOCUS, sent|defwinproc },
11388 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
11389 static const struct message SetActiveWindowSeq4[] =
11391 { HCBT_ACTIVATE, hook },
11392 { WM_NCACTIVATE, sent|wparam, 0 },
11393 { WM_GETTEXT, sent|defwinproc|optional },
11394 { WM_ACTIVATE, sent|wparam, 0 },
11395 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11396 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
11397 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11398 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11399 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11400 { WM_NCACTIVATE, sent|wparam, 1 },
11401 { WM_GETTEXT, sent|defwinproc|optional },
11402 { WM_ACTIVATE, sent|wparam, 1 },
11403 { HCBT_SETFOCUS, hook },
11404 { WM_KILLFOCUS, sent|defwinproc },
11405 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
11406 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11407 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
11408 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11409 { WM_SETFOCUS, sent|defwinproc },
11414 static void test_SetActiveWindow(void)
11416 HWND hwnd, popup, ret;
11418 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11419 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11420 100, 100, 200, 200, 0, 0, 0, NULL);
11422 popup = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11423 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_POPUP,
11424 100, 100, 200, 200, hwnd, 0, 0, NULL);
11426 ok(hwnd != 0, "Failed to create overlapped window\n");
11427 ok(popup != 0, "Failed to create popup window\n");
11428 SetForegroundWindow( popup );
11431 trace("SetActiveWindow(0)\n");
11432 ret = SetActiveWindow(0);
11433 ok( ret == popup, "Failed to SetActiveWindow(0)\n");
11434 ok_sequence(SetActiveWindowSeq0, "SetActiveWindow(0)", FALSE);
11437 trace("SetActiveWindow(hwnd), hwnd visible\n");
11438 ret = SetActiveWindow(hwnd);
11439 if (ret == hwnd) ok_sequence(SetActiveWindowSeq1, "SetActiveWindow(hwnd), hwnd visible", TRUE);
11442 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
11443 ret = SetActiveWindow(popup);
11444 ok( ret == hwnd, "Failed to SetActiveWindow(popup), popup visible\n");
11445 ok_sequence(SetActiveWindowSeq2, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE);
11448 ShowWindow(hwnd, SW_HIDE);
11449 ShowWindow(popup, SW_HIDE);
11452 trace("SetActiveWindow(hwnd), hwnd not visible\n");
11453 ret = SetActiveWindow(hwnd);
11454 ok( ret == NULL, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret );
11455 ok_sequence(SetActiveWindowSeq3, "SetActiveWindow(hwnd), hwnd not visible", TRUE);
11458 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
11459 ret = SetActiveWindow(popup);
11460 ok( ret == hwnd, "Failed to SetActiveWindow(popup)\n");
11461 ok_sequence(SetActiveWindowSeq4, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE);
11466 DestroyWindow(hwnd);
11469 static const struct message SetForegroundWindowSeq[] =
11471 { WM_NCACTIVATE, sent|wparam, 0 },
11472 { WM_GETTEXT, sent|defwinproc|optional },
11473 { WM_ACTIVATE, sent|wparam, 0 },
11474 { WM_ACTIVATEAPP, sent|wparam, 0 },
11475 { WM_KILLFOCUS, sent },
11476 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
11477 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
11481 static void test_SetForegroundWindow(void)
11485 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
11486 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11487 100, 100, 200, 200, 0, 0, 0, NULL);
11488 ok (hwnd != 0, "Failed to create overlapped window\n");
11489 SetForegroundWindow( hwnd );
11492 trace("SetForegroundWindow( 0 )\n");
11493 SetForegroundWindow( 0 );
11494 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
11495 trace("SetForegroundWindow( GetDesktopWindow() )\n");
11496 SetForegroundWindow( GetDesktopWindow() );
11497 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
11498 "foreground top level window", FALSE);
11501 DestroyWindow(hwnd);
11504 static void test_dbcs_wm_char(void)
11507 WCHAR wch, bad_wch;
11515 struct message wmCharSeq[2];
11518 if (!pGetCPInfoExA)
11520 win_skip("GetCPInfoExA is not available\n");
11524 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
11525 if (cpinfo.MaxCharSize != 2)
11527 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
11531 dbch[0] = dbch[1] = 0;
11533 bad_wch = cpinfo.UnicodeDefaultChar;
11534 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
11535 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
11536 for (k = 128; k <= 255; k++)
11542 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
11543 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
11544 (BYTE)str[0] == j && (BYTE)str[1] == k &&
11545 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
11556 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
11559 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
11560 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
11562 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
11563 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
11564 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
11565 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
11566 ok (hwnd != 0, "Failed to create overlapped window\n");
11567 ok (hwnd2 != 0, "Failed to create overlapped window\n");
11570 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
11571 wmCharSeq[0].message = WM_CHAR;
11572 wmCharSeq[0].flags = sent|wparam;
11573 wmCharSeq[0].wParam = wch;
11575 /* posted message */
11576 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11577 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11578 ok( !ret, "got message %x\n", msg.message );
11579 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11580 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11581 ok( ret, "no message\n" );
11582 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11583 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
11584 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11585 ok( !ret, "got message %x\n", msg.message );
11587 /* posted thread message */
11588 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
11589 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11590 ok( !ret, "got message %x\n", msg.message );
11591 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11592 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11593 ok( ret, "no message\n" );
11594 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11595 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
11596 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11597 ok( !ret, "got message %x\n", msg.message );
11601 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11602 ok_sequence( WmEmptySeq, "no messages", FALSE );
11603 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11604 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11605 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11606 ok( !ret, "got message %x\n", msg.message );
11608 /* sent message with timeout */
11610 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
11611 ok_sequence( WmEmptySeq, "no messages", FALSE );
11612 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
11613 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11614 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11615 ok( !ret, "got message %x\n", msg.message );
11617 /* sent message with timeout and callback */
11619 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
11620 ok_sequence( WmEmptySeq, "no messages", FALSE );
11621 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
11622 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11623 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11624 ok( !ret, "got message %x\n", msg.message );
11626 /* sent message with callback */
11628 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11629 ok_sequence( WmEmptySeq, "no messages", FALSE );
11630 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
11631 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11632 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11633 ok( !ret, "got message %x\n", msg.message );
11635 /* direct window proc call */
11637 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
11638 ok_sequence( WmEmptySeq, "no messages", FALSE );
11639 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
11640 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11642 /* dispatch message */
11644 msg.message = WM_CHAR;
11645 msg.wParam = dbch[0];
11647 DispatchMessageA( &msg );
11648 ok_sequence( WmEmptySeq, "no messages", FALSE );
11649 msg.wParam = dbch[1];
11650 DispatchMessageA( &msg );
11651 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11653 /* window handle is irrelevant */
11655 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
11656 ok_sequence( WmEmptySeq, "no messages", FALSE );
11657 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11658 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11659 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11660 ok( !ret, "got message %x\n", msg.message );
11662 /* interleaved post and send */
11664 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
11665 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
11666 ok_sequence( WmEmptySeq, "no messages", FALSE );
11667 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11668 ok( !ret, "got message %x\n", msg.message );
11669 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11670 ok_sequence( WmEmptySeq, "no messages", FALSE );
11671 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11672 ok( ret, "no message\n" );
11673 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11674 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
11675 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11676 ok( !ret, "got message %x\n", msg.message );
11677 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11678 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11679 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11680 ok( !ret, "got message %x\n", msg.message );
11682 /* interleaved sent message and winproc */
11684 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11685 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
11686 ok_sequence( WmEmptySeq, "no messages", FALSE );
11687 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11688 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11689 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
11690 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11692 /* interleaved winproc and dispatch */
11694 msg.message = WM_CHAR;
11695 msg.wParam = dbch[0];
11697 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
11698 DispatchMessageA( &msg );
11699 ok_sequence( WmEmptySeq, "no messages", FALSE );
11700 msg.wParam = dbch[1];
11701 DispatchMessageA( &msg );
11702 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11703 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
11704 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11706 /* interleaved sends */
11708 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11709 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
11710 ok_sequence( WmEmptySeq, "no messages", FALSE );
11711 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
11712 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11713 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11714 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11718 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
11719 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11720 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11721 ok( !ret, "got message %x\n", msg.message );
11723 /* other char messages are not magic */
11724 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
11725 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11726 ok( ret, "no message\n" );
11727 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
11728 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
11729 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11730 ok( !ret, "got message %x\n", msg.message );
11731 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
11732 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11733 ok( ret, "no message\n" );
11734 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
11735 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
11736 ret = PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE );
11737 ok( !ret, "got message %x\n", msg.message );
11739 /* test retrieving messages */
11741 PostMessageW( hwnd, WM_CHAR, wch, 0 );
11742 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11743 ok( ret, "no message\n" );
11744 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11745 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11746 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11747 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11748 ok( ret, "no message\n" );
11749 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11750 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11751 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11752 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11753 ok( !ret, "got message %x\n", msg.message );
11755 /* message filters */
11756 PostMessageW( hwnd, WM_CHAR, wch, 0 );
11757 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11758 ok( ret, "no message\n" );
11759 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11760 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11761 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11762 /* message id is filtered, hwnd is not */
11763 ret = PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE );
11764 ok( !ret, "no message\n" );
11765 ret = PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE );
11766 ok( ret, "no message\n" );
11767 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11768 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11769 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11770 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11771 ok( !ret, "got message %x\n", msg.message );
11773 /* mixing GetMessage and PostMessage */
11774 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
11775 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
11776 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11777 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11778 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11779 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
11782 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
11783 ret = PeekMessageA( &msg, 0, 0, 0, PM_REMOVE );
11784 ok( ret, "no message\n" );
11785 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11786 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11787 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11788 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
11789 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
11790 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 );
11791 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11792 ok( !ret, "got message %x\n", msg.message );
11794 /* without PM_REMOVE */
11795 PostMessageW( hwnd, WM_CHAR, wch, 0 );
11796 ret = PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
11797 ok( ret, "no message\n" );
11798 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11799 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11800 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11801 ret = PeekMessageA( &msg, 0, 0, 0, PM_REMOVE );
11802 ok( ret, "no message\n" );
11803 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11804 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11805 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11806 ret = PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE );
11807 ok( ret, "no message\n" );
11808 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11809 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11810 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11811 ret = PeekMessageA( &msg, 0, 0, 0, PM_REMOVE );
11812 ok( ret, "no message\n" );
11813 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11814 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11815 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11816 ret = PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE );
11817 ok( !ret, "got message %x\n", msg.message );
11819 DestroyWindow(hwnd);
11820 DestroyWindow(hwnd2);
11823 #define ID_LISTBOX 0x000f
11825 static const struct message wm_lb_setcursel_0[] =
11827 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
11828 { WM_CTLCOLORLISTBOX, sent|parent },
11829 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
11830 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11831 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11834 static const struct message wm_lb_setcursel_1[] =
11836 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
11837 { WM_CTLCOLORLISTBOX, sent|parent },
11838 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
11839 { WM_CTLCOLORLISTBOX, sent|parent },
11840 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
11841 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
11842 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
11845 static const struct message wm_lb_setcursel_2[] =
11847 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
11848 { WM_CTLCOLORLISTBOX, sent|parent },
11849 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
11850 { WM_CTLCOLORLISTBOX, sent|parent },
11851 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
11852 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
11853 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
11856 static const struct message wm_lb_click_0[] =
11858 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
11859 { HCBT_SETFOCUS, hook },
11860 { WM_KILLFOCUS, sent|parent },
11861 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
11862 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11863 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
11864 { WM_SETFOCUS, sent|defwinproc },
11866 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
11867 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
11868 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
11869 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
11870 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
11872 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
11873 { WM_CTLCOLORLISTBOX, sent|parent },
11874 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
11875 { WM_CTLCOLORLISTBOX, sent|parent },
11876 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
11877 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
11879 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11880 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11882 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
11883 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
11884 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
11885 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
11888 static const struct message wm_lb_deletestring[] =
11890 { LB_DELETESTRING, sent|wparam|lparam, 0, 0 },
11891 { WM_DELETEITEM, sent|wparam|parent|optional, ID_LISTBOX, 0 },
11892 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11893 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11896 static const struct message wm_lb_deletestring_reset[] =
11898 { LB_DELETESTRING, sent|wparam|lparam, 0, 0 },
11899 { LB_RESETCONTENT, sent|wparam|lparam|defwinproc|optional, 0, 0 },
11900 { WM_DELETEITEM, sent|wparam|parent|optional, ID_LISTBOX, 0 },
11901 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11902 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11906 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
11908 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
11910 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
11912 static LONG defwndproc_counter = 0;
11914 struct recvd_message msg;
11916 /* do not log painting messages */
11917 if (message != WM_PAINT &&
11918 message != WM_NCPAINT &&
11919 message != WM_SYNCPAINT &&
11920 message != WM_ERASEBKGND &&
11921 message != WM_NCHITTEST &&
11922 message != WM_GETTEXT &&
11923 !ignore_message( message ))
11926 msg.message = message;
11927 msg.flags = sent|wparam|lparam;
11928 if (defwndproc_counter) msg.flags |= defwinproc;
11931 msg.descr = "listbox";
11935 defwndproc_counter++;
11936 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
11937 defwndproc_counter--;
11942 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
11943 int caret_index, int top_index, int line)
11947 /* calling an orig proc helps to avoid unnecessary message logging */
11948 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
11949 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
11950 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
11951 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
11952 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
11953 ok_(__FILE__, line)(ret == caret_index ||
11954 broken(cur_sel == -1 && caret_index == 0 && ret == -1), /* nt4 */
11955 "expected caret index %d, got %ld\n", caret_index, ret);
11956 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
11957 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
11960 static void test_listbox_messages(void)
11962 HWND parent, listbox;
11965 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11966 100, 100, 200, 200, 0, 0, 0, NULL);
11967 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
11968 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
11969 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
11970 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
11972 check_lb_state(listbox, 0, LB_ERR, 0, 0);
11974 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
11975 ok(ret == 0, "expected 0, got %ld\n", ret);
11976 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
11977 ok(ret == 1, "expected 1, got %ld\n", ret);
11978 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
11979 ok(ret == 2, "expected 2, got %ld\n", ret);
11981 check_lb_state(listbox, 3, LB_ERR, 0, 0);
11985 log_all_parent_messages++;
11987 trace("selecting item 0\n");
11988 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
11989 ok(ret == 0, "expected 0, got %ld\n", ret);
11990 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
11991 check_lb_state(listbox, 3, 0, 0, 0);
11994 trace("selecting item 1\n");
11995 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
11996 ok(ret == 1, "expected 1, got %ld\n", ret);
11997 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
11998 check_lb_state(listbox, 3, 1, 1, 0);
12000 trace("selecting item 2\n");
12001 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
12002 ok(ret == 2, "expected 2, got %ld\n", ret);
12003 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
12004 check_lb_state(listbox, 3, 2, 2, 0);
12006 trace("clicking on item 0\n");
12007 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
12008 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
12009 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
12010 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
12011 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
12012 check_lb_state(listbox, 3, 0, 0, 0);
12015 trace("deleting item 0\n");
12016 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
12017 ok(ret == 2, "expected 2, got %ld\n", ret);
12018 ok_sequence(wm_lb_deletestring, "LB_DELETESTRING 0", FALSE );
12019 check_lb_state(listbox, 2, -1, 0, 0);
12022 trace("deleting item 0\n");
12023 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
12024 ok(ret == 1, "expected 1, got %ld\n", ret);
12025 ok_sequence(wm_lb_deletestring, "LB_DELETESTRING 0", FALSE );
12026 check_lb_state(listbox, 1, -1, 0, 0);
12029 trace("deleting item 0\n");
12030 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
12031 ok(ret == 0, "expected 0, got %ld\n", ret);
12032 ok_sequence(wm_lb_deletestring_reset, "LB_DELETESTRING 0", FALSE );
12033 check_lb_state(listbox, 0, -1, 0, 0);
12036 trace("deleting item 0\n");
12037 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
12038 ok(ret == LB_ERR, "expected LB_ERR, got %ld\n", ret);
12039 check_lb_state(listbox, 0, -1, 0, 0);
12042 log_all_parent_messages--;
12044 DestroyWindow(listbox);
12045 DestroyWindow(parent);
12048 /*************************** Menu test ******************************/
12049 static const struct message wm_popup_menu_1[] =
12051 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
12052 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
12053 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0x20000001 },
12054 { WM_SYSKEYDOWN, sent|wparam|lparam, 'E', 0x20000001 },
12055 { WM_SYSCHAR, sent|wparam|lparam, 'e', 0x20000001 },
12056 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'e' },
12057 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
12058 { WM_INITMENU, sent|lparam, 0, 0 },
12059 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(1,MF_HILITE|MF_POPUP) },
12060 { WM_INITMENUPOPUP, sent|lparam, 0, 1 },
12061 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't create a window */
12062 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(200,MF_HILITE) },
12063 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0xf0000001 },
12064 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
12065 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001, 0, 0x40000000 },
12066 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't create a window */
12067 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12068 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
12069 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
12070 { WM_MENUCOMMAND, sent }, /* |wparam, 200 - Win9x */
12071 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
12072 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
12075 static const struct message wm_popup_menu_2[] =
12077 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
12078 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
12079 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
12080 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
12081 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
12082 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
12083 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
12084 { WM_INITMENU, sent|lparam, 0, 0 },
12085 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
12086 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
12087 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
12088 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
12089 { HCBT_CREATEWND, hook },
12090 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12091 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12092 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
12093 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
12094 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
12095 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
12096 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
12097 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
12098 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
12099 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
12100 { HCBT_DESTROYWND, hook },
12101 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12102 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
12103 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12104 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
12105 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
12106 { WM_MENUCOMMAND, sent }, /* |wparam, 100 - Win9x */
12107 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
12108 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
12111 static const struct message wm_popup_menu_3[] =
12113 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
12114 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
12115 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
12116 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
12117 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
12118 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
12119 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
12120 { WM_INITMENU, sent|lparam, 0, 0 },
12121 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
12122 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
12123 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
12124 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
12125 { HCBT_CREATEWND, hook },
12126 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12127 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12128 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
12129 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
12130 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
12131 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
12132 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
12133 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
12134 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
12135 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
12136 { HCBT_DESTROYWND, hook },
12137 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12138 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
12139 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12140 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
12141 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
12142 { WM_COMMAND, sent|wparam|lparam, 100, 0 },
12143 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
12144 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
12148 static const struct message wm_single_menu_item[] =
12150 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
12151 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
12152 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'Q', 0x20000001 },
12153 { WM_SYSKEYDOWN, sent|wparam|lparam, 'Q', 0x20000001 },
12154 { WM_SYSCHAR, sent|wparam|lparam, 'q', 0x20000001 },
12155 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'q' },
12156 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
12157 { WM_INITMENU, sent|lparam, 0, 0 },
12158 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(300,MF_HILITE) },
12159 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
12160 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
12161 { WM_MENUCOMMAND, sent },
12162 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'Q', 0xe0000001 },
12163 { WM_SYSKEYUP, sent|wparam|lparam, 'Q', 0xe0000001 },
12164 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 },
12165 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
12167 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 1 },
12168 { WM_KEYDOWN, sent|wparam|lparam, VK_ESCAPE, 1 },
12169 { WM_CHAR, sent|wparam|lparam, VK_ESCAPE, 0x00000001 },
12170 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 0xc0000001 },
12171 { WM_KEYUP, sent|wparam|lparam, VK_ESCAPE, 0xc0000001 },
12175 static LRESULT WINAPI parent_menu_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
12177 if (message == WM_ENTERIDLE ||
12178 message == WM_INITMENU ||
12179 message == WM_INITMENUPOPUP ||
12180 message == WM_MENUSELECT ||
12181 message == WM_PARENTNOTIFY ||
12182 message == WM_ENTERMENULOOP ||
12183 message == WM_EXITMENULOOP ||
12184 message == WM_UNINITMENUPOPUP ||
12185 message == WM_KEYDOWN ||
12186 message == WM_KEYUP ||
12187 message == WM_CHAR ||
12188 message == WM_SYSKEYDOWN ||
12189 message == WM_SYSKEYUP ||
12190 message == WM_SYSCHAR ||
12191 message == WM_COMMAND ||
12192 message == WM_MENUCOMMAND)
12194 struct recvd_message msg;
12197 msg.message = message;
12198 msg.flags = sent|wparam|lparam;
12201 msg.descr = "parent_menu_proc";
12205 return DefWindowProcA(hwnd, message, wp, lp);
12208 static void set_menu_style(HMENU hmenu, DWORD style)
12213 mi.cbSize = sizeof(mi);
12214 mi.fMask = MIM_STYLE;
12215 mi.dwStyle = style;
12216 SetLastError(0xdeadbeef);
12217 ret = pSetMenuInfo(hmenu, &mi);
12218 ok(ret, "SetMenuInfo error %u\n", GetLastError());
12221 static DWORD get_menu_style(HMENU hmenu)
12226 mi.cbSize = sizeof(mi);
12227 mi.fMask = MIM_STYLE;
12229 SetLastError(0xdeadbeef);
12230 ret = pGetMenuInfo(hmenu, &mi);
12231 ok(ret, "GetMenuInfo error %u\n", GetLastError());
12236 static void test_menu_messages(void)
12240 HMENU hmenu, hmenu_popup;
12244 if (!pGetMenuInfo || !pSetMenuInfo)
12246 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
12250 cls.lpfnWndProc = parent_menu_proc;
12251 cls.cbClsExtra = 0;
12252 cls.cbWndExtra = 0;
12253 cls.hInstance = GetModuleHandleA(0);
12255 cls.hCursor = LoadCursorA(0, IDC_ARROW);
12256 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
12257 cls.lpszMenuName = NULL;
12258 cls.lpszClassName = "TestMenuClass";
12259 UnregisterClass(cls.lpszClassName, cls.hInstance);
12260 if (!RegisterClassA(&cls)) assert(0);
12262 SetLastError(0xdeadbeef);
12263 hwnd = CreateWindowExA(0, "TestMenuClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
12264 100, 100, 200, 200, 0, 0, 0, NULL);
12265 ok(hwnd != 0, "LoadMenuA error %u\n", GetLastError());
12267 SetLastError(0xdeadbeef);
12268 hmenu = LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
12269 ok(hmenu != 0, "LoadMenuA error %u\n", GetLastError());
12271 SetMenu(hwnd, hmenu);
12272 SetForegroundWindow( hwnd );
12274 set_menu_style(hmenu, MNS_NOTIFYBYPOS);
12275 style = get_menu_style(hmenu);
12276 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
12278 hmenu_popup = GetSubMenu(hmenu, 0);
12279 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12280 style = get_menu_style(hmenu_popup);
12281 ok(style == 0, "expected 0, got %u\n", style);
12283 hmenu_popup = GetSubMenu(hmenu_popup, 0);
12284 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12285 style = get_menu_style(hmenu_popup);
12286 ok(style == 0, "expected 0, got %u\n", style);
12289 trace("testing a popup menu command\n");
12291 keybd_event(VK_MENU, 0, 0, 0);
12292 keybd_event('E', 0, 0, 0);
12293 keybd_event('E', 0, KEYEVENTF_KEYUP, 0);
12294 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12295 keybd_event(VK_RETURN, 0, 0, 0);
12296 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
12297 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12299 TranslateMessage(&msg);
12300 DispatchMessage(&msg);
12302 if (!sequence_cnt) /* we didn't get any message */
12304 skip( "queuing key events not supported\n" );
12307 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
12308 if (sequence[0].message == WM_KEYUP && sequence[0].wParam == VK_MENU)
12310 win_skip( "menu tracking through VK_MENU not supported\n" );
12313 ok_sequence(wm_popup_menu_1, "popup menu command", FALSE);
12315 /* Alt+F, Right, Enter */
12316 trace("testing submenu of a popup menu command\n");
12318 keybd_event(VK_MENU, 0, 0, 0);
12319 keybd_event('F', 0, 0, 0);
12320 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
12321 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12322 keybd_event(VK_RIGHT, 0, 0, 0);
12323 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
12324 keybd_event(VK_RETURN, 0, 0, 0);
12325 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
12326 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12328 TranslateMessage(&msg);
12329 DispatchMessage(&msg);
12331 ok_sequence(wm_popup_menu_2, "submenu of a popup menu command", FALSE);
12333 trace("testing single menu item command\n");
12335 keybd_event(VK_MENU, 0, 0, 0);
12336 keybd_event('Q', 0, 0, 0);
12337 keybd_event('Q', 0, KEYEVENTF_KEYUP, 0);
12338 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12339 keybd_event(VK_ESCAPE, 0, 0, 0);
12340 keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
12341 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12343 TranslateMessage(&msg);
12344 DispatchMessage(&msg);
12346 ok_sequence(wm_single_menu_item, "single menu item command", FALSE);
12348 set_menu_style(hmenu, 0);
12349 style = get_menu_style(hmenu);
12350 ok(style == 0, "expected 0, got %u\n", style);
12352 hmenu_popup = GetSubMenu(hmenu, 0);
12353 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12354 set_menu_style(hmenu_popup, MNS_NOTIFYBYPOS);
12355 style = get_menu_style(hmenu_popup);
12356 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
12358 hmenu_popup = GetSubMenu(hmenu_popup, 0);
12359 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12360 style = get_menu_style(hmenu_popup);
12361 ok(style == 0, "expected 0, got %u\n", style);
12363 /* Alt+F, Right, Enter */
12364 trace("testing submenu of a popup menu command\n");
12366 keybd_event(VK_MENU, 0, 0, 0);
12367 keybd_event('F', 0, 0, 0);
12368 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
12369 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12370 keybd_event(VK_RIGHT, 0, 0, 0);
12371 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
12372 keybd_event(VK_RETURN, 0, 0, 0);
12373 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
12374 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12376 TranslateMessage(&msg);
12377 DispatchMessage(&msg);
12379 ok_sequence(wm_popup_menu_3, "submenu of a popup menu command", FALSE);
12382 DestroyWindow(hwnd);
12383 DestroyMenu(hmenu);
12387 static void test_paintingloop(void)
12391 paint_loop_done = 0;
12392 hwnd = CreateWindowExA(0x0,"PaintLoopWindowClass",
12393 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW,
12394 100, 100, 100, 100, 0, 0, 0, NULL );
12395 ok(hwnd != 0, "PaintLoop window error %u\n", GetLastError());
12396 ShowWindow(hwnd,SW_NORMAL);
12399 while (!paint_loop_done)
12402 if (PeekMessageA(&msg, 0, 0, 0, 1))
12404 TranslateMessage(&msg);
12405 DispatchMessage(&msg);
12408 DestroyWindow(hwnd);
12411 static void test_defwinproc(void)
12415 int gotwmquit = FALSE;
12416 hwnd = CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP, 0,0,0,0,0,0,0, NULL);
12418 DefWindowProcA( hwnd, WM_ENDSESSION, 1, 0);
12419 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) {
12420 if( msg.message == WM_QUIT) gotwmquit = TRUE;
12421 DispatchMessageA( &msg );
12423 ok( gotwmquit == FALSE, "Unexpected WM_QUIT message!\n");
12424 DestroyWindow( hwnd);
12427 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
12428 static void clear_clipboard_(int line, HWND hWnd)
12431 succ = OpenClipboard(hWnd);
12432 ok_(__FILE__, line)(succ, "OpenClipboard failed, err=%u\n", GetLastError());
12433 succ = EmptyClipboard();
12434 ok_(__FILE__, line)(succ, "EmptyClipboard failed, err=%u\n", GetLastError());
12435 succ = CloseClipboard();
12436 ok_(__FILE__, line)(succ, "CloseClipboard failed, err=%u\n", GetLastError());
12439 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
12440 static void expect_HWND_(int line, HWND expected, HWND got)
12442 ok_(__FILE__, line)(got==expected, "Expected %p, got %p\n", expected, got);
12445 static WNDPROC pOldViewerProc;
12447 static LRESULT CALLBACK recursive_viewer_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12449 static BOOL recursion_guard;
12451 if (message == WM_DRAWCLIPBOARD && !recursion_guard)
12453 recursion_guard = TRUE;
12454 clear_clipboard(hWnd);
12455 recursion_guard = FALSE;
12457 return CallWindowProcA(pOldViewerProc, hWnd, message, wParam, lParam);
12460 static void test_clipboard_viewers(void)
12462 static struct message wm_change_cb_chain[] =
12464 { WM_CHANGECBCHAIN, sent|wparam|lparam, 0, 0 },
12467 static const struct message wm_clipboard_destroyed[] =
12469 { WM_DESTROYCLIPBOARD, sent|wparam|lparam, 0, 0 },
12472 static struct message wm_clipboard_changed[] =
12474 { WM_DRAWCLIPBOARD, sent|wparam|lparam, 0, 0 },
12477 static struct message wm_clipboard_changed_and_owned[] =
12479 { WM_DESTROYCLIPBOARD, sent|wparam|lparam, 0, 0 },
12480 { WM_DRAWCLIPBOARD, sent|wparam|lparam, 0, 0 },
12484 HINSTANCE hInst = GetModuleHandleA(NULL);
12485 HWND hWnd1, hWnd2, hWnd3;
12489 hWnd1 = CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
12490 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
12491 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
12492 GetDesktopWindow(), NULL, hInst, NULL);
12493 hWnd2 = CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
12494 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
12495 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
12496 GetDesktopWindow(), NULL, hInst, NULL);
12497 hWnd3 = CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
12498 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
12499 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
12500 GetDesktopWindow(), NULL, hInst, NULL);
12501 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1, hWnd2, hWnd3);
12502 assert(hWnd1 && hWnd2 && hWnd3);
12506 /* Test getting the clipboard viewer and setting the viewer to NULL. */
12507 hOrigViewer = GetClipboardViewer();
12508 hRet = SetClipboardViewer(NULL);
12509 ok_sequence(WmEmptySeq, "set viewer to NULL", FALSE);
12510 expect_HWND(hOrigViewer, hRet);
12511 expect_HWND(NULL, GetClipboardViewer());
12513 /* Test registering hWnd1 as a viewer. */
12514 hRet = SetClipboardViewer(hWnd1);
12515 wm_clipboard_changed[0].wParam = (WPARAM) GetClipboardOwner();
12516 ok_sequence(wm_clipboard_changed, "set viewer NULL->1", FALSE);
12517 expect_HWND(NULL, hRet);
12518 expect_HWND(hWnd1, GetClipboardViewer());
12520 /* Test that changing the clipboard actually refreshes the registered viewer. */
12521 clear_clipboard(hWnd1);
12522 wm_clipboard_changed[0].wParam = (WPARAM) GetClipboardOwner();
12523 ok_sequence(wm_clipboard_changed, "clear clipbd (viewer=owner=1)", FALSE);
12525 /* Again, but with different owner. */
12526 clear_clipboard(hWnd2);
12527 wm_clipboard_changed_and_owned[1].wParam = (WPARAM) GetClipboardOwner();
12528 ok_sequence(wm_clipboard_changed_and_owned, "clear clipbd (viewer=1, owner=2)", FALSE);
12530 /* Test re-registering same window. */
12531 hRet = SetClipboardViewer(hWnd1);
12532 wm_clipboard_changed[0].wParam = (WPARAM) GetClipboardOwner();
12533 ok_sequence(wm_clipboard_changed, "set viewer 1->1", FALSE);
12534 expect_HWND(hWnd1, hRet);
12535 expect_HWND(hWnd1, GetClipboardViewer());
12537 /* Test ChangeClipboardChain. */
12538 ChangeClipboardChain(hWnd2, hWnd3);
12539 wm_change_cb_chain[0].wParam = (WPARAM) hWnd2;
12540 wm_change_cb_chain[0].lParam = (LPARAM) hWnd3;
12541 ok_sequence(wm_change_cb_chain, "change chain (viewer=1, remove=2, next=3)", FALSE);
12542 expect_HWND(hWnd1, GetClipboardViewer());
12544 ChangeClipboardChain(hWnd2, NULL);
12545 wm_change_cb_chain[0].wParam = (WPARAM) hWnd2;
12546 wm_change_cb_chain[0].lParam = 0;
12547 ok_sequence(wm_change_cb_chain, "change chain (viewer=1, remove=2, next=NULL)", FALSE);
12548 expect_HWND(hWnd1, GetClipboardViewer());
12550 ChangeClipboardChain(NULL, hWnd2);
12551 ok_sequence(WmEmptySeq, "change chain (viewer=1, remove=NULL, next=2)", TRUE);
12552 expect_HWND(hWnd1, GetClipboardViewer());
12554 /* Actually change clipboard viewer with ChangeClipboardChain. */
12555 ChangeClipboardChain(hWnd1, hWnd2);
12556 ok_sequence(WmEmptySeq, "change chain (viewer=remove=1, next=2)", FALSE);
12557 expect_HWND(hWnd2, GetClipboardViewer());
12559 /* Test that no refresh messages are sent when viewer has unregistered. */
12560 clear_clipboard(hWnd2);
12561 ok_sequence(WmEmptySeq, "clear clipd (viewer=2, owner=1)", FALSE);
12563 /* Register hWnd1 again. */
12564 ChangeClipboardChain(hWnd2, hWnd1);
12565 ok_sequence(WmEmptySeq, "change chain (viewer=remove=2, next=1)", FALSE);
12566 expect_HWND(hWnd1, GetClipboardViewer());
12568 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
12569 * changes the clipboard. When this happens, the system shouldn't send
12570 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
12572 pOldViewerProc = (WNDPROC) SetWindowLongPtrA(hWnd1, GWLP_WNDPROC, (LONG_PTR) recursive_viewer_proc);
12573 clear_clipboard(hWnd2);
12574 /* The clipboard owner is changed in recursive_viewer_proc: */
12575 wm_clipboard_changed[0].wParam = (WPARAM) hWnd2;
12576 ok_sequence(wm_clipboard_changed, "recursive clear clipbd (viewer=1, owner=2)", TRUE);
12578 /* Test unregistering. */
12579 ChangeClipboardChain(hWnd1, NULL);
12580 ok_sequence(WmEmptySeq, "change chain (viewer=remove=1, next=NULL)", FALSE);
12581 expect_HWND(NULL, GetClipboardViewer());
12583 clear_clipboard(hWnd1);
12584 ok_sequence(wm_clipboard_destroyed, "clear clipbd (no viewer, owner=1)", FALSE);
12586 DestroyWindow(hWnd1);
12587 DestroyWindow(hWnd2);
12588 DestroyWindow(hWnd3);
12589 SetClipboardViewer(hOrigViewer);
12592 static void test_PostMessage(void)
12594 static const struct
12600 { HWND_TOP /* 0 */, TRUE },
12601 { HWND_BROADCAST, TRUE },
12602 { HWND_BOTTOM, TRUE },
12603 { HWND_TOPMOST, TRUE },
12604 { HWND_NOTOPMOST, FALSE },
12605 { HWND_MESSAGE, FALSE },
12606 { (HWND)0xdeadbeef, FALSE }
12612 static const WCHAR staticW[] = {'s','t','a','t','i','c',0};
12614 SetLastError(0xdeadbeef);
12615 hwnd = CreateWindowExW(0, staticW, NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
12616 if (!hwnd && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
12618 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
12625 PostMessage(hwnd, WM_USER+1, 0x1234, 0x5678);
12626 PostMessage(0, WM_USER+2, 0x5678, 0x1234);
12628 for (i = 0; i < sizeof(data)/sizeof(data[0]); i++)
12630 memset(&msg, 0xab, sizeof(msg));
12631 ret = PeekMessageA(&msg, data[i].hwnd, 0, 0, PM_NOREMOVE);
12632 ok(ret == data[i].ret, "%d: hwnd %p expected %d, got %d\n", i, data[i].hwnd, data[i].ret, ret);
12636 ok(ret && msg.hwnd == 0 && msg.message == WM_USER+2 &&
12637 msg.wParam == 0x5678 && msg.lParam == 0x1234,
12638 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
12639 i, ret, msg.hwnd, msg.message, msg.wParam, msg.lParam);
12641 ok(ret && msg.hwnd == hwnd && msg.message == WM_USER+1 &&
12642 msg.wParam == 0x1234 && msg.lParam == 0x5678,
12643 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
12644 i, ret, msg.hwnd, msg.message, msg.wParam, msg.lParam, msg.hwnd);
12648 DestroyWindow(hwnd);
12652 static const struct
12656 } wait_idle_expect[] =
12658 /* 0 */ { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12659 { WAIT_TIMEOUT, 0, FALSE },
12660 { WAIT_TIMEOUT, 0, FALSE },
12661 { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12662 { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12663 /* 5 */ { WAIT_TIMEOUT, 0, FALSE },
12664 { WAIT_TIMEOUT, 0, FALSE },
12665 { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12668 /* 10 */ { 0, 0, FALSE },
12670 { 0, WAIT_TIMEOUT, FALSE },
12673 /* 15 */ { 0, 0, FALSE },
12674 { WAIT_TIMEOUT, 0, FALSE },
12675 { WAIT_TIMEOUT, 0, FALSE },
12676 { WAIT_TIMEOUT, 0, FALSE },
12677 { WAIT_TIMEOUT, 0, FALSE },
12678 /* 20 */ { WAIT_TIMEOUT, 0, FALSE },
12681 static DWORD CALLBACK do_wait_idle_child_thread( void *arg )
12685 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12687 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
12691 static void do_wait_idle_child( int arg )
12698 HANDLE start_event = OpenEventA( EVENT_ALL_ACCESS, FALSE, "test_WaitForInputIdle_start" );
12699 HANDLE end_event = OpenEventA( EVENT_ALL_ACCESS, FALSE, "test_WaitForInputIdle_end" );
12701 memset( &cls, 0, sizeof(cls) );
12702 cls.lpfnWndProc = DefWindowProc;
12703 cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
12704 cls.hCursor = LoadCursor(0, IDC_ARROW);
12705 cls.lpszClassName = "TestClass";
12706 RegisterClass( &cls );
12708 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ); /* create the msg queue */
12710 ok( start_event != 0, "failed to create start event, error %u\n", GetLastError() );
12711 ok( end_event != 0, "failed to create end event, error %u\n", GetLastError() );
12716 SetEvent( start_event );
12719 SetEvent( start_event );
12721 PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
12724 SetEvent( start_event );
12726 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12727 PostThreadMessage( GetCurrentThreadId(), WM_COMMAND, 0x1234, 0xabcd );
12728 PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
12731 SetEvent( start_event );
12733 SendMessage( HWND_BROADCAST, WM_WININICHANGE, 0, 0 );
12736 SetEvent( start_event );
12738 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12739 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessage( &msg );
12742 SetEvent( start_event );
12744 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12745 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
12748 SetEvent( start_event );
12750 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12751 while (PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ))
12753 GetMessage( &msg, 0, 0, 0 );
12754 DispatchMessage( &msg );
12758 SetEvent( start_event );
12760 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12761 SetTimer( hwnd, 3, 1, NULL );
12763 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessage( &msg );
12766 SetEvent( start_event );
12768 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12769 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
12772 SetEvent( start_event );
12774 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12775 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
12776 for (;;) GetMessage( &msg, 0, 0, 0 );
12779 SetEvent( start_event );
12781 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12782 SetTimer( hwnd, 3, 1, NULL );
12784 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
12787 SetEvent( start_event );
12789 return; /* exiting the process makes WaitForInputIdle return success too */
12791 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12793 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
12794 SetEvent( start_event );
12797 SetEvent( start_event );
12798 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12800 thread = CreateThread( NULL, 0, do_wait_idle_child_thread, NULL, 0, &id );
12801 WaitForSingleObject( thread, 10000 );
12802 CloseHandle( thread );
12805 SetEvent( start_event );
12807 PeekMessage( &msg, HWND_TOPMOST, 0, 0, PM_NOREMOVE );
12810 SetEvent( start_event );
12812 PeekMessage( &msg, HWND_BROADCAST, 0, 0, PM_NOREMOVE );
12815 SetEvent( start_event );
12817 PeekMessage( &msg, HWND_BOTTOM, 0, 0, PM_NOREMOVE );
12820 SetEvent( start_event );
12822 PeekMessage( &msg, (HWND)0xdeadbeef, 0, 0, PM_NOREMOVE );
12825 SetEvent( start_event );
12827 PeekMessage( &msg, HWND_NOTOPMOST, 0, 0, PM_NOREMOVE );
12830 SetEvent( start_event );
12832 PeekMessage( &msg, HWND_MESSAGE, 0, 0, PM_NOREMOVE );
12835 SetEvent( start_event );
12837 PeekMessage( &msg, GetDesktopWindow(), 0, 0, PM_NOREMOVE );
12840 WaitForSingleObject( end_event, 2000 );
12841 CloseHandle( start_event );
12842 CloseHandle( end_event );
12843 if (hwnd) DestroyWindow( hwnd );
12846 static LRESULT CALLBACK wait_idle_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
12848 if (msg == WM_WININICHANGE) Sleep( 200 ); /* make sure the child waits */
12849 return DefWindowProcA( hwnd, msg, wp, lp );
12852 static DWORD CALLBACK wait_idle_thread( void *arg )
12858 memset( &cls, 0, sizeof(cls) );
12859 cls.lpfnWndProc = wait_idle_proc;
12860 cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
12861 cls.hCursor = LoadCursor(0, IDC_ARROW);
12862 cls.lpszClassName = "TestClass";
12863 RegisterClass( &cls );
12865 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
12866 while (GetMessage( &msg, 0, 0, 0 )) DispatchMessage( &msg );
12867 DestroyWindow(hwnd);
12871 static void test_WaitForInputIdle( char *argv0 )
12873 char path[MAX_PATH];
12874 PROCESS_INFORMATION pi;
12875 STARTUPINFOA startup;
12877 HANDLE start_event, end_event, thread;
12880 const IMAGE_DOS_HEADER *dos = (const IMAGE_DOS_HEADER *)GetModuleHandleA(0);
12881 const IMAGE_NT_HEADERS *nt = (const IMAGE_NT_HEADERS *)((const char *)dos + dos->e_lfanew);
12882 BOOL console_app = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_GUI);
12884 if (console_app) /* build the test with -mwindows for better coverage */
12885 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
12887 start_event = CreateEventA(NULL, 0, 0, "test_WaitForInputIdle_start");
12888 end_event = CreateEventA(NULL, 0, 0, "test_WaitForInputIdle_end");
12889 ok(start_event != 0, "failed to create start event, error %u\n", GetLastError());
12890 ok(end_event != 0, "failed to create end event, error %u\n", GetLastError());
12892 memset( &startup, 0, sizeof(startup) );
12893 startup.cb = sizeof(startup);
12894 startup.dwFlags = STARTF_USESHOWWINDOW;
12895 startup.wShowWindow = SW_SHOWNORMAL;
12897 thread = CreateThread( NULL, 0, wait_idle_thread, NULL, 0, &id );
12899 for (i = 0; i < sizeof(wait_idle_expect)/sizeof(wait_idle_expect[0]); i++)
12901 ResetEvent( start_event );
12902 ResetEvent( end_event );
12903 sprintf( path, "%s msg %u", argv0, i );
12904 ret = CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &pi );
12905 ok( ret, "CreateProcess '%s' failed err %u.\n", path, GetLastError() );
12908 ret = WaitForSingleObject( start_event, 5000 );
12909 ok( ret == WAIT_OBJECT_0, "%u: WaitForSingleObject failed\n", i );
12910 if (ret == WAIT_OBJECT_0)
12912 ret = WaitForInputIdle( pi.hProcess, 1000 );
12913 if (ret == WAIT_FAILED)
12915 ret == wait_idle_expect[i].exp ||
12916 broken(ret == wait_idle_expect[i].broken),
12917 "%u: WaitForInputIdle error %08x expected %08x\n",
12918 i, ret, wait_idle_expect[i].exp );
12919 else if (wait_idle_expect[i].todo)
12921 ok( ret == wait_idle_expect[i].exp || broken(ret == wait_idle_expect[i].broken),
12922 "%u: WaitForInputIdle error %08x expected %08x\n",
12923 i, ret, wait_idle_expect[i].exp );
12925 ok( ret == wait_idle_expect[i].exp || broken(ret == wait_idle_expect[i].broken),
12926 "%u: WaitForInputIdle error %08x expected %08x\n",
12927 i, ret, wait_idle_expect[i].exp );
12928 SetEvent( end_event );
12929 WaitForSingleObject( pi.hProcess, 1000 ); /* give it a chance to exit on its own */
12931 TerminateProcess( pi.hProcess, 0 ); /* just in case */
12932 winetest_wait_child_process( pi.hProcess );
12933 ret = WaitForInputIdle( pi.hProcess, 100 );
12934 ok( ret == WAIT_FAILED, "%u: WaitForInputIdle after exit error %08x\n", i, ret );
12935 CloseHandle( pi.hProcess );
12936 CloseHandle( pi.hThread );
12939 CloseHandle( start_event );
12940 PostThreadMessage( id, WM_QUIT, 0, 0 );
12941 WaitForSingleObject( thread, 10000 );
12942 CloseHandle( thread );
12945 static const struct message WmSetParentSeq_1[] = {
12946 { WM_SHOWWINDOW, sent|wparam, 0 },
12947 { EVENT_OBJECT_PARENTCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12948 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
12949 { WM_CHILDACTIVATE, sent },
12950 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE },
12951 { WM_MOVE, sent|defwinproc|wparam, 0 },
12952 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12953 { WM_SHOWWINDOW, sent|wparam, 1 },
12957 static const struct message WmSetParentSeq_2[] = {
12958 { WM_SHOWWINDOW, sent|wparam, 0 },
12959 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
12960 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
12961 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
12962 { HCBT_SETFOCUS, hook|optional },
12963 { WM_NCACTIVATE, sent|wparam|optional, 0 },
12964 { WM_ACTIVATE, sent|wparam|optional, 0 },
12965 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
12966 { WM_KILLFOCUS, sent|wparam, 0 },
12967 { EVENT_OBJECT_PARENTCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12968 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
12969 { HCBT_ACTIVATE, hook|optional },
12970 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
12971 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
12972 { WM_NCACTIVATE, sent|wparam|optional, 1 },
12973 { WM_ACTIVATE, sent|wparam|optional, 1 },
12974 { HCBT_SETFOCUS, hook|optional },
12975 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
12976 { WM_SETFOCUS, sent|optional|defwinproc },
12977 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOREDRAW|SWP_NOSIZE|SWP_NOCLIENTSIZE },
12978 { WM_MOVE, sent|defwinproc|wparam, 0 },
12979 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12980 { WM_SHOWWINDOW, sent|wparam, 1 },
12981 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
12982 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
12983 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
12988 static void test_SetParent(void)
12990 HWND parent1, parent2, child, popup;
12993 parent1 = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
12994 100, 100, 200, 200, 0, 0, 0, NULL);
12995 ok(parent1 != 0, "Failed to create parent1 window\n");
12997 parent2 = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
12998 400, 100, 200, 200, 0, 0, 0, NULL);
12999 ok(parent2 != 0, "Failed to create parent2 window\n");
13001 /* WS_CHILD window */
13002 child = CreateWindowEx(0, "TestWindowClass", NULL, WS_CHILD | WS_VISIBLE,
13003 10, 10, 150, 150, parent1, 0, 0, NULL);
13004 ok(child != 0, "Failed to create child window\n");
13006 GetWindowRect(parent1, &rc);
13007 trace("parent1 (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
13008 GetWindowRect(child, &rc_old);
13009 MapWindowPoints(0, parent1, (POINT *)&rc_old, 2);
13010 trace("child (%d,%d)-(%d,%d)\n", rc_old.left, rc_old.top, rc_old.right, rc_old.bottom);
13014 SetParent(child, parent2);
13016 ok_sequence(WmSetParentSeq_1, "SetParent() visible WS_CHILD", TRUE);
13018 ok(GetWindowLongA(child, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
13019 ok(!IsWindowVisible(child), "IsWindowVisible() should return FALSE\n");
13021 GetWindowRect(parent2, &rc);
13022 trace("parent2 (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
13023 GetWindowRect(child, &rc);
13024 MapWindowPoints(0, parent2, (POINT *)&rc, 2);
13025 trace("child (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
13027 ok(EqualRect(&rc_old, &rc), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
13028 rc_old.left, rc_old.top, rc_old.right, rc_old.bottom,
13029 rc.left, rc.top, rc.right, rc.bottom );
13031 /* WS_POPUP window */
13032 popup = CreateWindowEx(0, "TestWindowClass", NULL, WS_POPUP | WS_VISIBLE,
13033 20, 20, 100, 100, 0, 0, 0, NULL);
13034 ok(popup != 0, "Failed to create popup window\n");
13036 GetWindowRect(popup, &rc_old);
13037 trace("popup (%d,%d)-(%d,%d)\n", rc_old.left, rc_old.top, rc_old.right, rc_old.bottom);
13041 SetParent(popup, child);
13043 ok_sequence(WmSetParentSeq_2, "SetParent() visible WS_POPUP", TRUE);
13045 ok(GetWindowLongA(popup, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
13046 ok(!IsWindowVisible(popup), "IsWindowVisible() should return FALSE\n");
13048 GetWindowRect(child, &rc);
13049 trace("parent2 (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
13050 GetWindowRect(popup, &rc);
13051 MapWindowPoints(0, child, (POINT *)&rc, 2);
13052 trace("popup (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
13054 ok(EqualRect(&rc_old, &rc), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
13055 rc_old.left, rc_old.top, rc_old.right, rc_old.bottom,
13056 rc.left, rc.top, rc.right, rc.bottom );
13058 DestroyWindow(popup);
13059 DestroyWindow(child);
13060 DestroyWindow(parent1);
13061 DestroyWindow(parent2);
13066 static const struct message WmKeyReleaseOnly[] = {
13067 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0x80000001 },
13068 { WM_KEYUP, sent|wparam|lparam, 0x41, 0x80000001 },
13071 static const struct message WmKeyPressNormal[] = {
13072 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0x1 },
13073 { WM_KEYDOWN, sent|wparam|lparam, 0x41, 0x1 },
13076 static const struct message WmKeyPressRepeat[] = {
13077 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0x40000001 },
13078 { WM_KEYDOWN, sent|wparam|lparam, 0x41, 0x40000001 },
13081 static const struct message WmKeyReleaseNormal[] = {
13082 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0xc0000001 },
13083 { WM_KEYUP, sent|wparam|lparam, 0x41, 0xc0000001 },
13087 static void test_keyflags(void)
13091 BYTE keyboard_state[256];
13094 test_window = CreateWindowEx(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
13095 100, 100, 200, 200, 0, 0, 0, NULL);
13100 /* keyup without a keydown */
13101 keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
13102 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13103 DispatchMessage(&msg);
13104 ok_sequence(WmKeyReleaseOnly, "key release only", TRUE);
13106 key_state = GetAsyncKeyState(0x41);
13107 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13109 key_state = GetKeyState(0x41);
13110 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13113 keybd_event(0x41, 0, 0, 0);
13114 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13115 DispatchMessage(&msg);
13116 ok_sequence(WmKeyPressNormal, "key press only", FALSE);
13118 key_state = GetAsyncKeyState(0x41);
13119 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13121 key_state = GetKeyState(0x41);
13122 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13124 /* keydown repeat */
13125 keybd_event(0x41, 0, 0, 0);
13126 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13127 DispatchMessage(&msg);
13128 ok_sequence(WmKeyPressRepeat, "key press repeat", FALSE);
13130 key_state = GetAsyncKeyState(0x41);
13131 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13133 key_state = GetKeyState(0x41);
13134 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13137 keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
13138 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13139 DispatchMessage(&msg);
13140 ok_sequence(WmKeyReleaseNormal, "key release repeat", FALSE);
13142 key_state = GetAsyncKeyState(0x41);
13143 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13145 key_state = GetKeyState(0x41);
13146 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13148 /* set the key state in this thread */
13149 GetKeyboardState(keyboard_state);
13150 keyboard_state[0x41] = 0x80;
13151 SetKeyboardState(keyboard_state);
13153 key_state = GetAsyncKeyState(0x41);
13154 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13157 keybd_event(0x41, 0, 0, 0);
13158 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13159 DispatchMessage(&msg);
13160 ok_sequence(WmKeyPressRepeat, "key press after setkeyboardstate", TRUE);
13162 key_state = GetAsyncKeyState(0x41);
13163 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13165 key_state = GetKeyState(0x41);
13166 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13168 /* clear the key state in this thread */
13169 GetKeyboardState(keyboard_state);
13170 keyboard_state[0x41] = 0;
13171 SetKeyboardState(keyboard_state);
13173 key_state = GetAsyncKeyState(0x41);
13174 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13177 keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
13178 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13179 DispatchMessage(&msg);
13180 ok_sequence(WmKeyReleaseOnly, "key release after setkeyboardstate", TRUE);
13182 key_state = GetAsyncKeyState(0x41);
13183 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13185 key_state = GetKeyState(0x41);
13186 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13188 DestroyWindow(test_window);
13192 static const struct message WmHotkeyPressLWIN[] = {
13193 { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED },
13194 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 },
13195 { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 },
13198 static const struct message WmHotkeyPress[] = {
13199 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13200 { WM_HOTKEY, sent|wparam, 5 },
13203 static const struct message WmHotkeyRelease[] = {
13204 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13205 { HCBT_KEYSKIPPED, hook|lparam|optional, 0, 0x80000001 },
13206 { WM_KEYUP, sent|lparam, 0, 0x80000001 },
13209 static const struct message WmHotkeyReleaseLWIN[] = {
13210 { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP },
13211 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 },
13212 { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 },
13215 static const struct message WmHotkeyCombined[] = {
13216 { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED },
13217 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13218 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13219 { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP },
13220 { WM_APP, sent, 0, 0 },
13221 { WM_HOTKEY, sent|wparam, 5 },
13222 { WM_APP+1, sent, 0, 0 },
13223 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 },
13224 { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 },
13225 { HCBT_KEYSKIPPED, hook|optional, 0, 0x80000001 },
13226 { WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13227 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 },
13228 { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 },
13231 static const struct message WmHotkeyPrevious[] = {
13232 { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED },
13233 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13234 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13235 { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP },
13236 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 },
13237 { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 },
13238 { HCBT_KEYSKIPPED, hook|lparam|optional, 0, 1 },
13239 { WM_KEYDOWN, sent|lparam, 0, 1 },
13240 { HCBT_KEYSKIPPED, hook|optional|lparam, 0, 0xc0000001 },
13241 { WM_KEYUP, sent|lparam, 0, 0xc0000001 },
13242 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 },
13243 { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 },
13246 static const struct message WmHotkeyNew[] = {
13247 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13248 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13249 { WM_HOTKEY, sent|wparam, 5 },
13250 { HCBT_KEYSKIPPED, hook|optional, 0, 0x80000001 },
13251 { WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13255 static int hotkey_letter;
13257 static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
13259 struct recvd_message msg;
13261 if (nCode == HC_ACTION)
13263 KBDLLHOOKSTRUCT *kdbhookstruct = (KBDLLHOOKSTRUCT*)lParam;
13266 msg.message = wParam;
13267 msg.flags = kbd_hook|wparam|lparam;
13268 msg.wParam = kdbhookstruct->vkCode;
13269 msg.lParam = kdbhookstruct->flags;
13270 msg.descr = "KeyboardHookProc";
13273 if (wParam == WM_KEYUP || wParam == WM_KEYDOWN)
13275 ok(kdbhookstruct->vkCode == VK_LWIN || kdbhookstruct->vkCode == hotkey_letter,
13276 "unexpected keycode %x\n", kdbhookstruct->vkCode);
13280 return CallNextHookEx(hKBD_hook, nCode, wParam, lParam);
13283 static void test_hotkey(void)
13285 HWND test_window, taskbar_window;
13288 DWORD queue_status;
13291 SetLastError(0xdeadbeef);
13292 ret = UnregisterHotKey(NULL, 0);
13293 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13294 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13295 "unexpected error %d\n", GetLastError());
13299 skip("hotkeys not supported\n");
13303 test_window = CreateWindowEx(0, "HotkeyWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
13304 100, 100, 200, 200, 0, 0, 0, NULL);
13308 SetLastError(0xdeadbeef);
13309 ret = UnregisterHotKey(test_window, 0);
13310 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13311 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13312 "unexpected error %d\n", GetLastError());
13314 /* Search for a Windows Key + letter combination that hasn't been registered */
13315 for (hotkey_letter = 0x41; hotkey_letter <= 0x51; hotkey_letter ++)
13317 SetLastError(0xdeadbeef);
13318 ret = RegisterHotKey(test_window, 5, MOD_WIN, hotkey_letter);
13326 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13327 "unexpected error %d\n", GetLastError());
13331 if (hotkey_letter == 0x52)
13333 ok(0, "Couldn't find any free Windows Key + letter combination\n");
13337 hKBD_hook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, GetModuleHandle(NULL), 0);
13338 if (!hKBD_hook) win_skip("WH_KEYBOARD_LL is not supported\n");
13340 /* Same key combination, different id */
13341 SetLastError(0xdeadbeef);
13342 ret = RegisterHotKey(test_window, 4, MOD_WIN, hotkey_letter);
13343 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13344 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13345 "unexpected error %d\n", GetLastError());
13347 /* Same key combination, different window */
13348 SetLastError(0xdeadbeef);
13349 ret = RegisterHotKey(NULL, 5, MOD_WIN, hotkey_letter);
13350 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13351 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13352 "unexpected error %d\n", GetLastError());
13354 /* Register the same hotkey twice */
13355 SetLastError(0xdeadbeef);
13356 ret = RegisterHotKey(test_window, 5, MOD_WIN, hotkey_letter);
13357 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13358 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13359 "unexpected error %d\n", GetLastError());
13361 /* Window on another thread */
13362 taskbar_window = FindWindowA("Shell_TrayWnd", NULL);
13363 if (!taskbar_window)
13365 skip("no taskbar?\n");
13369 SetLastError(0xdeadbeef);
13370 ret = RegisterHotKey(taskbar_window, 5, 0, hotkey_letter);
13371 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13372 ok(GetLastError() == ERROR_WINDOW_OF_OTHER_THREAD || broken(GetLastError() == 0xdeadbeef),
13373 "unexpected error %d\n", GetLastError());
13376 /* Inject the appropriate key sequence */
13377 keybd_event(VK_LWIN, 0, 0, 0);
13378 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13379 DispatchMessage(&msg);
13380 ok_sequence(WmHotkeyPressLWIN, "window hotkey press LWIN", FALSE);
13382 keybd_event(hotkey_letter, 0, 0, 0);
13383 queue_status = GetQueueStatus(QS_HOTKEY);
13384 ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
13385 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13387 if (msg.message == WM_HOTKEY)
13389 ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
13390 ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13392 DispatchMessage(&msg);
13394 ok_sequence(WmHotkeyPress, "window hotkey press", FALSE);
13396 queue_status = GetQueueStatus(QS_HOTKEY);
13397 ok((queue_status & (QS_HOTKEY << 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status);
13399 key_state = GetAsyncKeyState(hotkey_letter);
13400 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13402 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13403 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13404 DispatchMessage(&msg);
13405 ok_sequence(WmHotkeyRelease, "window hotkey release", TRUE);
13407 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13408 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13409 DispatchMessage(&msg);
13410 ok_sequence(WmHotkeyReleaseLWIN, "window hotkey release LWIN", FALSE);
13412 /* normal posted WM_HOTKEY messages set QS_HOTKEY */
13413 PostMessage(test_window, WM_HOTKEY, 0, 0);
13414 queue_status = GetQueueStatus(QS_HOTKEY);
13415 ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
13416 queue_status = GetQueueStatus(QS_POSTMESSAGE);
13417 ok((queue_status & (QS_POSTMESSAGE << 16)) == QS_POSTMESSAGE << 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status);
13418 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13419 DispatchMessage(&msg);
13422 /* Send and process all messages at once */
13423 PostMessage(test_window, WM_APP, 0, 0);
13424 keybd_event(VK_LWIN, 0, 0, 0);
13425 keybd_event(hotkey_letter, 0, 0, 0);
13426 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13427 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13429 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13431 if (msg.message == WM_HOTKEY)
13433 ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
13434 ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13436 DispatchMessage(&msg);
13438 ok_sequence(WmHotkeyCombined, "window hotkey combined", FALSE);
13440 /* Register same hwnd/id with different key combination */
13441 ret = RegisterHotKey(test_window, 5, 0, hotkey_letter);
13442 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13444 /* Previous key combination does not work */
13445 keybd_event(VK_LWIN, 0, 0, 0);
13446 keybd_event(hotkey_letter, 0, 0, 0);
13447 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13448 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13450 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13451 DispatchMessage(&msg);
13452 ok_sequence(WmHotkeyPrevious, "window hotkey previous", FALSE);
13454 /* New key combination works */
13455 keybd_event(hotkey_letter, 0, 0, 0);
13456 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13458 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13460 if (msg.message == WM_HOTKEY)
13462 ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
13463 ok(msg.lParam == MAKELPARAM(0, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13465 DispatchMessage(&msg);
13467 ok_sequence(WmHotkeyNew, "window hotkey new", FALSE);
13469 /* Unregister hotkey properly */
13470 ret = UnregisterHotKey(test_window, 5);
13471 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13473 /* Unregister hotkey again */
13474 SetLastError(0xdeadbeef);
13475 ret = UnregisterHotKey(test_window, 5);
13476 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13477 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13478 "unexpected error %d\n", GetLastError());
13480 /* Register thread hotkey */
13481 ret = RegisterHotKey(NULL, 5, MOD_WIN, hotkey_letter);
13482 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13484 /* Inject the appropriate key sequence */
13485 keybd_event(VK_LWIN, 0, 0, 0);
13486 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13488 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13489 DispatchMessage(&msg);
13491 ok_sequence(WmHotkeyPressLWIN, "thread hotkey press LWIN", FALSE);
13493 keybd_event(hotkey_letter, 0, 0, 0);
13494 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13496 if (msg.message == WM_HOTKEY)
13498 struct recvd_message message;
13499 ok(msg.hwnd == NULL, "unexpected hwnd %p\n", msg.hwnd);
13500 ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13501 message.message = msg.message;
13502 message.flags = sent|wparam|lparam;
13503 message.wParam = msg.wParam;
13504 message.lParam = msg.lParam;
13505 message.descr = "test_hotkey thread message";
13506 add_message(&message);
13509 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13510 DispatchMessage(&msg);
13512 ok_sequence(WmHotkeyPress, "thread hotkey press", FALSE);
13514 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13515 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13517 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13518 DispatchMessage(&msg);
13520 ok_sequence(WmHotkeyRelease, "thread hotkey release", TRUE);
13522 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13523 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13525 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13526 DispatchMessage(&msg);
13528 ok_sequence(WmHotkeyReleaseLWIN, "thread hotkey release LWIN", FALSE);
13530 /* Unregister thread hotkey */
13531 ret = UnregisterHotKey(NULL, 5);
13532 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13534 if (hKBD_hook) UnhookWindowsHookEx(hKBD_hook);
13538 UnregisterHotKey(NULL, 5);
13539 UnregisterHotKey(test_window, 5);
13540 DestroyWindow(test_window);
13545 static const struct message WmSetFocus_1[] = {
13546 { HCBT_SETFOCUS, hook }, /* child */
13547 { HCBT_ACTIVATE, hook }, /* parent */
13548 { WM_QUERYNEWPALETTE, sent|wparam|lparam|parent|optional, 0, 0 },
13549 { WM_WINDOWPOSCHANGING, sent|parent, 0, SWP_NOSIZE|SWP_NOMOVE },
13550 { WM_ACTIVATEAPP, sent|wparam|parent, 1 },
13551 { WM_NCACTIVATE, sent|parent },
13552 { WM_GETTEXT, sent|defwinproc|parent|optional },
13553 { WM_GETTEXT, sent|defwinproc|parent|optional },
13554 { WM_ACTIVATE, sent|wparam|parent, 1 },
13555 { HCBT_SETFOCUS, hook }, /* parent */
13556 { WM_SETFOCUS, sent|defwinproc|parent },
13557 { WM_KILLFOCUS, sent|parent },
13558 { WM_SETFOCUS, sent },
13561 static const struct message WmSetFocus_2[] = {
13562 { HCBT_SETFOCUS, hook }, /* parent */
13563 { WM_KILLFOCUS, sent },
13564 { WM_SETFOCUS, sent|parent },
13567 static const struct message WmSetFocus_3[] = {
13568 { HCBT_SETFOCUS, hook }, /* child */
13571 static const struct message WmSetFocus_4[] = {
13575 static void test_SetFocus(void)
13577 HWND parent, old_parent, child, old_focus, old_active;
13579 struct wnd_event wnd_event;
13583 wnd_event.start_event = CreateEvent(NULL, 0, 0, NULL);
13584 ok(wnd_event.start_event != 0, "CreateEvent error %d\n", GetLastError());
13585 hthread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
13586 ok(hthread != 0, "CreateThread error %d\n", GetLastError());
13587 ret = WaitForSingleObject(wnd_event.start_event, INFINITE);
13588 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
13589 CloseHandle(wnd_event.start_event);
13591 parent = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
13592 0, 0, 0, 0, 0, 0, 0, NULL);
13593 ok(parent != 0, "failed to create parent window\n");
13594 child = CreateWindowEx(0, "TestWindowClass", NULL, WS_CHILD,
13595 0, 0, 0, 0, parent, 0, 0, NULL);
13596 ok(child != 0, "failed to create child window\n");
13598 trace("parent %p, child %p, thread window %p\n", parent, child, wnd_event.hwnd);
13601 SetActiveWindow(0);
13606 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
13607 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
13609 log_all_parent_messages++;
13611 old_focus = SetFocus(child);
13612 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13613 ok_sequence(WmSetFocus_1, "SetFocus on a child window", TRUE);
13614 ok(old_focus == parent, "expected old focus %p, got %p\n", parent, old_focus);
13615 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13616 ok(GetFocus() == child, "expected focus %p, got %p\n", child, GetFocus());
13618 old_focus = SetFocus(parent);
13619 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13620 ok_sequence(WmSetFocus_2, "SetFocus on a parent window", FALSE);
13621 ok(old_focus == child, "expected old focus %p, got %p\n", child, old_focus);
13622 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13623 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13625 SetLastError(0xdeadbeef);
13626 old_focus = SetFocus((HWND)0xdeadbeef);
13627 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
13628 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
13629 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13630 ok_sequence(WmEmptySeq, "SetFocus on an invalid window", FALSE);
13631 ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
13632 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13633 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13635 SetLastError(0xdeadbeef);
13636 old_focus = SetFocus(GetDesktopWindow());
13637 ok(GetLastError() == ERROR_ACCESS_DENIED /* Vista+ */ ||
13638 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
13639 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13640 ok_sequence(WmEmptySeq, "SetFocus on a desktop window", TRUE);
13641 ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
13642 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13643 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13645 SetLastError(0xdeadbeef);
13646 old_focus = SetFocus(wnd_event.hwnd);
13647 ok(GetLastError() == ERROR_ACCESS_DENIED /* Vista+ */ ||
13648 broken(GetLastError() == 0xdeadbeef), "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError());
13649 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13650 ok_sequence(WmEmptySeq, "SetFocus on another thread window", TRUE);
13651 ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
13652 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13653 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13655 SetLastError(0xdeadbeef);
13656 old_active = SetActiveWindow((HWND)0xdeadbeef);
13657 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
13658 "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
13659 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13660 ok_sequence(WmEmptySeq, "SetActiveWindow on an invalid window", FALSE);
13661 ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
13662 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13663 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13665 SetLastError(0xdeadbeef);
13666 old_active = SetActiveWindow(GetDesktopWindow());
13668 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
13669 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13670 ok_sequence(WmEmptySeq, "SetActiveWindow on a desktop window", TRUE);
13671 ok(old_active == 0, "expected old focus 0, got %p\n", old_focus);
13672 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13673 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13675 SetLastError(0xdeadbeef);
13676 old_active = SetActiveWindow(wnd_event.hwnd);
13678 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
13679 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13680 ok_sequence(WmEmptySeq, "SetActiveWindow on another thread window", TRUE);
13681 ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
13682 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13683 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13685 SetLastError(0xdeadbeef);
13686 ret = AttachThreadInput(GetCurrentThreadId(), tid, TRUE);
13687 ok(ret, "AttachThreadInput error %d\n", GetLastError());
13690 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13691 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13696 old_focus = SetFocus(wnd_event.hwnd);
13697 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13698 ok(old_focus == wnd_event.hwnd, "expected old focus %p, got %p\n", wnd_event.hwnd, old_focus);
13699 ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
13700 ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
13702 old_focus = SetFocus(parent);
13703 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13704 ok(old_focus == parent, "expected old focus %p, got %p\n", parent, old_focus);
13705 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13706 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13711 old_active = SetActiveWindow(wnd_event.hwnd);
13712 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13713 ok(old_active == parent, "expected old focus %p, got %p\n", parent, old_active);
13714 ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
13715 ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
13717 SetLastError(0xdeadbeef);
13718 ret = AttachThreadInput(GetCurrentThreadId(), tid, FALSE);
13719 ok(ret, "AttachThreadInput error %d\n", GetLastError());
13721 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
13722 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
13724 old_parent = SetParent(child, GetDesktopWindow());
13725 ok(old_parent == parent, "expected old parent %p, got %p\n", parent, old_parent);
13727 ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
13728 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
13730 old_focus = SetFocus(parent);
13731 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13732 ok(old_focus == parent, "expected old focus %p, got %p\n", parent, old_focus);
13733 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13734 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13739 SetLastError(0xdeadbeef);
13740 old_focus = SetFocus(child);
13742 ok(GetLastError() == ERROR_INVALID_PARAMETER /* Vista+ */ ||
13743 broken(GetLastError() == 0) /* XP */ ||
13744 broken(GetLastError() == 0xdeadbeef), "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
13745 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13746 ok_sequence(WmSetFocus_3, "SetFocus on a child window", TRUE);
13747 ok(old_focus == 0, "expected old focus 0, got %p\n", old_focus);
13748 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13749 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13751 SetLastError(0xdeadbeef);
13752 old_active = SetActiveWindow(child);
13753 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
13754 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
13755 ok_sequence(WmEmptySeq, "SetActiveWindow on a child window", FALSE);
13756 ok(old_active == parent, "expected old active %p, got %p\n", parent, old_active);
13757 ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
13758 ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
13760 log_all_parent_messages--;
13762 DestroyWindow(child);
13763 DestroyWindow(parent);
13765 ret = PostMessage(wnd_event.hwnd, WM_QUIT, 0, 0);
13766 ok(ret, "PostMessage(WM_QUIT) error %d\n", GetLastError());
13767 ret = WaitForSingleObject(hthread, INFINITE);
13768 ok(ret == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
13769 CloseHandle(hthread);
13772 static const struct message WmSetLayeredStyle[] = {
13773 { WM_STYLECHANGING, sent },
13774 { WM_STYLECHANGED, sent },
13775 { WM_GETTEXT, sent|defwinproc|optional },
13779 static const struct message WmSetLayeredStyle2[] = {
13780 { WM_STYLECHANGING, sent },
13781 { WM_STYLECHANGED, sent },
13782 { WM_WINDOWPOSCHANGING, sent|optional|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
13783 { WM_NCCALCSIZE, sent|optional|wparam|defwinproc, 1 },
13784 { WM_WINDOWPOSCHANGED, sent|optional|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
13785 { WM_MOVE, sent|optional|defwinproc|wparam, 0 },
13786 { WM_SIZE, sent|optional|defwinproc|wparam, SIZE_RESTORED },
13790 struct layered_window_info
13799 static DWORD CALLBACK update_layered_proc( void *param )
13801 struct layered_window_info *info = param;
13802 POINT src = { 0, 0 };
13804 info->ret = pUpdateLayeredWindow( info->hwnd, 0, NULL, &info->size,
13805 info->hdc, &src, 0, NULL, ULW_OPAQUE );
13806 ok( info->ret, "failed\n");
13807 SetEvent( info->event );
13811 static void test_layered_window(void)
13822 struct layered_window_info info;
13824 if (!pUpdateLayeredWindow)
13826 win_skip( "UpdateLayeredWindow not supported\n" );
13830 hdc = CreateCompatibleDC( 0 );
13831 bmp = CreateCompatibleBitmap( hdc, 300, 300 );
13832 SelectObject( hdc, bmp );
13834 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_CAPTION | WS_THICKFRAME | WS_SYSMENU,
13835 100, 100, 300, 300, 0, 0, 0, NULL);
13836 ok( hwnd != 0, "failed to create window\n" );
13837 ShowWindow( hwnd, SW_SHOWNORMAL );
13838 UpdateWindow( hwnd );
13842 GetWindowRect( hwnd, &rect );
13843 GetClientRect( hwnd, &client );
13844 ok( client.right < rect.right - rect.left, "wrong client area\n" );
13845 ok( client.bottom < rect.bottom - rect.top, "wrong client area\n" );
13848 pos.x = pos.y = 300;
13849 size.cx = size.cy = 250;
13850 ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
13851 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
13852 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
13853 SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
13854 ok_sequence( WmSetLayeredStyle, "WmSetLayeredStyle", FALSE );
13856 ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
13857 ok( ret, "UpdateLayeredWindow failed err %u\n", GetLastError() );
13858 ok_sequence( WmEmptySeq, "UpdateLayeredWindow", FALSE );
13859 GetWindowRect( hwnd, &rect );
13860 ok( rect.left == 300 && rect.top == 300 && rect.right == 550 && rect.bottom == 550,
13861 "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13862 GetClientRect( hwnd, &rect );
13863 ok( rect.right == client.right - 50 && rect.bottom == client.bottom - 50,
13864 "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13868 ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
13869 ok( ret, "UpdateLayeredWindow failed err %u\n", GetLastError() );
13870 ok_sequence( WmEmptySeq, "UpdateLayeredWindow", FALSE );
13871 GetWindowRect( hwnd, &rect );
13872 ok( rect.left == 300 && rect.top == 200 && rect.right == 450 && rect.bottom == 450,
13873 "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13874 GetClientRect( hwnd, &rect );
13875 ok( rect.right == client.right - 150 && rect.bottom == client.bottom - 50,
13876 "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13878 SetWindowLong( hwnd, GWL_STYLE,
13879 GetWindowLong(hwnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU) );
13880 ok_sequence( WmSetLayeredStyle2, "WmSetLayeredStyle2", FALSE );
13884 ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
13885 ok( ret, "UpdateLayeredWindow failed err %u\n", GetLastError() );
13886 ok_sequence( WmEmptySeq, "UpdateLayeredWindow", FALSE );
13887 GetWindowRect( hwnd, &rect );
13888 ok( rect.left == 200 && rect.top == 200 && rect.right == 400 && rect.bottom == 450,
13889 "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13890 GetClientRect( hwnd, &rect );
13891 ok( (rect.right == 200 && rect.bottom == 250) ||
13892 broken(rect.right == client.right - 100 && rect.bottom == client.bottom - 50),
13893 "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13896 ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
13897 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
13898 ok( GetLastError() == ERROR_INVALID_PARAMETER || broken(ERROR_MR_MID_NOT_FOUND) /* win7 */,
13899 "wrong error %u\n", GetLastError() );
13902 ret = pUpdateLayeredWindow( hwnd, 0, &pos, &size, hdc, &src, 0, NULL, ULW_OPAQUE );
13903 ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" );
13904 ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
13906 SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED );
13907 ok_sequence( WmSetLayeredStyle, "WmSetLayeredStyle", FALSE );
13908 GetWindowRect( hwnd, &rect );
13909 ok( rect.left == 200 && rect.top == 200 && rect.right == 400 && rect.bottom == 450,
13910 "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13911 GetClientRect( hwnd, &rect );
13912 ok( (rect.right == 200 && rect.bottom == 250) ||
13913 broken(rect.right == client.right - 100 && rect.bottom == client.bottom - 50),
13914 "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13916 SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
13919 info.size.cx = 250;
13920 info.size.cy = 300;
13921 info.event = CreateEventA( NULL, TRUE, FALSE, NULL );
13923 thread = CreateThread( NULL, 0, update_layered_proc, &info, 0, &tid );
13924 ok( WaitForSingleObject( info.event, 1000 ) == 0, "wait failed\n" );
13925 ok( info.ret, "UpdateLayeredWindow failed in other thread\n" );
13926 WaitForSingleObject( thread, 1000 );
13927 CloseHandle( thread );
13928 GetWindowRect( hwnd, &rect );
13929 ok( rect.left == 200 && rect.top == 200 && rect.right == 450 && rect.bottom == 500,
13930 "wrong window rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13931 GetClientRect( hwnd, &rect );
13932 ok( (rect.right == 250 && rect.bottom == 300) ||
13933 broken(rect.right == client.right - 50 && rect.bottom == client.bottom),
13934 "wrong client rect %d,%d,%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
13936 DestroyWindow( hwnd );
13938 DeleteObject( bmp );
13945 BOOL (WINAPI *pIsWinEventHookInstalled)(DWORD)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
13946 HMODULE hModuleImm32;
13947 BOOL (WINAPI *pImmDisableIME)(DWORD);
13949 int argc = winetest_get_mainargs( &test_argv );
13953 /* Child process. */
13954 sscanf (test_argv[2], "%d", (unsigned int *) &arg);
13955 do_wait_idle_child( arg );
13961 hModuleImm32 = LoadLibrary("imm32.dll");
13962 if (hModuleImm32) {
13963 pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME");
13964 if (pImmDisableIME)
13967 pImmDisableIME = NULL;
13968 FreeLibrary(hModuleImm32);
13970 if (!RegisterWindowClasses()) assert(0);
13972 if (pSetWinEventHook)
13974 hEvent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX,
13975 GetModuleHandleA(0), win_event_proc,
13976 0, GetCurrentThreadId(),
13977 WINEVENT_INCONTEXT);
13978 if (pIsWinEventHookInstalled && hEvent_hook)
13981 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
13982 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
13985 if (!hEvent_hook) win_skip( "no win event hook support\n" );
13987 cbt_hook_thread_id = GetCurrentThreadId();
13988 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
13989 if (!hCBT_hook) win_skip( "cannot set global hook, will skip hook tests\n" );
13993 /* Fix message sequences before removing 4 lines below */
13995 if (pUnhookWinEvent && hEvent_hook)
13997 ret = pUnhookWinEvent(hEvent_hook);
13998 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
13999 pUnhookWinEvent = 0;
14006 test_PostMessage();
14008 test_PeekMessage();
14009 test_PeekMessage2();
14010 test_WaitForInputIdle( test_argv[0] );
14011 test_scrollwindowex();
14013 test_setwindowpos();
14015 invisible_parent_tests();
14016 test_mdi_messages();
14017 test_button_messages();
14018 test_static_messages();
14019 test_listbox_messages();
14020 test_combobox_messages();
14021 test_wmime_keydown_message();
14022 test_paint_messages();
14023 test_interthread_messages();
14024 test_message_conversion();
14025 test_accelerators();
14027 test_timers_no_wnd();
14028 if (hCBT_hook) test_set_hook();
14029 test_DestroyWindow();
14030 test_DispatchMessage();
14031 test_SendMessageTimeout();
14032 test_edit_messages();
14033 test_quit_message();
14034 test_SetActiveWindow();
14036 if (!pTrackMouseEvent)
14037 win_skip("TrackMouseEvent is not available\n");
14039 test_TrackMouseEvent();
14041 test_SetWindowRgn();
14043 test_dialog_messages();
14045 test_nullCallback();
14046 test_dbcs_wm_char();
14047 test_menu_messages();
14048 test_paintingloop();
14050 test_clipboard_viewers();
14053 test_layered_window();
14054 /* keep it the last test, under Windows it tends to break the tests
14055 * which rely on active/foreground windows being correct.
14057 test_SetForegroundWindow();
14059 UnhookWindowsHookEx(hCBT_hook);
14060 if (pUnhookWinEvent && hEvent_hook)
14062 ret = pUnhookWinEvent(hEvent_hook);
14063 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
14064 SetLastError(0xdeadbeef);
14065 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
14066 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
14067 GetLastError() == 0xdeadbeef, /* Win9x */
14068 "unexpected error %d\n", GetLastError());