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 maximaze 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 /* kernel32 functions */
1725 static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
1727 static void init_procs(void)
1729 HMODULE user32 = GetModuleHandleA("user32.dll");
1730 HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
1732 #define GET_PROC(dll, func) \
1733 p ## func = (void*)GetProcAddress(dll, #func); \
1735 trace("GetProcAddress(%s) failed\n", #func); \
1738 GET_PROC(user32, GetAncestor)
1739 GET_PROC(user32, GetMenuInfo)
1740 GET_PROC(user32, NotifyWinEvent)
1741 GET_PROC(user32, SetMenuInfo)
1742 GET_PROC(user32, SetWinEventHook)
1743 GET_PROC(user32, TrackMouseEvent)
1744 GET_PROC(user32, UnhookWinEvent)
1745 GET_PROC(user32, GetMonitorInfoA)
1746 GET_PROC(user32, MonitorFromPoint)
1748 GET_PROC(kernel32, GetCPInfoExA)
1753 static const char *get_winpos_flags(UINT flags)
1755 static char buffer[300];
1758 #define DUMP(flag) do { if (flags & flag) { strcat( buffer, "|" #flag ); flags &= ~flag; } } while(0)
1759 DUMP( SWP_SHOWWINDOW );
1760 DUMP( SWP_HIDEWINDOW );
1761 DUMP( SWP_NOACTIVATE );
1762 DUMP( SWP_FRAMECHANGED );
1763 DUMP( SWP_NOCOPYBITS );
1764 DUMP( SWP_NOOWNERZORDER );
1765 DUMP( SWP_NOSENDCHANGING );
1766 DUMP( SWP_DEFERERASE );
1767 DUMP( SWP_ASYNCWINDOWPOS );
1768 DUMP( SWP_NOZORDER );
1769 DUMP( SWP_NOREDRAW );
1772 DUMP( SWP_NOCLIENTSIZE );
1773 DUMP( SWP_NOCLIENTMOVE );
1774 if (flags) sprintf(buffer + strlen(buffer),"|0x%04x", flags);
1779 static BOOL ignore_message( UINT message )
1781 /* these are always ignored */
1782 return (message >= 0xc000 ||
1783 message == WM_GETICON ||
1784 message == WM_GETOBJECT ||
1785 message == WM_TIMECHANGE ||
1786 message == WM_DISPLAYCHANGE ||
1787 message == WM_DEVICECHANGE ||
1788 message == WM_DWMNCRENDERINGCHANGED);
1792 #define add_message(msg) add_message_(__LINE__,msg);
1793 static void add_message_(int line, const struct recvd_message *msg)
1795 struct recvd_message *seq;
1800 sequence = HeapAlloc( GetProcessHeap(), 0, sequence_size * sizeof(*sequence) );
1802 if (sequence_cnt == sequence_size)
1805 sequence = HeapReAlloc( GetProcessHeap(), 0, sequence, sequence_size * sizeof(*sequence) );
1809 seq = &sequence[sequence_cnt];
1810 seq->hwnd = msg->hwnd;
1811 seq->message = msg->message;
1812 seq->flags = msg->flags;
1813 seq->wParam = msg->wParam;
1814 seq->lParam = msg->lParam;
1816 seq->descr = msg->descr;
1821 if (msg->flags & hook)
1823 static const char * const CBT_code_name[10] =
1831 "HCBT_CLICKSKIPPED",
1836 const char *code_name = (msg->message <= HCBT_SETFOCUS) ? CBT_code_name[msg->message] : "Unknown";
1838 sprintf( seq->output, "%s: hook %d (%s) wp %08lx lp %08lx",
1839 msg->descr, msg->message, code_name, msg->wParam, msg->lParam );
1841 else if (msg->flags & winevent_hook)
1843 sprintf( seq->output, "%s: winevent %p %08x %08lx %08lx",
1844 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
1848 switch (msg->message)
1850 case WM_WINDOWPOSCHANGING:
1851 case WM_WINDOWPOSCHANGED:
1853 WINDOWPOS *winpos = (WINDOWPOS *)msg->lParam;
1855 sprintf( seq->output, "%s: %p WM_WINDOWPOS%s wp %08lx lp %08lx after %p x %d y %d cx %d cy %d flags %s",
1856 msg->descr, msg->hwnd,
1857 (msg->message == WM_WINDOWPOSCHANGING) ? "CHANGING" : "CHANGED",
1858 msg->wParam, msg->lParam, winpos->hwndInsertAfter,
1859 winpos->x, winpos->y, winpos->cx, winpos->cy,
1860 get_winpos_flags(winpos->flags) );
1862 /* Log only documented flags, win2k uses 0x1000 and 0x2000
1863 * in the high word for internal purposes
1865 seq->wParam = winpos->flags & 0xffff;
1866 /* We are not interested in the flags that don't match under XP and Win9x */
1867 seq->wParam &= ~SWP_NOZORDER;
1873 DRAW_ITEM_STRUCT di;
1874 DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)msg->lParam;
1876 sprintf( seq->output, "%s: %p WM_DRAWITEM: type %x, ctl_id %x, item_id %x, action %x, state %x",
1877 msg->descr, msg->hwnd, dis->CtlType, dis->CtlID,
1878 dis->itemID, dis->itemAction, dis->itemState);
1881 di.u.item.type = dis->CtlType;
1882 di.u.item.ctl_id = dis->CtlID;
1883 if (dis->CtlType == ODT_LISTBOX ||
1884 dis->CtlType == ODT_COMBOBOX ||
1885 dis->CtlType == ODT_MENU)
1886 di.u.item.item_id = dis->itemID;
1887 di.u.item.action = dis->itemAction;
1888 di.u.item.state = dis->itemState;
1890 seq->lParam = di.u.lp;
1894 if (msg->message >= 0xc000) return; /* ignore registered messages */
1895 sprintf( seq->output, "%s: %p %04x wp %08lx lp %08lx",
1896 msg->descr, msg->hwnd, msg->message, msg->wParam, msg->lParam );
1898 if (msg->flags & (sent|posted|parent|defwinproc|beginpaint))
1899 sprintf( seq->output + strlen(seq->output), " (flags %x)", msg->flags );
1906 /* try to make sure pending X events have been processed before continuing */
1907 static void flush_events(void)
1911 int min_timeout = 100;
1912 DWORD time = GetTickCount() + diff;
1916 if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
1917 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
1918 diff = time - GetTickCount();
1922 static void flush_sequence(void)
1924 HeapFree(GetProcessHeap(), 0, sequence);
1926 sequence_cnt = sequence_size = 0;
1929 static void dump_sequence(const struct message *expected, const char *context, const char *file, int line)
1931 const struct recvd_message *actual = sequence;
1932 unsigned int count = 0;
1934 trace_(file, line)("Failed sequence %s:\n", context );
1935 while (expected->message && actual->message)
1937 if (actual->output[0])
1939 if (expected->flags & hook)
1941 trace_(file, line)( " %u: expected: hook %04x - actual: %s\n",
1942 count, expected->message, actual->output );
1944 else if (expected->flags & winevent_hook)
1946 trace_(file, line)( " %u: expected: winevent %04x - actual: %s\n",
1947 count, expected->message, actual->output );
1949 else if (expected->flags & kbd_hook)
1951 trace_(file, line)( " %u: expected: kbd %04x - actual: %s\n",
1952 count, expected->message, actual->output );
1956 trace_(file, line)( " %u: expected: msg %04x - actual: %s\n",
1957 count, expected->message, actual->output );
1961 if (expected->message == actual->message)
1963 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) &&
1964 (expected->flags & optional))
1966 /* don't match messages if their defwinproc status differs */
1975 /* silently drop winevent messages if there is no support for them */
1976 else if ((expected->flags & optional) || ((expected->flags & winevent_hook) && !hEvent_hook))
1986 /* optional trailing messages */
1987 while (expected->message && ((expected->flags & optional) ||
1988 ((expected->flags & winevent_hook) && !hEvent_hook)))
1990 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
1995 if (expected->message)
1997 trace_(file, line)( " %u: expected: msg %04x - actual: nothing\n", count, expected->message );
2001 while (actual->message && actual->output[0])
2003 trace_(file, line)( " %u: expected: nothing - actual: %s\n", count, actual->output );
2009 #define ok_sequence( exp, contx, todo) \
2010 ok_sequence_( (exp), (contx), (todo), __FILE__, __LINE__)
2013 static void ok_sequence_(const struct message *expected_list, const char *context, int todo,
2014 const char *file, int line)
2016 static const struct recvd_message end_of_sequence;
2017 const struct message *expected = expected_list;
2018 const struct recvd_message *actual;
2019 int failcount = 0, dump = 0;
2020 unsigned int count = 0;
2022 add_message(&end_of_sequence);
2026 while (expected->message && actual->message)
2028 if (expected->message == actual->message &&
2029 !((expected->flags ^ actual->flags) & (hook|winevent_hook|kbd_hook)))
2031 if (expected->flags & wparam)
2033 if (((expected->wParam ^ actual->wParam) & ~expected->wp_mask) && todo)
2037 if (strcmp(winetest_platform, "wine")) dump++;
2038 ok_( file, line) (FALSE,
2039 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2040 context, count, expected->message, expected->wParam, actual->wParam);
2045 ok_( file, line)( ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) == 0,
2046 "%s: %u: in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
2047 context, count, expected->message, expected->wParam, actual->wParam);
2048 if ((expected->wParam ^ actual->wParam) & ~expected->wp_mask) dump++;
2052 if (expected->flags & lparam)
2054 if (((expected->lParam ^ actual->lParam) & ~expected->lp_mask) && todo)
2058 if (strcmp(winetest_platform, "wine")) dump++;
2059 ok_( file, line) (FALSE,
2060 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2061 context, count, expected->message, expected->lParam, actual->lParam);
2066 ok_( file, line)(((expected->lParam ^ actual->lParam) & ~expected->lp_mask) == 0,
2067 "%s: %u: in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
2068 context, count, expected->message, expected->lParam, actual->lParam);
2069 if ((expected->lParam ^ actual->lParam) & ~expected->lp_mask) dump++;
2072 if ((expected->flags & optional) &&
2073 ((expected->flags ^ actual->flags) & (defwinproc|parent)))
2075 /* don't match optional messages if their defwinproc or parent status differs */
2080 if ((expected->flags & defwinproc) != (actual->flags & defwinproc) && todo)
2084 if (strcmp(winetest_platform, "wine")) dump++;
2085 ok_( file, line) (FALSE,
2086 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2087 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
2092 ok_( file, line) ((expected->flags & defwinproc) == (actual->flags & defwinproc),
2093 "%s: %u: the msg 0x%04x should %shave been sent by DefWindowProc\n",
2094 context, count, expected->message, (expected->flags & defwinproc) ? "" : "NOT ");
2095 if ((expected->flags & defwinproc) != (actual->flags & defwinproc)) dump++;
2098 ok_( file, line) ((expected->flags & beginpaint) == (actual->flags & beginpaint),
2099 "%s: %u: the msg 0x%04x should %shave been sent by BeginPaint\n",
2100 context, count, expected->message, (expected->flags & beginpaint) ? "" : "NOT ");
2101 if ((expected->flags & beginpaint) != (actual->flags & beginpaint)) dump++;
2103 ok_( file, line) ((expected->flags & (sent|posted)) == (actual->flags & (sent|posted)),
2104 "%s: %u: the msg 0x%04x should have been %s\n",
2105 context, count, expected->message, (expected->flags & posted) ? "posted" : "sent");
2106 if ((expected->flags & (sent|posted)) != (actual->flags & (sent|posted))) dump++;
2108 ok_( file, line) ((expected->flags & parent) == (actual->flags & parent),
2109 "%s: %u: the msg 0x%04x was expected in %s\n",
2110 context, count, expected->message, (expected->flags & parent) ? "parent" : "child");
2111 if ((expected->flags & parent) != (actual->flags & parent)) dump++;
2113 ok_( file, line) ((expected->flags & hook) == (actual->flags & hook),
2114 "%s: %u: the msg 0x%04x should have been sent by a hook\n",
2115 context, count, expected->message);
2116 if ((expected->flags & hook) != (actual->flags & hook)) dump++;
2118 ok_( file, line) ((expected->flags & winevent_hook) == (actual->flags & winevent_hook),
2119 "%s: %u: the msg 0x%04x should have been sent by a winevent hook\n",
2120 context, count, expected->message);
2121 if ((expected->flags & winevent_hook) != (actual->flags & winevent_hook)) dump++;
2123 ok_( file, line) ((expected->flags & kbd_hook) == (actual->flags & kbd_hook),
2124 "%s: %u: the msg 0x%04x should have been sent by a keyboard hook\n",
2125 context, count, expected->message);
2126 if ((expected->flags & kbd_hook) != (actual->flags & kbd_hook)) dump++;
2131 /* silently drop hook messages if there is no support for them */
2132 else if ((expected->flags & optional) ||
2133 ((expected->flags & hook) && !hCBT_hook) ||
2134 ((expected->flags & winevent_hook) && !hEvent_hook) ||
2135 ((expected->flags & kbd_hook) && !hKBD_hook))
2141 if (strcmp(winetest_platform, "wine")) dump++;
2142 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2143 context, count, expected->message, actual->message);
2149 ok_( file, line) (FALSE, "%s: %u: the msg 0x%04x was expected, but got msg 0x%04x instead\n",
2150 context, count, expected->message, actual->message);
2158 /* skip all optional trailing messages */
2159 while (expected->message && ((expected->flags & optional) ||
2160 ((expected->flags & hook) && !hCBT_hook) ||
2161 ((expected->flags & winevent_hook) && !hEvent_hook)))
2167 if (expected->message || actual->message) {
2169 if (strcmp(winetest_platform, "wine")) dump++;
2170 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2171 context, count, expected->message, actual->message);
2177 if (expected->message || actual->message)
2180 ok_( file, line) (FALSE, "%s: %u: the msg sequence is not complete: expected %04x - actual %04x\n",
2181 context, count, expected->message, actual->message);
2184 if( todo && !failcount) /* succeeded yet marked todo */
2186 if (!strcmp(winetest_platform, "wine")) dump++;
2187 ok_( file, line)( TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
2191 if (dump) dump_sequence(expected_list, context, file, line);
2195 #define expect(EXPECTED,GOT) ok((GOT)==(EXPECTED), "Expected %d, got %d\n", (EXPECTED), (GOT))
2197 /******************************** MDI test **********************************/
2199 /* CreateWindow for MDI frame window, initially visible */
2200 static const struct message WmCreateMDIframeSeq[] = {
2201 { HCBT_CREATEWND, hook },
2202 { WM_GETMINMAXINFO, sent },
2203 { WM_NCCREATE, sent },
2204 { WM_NCCALCSIZE, sent|wparam, 0 },
2205 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2206 { WM_CREATE, sent },
2207 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2208 { WM_NOTIFYFORMAT, sent|optional },
2209 { WM_QUERYUISTATE, sent|optional },
2210 { WM_WINDOWPOSCHANGING, sent|optional },
2211 { WM_GETMINMAXINFO, sent|optional },
2212 { WM_NCCALCSIZE, sent|optional },
2213 { WM_WINDOWPOSCHANGED, sent|optional },
2214 { WM_SHOWWINDOW, sent|wparam, 1 },
2215 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2216 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2217 { HCBT_ACTIVATE, hook },
2218 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
2219 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
2220 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* XP */
2221 { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, /* Win9x doesn't send it */
2222 { WM_NCACTIVATE, sent },
2223 { WM_GETTEXT, sent|defwinproc|optional },
2224 { WM_ACTIVATE, sent|wparam, 1 },
2225 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* Win9x */
2226 { HCBT_SETFOCUS, hook },
2227 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2228 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
2229 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2230 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
2231 /* Win9x adds SWP_NOZORDER below */
2232 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2233 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2234 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2235 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2239 /* DestroyWindow for MDI frame window, initially visible */
2240 static const struct message WmDestroyMDIframeSeq[] = {
2241 { HCBT_DESTROYWND, hook },
2242 { 0x0090, sent|optional },
2243 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2244 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2245 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2246 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2247 { WM_NCACTIVATE, sent|wparam|optional, 0 }, /* XP */
2248 { WM_ACTIVATE, sent|wparam|optional, 0 }, /* Win9x */
2249 { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Win9x */
2250 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
2251 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2252 { WM_DESTROY, sent },
2253 { WM_NCDESTROY, sent },
2256 /* CreateWindow for MDI client window, initially visible */
2257 static const struct message WmCreateMDIclientSeq[] = {
2258 { HCBT_CREATEWND, hook },
2259 { WM_NCCREATE, sent },
2260 { WM_NCCALCSIZE, sent|wparam, 0 },
2261 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2262 { WM_CREATE, sent },
2263 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2264 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2265 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2267 { WM_PARENTNOTIFY, sent|wparam, WM_CREATE }, /* in MDI frame */
2268 { WM_SHOWWINDOW, sent|wparam, 1 },
2269 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2270 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2271 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2274 /* ShowWindow(SW_SHOW) for MDI client window */
2275 static const struct message WmShowMDIclientSeq[] = {
2276 { WM_SHOWWINDOW, sent|wparam, 1 },
2277 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2278 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2279 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2282 /* ShowWindow(SW_HIDE) for MDI client window */
2283 static const struct message WmHideMDIclientSeq[] = {
2284 { WM_SHOWWINDOW, sent|wparam, 0 },
2285 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2286 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* win2000 */
2287 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP */
2288 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2291 /* DestroyWindow for MDI client window, initially visible */
2292 static const struct message WmDestroyMDIclientSeq[] = {
2293 { HCBT_DESTROYWND, hook },
2294 { 0x0090, sent|optional },
2295 { WM_PARENTNOTIFY, sent|wparam, WM_DESTROY }, /* in MDI frame */
2296 { WM_SHOWWINDOW, sent|wparam, 0 },
2297 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2298 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2299 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2300 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2301 { WM_DESTROY, sent },
2302 { WM_NCDESTROY, sent },
2305 /* CreateWindow for MDI child window, initially visible */
2306 static const struct message WmCreateMDIchildVisibleSeq[] = {
2307 { HCBT_CREATEWND, hook },
2308 { WM_NCCREATE, sent },
2309 { WM_NCCALCSIZE, sent|wparam, 0 },
2310 { WM_CREATE, sent },
2311 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2312 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2314 /* Win2k sends wparam set to
2315 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2316 * while Win9x doesn't bother to set child window id according to
2317 * CLIENTCREATESTRUCT.idFirstChild
2319 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2320 { WM_SHOWWINDOW, sent|wparam, 1 },
2321 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2322 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2323 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2324 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2325 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2326 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2327 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2329 /* Win9x: message sequence terminates here. */
2331 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2332 { HCBT_SETFOCUS, hook }, /* in MDI client */
2333 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2334 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2335 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2336 { WM_SETFOCUS, sent }, /* in MDI client */
2337 { HCBT_SETFOCUS, hook },
2338 { WM_KILLFOCUS, sent }, /* in MDI client */
2339 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2340 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2341 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2342 { WM_SETFOCUS, sent|defwinproc },
2343 { WM_MDIACTIVATE, sent|defwinproc },
2346 /* CreateWindow for MDI child window with invisible parent */
2347 static const struct message WmCreateMDIchildInvisibleParentSeq[] = {
2348 { HCBT_CREATEWND, hook },
2349 { WM_GETMINMAXINFO, sent },
2350 { WM_NCCREATE, sent },
2351 { WM_NCCALCSIZE, sent|wparam, 0 },
2352 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam|optional, 0, 0 },
2353 { WM_CREATE, sent },
2354 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2355 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2357 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2358 { WM_SHOWWINDOW, sent|wparam, 1 },
2359 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
2360 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2361 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2362 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2364 /* Win9x: message sequence terminates here. */
2366 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2367 { HCBT_SETFOCUS, hook }, /* in MDI client */
2368 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2369 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2370 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2371 { WM_SETFOCUS, sent }, /* in MDI client */
2372 { HCBT_SETFOCUS, hook },
2373 { WM_KILLFOCUS, sent }, /* in MDI client */
2374 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2375 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2376 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2377 { WM_SETFOCUS, sent|defwinproc },
2378 { WM_MDIACTIVATE, sent|defwinproc },
2381 /* DestroyWindow for MDI child window, initially visible */
2382 static const struct message WmDestroyMDIchildVisibleSeq[] = {
2383 { HCBT_DESTROYWND, hook },
2384 /* Win2k sends wparam set to
2385 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2386 * while Win9x doesn't bother to set child window id according to
2387 * CLIENTCREATESTRUCT.idFirstChild
2389 { 0x0090, sent|optional },
2390 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2391 { WM_SHOWWINDOW, sent|wparam, 0 },
2392 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2393 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2394 { WM_ERASEBKGND, sent|parent|optional },
2395 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2397 /* { WM_DESTROY, sent }
2398 * Win9x: message sequence terminates here.
2401 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2402 { WM_KILLFOCUS, sent },
2403 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2404 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2405 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2406 { WM_SETFOCUS, sent }, /* in MDI client */
2408 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2409 { WM_KILLFOCUS, sent }, /* in MDI client */
2410 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2411 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2412 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2413 { WM_SETFOCUS, sent }, /* in MDI client */
2415 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2417 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2418 { WM_KILLFOCUS, sent },
2419 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2420 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2421 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2422 { WM_SETFOCUS, sent }, /* in MDI client */
2424 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2425 { WM_KILLFOCUS, sent }, /* in MDI client */
2426 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2427 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2428 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2429 { WM_SETFOCUS, sent }, /* in MDI client */
2431 { WM_DESTROY, sent },
2433 { HCBT_SETFOCUS, hook }, /* set focus to MDI client */
2434 { WM_KILLFOCUS, sent },
2435 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2436 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2437 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2438 { WM_SETFOCUS, sent }, /* in MDI client */
2440 { HCBT_SETFOCUS, hook }, /* MDI client sets focus back to MDI child */
2441 { WM_KILLFOCUS, sent }, /* in MDI client */
2442 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2443 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2444 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2445 { WM_SETFOCUS, sent }, /* in MDI client */
2447 { WM_NCDESTROY, sent },
2450 /* CreateWindow for MDI child window, initially invisible */
2451 static const struct message WmCreateMDIchildInvisibleSeq[] = {
2452 { HCBT_CREATEWND, hook },
2453 { WM_NCCREATE, sent },
2454 { WM_NCCALCSIZE, sent|wparam, 0 },
2455 { WM_CREATE, sent },
2456 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2457 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2459 /* Win2k sends wparam set to
2460 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2461 * while Win9x doesn't bother to set child window id according to
2462 * CLIENTCREATESTRUCT.idFirstChild
2464 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2467 /* DestroyWindow for MDI child window, initially invisible */
2468 static const struct message WmDestroyMDIchildInvisibleSeq[] = {
2469 { HCBT_DESTROYWND, hook },
2470 /* Win2k sends wparam set to
2471 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2472 * while Win9x doesn't bother to set child window id according to
2473 * CLIENTCREATESTRUCT.idFirstChild
2475 { 0x0090, sent|optional },
2476 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2477 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2478 { WM_DESTROY, sent },
2479 { WM_NCDESTROY, sent },
2480 /* FIXME: Wine destroys an icon/title window while Windows doesn't */
2481 { WM_PARENTNOTIFY, sent|wparam|optional, WM_DESTROY }, /* MDI client */
2484 /* CreateWindow for the 1st MDI child window, initially visible and maximized */
2485 static const struct message WmCreateMDIchildVisibleMaxSeq1[] = {
2486 { HCBT_CREATEWND, hook },
2487 { WM_NCCREATE, sent },
2488 { WM_NCCALCSIZE, sent|wparam, 0 },
2489 { WM_CREATE, sent },
2490 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2491 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2493 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2494 { WM_GETMINMAXINFO, sent },
2495 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2496 { WM_NCCALCSIZE, sent|wparam, 1 },
2497 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2498 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2500 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2501 { WM_NCCALCSIZE, sent|wparam, 1 },
2502 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2503 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2504 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2505 /* Win2k sends wparam set to
2506 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2507 * while Win9x doesn't bother to set child window id according to
2508 * CLIENTCREATESTRUCT.idFirstChild
2510 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2511 { WM_SHOWWINDOW, sent|wparam, 1 },
2512 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2513 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2514 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2515 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2516 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2517 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2518 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_FRAMECHANGED },
2520 /* Win9x: message sequence terminates here. */
2522 { WM_NCACTIVATE, sent|wparam|defwinproc|optional, 1 },
2523 { HCBT_SETFOCUS, hook|optional }, /* in MDI client */
2524 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2525 { WM_IME_NOTIFY, sent|wparam|optional, 2 }, /* in MDI client */
2526 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2527 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2528 { HCBT_SETFOCUS, hook|optional },
2529 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
2530 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2531 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2532 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2533 { WM_SETFOCUS, sent|defwinproc|optional },
2534 { WM_MDIACTIVATE, sent|defwinproc|optional },
2536 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2537 { WM_NCCALCSIZE, sent|wparam, 1 },
2538 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2539 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2542 /* CreateWindow for the 2nd MDI child window, initially visible and maximized */
2543 static const struct message WmCreateMDIchildVisibleMaxSeq2[] = {
2544 /* restore the 1st MDI child */
2545 { WM_SETREDRAW, sent|wparam, 0 },
2546 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2547 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
2548 { WM_NCCALCSIZE, sent|wparam, 1 },
2549 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2550 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2551 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2553 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2554 { WM_NCCALCSIZE, sent|wparam, 1 },
2555 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2556 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2557 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2558 { WM_SETREDRAW, sent|wparam, 1 }, /* in the 1st MDI child */
2559 /* create the 2nd MDI child */
2560 { HCBT_CREATEWND, hook },
2561 { WM_NCCREATE, sent },
2562 { WM_NCCALCSIZE, sent|wparam, 0 },
2563 { WM_CREATE, sent },
2564 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2565 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2567 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2568 { WM_GETMINMAXINFO, sent },
2569 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2570 { WM_NCCALCSIZE, sent|wparam, 1 },
2571 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2572 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2573 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2575 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2576 { WM_NCCALCSIZE, sent|wparam, 1 },
2577 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2578 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2579 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2580 /* Win2k sends wparam set to
2581 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2582 * while Win9x doesn't bother to set child window id according to
2583 * CLIENTCREATESTRUCT.idFirstChild
2585 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2586 { WM_SHOWWINDOW, sent|wparam, 1 },
2587 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2588 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2589 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2590 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2591 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2592 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2594 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2595 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2597 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2599 /* Win9x: message sequence terminates here. */
2601 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2602 { HCBT_SETFOCUS, hook },
2603 { WM_KILLFOCUS, sent|defwinproc|optional }, /* in the 1st MDI child */
2604 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 }, /* in the 1st MDI child */
2605 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2606 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2607 { WM_SETFOCUS, sent }, /* in MDI client */
2608 { HCBT_SETFOCUS, hook },
2609 { WM_KILLFOCUS, sent }, /* in MDI client */
2610 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2611 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2612 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2613 { WM_SETFOCUS, sent|defwinproc },
2615 { WM_MDIACTIVATE, sent|defwinproc },
2617 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2618 { WM_NCCALCSIZE, sent|wparam, 1 },
2619 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2620 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2623 /* WM_MDICREATE MDI child window, initially visible and maximized */
2624 static const struct message WmCreateMDIchildVisibleMaxSeq3[] = {
2625 { WM_MDICREATE, sent },
2626 { HCBT_CREATEWND, hook },
2627 { WM_NCCREATE, sent },
2628 { WM_NCCALCSIZE, sent|wparam, 0 },
2629 { WM_CREATE, sent },
2630 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2631 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2633 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2634 { WM_GETMINMAXINFO, sent },
2635 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2636 { WM_NCCALCSIZE, sent|wparam, 1 },
2637 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2638 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2641 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2642 { WM_NCCALCSIZE, sent|wparam, 1 },
2643 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2644 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2645 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2647 /* Win2k sends wparam set to
2648 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2649 * while Win9x doesn't bother to set child window id according to
2650 * CLIENTCREATESTRUCT.idFirstChild
2652 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2653 { WM_SHOWWINDOW, sent|wparam, 1 },
2654 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2656 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2658 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2659 { WM_MDIREFRESHMENU, sent/*|wparam|lparam, 0, 0*/ },
2660 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
2662 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2663 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2665 /* Win9x: message sequence terminates here. */
2667 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2668 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2669 { HCBT_SETFOCUS, hook }, /* in MDI client */
2670 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2671 { WM_IME_NOTIFY, sent|wparam|optional, 2 },
2672 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam|optional, OBJID_CLIENT, 0 },
2673 { WM_SETFOCUS, sent|optional }, /* in MDI client */
2674 { HCBT_SETFOCUS, hook|optional },
2675 { WM_KILLFOCUS, sent }, /* in MDI client */
2676 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2677 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2678 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2679 { WM_SETFOCUS, sent|defwinproc },
2681 { WM_MDIACTIVATE, sent|defwinproc },
2684 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2685 { WM_NCCALCSIZE, sent|wparam, 1 },
2686 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2687 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
2690 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2691 { WM_NCCALCSIZE, sent|wparam, 1 },
2692 { 0x0093, sent|defwinproc|optional },
2693 { 0x0093, sent|defwinproc|optional },
2694 { 0x0093, sent|defwinproc|optional },
2695 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2696 { WM_MOVE, sent|defwinproc },
2697 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2700 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2701 { WM_NCCALCSIZE, sent|wparam, 1 },
2702 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2703 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2706 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2707 { WM_NCCALCSIZE, sent|wparam, 1 },
2708 { 0x0093, sent|optional },
2709 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2710 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2712 { 0x0093, sent|optional },
2713 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2714 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2715 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP sends it to MDI frame */
2716 { 0x0093, sent|defwinproc|optional },
2717 { 0x0093, sent|defwinproc|optional },
2718 { 0x0093, sent|defwinproc|optional },
2719 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2720 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2724 /* CreateWindow for the 1st MDI child window, initially invisible and maximized */
2725 static const struct message WmCreateMDIchildInvisibleMaxSeq4[] = {
2726 { HCBT_CREATEWND, hook },
2727 { WM_GETMINMAXINFO, sent },
2728 { WM_NCCREATE, sent },
2729 { WM_NCCALCSIZE, sent|wparam, 0 },
2730 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, 0, 0 },
2731 { WM_CREATE, sent },
2732 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
2733 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2734 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_NOZORDER }, /* MDI frame */
2735 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI frame */
2736 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOZORDER }, /* MDI frame */
2738 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2739 { WM_GETMINMAXINFO, sent },
2740 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_STATECHANGED },
2741 { WM_GETMINMAXINFO, sent|defwinproc },
2742 { WM_NCCALCSIZE, sent|wparam, 1 },
2743 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_STATECHANGED },
2744 { WM_MOVE, sent|defwinproc },
2745 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2747 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2748 { WM_NCCALCSIZE, sent|wparam, 1 },
2749 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2750 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2751 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* MDI child */
2752 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2753 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2754 /* Win2k sends wparam set to
2755 * MAKEWPARAM(WM_CREATE, MDI_FIRST_CHILD_ID + nTotalCreated),
2756 * while Win9x doesn't bother to set child window id according to
2757 * CLIENTCREATESTRUCT.idFirstChild
2759 { WM_PARENTNOTIFY, sent /*|wparam, WM_CREATE*/ }, /* in MDI client */
2762 /* WM_SYSCOMMAND/SC_CLOSE for the 2nd MDI child window, initially visible and maximized */
2763 static const struct message WmDestroyMDIchildVisibleMaxSeq2[] = {
2764 { WM_SYSCOMMAND, sent|wparam, SC_CLOSE },
2765 { HCBT_SYSCOMMAND, hook },
2766 { WM_CLOSE, sent|defwinproc },
2767 { WM_MDIDESTROY, sent }, /* in MDI client */
2769 /* bring the 1st MDI child to top */
2770 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE }, /* in the 1st MDI child */
2771 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE }, /* in the 2nd MDI child */
2773 { EVENT_OBJECT_REORDER, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2775 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 }, /* in the 1st MDI child */
2776 { WM_NCACTIVATE, sent|wparam|defwinproc, 0 }, /* in the 1st MDI child */
2777 { WM_MDIACTIVATE, sent|defwinproc }, /* in the 1st MDI child */
2779 /* maximize the 1st MDI child */
2780 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
2781 { WM_GETMINMAXINFO, sent|defwinproc },
2782 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_STATECHANGED },
2783 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2784 { WM_CHILDACTIVATE, sent|defwinproc|wparam|lparam, 0, 0 },
2785 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2786 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2788 /* restore the 2nd MDI child */
2789 { WM_SETREDRAW, sent|defwinproc|wparam, 0 },
2790 { HCBT_MINMAX, hook|lparam, 0, SW_NORMALNA },
2791 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2792 { WM_NCCALCSIZE, sent|defwinproc|wparam, 1 },
2794 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2796 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2797 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2799 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2801 { WM_SETREDRAW, sent|defwinproc|wparam, 1 },
2803 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2804 { WM_NCCALCSIZE, sent|wparam, 1 },
2805 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2806 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2807 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2809 /* bring the 1st MDI child to top */
2810 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2811 { WM_NCACTIVATE, sent|wparam|defwinproc, 1 },
2812 { HCBT_SETFOCUS, hook },
2813 { WM_KILLFOCUS, sent|defwinproc },
2814 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
2815 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2816 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2817 { WM_SETFOCUS, sent }, /* in MDI client */
2818 { HCBT_SETFOCUS, hook },
2819 { WM_KILLFOCUS, sent }, /* in MDI client */
2820 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2821 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
2822 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2823 { WM_SETFOCUS, sent|defwinproc },
2824 { WM_MDIACTIVATE, sent|defwinproc },
2825 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2827 /* apparently ShowWindow(SW_SHOW) on an MDI client */
2828 { WM_SHOWWINDOW, sent|wparam, 1 },
2829 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2830 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2831 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2832 { WM_MDIREFRESHMENU, sent },
2834 { HCBT_DESTROYWND, hook },
2835 /* Win2k sends wparam set to
2836 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
2837 * while Win9x doesn't bother to set child window id according to
2838 * CLIENTCREATESTRUCT.idFirstChild
2840 { 0x0090, sent|defwinproc|optional },
2841 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
2842 { WM_SHOWWINDOW, sent|defwinproc|wparam, 0 },
2843 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2844 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2845 { WM_ERASEBKGND, sent|parent|optional },
2846 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2848 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
2849 { WM_DESTROY, sent|defwinproc },
2850 { WM_NCDESTROY, sent|defwinproc },
2853 /* WM_MDIDESTROY for the single MDI child window, initially visible and maximized */
2854 static const struct message WmDestroyMDIchildVisibleMaxSeq1[] = {
2855 { WM_MDIDESTROY, sent }, /* in MDI client */
2856 { WM_SHOWWINDOW, sent|wparam, 0 },
2857 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2858 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
2859 { WM_ERASEBKGND, sent|parent|optional },
2860 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2862 { HCBT_SETFOCUS, hook },
2863 { WM_KILLFOCUS, sent },
2864 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2865 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2866 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2867 { WM_SETFOCUS, sent }, /* in MDI client */
2868 { HCBT_SETFOCUS, hook },
2869 { WM_KILLFOCUS, sent }, /* in MDI client */
2870 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
2871 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
2872 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2873 { WM_SETFOCUS, sent },
2876 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2877 { WM_NCCALCSIZE, sent|wparam, 1 },
2878 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2879 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2882 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2883 { WM_NCCALCSIZE, sent|wparam, 1 },
2884 { 0x0093, sent|defwinproc|optional },
2885 { 0x0093, sent|defwinproc|optional },
2886 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2887 { WM_MOVE, sent|defwinproc },
2888 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2891 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2892 { WM_NCCALCSIZE, sent|wparam, 1 },
2893 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2894 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2897 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2898 { WM_NCCALCSIZE, sent|wparam, 1 },
2899 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2900 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2903 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2904 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2905 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2906 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2909 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2910 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2911 { 0x0093, sent|defwinproc|optional },
2912 { 0x0093, sent|defwinproc|optional },
2913 { 0x0093, sent|defwinproc|optional },
2914 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2915 { WM_MOVE, sent|defwinproc },
2916 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2919 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2920 { WM_NCCALCSIZE, sent|wparam, 1 },
2921 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2922 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2925 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
2926 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2927 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
2928 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
2929 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2930 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2932 { 0x0093, sent|defwinproc|optional },
2933 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 }, /* XP sends it to MDI frame */
2934 { 0x0093, sent|defwinproc|optional },
2935 { 0x0093, sent|defwinproc|optional },
2936 { 0x0093, sent|defwinproc|optional },
2937 { 0x0093, sent|optional },
2939 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2940 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2941 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2942 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2943 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2946 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2947 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
2948 { 0x0093, sent|defwinproc|optional },
2949 { 0x0093, sent|defwinproc|optional },
2950 { 0x0093, sent|defwinproc|optional },
2951 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2952 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2953 { 0x0093, sent|optional },
2955 { WM_NCACTIVATE, sent|wparam, 0 },
2956 { WM_MDIACTIVATE, sent },
2958 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNORMAL },
2959 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_STATECHANGED },
2960 { WM_NCCALCSIZE, sent|wparam, 1 },
2962 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
2964 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
2965 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
2966 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2969 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2970 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
2971 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
2972 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2975 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2976 { WM_NCCALCSIZE, sent|wparam, 1 },
2977 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
2978 { WM_MOVE, sent|defwinproc },
2979 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
2982 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
2983 { WM_NCCALCSIZE, sent|wparam, 1 },
2984 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOCLIENTMOVE },
2985 { WM_SIZE, sent|wparam, SIZE_RESTORED },
2986 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
2987 { WM_NCCALCSIZE, sent|wparam|optional, 1 }, /* XP */
2988 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI client */
2989 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
2990 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* XP sends a duplicate */
2992 { HCBT_SETFOCUS, hook },
2993 { WM_KILLFOCUS, sent },
2994 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
2995 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
2996 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
2997 { WM_SETFOCUS, sent }, /* in MDI client */
2999 { WM_MDIREFRESHMENU, sent }, /* in MDI client */
3001 { HCBT_DESTROYWND, hook },
3002 /* Win2k sends wparam set to
3003 * MAKEWPARAM(WM_DESTROY, MDI_FIRST_CHILD_ID + nTotalCreated),
3004 * while Win9x doesn't bother to set child window id according to
3005 * CLIENTCREATESTRUCT.idFirstChild
3007 { 0x0090, sent|optional },
3008 { WM_PARENTNOTIFY, sent /*|wparam, WM_DESTROY*/ }, /* in MDI client */
3010 { WM_SHOWWINDOW, sent|wparam, 0 },
3011 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3012 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
3013 { WM_ERASEBKGND, sent|parent|optional },
3014 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3016 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 },
3017 { WM_DESTROY, sent },
3018 { WM_NCDESTROY, sent },
3021 /* ShowWindow(SW_MAXIMIZE) for a not visible MDI child window */
3022 static const struct message WmMaximizeMDIchildInvisibleSeq[] = {
3023 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3024 { WM_GETMINMAXINFO, sent },
3025 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
3026 { WM_NCCALCSIZE, sent|wparam, 1 },
3027 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3028 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3030 { WM_WINDOWPOSCHANGING, sent|wparam|optional|defwinproc, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3031 { WM_NCACTIVATE, sent|wparam|optional|defwinproc, 1 },
3032 { HCBT_SETFOCUS, hook|optional },
3033 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
3034 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3035 { WM_SETFOCUS, sent|optional }, /* in MDI client */
3036 { HCBT_SETFOCUS, hook|optional },
3037 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
3038 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
3039 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3040 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3041 { WM_SETFOCUS, sent|optional|defwinproc },
3042 { WM_MDIACTIVATE, sent|optional|defwinproc },
3043 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3044 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3046 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3047 { WM_NCCALCSIZE, sent|wparam, 1 },
3048 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3049 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3050 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3053 /* ShowWindow(SW_MAXIMIZE) for a not visible maximized MDI child window */
3054 static const struct message WmMaximizeMDIchildInvisibleSeq2[] = {
3055 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3056 { WM_GETMINMAXINFO, sent },
3057 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED },
3058 { WM_GETMINMAXINFO, sent|defwinproc },
3059 { WM_NCCALCSIZE, sent|wparam, 1 },
3060 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3061 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3063 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3064 { WM_NCACTIVATE, sent|wparam|defwinproc|optional, 1 },
3065 { HCBT_SETFOCUS, hook|optional },
3066 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, /* in MDI client */
3067 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3068 { WM_SETFOCUS, sent|optional }, /* in MDI client */
3069 { HCBT_SETFOCUS, hook|optional },
3070 { WM_KILLFOCUS, sent|optional }, /* in MDI client */
3071 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, /* in MDI client */
3072 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
3073 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3074 { WM_SETFOCUS, sent|defwinproc|optional },
3075 { WM_MDIACTIVATE, sent|defwinproc|optional },
3076 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3077 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3080 /* WM_MDIMAXIMIZE for an MDI child window with invisible parent */
3081 static const struct message WmMaximizeMDIchildInvisibleParentSeq[] = {
3082 { WM_MDIMAXIMIZE, sent }, /* in MDI client */
3083 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3084 { WM_GETMINMAXINFO, sent },
3085 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3086 { WM_GETMINMAXINFO, sent|defwinproc },
3087 { WM_NCCALCSIZE, sent|wparam, 1 },
3088 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam|optional, 0, 0 }, /* XP doesn't send it */
3089 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3090 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOREDRAW|SWP_STATECHANGED },
3091 { WM_MOVE, sent|defwinproc },
3092 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3094 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3095 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
3096 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3097 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
3098 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3099 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
3101 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3102 { WM_NCCALCSIZE, sent|wparam, 1 },
3103 { 0x0093, sent|defwinproc|optional },
3104 { 0x0094, sent|defwinproc|optional },
3105 { 0x0094, sent|defwinproc|optional },
3106 { 0x0094, sent|defwinproc|optional },
3107 { 0x0094, sent|defwinproc|optional },
3108 { 0x0093, sent|defwinproc|optional },
3109 { 0x0093, sent|defwinproc|optional },
3110 { 0x0091, sent|defwinproc|optional },
3111 { 0x0092, sent|defwinproc|optional },
3112 { 0x0092, sent|defwinproc|optional },
3113 { 0x0092, sent|defwinproc|optional },
3114 { 0x0092, sent|defwinproc|optional },
3115 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3116 { WM_MOVE, sent|defwinproc },
3117 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3118 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame win2000 */
3120 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOACTIVATE },
3121 { WM_NCCALCSIZE, sent|wparam, 1 },
3122 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
3123 { WM_SIZE, sent|wparam, SIZE_RESTORED },
3125 { WM_WINDOWPOSCHANGING, sent|wparam|defwinproc, SWP_NOACTIVATE },
3126 { WM_GETMINMAXINFO, sent|defwinproc },
3127 { WM_NCCALCSIZE, sent|wparam|defwinproc, 1 },
3128 { WM_WINDOWPOSCHANGED, sent|wparam|defwinproc, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTMOVE },
3129 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3130 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child win2000 */
3131 { WM_NCCALCSIZE, sent|wparam|defwinproc|optional, 1 },
3132 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3133 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3134 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI client XP */
3136 { 0x0093, sent|optional },
3137 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
3138 { 0x0093, sent|defwinproc|optional },
3139 { 0x0093, sent|defwinproc|optional },
3140 { 0x0093, sent|defwinproc|optional },
3141 { 0x0091, sent|defwinproc|optional },
3142 { 0x0092, sent|defwinproc|optional },
3143 { 0x0092, sent|defwinproc|optional },
3144 { 0x0092, sent|defwinproc|optional },
3145 { 0x0092, sent|defwinproc|optional },
3146 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
3147 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI frame XP */
3148 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam|optional, 0, 0 }, /* MDI child XP */
3151 /* ShowWindow(SW_MAXIMIZE) for a visible MDI child window */
3152 static const struct message WmMaximizeMDIchildVisibleSeq[] = {
3153 { HCBT_MINMAX, hook|lparam, 0, SW_MAXIMIZE },
3154 { WM_GETMINMAXINFO, sent },
3155 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3156 { WM_NCCALCSIZE, sent|wparam, 1 },
3157 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3158 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3159 { WM_SIZE, sent|defwinproc|wparam, SIZE_MAXIMIZED },
3161 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3162 { WM_NCCALCSIZE, sent|wparam, 1 },
3163 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3164 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3165 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3168 /* ShowWindow(SW_RESTORE) for a visible maximized MDI child window */
3169 static const struct message WmRestoreMDIchildVisibleSeq[] = {
3170 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3171 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED },
3172 { WM_NCCALCSIZE, sent|wparam, 1 },
3173 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3174 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3175 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3177 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3178 { WM_NCCALCSIZE, sent|wparam, 1 },
3179 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3180 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3181 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3184 /* ShowWindow(SW_RESTORE) for a visible minimized MDI child window */
3185 static const struct message WmRestoreMDIchildVisibleSeq_2[] = {
3186 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3187 { WM_QUERYOPEN, sent|wparam|lparam, 0, 0 },
3188 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
3189 { WM_NCCALCSIZE, sent|wparam, 1 },
3190 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3191 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
3192 { WM_MOVE, sent|defwinproc },
3193 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3194 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3195 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3196 { HCBT_SETFOCUS, hook },
3197 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
3198 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
3199 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
3200 { WM_SETFOCUS, sent },
3203 /* ShowWindow(SW_MINIMIZE) for a visible restored MDI child window */
3204 static const struct message WmMinimizeMDIchildVisibleSeq[] = {
3205 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
3206 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
3207 { WM_NCCALCSIZE, sent|wparam, 1 },
3208 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_STATECHANGED },
3209 { WM_MOVE, sent|defwinproc },
3210 { WM_SIZE, sent|defwinproc|wparam|lparam, SIZE_MINIMIZED, 0 },
3211 { WM_CHILDACTIVATE, sent|wparam|lparam|defwinproc, 0, 0 },
3212 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3213 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3214 /* FIXME: Wine creates an icon/title window while Windows doesn't */
3215 { WM_PARENTNOTIFY, sent|parent|wparam|optional, WM_CREATE }, /* MDI client */
3218 /* ShowWindow(SW_RESTORE) for a not visible MDI child window */
3219 static const struct message WmRestoreMDIchildInisibleSeq[] = {
3220 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
3221 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_STATECHANGED },
3222 { WM_NCCALCSIZE, sent|wparam, 1 },
3223 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
3224 { WM_CHILDACTIVATE, sent|wparam|lparam, 0, 0 },
3225 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOCLIENTMOVE|SWP_STATECHANGED },
3226 { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED },
3228 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
3229 { WM_NCCALCSIZE, sent|wparam, 1 },
3230 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
3231 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI frame */
3232 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, /* MDI child */
3236 static HWND mdi_client;
3237 static WNDPROC old_mdi_client_proc;
3239 static LRESULT WINAPI mdi_client_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3241 struct recvd_message msg;
3243 /* do not log painting messages */
3244 if (message != WM_PAINT &&
3245 message != WM_NCPAINT &&
3246 message != WM_SYNCPAINT &&
3247 message != WM_ERASEBKGND &&
3248 message != WM_NCHITTEST &&
3249 message != WM_GETTEXT &&
3250 message != WM_MDIGETACTIVE &&
3251 !ignore_message( message ))
3254 msg.message = message;
3255 msg.flags = sent|wparam|lparam;
3256 msg.wParam = wParam;
3257 msg.lParam = lParam;
3258 msg.descr = "mdi client";
3262 return CallWindowProcA(old_mdi_client_proc, hwnd, message, wParam, lParam);
3265 static LRESULT WINAPI mdi_child_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3267 static LONG defwndproc_counter = 0;
3269 struct recvd_message msg;
3271 /* do not log painting messages */
3272 if (message != WM_PAINT &&
3273 message != WM_NCPAINT &&
3274 message != WM_SYNCPAINT &&
3275 message != WM_ERASEBKGND &&
3276 message != WM_NCHITTEST &&
3277 message != WM_GETTEXT &&
3278 !ignore_message( message ))
3282 case WM_MDIACTIVATE:
3284 HWND active, client = GetParent(hwnd);
3286 active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
3288 if (hwnd == (HWND)lParam) /* if we are being activated */
3289 ok (active == (HWND)lParam, "new active %p != active %p\n", (HWND)lParam, active);
3291 ok (active == (HWND)wParam, "old active %p != active %p\n", (HWND)wParam, active);
3297 msg.message = message;
3298 msg.flags = sent|wparam|lparam;
3299 if (defwndproc_counter) msg.flags |= defwinproc;
3300 msg.wParam = wParam;
3301 msg.lParam = lParam;
3302 msg.descr = "mdi child";
3306 defwndproc_counter++;
3307 ret = DefMDIChildProcA(hwnd, message, wParam, lParam);
3308 defwndproc_counter--;
3313 static LRESULT WINAPI mdi_frame_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3315 static LONG defwndproc_counter = 0;
3317 struct recvd_message msg;
3319 /* do not log painting messages */
3320 if (message != WM_PAINT &&
3321 message != WM_NCPAINT &&
3322 message != WM_SYNCPAINT &&
3323 message != WM_ERASEBKGND &&
3324 message != WM_NCHITTEST &&
3325 message != WM_GETTEXT &&
3326 !ignore_message( message ))
3329 msg.message = message;
3330 msg.flags = sent|wparam|lparam;
3331 if (defwndproc_counter) msg.flags |= defwinproc;
3332 msg.wParam = wParam;
3333 msg.lParam = lParam;
3334 msg.descr = "mdi frame";
3338 defwndproc_counter++;
3339 ret = DefFrameProcA(hwnd, mdi_client, message, wParam, lParam);
3340 defwndproc_counter--;
3345 static BOOL mdi_RegisterWindowClasses(void)
3350 cls.lpfnWndProc = mdi_frame_wnd_proc;
3353 cls.hInstance = GetModuleHandleA(0);
3355 cls.hCursor = LoadCursorA(0, IDC_ARROW);
3356 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
3357 cls.lpszMenuName = NULL;
3358 cls.lpszClassName = "MDI_frame_class";
3359 if (!RegisterClassA(&cls)) return FALSE;
3361 cls.lpfnWndProc = mdi_child_wnd_proc;
3362 cls.lpszClassName = "MDI_child_class";
3363 if (!RegisterClassA(&cls)) return FALSE;
3365 if (!GetClassInfoA(0, "MDIClient", &cls)) assert(0);
3366 old_mdi_client_proc = cls.lpfnWndProc;
3367 cls.hInstance = GetModuleHandleA(0);
3368 cls.lpfnWndProc = mdi_client_hook_proc;
3369 cls.lpszClassName = "MDI_client_class";
3370 if (!RegisterClassA(&cls)) assert(0);
3375 static void test_mdi_messages(void)
3377 MDICREATESTRUCTA mdi_cs;
3378 CLIENTCREATESTRUCT client_cs;
3379 HWND mdi_frame, mdi_child, mdi_child2, active_child;
3382 HMENU hMenu = CreateMenu();
3384 if (!mdi_RegisterWindowClasses()) assert(0);
3388 trace("creating MDI frame window\n");
3389 mdi_frame = CreateWindowExA(0, "MDI_frame_class", "MDI frame window",
3390 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
3391 WS_MAXIMIZEBOX | WS_VISIBLE,
3392 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
3393 GetDesktopWindow(), hMenu,
3394 GetModuleHandleA(0), NULL);
3396 ok_sequence(WmCreateMDIframeSeq, "Create MDI frame window", FALSE);
3398 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3399 ok(GetFocus() == mdi_frame, "wrong focus window %p\n", GetFocus());
3401 trace("creating MDI client window\n");
3402 GetClientRect(mdi_frame, &rc);
3403 client_cs.hWindowMenu = 0;
3404 client_cs.idFirstChild = MDI_FIRST_CHILD_ID;
3405 mdi_client = CreateWindowExA(0, "MDI_client_class",
3407 WS_CHILD | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
3408 rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
3409 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3411 ok_sequence(WmCreateMDIclientSeq, "Create visible MDI client window", FALSE);
3413 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3414 ok(GetFocus() == mdi_frame, "input focus should be on MDI frame not on %p\n", GetFocus());
3416 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3417 ok(!active_child, "wrong active MDI child %p\n", active_child);
3418 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3423 trace("creating invisible MDI child window\n");
3424 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3426 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3427 mdi_client, 0, GetModuleHandleA(0), NULL);
3431 ShowWindow(mdi_child, SW_SHOWNORMAL);
3432 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOWNORMAL) MDI child window", FALSE);
3434 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3435 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3437 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3438 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3440 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3441 ok(!active_child, "wrong active MDI child %p\n", active_child);
3442 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3444 ShowWindow(mdi_child, SW_HIDE);
3445 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE) MDI child window", FALSE);
3448 ShowWindow(mdi_child, SW_SHOW);
3449 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW) MDI child window", FALSE);
3451 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3452 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3454 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3455 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3457 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3458 ok(!active_child, "wrong active MDI child %p\n", active_child);
3459 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3461 DestroyWindow(mdi_child);
3464 trace("creating visible MDI child window\n");
3465 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3466 WS_CHILD | WS_VISIBLE,
3467 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3468 mdi_client, 0, GetModuleHandleA(0), NULL);
3470 ok_sequence(WmCreateMDIchildVisibleSeq, "Create visible MDI child window", FALSE);
3472 ok(GetWindowLongA(mdi_child, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3473 ok(IsWindowVisible(mdi_child), "MDI child should be visible\n");
3475 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3476 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3478 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3479 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3480 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3483 DestroyWindow(mdi_child);
3484 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3486 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3487 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3489 /* Win2k: MDI client still returns a just destroyed child as active
3490 * Win9x: MDI client returns 0
3492 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3493 ok(active_child == mdi_child || /* win2k */
3494 !active_child, /* win9x */
3495 "wrong active MDI child %p\n", active_child);
3496 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3500 trace("creating invisible MDI child window\n");
3501 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3503 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3504 mdi_client, 0, GetModuleHandleA(0), NULL);
3506 ok_sequence(WmCreateMDIchildInvisibleSeq, "Create invisible MDI child window", FALSE);
3508 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should not be visible\n");
3509 ok(!IsWindowVisible(mdi_child2), "MDI child should not be visible\n");
3511 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3512 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3514 /* Win2k: MDI client still returns a just destroyed child as active
3515 * Win9x: MDI client returns mdi_child2
3517 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3518 ok(active_child == mdi_child || /* win2k */
3519 active_child == mdi_child2, /* win9x */
3520 "wrong active MDI child %p\n", active_child);
3521 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3524 ShowWindow(mdi_child2, SW_MAXIMIZE);
3525 ok_sequence(WmMaximizeMDIchildInvisibleSeq, "ShowWindow(SW_MAXIMIZE):invisible MDI child", FALSE);
3527 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3528 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3530 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3531 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3532 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3535 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3536 ok(GetFocus() == mdi_child2 || /* win2k */
3537 GetFocus() == 0, /* win9x */
3538 "wrong focus window %p\n", GetFocus());
3543 ShowWindow(mdi_child2, SW_HIDE);
3544 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3546 ShowWindow(mdi_child2, SW_RESTORE);
3547 ok_sequence(WmRestoreMDIchildInisibleSeq, "ShowWindow(SW_RESTORE):invisible MDI child", FALSE);
3550 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3551 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3553 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3554 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3555 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3561 ShowWindow(mdi_child2, SW_HIDE);
3562 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3564 ShowWindow(mdi_child2, SW_SHOW);
3565 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):MDI child", FALSE);
3567 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3568 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3570 ShowWindow(mdi_child2, SW_MAXIMIZE);
3571 ok_sequence(WmMaximizeMDIchildVisibleSeq, "ShowWindow(SW_MAXIMIZE):MDI child", FALSE);
3573 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3574 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3576 ShowWindow(mdi_child2, SW_RESTORE);
3577 ok_sequence(WmRestoreMDIchildVisibleSeq, "ShowWindow(SW_RESTORE):maximized MDI child", FALSE);
3579 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3580 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3582 ShowWindow(mdi_child2, SW_MINIMIZE);
3583 ok_sequence(WmMinimizeMDIchildVisibleSeq, "ShowWindow(SW_MINIMIZE):MDI child", TRUE);
3585 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3586 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3588 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3589 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3590 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3593 ShowWindow(mdi_child2, SW_RESTORE);
3594 ok_sequence(WmRestoreMDIchildVisibleSeq_2, "ShowWindow(SW_RESTORE):minimized MDI child", FALSE);
3596 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3597 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3599 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3600 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3601 ok(!zoomed, "wrong zoomed state %d\n", zoomed);
3607 ShowWindow(mdi_child2, SW_HIDE);
3608 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):MDI child", FALSE);
3610 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3611 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3613 DestroyWindow(mdi_child2);
3614 ok_sequence(WmDestroyMDIchildInvisibleSeq, "Destroy invisible MDI child window", FALSE);
3616 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3617 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3619 /* test for maximized MDI children */
3620 trace("creating maximized visible MDI child window 1\n");
3621 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3622 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3623 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3624 mdi_client, 0, GetModuleHandleA(0), NULL);
3626 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window", TRUE);
3627 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3629 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3630 ok(GetFocus() == mdi_child || /* win2k */
3631 GetFocus() == 0, /* win9x */
3632 "wrong focus window %p\n", GetFocus());
3634 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3635 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3636 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3639 trace("creating maximized visible MDI child window 2\n");
3640 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3641 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3642 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3643 mdi_client, 0, GetModuleHandleA(0), NULL);
3645 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3646 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3647 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3649 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3650 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3652 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3653 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3654 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3657 trace("destroying maximized visible MDI child window 2\n");
3658 DestroyWindow(mdi_child2);
3659 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3661 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3663 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3664 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3666 /* Win2k: MDI client still returns a just destroyed child as active
3667 * Win9x: MDI client returns 0
3669 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3670 ok(active_child == mdi_child2 || /* win2k */
3671 !active_child, /* win9x */
3672 "wrong active MDI child %p\n", active_child);
3675 ShowWindow(mdi_child, SW_MAXIMIZE);
3676 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3679 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3680 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3682 trace("re-creating maximized visible MDI child window 2\n");
3683 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3684 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3685 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3686 mdi_client, 0, GetModuleHandleA(0), NULL);
3688 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child 2 window", TRUE);
3689 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized\n");
3690 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized\n");
3692 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3693 ok(GetFocus() == mdi_child2, "wrong focus window %p\n", GetFocus());
3695 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3696 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3697 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3700 SendMessageA(mdi_child2, WM_SYSCOMMAND, SC_CLOSE, 0);
3701 ok_sequence(WmDestroyMDIchildVisibleMaxSeq2, "WM_SYSCOMMAND/SC_CLOSE on a visible maximized MDI child window", TRUE);
3702 ok(!IsWindow(mdi_child2), "MDI child 2 should be destroyed\n");
3704 ok(IsZoomed(mdi_child), "1st MDI child should be maximized\n");
3705 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3706 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3708 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3709 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3710 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3713 DestroyWindow(mdi_child);
3714 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible MDI child window", TRUE);
3716 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3717 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3719 /* Win2k: MDI client still returns a just destroyed child as active
3720 * Win9x: MDI client returns 0
3722 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3723 ok(active_child == mdi_child || /* win2k */
3724 !active_child, /* win9x */
3725 "wrong active MDI child %p\n", active_child);
3728 trace("creating maximized invisible MDI child window\n");
3729 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3730 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
3731 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3732 mdi_client, 0, GetModuleHandleA(0), NULL);
3734 ok_sequence(WmCreateMDIchildInvisibleMaxSeq4, "Create maximized invisible MDI child window", FALSE);
3735 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3736 ok(!(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE), "MDI child should be not visible\n");
3737 ok(!IsWindowVisible(mdi_child2), "MDI child should be not visible\n");
3739 /* Win2k: MDI client still returns a just destroyed child as active
3740 * Win9x: MDI client returns 0
3742 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3743 ok(active_child == mdi_child || /* win2k */
3744 !active_child || active_child == mdi_child2, /* win9x */
3745 "wrong active MDI child %p\n", active_child);
3748 trace("call ShowWindow(mdi_child, SW_MAXIMIZE)\n");
3749 ShowWindow(mdi_child2, SW_MAXIMIZE);
3750 ok_sequence(WmMaximizeMDIchildInvisibleSeq2, "ShowWindow(SW_MAXIMIZE):invisible maximized MDI child", FALSE);
3751 ok(IsZoomed(mdi_child2), "MDI child should be maximized\n");
3752 ok(GetWindowLongA(mdi_child2, GWL_STYLE) & WS_VISIBLE, "MDI child should be visible\n");
3753 ok(IsWindowVisible(mdi_child2), "MDI child should be visible\n");
3755 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3756 ok(active_child == mdi_child2, "wrong active MDI child %p\n", active_child);
3757 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3760 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3763 /* end of test for maximized MDI children */
3766 trace("creating maximized visible MDI child window 1(Switch test)\n");
3767 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3768 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3769 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3770 mdi_client, 0, GetModuleHandleA(0), NULL);
3772 ok_sequence(WmCreateMDIchildVisibleMaxSeq1, "Create maximized visible 1st MDI child window(Switch test)", TRUE);
3773 ok(IsZoomed(mdi_child), "1st MDI child should be maximized(Switch test)\n");
3775 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3776 ok(GetFocus() == mdi_child || /* win2k */
3777 GetFocus() == 0, /* win9x */
3778 "wrong focus window %p(Switch test)\n", GetFocus());
3780 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3781 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3782 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3785 trace("creating maximized visible MDI child window 2(Switch test)\n");
3786 mdi_child2 = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3787 WS_CHILD | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE,
3788 0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
3789 mdi_client, 0, GetModuleHandleA(0), NULL);
3791 ok_sequence(WmCreateMDIchildVisibleMaxSeq2, "Create maximized visible 2nd MDI child window (Switch test)", TRUE);
3793 ok(IsZoomed(mdi_child2), "2nd MDI child should be maximized(Switch test)\n");
3794 ok(!IsZoomed(mdi_child), "1st MDI child should NOT be maximized(Switch test)\n");
3796 ok(GetActiveWindow() == mdi_frame, "wrong active window %p(Switch test)\n", GetActiveWindow());
3797 ok(GetFocus() == mdi_child2, "wrong focus window %p(Switch test)\n", GetFocus());
3799 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3800 ok(active_child == mdi_child2, "wrong active MDI child %p(Switch test)\n", active_child);
3801 ok(zoomed, "wrong zoomed state %d(Switch test)\n", zoomed);
3804 trace("Switch child window.\n");
3805 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child, 0);
3806 ok_sequence(WmSwitchChild, "Child did not switch correctly", TRUE);
3807 trace("end of test for switch maximized MDI children\n");
3810 /* Prepare for switching test of not maximized MDI children */
3811 ShowWindow( mdi_child, SW_NORMAL );
3812 ok(!IsZoomed(mdi_child), "wrong zoomed state for %p(Switch test)\n", mdi_child);
3813 ok(!IsZoomed(mdi_child2), "wrong zoomed state for %p(Switch test)\n", mdi_child2);
3814 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0);
3815 ok(active_child == mdi_child, "wrong active MDI child %p(Switch test)\n", active_child);
3818 SendMessageA(mdi_client, WM_MDIACTIVATE, (WPARAM)mdi_child2, 0);
3819 ok_sequence(WmSwitchNotMaximizedChild, "Not maximized child did not switch correctly", FALSE);
3820 trace("end of test for switch not maximized MDI children\n");
3823 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3826 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child2, 0);
3831 /* end of tests for switch maximized/not maximized MDI children */
3833 mdi_cs.szClass = "MDI_child_Class";
3834 mdi_cs.szTitle = "MDI child";
3835 mdi_cs.hOwner = GetModuleHandleA(0);
3838 mdi_cs.cx = CW_USEDEFAULT;
3839 mdi_cs.cy = CW_USEDEFAULT;
3840 mdi_cs.style = WS_CHILD | WS_SYSMENU | WS_VISIBLE | WS_MAXIMIZEBOX | WS_MAXIMIZE;
3842 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
3843 ok(mdi_child != 0, "MDI child creation failed\n");
3844 ok_sequence(WmCreateMDIchildVisibleMaxSeq3, "WM_MDICREATE for maximized visible MDI child window", TRUE);
3846 ok(GetMenuItemID(hMenu, GetMenuItemCount(hMenu) - 1) == SC_CLOSE, "SC_CLOSE menu item not found\n");
3848 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3849 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3851 ok(IsZoomed(mdi_child), "MDI child should be maximized\n");
3852 ok(GetActiveWindow() == mdi_frame, "wrong active window %p\n", GetActiveWindow());
3853 ok(GetFocus() == mdi_child, "wrong focus window %p\n", GetFocus());
3855 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3856 ok(active_child == mdi_child, "wrong active MDI child %p\n", active_child);
3857 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3860 SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
3861 ok_sequence(WmDestroyMDIchildVisibleMaxSeq1, "Destroy visible maximized MDI child window", TRUE);
3863 ok(!IsWindow(mdi_child), "MDI child should be destroyed\n");
3864 active_child = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, (LPARAM)&zoomed);
3865 ok(!active_child, "wrong active MDI child %p\n", active_child);
3870 DestroyWindow(mdi_client);
3871 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3873 /* test maximization of MDI child with invisible parent */
3874 client_cs.hWindowMenu = 0;
3875 mdi_client = CreateWindow("MDI_client_class",
3877 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
3879 mdi_frame, 0, GetModuleHandleA(0), &client_cs);
3880 ok_sequence(WmCreateMDIclientSeq, "Create MDI client window", FALSE);
3882 ShowWindow(mdi_client, SW_HIDE);
3883 ok_sequence(WmHideMDIclientSeq, "Hide MDI client window", FALSE);
3885 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_class", "MDI child",
3886 WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL,
3888 mdi_client, 0, GetModuleHandleA(0), NULL);
3889 ok_sequence(WmCreateMDIchildInvisibleParentSeq, "Create MDI child window with invisible parent", FALSE);
3891 SendMessage(mdi_client, WM_MDIMAXIMIZE, (WPARAM) mdi_child, 0);
3892 ok_sequence(WmMaximizeMDIchildInvisibleParentSeq, "Maximize MDI child window with invisible parent", TRUE);
3893 zoomed = IsZoomed(mdi_child);
3894 ok(zoomed, "wrong zoomed state %d\n", zoomed);
3896 ShowWindow(mdi_client, SW_SHOW);
3897 ok_sequence(WmShowMDIclientSeq, "Show MDI client window", FALSE);
3899 DestroyWindow(mdi_child);
3900 ok_sequence(WmDestroyMDIchildVisibleSeq, "Destroy visible maximized MDI child window", TRUE);
3902 /* end of test for maximization of MDI child with invisible parent */
3904 DestroyWindow(mdi_client);
3905 ok_sequence(WmDestroyMDIclientSeq, "Destroy MDI client window", FALSE);
3907 DestroyWindow(mdi_frame);
3908 ok_sequence(WmDestroyMDIframeSeq, "Destroy MDI frame window", FALSE);
3910 /************************* End of MDI test **********************************/
3912 static void test_WM_SETREDRAW(HWND hwnd)
3914 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
3919 SendMessageA(hwnd, WM_SETREDRAW, FALSE, 0);
3920 ok_sequence(WmSetRedrawFalseSeq, "SetRedraw:FALSE", FALSE);
3922 ok(!(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should NOT be set\n");
3923 ok(!IsWindowVisible(hwnd), "IsWindowVisible() should return FALSE\n");
3926 SendMessageA(hwnd, WM_SETREDRAW, TRUE, 0);
3927 ok_sequence(WmSetRedrawTrueSeq, "SetRedraw:TRUE", FALSE);
3929 ok(GetWindowLongA(hwnd, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
3930 ok(IsWindowVisible(hwnd), "IsWindowVisible() should return TRUE\n");
3932 /* restore original WS_VISIBLE state */
3933 SetWindowLongA(hwnd, GWL_STYLE, style);
3939 static INT_PTR CALLBACK TestModalDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
3941 struct recvd_message msg;
3943 if (ignore_message( message )) return 0;
3949 case WM_NCMOUSEMOVE:
3950 case WM_NCMOUSELEAVE:
3958 msg.message = message;
3959 msg.flags = sent|wparam|lparam;
3960 msg.wParam = wParam;
3961 msg.lParam = lParam;
3962 msg.descr = "dialog";
3965 if (message == WM_INITDIALOG) SetTimer( hwnd, 1, 100, NULL );
3966 if (message == WM_TIMER) EndDialog( hwnd, 0 );
3970 static void test_hv_scroll_1(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
3972 DWORD style, exstyle;
3976 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
3977 style = GetWindowLongA(hwnd, GWL_STYLE);
3978 /* do not be confused by WS_DLGFRAME set */
3979 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
3981 if (clear) ok(style & clear, "style %08x should be set\n", clear);
3982 if (set) ok(!(style & set), "style %08x should not be set\n", set);
3984 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3985 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3986 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
3987 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollRange(SB_HORZ/SB_VERT) NC", FALSE);
3989 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollRange(SB_HORZ/SB_VERT)", FALSE);
3991 style = GetWindowLongA(hwnd, GWL_STYLE);
3992 if (set) ok(style & set, "style %08x should be set\n", set);
3993 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
3995 /* a subsequent call should do nothing */
3996 ret = SetScrollRange(hwnd, ctl, min, max, FALSE);
3997 ok( ret, "SetScrollRange(%d) error %d\n", ctl, GetLastError());
3998 ok_sequence(WmEmptySeq, "SetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
4002 ret = GetScrollRange(hwnd, ctl, &xmin, &xmax);
4003 ok( ret, "GetScrollRange(%d) error %d\n", ctl, GetLastError());
4004 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
4005 ok(xmin == min, "unexpected min scroll value %d\n", xmin);
4006 ok(xmax == max, "unexpected max scroll value %d\n", xmax);
4009 static void test_hv_scroll_2(HWND hwnd, INT ctl, DWORD clear, DWORD set, INT min, INT max)
4011 DWORD style, exstyle;
4015 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
4016 style = GetWindowLongA(hwnd, GWL_STYLE);
4017 /* do not be confused by WS_DLGFRAME set */
4018 if ((style & WS_CAPTION) == WS_CAPTION) style &= ~WS_CAPTION;
4020 if (clear) ok(style & clear, "style %08x should be set\n", clear);
4021 if (set) ok(!(style & set), "style %08x should not be set\n", set);
4023 si.cbSize = sizeof(si);
4024 si.fMask = SIF_RANGE;
4027 SetScrollInfo(hwnd, ctl, &si, TRUE);
4028 if ((style & (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME)) || (exstyle & WS_EX_DLGMODALFRAME))
4029 ok_sequence(WmSetScrollRangeHV_NC_Seq, "SetScrollInfo(SB_HORZ/SB_VERT) NC", FALSE);
4031 ok_sequence(WmSetScrollRangeHVSeq, "SetScrollInfo(SB_HORZ/SB_VERT)", FALSE);
4033 style = GetWindowLongA(hwnd, GWL_STYLE);
4034 if (set) ok(style & set, "style %08x should be set\n", set);
4035 if (clear) ok(!(style & clear), "style %08x should not be set\n", clear);
4037 /* a subsequent call should do nothing */
4038 SetScrollInfo(hwnd, ctl, &si, TRUE);
4039 if (style & WS_HSCROLL)
4040 ok_sequence(WmSetScrollRangeHSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4041 else if (style & WS_VSCROLL)
4042 ok_sequence(WmSetScrollRangeVSeq_empty, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4044 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4046 si.fMask = SIF_PAGE;
4048 SetScrollInfo(hwnd, ctl, &si, FALSE);
4049 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4053 SetScrollInfo(hwnd, ctl, &si, FALSE);
4054 ok_sequence(WmEmptySeq, "SetScrollInfo(SB_HORZ/SB_VERT) empty sequence", FALSE);
4056 si.fMask = SIF_RANGE;
4057 si.nMin = 0xdeadbeef;
4058 si.nMax = 0xdeadbeef;
4059 ret = GetScrollInfo(hwnd, ctl, &si);
4060 ok( ret, "GetScrollInfo error %d\n", GetLastError());
4061 ok_sequence(WmEmptySeq, "GetScrollRange(SB_HORZ/SB_VERT) empty sequence", FALSE);
4062 ok(si.nMin == min, "unexpected min scroll value %d\n", si.nMin);
4063 ok(si.nMax == max, "unexpected max scroll value %d\n", si.nMax);
4066 /* Win9x sends WM_USER+xxx while and NT versions send SBM_xxx messages */
4067 static void test_scroll_messages(HWND hwnd)
4078 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
4079 ok( ret, "GetScrollRange error %d\n", GetLastError());
4080 if (sequence->message != WmGetScrollRangeSeq[0].message)
4081 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
4082 /* values of min and max are undefined */
4085 ret = SetScrollRange(hwnd, SB_CTL, 10, 150, FALSE);
4086 ok( ret, "SetScrollRange error %d\n", GetLastError());
4087 if (sequence->message != WmSetScrollRangeSeq[0].message)
4088 trace("SetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
4093 ret = GetScrollRange(hwnd, SB_CTL, &min, &max);
4094 ok( ret, "GetScrollRange error %d\n", GetLastError());
4095 if (sequence->message != WmGetScrollRangeSeq[0].message)
4096 trace("GetScrollRange(SB_CTL) generated unknown message %04x\n", sequence->message);
4097 /* values of min and max are undefined */
4100 si.cbSize = sizeof(si);
4101 si.fMask = SIF_RANGE;
4104 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4105 if (sequence->message != WmSetScrollRangeSeq[0].message)
4106 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4109 si.fMask = SIF_PAGE;
4111 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4112 if (sequence->message != WmSetScrollRangeSeq[0].message)
4113 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4118 SetScrollInfo(hwnd, SB_CTL, &si, FALSE);
4119 if (sequence->message != WmSetScrollRangeSeq[0].message)
4120 trace("SetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4123 si.fMask = SIF_RANGE;
4124 si.nMin = 0xdeadbeef;
4125 si.nMax = 0xdeadbeef;
4126 ret = GetScrollInfo(hwnd, SB_CTL, &si);
4127 ok( ret, "GetScrollInfo error %d\n", GetLastError());
4128 if (sequence->message != WmGetScrollInfoSeq[0].message)
4129 trace("GetScrollInfo(SB_CTL) generated unknown message %04x\n", sequence->message);
4130 /* values of min and max are undefined */
4133 /* set WS_HSCROLL */
4134 test_hv_scroll_1(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
4135 /* clear WS_HSCROLL */
4136 test_hv_scroll_1(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
4138 /* set WS_HSCROLL */
4139 test_hv_scroll_2(hwnd, SB_HORZ, 0, WS_HSCROLL, 10, 150);
4140 /* clear WS_HSCROLL */
4141 test_hv_scroll_2(hwnd, SB_HORZ, WS_HSCROLL, 0, 0, 0);
4143 /* set WS_VSCROLL */
4144 test_hv_scroll_1(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
4145 /* clear WS_VSCROLL */
4146 test_hv_scroll_1(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
4148 /* set WS_VSCROLL */
4149 test_hv_scroll_2(hwnd, SB_VERT, 0, WS_VSCROLL, 10, 150);
4150 /* clear WS_VSCROLL */
4151 test_hv_scroll_2(hwnd, SB_VERT, WS_VSCROLL, 0, 0, 0);
4154 static void test_showwindow(void)
4159 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4160 100, 100, 200, 200, 0, 0, 0, NULL);
4161 ok (hwnd != 0, "Failed to create overlapped window\n");
4162 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4163 0, 0, 10, 10, hwnd, 0, 0, NULL);
4164 ok (hchild != 0, "Failed to create child\n");
4167 /* ShowWindow( SW_SHOWNA) for invisible top level window */
4168 trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
4169 ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4170 ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window", FALSE);
4172 /* ShowWindow( SW_SHOWNA) for now visible top level window */
4173 trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
4174 ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4175 ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window", FALSE);
4176 /* back to invisible */
4177 ShowWindow(hchild, SW_HIDE);
4178 ShowWindow(hwnd, SW_HIDE);
4180 /* ShowWindow(SW_SHOWNA) with child and parent invisible */
4181 trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
4182 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4183 ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent", FALSE);
4184 /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
4185 ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
4187 trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
4188 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4189 ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent", FALSE);
4190 /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
4191 ShowWindow( hwnd, SW_SHOW);
4193 trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
4194 ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
4195 ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent", FALSE);
4197 /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
4198 ShowWindow( hchild, SW_HIDE);
4200 trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
4201 ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
4202 ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent", FALSE);
4205 ok(GetCapture() == hchild, "wrong capture window %p\n", GetCapture());
4206 DestroyWindow(hchild);
4207 ok(!GetCapture(), "wrong capture window %p\n", GetCapture());
4209 DestroyWindow(hwnd);
4214 * 1. Create invisible maximized popup window.
4215 * 2. Move and resize it.
4216 * 3. Show it maximized.
4218 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4219 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
4220 100, 100, 200, 200, 0, 0, 0, NULL);
4221 ok (hwnd != 0, "Failed to create popup window\n");
4222 ok(IsZoomed(hwnd), "window should be maximized\n");
4223 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4225 GetWindowRect(hwnd, &rc);
4226 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
4227 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
4228 "Invalid maximized size before ShowWindow (%d,%d)-(%d,%d)\n",
4229 rc.left, rc.top, rc.right, rc.bottom);
4230 /* Reset window's size & position */
4231 SetWindowPos(hwnd, 0, 10, 10, 200, 200, SWP_NOZORDER | SWP_NOACTIVATE);
4232 ok(IsZoomed(hwnd), "window should be maximized\n");
4235 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4236 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4237 ok(IsZoomed(hwnd), "window should be maximized\n");
4238 ok_sequence(WmShowMaxPopupResizedSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup", FALSE);
4240 GetWindowRect(hwnd, &rc);
4241 ok( rc.right-rc.left == GetSystemMetrics(SM_CXSCREEN) &&
4242 rc.bottom-rc.top == GetSystemMetrics(SM_CYSCREEN),
4243 "Invalid maximized size after ShowWindow (%d,%d)-(%d,%d)\n",
4244 rc.left, rc.top, rc.right, rc.bottom);
4245 DestroyWindow(hwnd);
4249 * 1. Create invisible maximized popup window.
4250 * 2. Show it maximized.
4252 trace("calling CreateWindowExA( WS_MAXIMIZE ) for invisible maximized popup window\n");
4253 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE,
4254 100, 100, 200, 200, 0, 0, 0, NULL);
4255 ok (hwnd != 0, "Failed to create popup window\n");
4256 ok(IsZoomed(hwnd), "window should be maximized\n");
4257 ok_sequence(WmCreateInvisibleMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4259 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for invisible maximized popup window\n");
4260 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4261 ok(IsZoomed(hwnd), "window should be maximized\n");
4262 ok_sequence(WmShowMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup", FALSE);
4263 DestroyWindow(hwnd);
4267 * 1. Create visible maximized popup window.
4269 trace("calling CreateWindowExA( WS_MAXIMIZE ) for maximized popup window\n");
4270 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_MAXIMIZE | WS_VISIBLE,
4271 100, 100, 200, 200, 0, 0, 0, NULL);
4272 ok (hwnd != 0, "Failed to create popup window\n");
4273 ok(IsZoomed(hwnd), "window should be maximized\n");
4274 ok_sequence(WmCreateMaxPopupSeq, "CreateWindow(WS_MAXIMIZED):popup", FALSE);
4275 DestroyWindow(hwnd);
4279 * 1. Create visible popup window.
4282 trace("calling CreateWindowExA( WS_VISIBLE ) for popup window\n");
4283 hwnd = CreateWindowExA(0, "TestWindowClass", "Test popup", WS_POPUP | WS_VISIBLE,
4284 100, 100, 200, 200, 0, 0, 0, NULL);
4285 ok (hwnd != 0, "Failed to create popup window\n");
4286 ok(!IsZoomed(hwnd), "window should NOT be maximized\n");
4287 ok_sequence(WmCreatePopupSeq, "CreateWindow(WS_VISIBLE):popup", FALSE);
4289 trace("calling ShowWindow( SW_SHOWMAXIMIZE ) for visible popup window\n");
4290 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4291 ok(IsZoomed(hwnd), "window should be maximized\n");
4292 ok_sequence(WmShowVisMaxPopupSeq, "ShowWindow(SW_SHOWMAXIMIZED):popup", FALSE);
4293 DestroyWindow(hwnd);
4297 static void test_sys_menu(void)
4303 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4304 100, 100, 200, 200, 0, 0, 0, NULL);
4305 ok (hwnd != 0, "Failed to create overlapped window\n");
4309 /* test existing window without CS_NOCLOSE style */
4310 hmenu = GetSystemMenu(hwnd, FALSE);
4311 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4313 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4314 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4315 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4317 EnableMenuItem(hmenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
4318 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4320 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4321 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4322 ok((state & (MF_DISABLED | MF_GRAYED)) == MF_GRAYED, "wrong SC_CLOSE state %x\n", state);
4324 EnableMenuItem(hmenu, SC_CLOSE, 0);
4325 ok_sequence(WmEmptySeq, "WmEnableMenuItem", FALSE);
4327 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4328 ok(state != 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4329 ok(!(state & (MF_DISABLED | MF_GRAYED)), "wrong SC_CLOSE state %x\n", state);
4331 /* test whether removing WS_SYSMENU destroys a system menu */
4332 SetWindowLongW(hwnd, GWL_STYLE, WS_POPUP);
4333 SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4335 hmenu = GetSystemMenu(hwnd, FALSE);
4336 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4338 DestroyWindow(hwnd);
4340 /* test new window with CS_NOCLOSE style */
4341 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4342 100, 100, 200, 200, 0, 0, 0, NULL);
4343 ok (hwnd != 0, "Failed to create overlapped window\n");
4345 hmenu = GetSystemMenu(hwnd, FALSE);
4346 ok(hmenu != 0, "GetSystemMenu error %d\n", GetLastError());
4348 state = GetMenuState(hmenu, SC_CLOSE, MF_BYCOMMAND);
4349 ok(state == 0xffffffff, "wrong SC_CLOSE state %x\n", state);
4351 DestroyWindow(hwnd);
4353 /* test new window without WS_SYSMENU style */
4354 hwnd = CreateWindowExA(0, "NoCloseWindowClass", NULL, WS_OVERLAPPEDWINDOW & ~WS_SYSMENU,
4355 100, 100, 200, 200, 0, 0, 0, NULL);
4356 ok(hwnd != 0, "Failed to create overlapped window\n");
4358 hmenu = GetSystemMenu(hwnd, FALSE);
4359 ok(!hmenu, "GetSystemMenu error %d\n", GetLastError());
4361 DestroyWindow(hwnd);
4364 /* For shown WS_OVERLAPPEDWINDOW */
4365 static const struct message WmSetIcon_1[] = {
4366 { WM_SETICON, sent },
4367 { 0x00AE, sent|defwinproc|optional }, /* XP */
4368 { WM_GETTEXT, sent|defwinproc|optional },
4369 { WM_GETTEXT, sent|defwinproc|optional }, /* XP sends a duplicate */
4373 /* For WS_POPUP and hidden WS_OVERLAPPEDWINDOW */
4374 static const struct message WmSetIcon_2[] = {
4375 { WM_SETICON, sent },
4379 /* Sending undocumented 0x3B message with wparam = 0x8000000b */
4380 static const struct message WmInitEndSession[] = {
4382 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4386 /* Sending undocumented 0x3B message with wparam = 0x0000000b */
4387 static const struct message WmInitEndSession_2[] = {
4389 { WM_QUERYENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4393 /* Sending undocumented 0x3B message with wparam = 0x80000008 */
4394 static const struct message WmInitEndSession_3[] = {
4396 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, ENDSESSION_LOGOFF },
4400 /* Sending undocumented 0x3B message with wparam = 0x00000008 */
4401 static const struct message WmInitEndSession_4[] = {
4403 { WM_ENDSESSION, sent|defwinproc|wparam|lparam, 0, 0 },
4407 /* Sending undocumented 0x3B message with wparam = 0x80000001 */
4408 static const struct message WmInitEndSession_5[] = {
4410 { WM_ENDSESSION, sent|defwinproc/*|wparam*/|lparam, 1, ENDSESSION_LOGOFF },
4414 static const struct message WmOptionalPaint[] = {
4415 { WM_PAINT, sent|optional },
4416 { WM_NCPAINT, sent|beginpaint|optional },
4417 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
4418 { WM_ERASEBKGND, sent|beginpaint|optional },
4422 static const struct message WmZOrder[] = {
4423 { WM_WINDOWPOSCHANGING, sent|wparam, 0, 0 },
4424 { WM_GETMINMAXINFO, sent|defwinproc|wparam, 0, 0 },
4425 { HCBT_ACTIVATE, hook },
4426 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
4427 { WM_WINDOWPOSCHANGING, sent|wparam, 3, 0 },
4428 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0 },
4429 { WM_GETTEXT, sent|optional },
4430 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
4431 { WM_ACTIVATEAPP, sent|wparam, 1, 0 },
4432 { WM_NCACTIVATE, sent|lparam, 1, 0 },
4433 { WM_GETTEXT, sent|defwinproc|optional },
4434 { WM_GETTEXT, sent|defwinproc|optional },
4435 { WM_ACTIVATE, sent|wparam|lparam, 1, 0 },
4436 { HCBT_SETFOCUS, hook },
4437 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
4438 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
4439 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
4440 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
4441 { WM_GETTEXT, sent|optional },
4442 { WM_NCCALCSIZE, sent|optional },
4446 static void test_MsgWaitForMultipleObjects(HWND hwnd)
4451 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4452 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4454 PostMessageA(hwnd, WM_USER, 0, 0);
4456 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4457 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4459 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4460 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4462 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4463 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4465 PostMessageA(hwnd, WM_USER, 0, 0);
4467 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4468 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4470 ok(PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "PeekMessage should succeed\n");
4471 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
4473 /* shows QS_POSTMESSAGE flag is cleared in the PeekMessage call */
4474 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4475 ok(ret == WAIT_TIMEOUT, "MsgWaitForMultipleObjects returned %x\n", ret);
4477 PostMessageA(hwnd, WM_USER, 0, 0);
4479 /* new incoming message causes it to become signaled again */
4480 ret = MsgWaitForMultipleObjects(0, NULL, FALSE, 0, QS_POSTMESSAGE);
4481 ok(ret == WAIT_OBJECT_0, "MsgWaitForMultipleObjects returned %x\n", ret);
4483 ok(PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n");
4484 ok(msg.message == WM_USER, "got %04x instead of WM_USER\n", msg.message);
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);
4489 /* test if we receive the right sequence of messages */
4490 static void test_messages(void)
4492 HWND hwnd, hparent, hchild;
4493 HWND hchild2, hbutton;
4500 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4501 100, 100, 200, 200, 0, 0, 0, NULL);
4502 ok (hwnd != 0, "Failed to create overlapped window\n");
4503 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4505 /* test ShowWindow(SW_HIDE) on a newly created invisible window */
4506 ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
4507 ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped, invisible", FALSE);
4509 /* test WM_SETREDRAW on a not visible top level window */
4510 test_WM_SETREDRAW(hwnd);
4512 SetWindowPos(hwnd, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4514 ok_sequence(WmSWP_ShowOverlappedSeq, "SetWindowPos:SWP_SHOWWINDOW:overlapped", FALSE);
4515 ok(IsWindowVisible(hwnd), "window should be visible at this point\n");
4517 ok(GetActiveWindow() == hwnd, "window should be active\n");
4518 ok(GetFocus() == hwnd, "window should have input focus\n");
4519 ShowWindow(hwnd, SW_HIDE);
4521 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4523 ShowWindow(hwnd, SW_SHOW);
4525 ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
4527 ShowWindow(hwnd, SW_HIDE);
4529 ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
4531 ShowWindow(hwnd, SW_SHOWMAXIMIZED);
4533 ok_sequence(WmShowMaxOverlappedSeq, "ShowWindow(SW_SHOWMAXIMIZED):overlapped", TRUE);
4536 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MAXIMIZE)
4538 ShowWindow(hwnd, SW_RESTORE);
4540 ok_sequence(WmShowRestoreMaxOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", TRUE);
4544 ShowWindow(hwnd, SW_MINIMIZE);
4546 ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE);
4549 if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MINIMIZE)
4551 ShowWindow(hwnd, SW_RESTORE);
4553 ok_sequence(WmShowRestoreMinOverlappedSeq, "ShowWindow(SW_RESTORE):overlapped", TRUE);
4557 ShowWindow(hwnd, SW_SHOW);
4559 ok_sequence(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE);
4561 SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4562 ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE);
4563 ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n");
4564 ok(GetActiveWindow() == hwnd, "window should still be active\n");
4566 /* test WM_SETREDRAW on a visible top level window */
4567 ShowWindow(hwnd, SW_SHOW);
4569 test_WM_SETREDRAW(hwnd);
4571 trace("testing scroll APIs on a visible top level window %p\n", hwnd);
4572 test_scroll_messages(hwnd);
4574 /* test resizing and moving */
4575 SetWindowPos( hwnd, 0, 0, 0, 300, 300, SWP_NOMOVE|SWP_NOACTIVATE );
4576 ok_sequence(WmSWP_ResizeSeq, "SetWindowPos:Resize", FALSE );
4579 SetWindowPos( hwnd, 0, 200, 200, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE );
4580 ok_sequence(WmSWP_MoveSeq, "SetWindowPos:Move", FALSE );
4583 SetWindowPos( hwnd, 0, 200, 200, 250, 250, SWP_NOZORDER|SWP_NOACTIVATE );
4584 ok_sequence(WmSWP_ResizeNoZOrder, "SetWindowPos:WmSWP_ResizeNoZOrder", FALSE );
4588 /* popups don't get WM_GETMINMAXINFO */
4589 SetWindowLongW( hwnd, GWL_STYLE, WS_VISIBLE|WS_POPUP );
4590 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_FRAMECHANGED);
4592 SetWindowPos( hwnd, 0, 0, 0, 200, 200, SWP_NOMOVE|SWP_NOACTIVATE );
4593 ok_sequence(WmSWP_ResizePopupSeq, "SetWindowPos:ResizePopup", FALSE );
4595 DestroyWindow(hwnd);
4596 ok_sequence(WmDestroyOverlappedSeq, "DestroyWindow:overlapped", FALSE);
4598 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4599 100, 100, 200, 200, 0, 0, 0, NULL);
4600 ok (hparent != 0, "Failed to create parent window\n");
4603 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_MAXIMIZE,
4604 0, 0, 10, 10, hparent, 0, 0, NULL);
4605 ok (hchild != 0, "Failed to create child window\n");
4606 ok_sequence(WmCreateMaximizedChildSeq, "CreateWindow:maximized child", FALSE);
4607 DestroyWindow(hchild);
4610 /* visible child window with a caption */
4611 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
4612 WS_CHILD | WS_VISIBLE | WS_CAPTION,
4613 0, 0, 10, 10, hparent, 0, 0, NULL);
4614 ok (hchild != 0, "Failed to create child window\n");
4615 ok_sequence(WmCreateVisibleChildSeq, "CreateWindow:visible child", FALSE);
4617 trace("testing scroll APIs on a visible child window %p\n", hchild);
4618 test_scroll_messages(hchild);
4620 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4621 ok_sequence(WmShowChildSeq_4, "SetWindowPos(SWP_SHOWWINDOW):child with a caption", FALSE);
4623 DestroyWindow(hchild);
4626 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4627 0, 0, 10, 10, hparent, 0, 0, NULL);
4628 ok (hchild != 0, "Failed to create child window\n");
4629 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4631 hchild2 = CreateWindowExA(0, "SimpleWindowClass", "Test child2", WS_CHILD,
4632 100, 100, 50, 50, hparent, 0, 0, NULL);
4633 ok (hchild2 != 0, "Failed to create child2 window\n");
4636 hbutton = CreateWindowExA(0, "TestWindowClass", "Test button", WS_CHILD,
4637 0, 100, 50, 50, hchild, 0, 0, NULL);
4638 ok (hbutton != 0, "Failed to create button window\n");
4640 /* test WM_SETREDRAW on a not visible child window */
4641 test_WM_SETREDRAW(hchild);
4643 ShowWindow(hchild, SW_SHOW);
4644 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4646 /* check parent messages too */
4647 log_all_parent_messages++;
4648 ShowWindow(hchild, SW_HIDE);
4649 ok_sequence(WmHideChildSeq2, "ShowWindow(SW_HIDE):child", FALSE);
4650 log_all_parent_messages--;
4652 ShowWindow(hchild, SW_SHOW);
4653 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4655 ShowWindow(hchild, SW_HIDE);
4656 ok_sequence(WmHideChildSeq, "ShowWindow(SW_HIDE):child", FALSE);
4658 ShowWindow(hchild, SW_SHOW);
4659 ok_sequence(WmShowChildSeq, "ShowWindow(SW_SHOW):child", FALSE);
4661 /* test WM_SETREDRAW on a visible child window */
4662 test_WM_SETREDRAW(hchild);
4664 log_all_parent_messages++;
4665 MoveWindow(hchild, 10, 10, 20, 20, TRUE);
4666 ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child", FALSE);
4667 log_all_parent_messages--;
4669 ShowWindow(hchild, SW_HIDE);
4671 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4672 ok_sequence(WmShowChildSeq_2, "SetWindowPos:show_child_2", FALSE);
4674 ShowWindow(hchild, SW_HIDE);
4676 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
4677 ok_sequence(WmShowChildSeq_3, "SetWindowPos:show_child_3", FALSE);
4679 /* DestroyWindow sequence below expects that a child has focus */
4683 DestroyWindow(hchild);
4684 ok_sequence(WmDestroyChildSeq, "DestroyWindow:child", FALSE);
4685 DestroyWindow(hchild2);
4686 DestroyWindow(hbutton);
4689 hchild = CreateWindowExA(0, "TestWindowClass", "Test Child Popup", WS_CHILD | WS_POPUP,
4690 0, 0, 100, 100, hparent, 0, 0, NULL);
4691 ok (hchild != 0, "Failed to create child popup window\n");
4692 ok_sequence(WmCreateChildPopupSeq, "CreateWindow:child_popup", FALSE);
4693 DestroyWindow(hchild);
4695 /* test what happens to a window which sets WS_VISIBLE in WM_CREATE */
4697 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP,
4698 0, 0, 100, 100, hparent, 0, 0, NULL);
4699 ok (hchild != 0, "Failed to create popup window\n");
4700 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4701 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4702 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4704 ShowWindow(hchild, SW_SHOW);
4705 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4707 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4708 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4710 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
4711 ok_sequence(WmShowVisiblePopupSeq_3, "SetWindowPos:show_visible_popup_3", FALSE);
4712 DestroyWindow(hchild);
4714 /* this time add WS_VISIBLE for CreateWindowEx, but this fact actually
4715 * changes nothing in message sequences.
4718 hchild = CreateWindowExA(0, "TestPopupClass", "Test Popup", WS_POPUP | WS_VISIBLE,
4719 0, 0, 100, 100, hparent, 0, 0, NULL);
4720 ok (hchild != 0, "Failed to create popup window\n");
4721 ok_sequence(WmCreateInvisiblePopupSeq, "CreateWindow:invisible_popup", FALSE);
4722 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4723 ok(IsWindowVisible(hchild), "IsWindowVisible() should return TRUE\n");
4725 ShowWindow(hchild, SW_SHOW);
4726 ok_sequence(WmEmptySeq, "ShowWindow:show_visible_popup", FALSE);
4728 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
4729 ok_sequence(WmShowVisiblePopupSeq_2, "SetWindowPos:show_visible_popup_2", FALSE);
4730 DestroyWindow(hchild);
4733 hwnd = CreateWindowExA(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL, WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
4734 0, 0, 100, 100, hparent, 0, 0, NULL);
4735 ok(hwnd != 0, "Failed to create custom dialog window\n");
4736 ok_sequence(WmCreateCustomDialogSeq, "CreateCustomDialog", TRUE);
4739 trace("testing scroll APIs on a visible dialog %p\n", hwnd);
4740 test_scroll_messages(hwnd);
4746 SendMessage(hwnd, WM_NULL, 0, 0);
4749 after_end_dialog = 1;
4750 EndDialog( hwnd, 0 );
4751 ok_sequence(WmEndCustomDialogSeq, "EndCustomDialog", FALSE);
4753 DestroyWindow(hwnd);
4754 after_end_dialog = 0;
4757 hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP,
4758 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL);
4759 ok(hwnd != 0, "Failed to create custom dialog window\n");
4761 trace("call ShowWindow(%p, SW_SHOW)\n", hwnd);
4762 ShowWindow(hwnd, SW_SHOW);
4763 ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE);
4764 DestroyWindow(hwnd);
4767 DialogBoxA( 0, "TEST_DIALOG", hparent, TestModalDlgProcA );
4768 ok_sequence(WmModalDialogSeq, "ModalDialog", TRUE);
4770 DestroyWindow(hparent);
4773 /* Message sequence for SetMenu */
4774 ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n");
4775 ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE);
4777 hmenu = CreateMenu();
4778 ok (hmenu != 0, "Failed to create menu\n");
4779 ok (InsertMenuA(hmenu, -1, MF_BYPOSITION, 0x1000, "foo"), "InsertMenu failed\n");
4780 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
4781 100, 100, 200, 200, 0, hmenu, 0, NULL);
4782 ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped", FALSE);
4783 ok (SetMenu(hwnd, 0), "SetMenu\n");
4784 ok_sequence(WmSetMenuNonVisibleSizeChangeSeq, "SetMenu:NonVisibleSizeChange", FALSE);
4785 ok (SetMenu(hwnd, 0), "SetMenu\n");
4786 ok_sequence(WmSetMenuNonVisibleNoSizeChangeSeq, "SetMenu:NonVisibleNoSizeChange", FALSE);
4787 ShowWindow(hwnd, SW_SHOW);
4788 UpdateWindow( hwnd );
4791 ok (SetMenu(hwnd, 0), "SetMenu\n");
4792 ok_sequence(WmSetMenuVisibleNoSizeChangeSeq, "SetMenu:VisibleNoSizeChange", FALSE);
4793 ok (SetMenu(hwnd, hmenu), "SetMenu\n");
4794 ok_sequence(WmSetMenuVisibleSizeChangeSeq, "SetMenu:VisibleSizeChange", FALSE);
4796 UpdateWindow( hwnd );
4799 ok(DrawMenuBar(hwnd), "DrawMenuBar\n");
4801 ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE);
4803 DestroyWindow(hwnd);
4806 /* Message sequence for EnableWindow */
4807 hparent = CreateWindowExA(0, "TestWindowClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
4808 100, 100, 200, 200, 0, 0, 0, NULL);
4809 ok (hparent != 0, "Failed to create parent window\n");
4810 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
4811 0, 0, 10, 10, hparent, 0, 0, NULL);
4812 ok (hchild != 0, "Failed to create child window\n");
4818 EnableWindow(hparent, FALSE);
4819 ok_sequence(WmEnableWindowSeq_1, "EnableWindow(FALSE)", FALSE);
4821 EnableWindow(hparent, TRUE);
4822 ok_sequence(WmEnableWindowSeq_2, "EnableWindow(TRUE)", FALSE);
4827 test_MsgWaitForMultipleObjects(hparent);
4829 /* the following test causes an exception in user.exe under win9x */
4830 if (!PostMessageW( hparent, WM_USER, 0, 0 ))
4832 DestroyWindow(hparent);
4836 PostMessageW( hparent, WM_USER+1, 0, 0 );
4837 /* PeekMessage(NULL) fails, but still removes the message */
4838 SetLastError(0xdeadbeef);
4839 ok( !PeekMessageW( NULL, 0, 0, 0, PM_REMOVE ), "PeekMessage(NULL) should fail\n" );
4840 ok( GetLastError() == ERROR_NOACCESS || /* Win2k */
4841 GetLastError() == 0xdeadbeef, /* NT4 */
4842 "last error is %d\n", GetLastError() );
4843 ok( PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ), "PeekMessage should succeed\n" );
4844 ok( msg.message == WM_USER+1, "got %x instead of WM_USER+1\n", msg.message );
4846 DestroyWindow(hchild);
4847 DestroyWindow(hparent);
4850 /* Message sequences for WM_SETICON */
4851 trace("testing WM_SETICON\n");
4852 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
4853 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4855 ShowWindow(hwnd, SW_SHOW);
4859 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4860 ok_sequence(WmSetIcon_1, "WM_SETICON for shown window with caption", FALSE);
4862 ShowWindow(hwnd, SW_HIDE);
4865 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4866 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window with caption", FALSE);
4867 DestroyWindow(hwnd);
4870 hwnd = CreateWindowExA(0, "TestPopupClass", NULL, WS_POPUP,
4871 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
4873 ShowWindow(hwnd, SW_SHOW);
4877 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4878 ok_sequence(WmSetIcon_2, "WM_SETICON for shown window without caption", FALSE);
4880 ShowWindow(hwnd, SW_HIDE);
4883 SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(0, IDI_APPLICATION));
4884 ok_sequence(WmSetIcon_2, "WM_SETICON for hidden window without caption", FALSE);
4887 res = SendMessage(hwnd, 0x3B, 0x8000000b, 0);
4890 todo_wine win_skip( "Message 0x3b not supported\n" );
4893 ok_sequence(WmInitEndSession, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x8000000b", TRUE);
4894 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x8000000b, 0) should have returned 1 instead of %ld\n", res);
4895 res = SendMessage(hwnd, 0x3B, 0x0000000b, 0);
4896 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000b", TRUE);
4897 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000b, 0) should have returned 1 instead of %ld\n", res);
4898 res = SendMessage(hwnd, 0x3B, 0x0000000f, 0);
4899 ok_sequence(WmInitEndSession_2, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x0000000f", TRUE);
4900 ok(res == 1, "SendMessage(hwnd, 0x3B, 0x0000000f, 0) should have returned 1 instead of %ld\n", res);
4903 res = SendMessage(hwnd, 0x3B, 0x80000008, 0);
4904 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000008", TRUE);
4905 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000008, 0) should have returned 2 instead of %ld\n", res);
4906 res = SendMessage(hwnd, 0x3B, 0x00000008, 0);
4907 ok_sequence(WmInitEndSession_4, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x00000008", TRUE);
4908 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x00000008, 0) should have returned 2 instead of %ld\n", res);
4910 res = SendMessage(hwnd, 0x3B, 0x80000004, 0);
4911 ok_sequence(WmInitEndSession_3, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000004", TRUE);
4912 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000004, 0) should have returned 2 instead of %ld\n", res);
4914 res = SendMessage(hwnd, 0x3B, 0x80000001, 0);
4915 ok_sequence(WmInitEndSession_5, "Handling of undocumented 0x3B message by DefWindowProc wparam=0x80000001", TRUE);
4916 ok(res == 2, "SendMessage(hwnd, 0x3B, 0x80000001, 0) should have returned 2 instead of %ld\n", res);
4919 DestroyWindow(hwnd);
4923 static void test_setwindowpos(void)
4928 const INT winX = 100;
4929 const INT winY = 100;
4930 const INT sysX = GetSystemMetrics(SM_CXMINTRACK);
4932 hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0,
4933 0, 0, winX, winY, 0,
4936 GetWindowRect(hwnd, &rc);
4937 expect(sysX, rc.right);
4938 expect(winY, rc.bottom);
4942 res = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, winX, winY, 0);
4943 ok_sequence(WmZOrder, "Z-Order", TRUE);
4944 ok(res == TRUE, "SetWindowPos expected TRUE, got %ld\n", res);
4946 GetWindowRect(hwnd, &rc);
4947 expect(sysX, rc.right);
4948 expect(winY, rc.bottom);
4949 DestroyWindow(hwnd);
4952 static void invisible_parent_tests(void)
4954 HWND hparent, hchild;
4956 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
4957 100, 100, 200, 200, 0, 0, 0, NULL);
4958 ok (hparent != 0, "Failed to create parent window\n");
4961 /* test showing child with hidden parent */
4963 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4964 0, 0, 10, 10, hparent, 0, 0, NULL);
4965 ok (hchild != 0, "Failed to create child window\n");
4966 ok_sequence(WmCreateChildSeq, "CreateWindow:child", FALSE);
4968 ShowWindow( hchild, SW_MINIMIZE );
4969 ok_sequence(WmShowChildInvisibleParentSeq_1, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4970 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4971 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4976 ShowWindow( hchild, SW_MINIMIZE );
4977 ok_sequence(WmShowChildInvisibleParentSeq_1r, "ShowWindow(SW_MINIMIZE) child with invisible parent", FALSE);
4979 DestroyWindow(hchild);
4980 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4981 0, 0, 10, 10, hparent, 0, 0, NULL);
4984 ShowWindow( hchild, SW_MAXIMIZE );
4985 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4986 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
4987 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
4992 ShowWindow( hchild, SW_MAXIMIZE );
4993 ok_sequence(WmShowChildInvisibleParentSeq_2r, "ShowWindow(SW_MAXIMIZE) child with invisible parent", FALSE);
4995 DestroyWindow(hchild);
4996 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
4997 0, 0, 10, 10, hparent, 0, 0, NULL);
5000 ShowWindow( hchild, SW_RESTORE );
5001 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_RESTORE) child with invisible parent", FALSE);
5002 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5003 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5005 DestroyWindow(hchild);
5006 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5007 0, 0, 10, 10, hparent, 0, 0, NULL);
5010 ShowWindow( hchild, SW_SHOWMINIMIZED );
5011 ok_sequence(WmShowChildInvisibleParentSeq_3, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
5012 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5013 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5018 ShowWindow( hchild, SW_SHOWMINIMIZED );
5019 ok_sequence(WmShowChildInvisibleParentSeq_3r, "ShowWindow(SW_SHOWMINIMIZED) child with invisible parent", FALSE);
5021 DestroyWindow(hchild);
5022 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5023 0, 0, 10, 10, hparent, 0, 0, NULL);
5026 /* same as ShowWindow( hchild, SW_MAXIMIZE ); */
5027 ShowWindow( hchild, SW_SHOWMAXIMIZED );
5028 ok_sequence(WmShowChildInvisibleParentSeq_2, "ShowWindow(SW_SHOWMAXIMIZED) child with invisible parent", FALSE);
5029 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5030 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5032 DestroyWindow(hchild);
5033 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5034 0, 0, 10, 10, hparent, 0, 0, NULL);
5037 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
5038 ok_sequence(WmShowChildInvisibleParentSeq_4, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
5039 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5040 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5045 ShowWindow( hchild, SW_SHOWMINNOACTIVE );
5046 ok_sequence(WmShowChildInvisibleParentSeq_4r, "ShowWindow(SW_SHOWMINNOACTIVE) child with invisible parent", FALSE);
5048 DestroyWindow(hchild);
5049 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5050 0, 0, 10, 10, hparent, 0, 0, NULL);
5053 /* FIXME: looks like XP SP2 doesn't know about SW_FORCEMINIMIZE at all */
5054 ShowWindow( hchild, SW_FORCEMINIMIZE );
5055 ok_sequence(WmEmptySeq, "ShowWindow(SW_FORCEMINIMIZE) child with invisible parent", TRUE);
5057 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
5059 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5061 DestroyWindow(hchild);
5062 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5063 0, 0, 10, 10, hparent, 0, 0, NULL);
5066 ShowWindow( hchild, SW_SHOWNA );
5067 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
5068 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5069 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5074 ShowWindow( hchild, SW_SHOWNA );
5075 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOWNA) child with invisible parent", FALSE);
5077 DestroyWindow(hchild);
5078 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
5079 0, 0, 10, 10, hparent, 0, 0, NULL);
5082 ShowWindow( hchild, SW_SHOW );
5083 ok_sequence(WmShowChildInvisibleParentSeq_5, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
5084 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5085 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5090 ShowWindow( hchild, SW_SHOW );
5091 ok_sequence(WmEmptySeq, "ShowWindow(SW_SHOW) child with invisible parent", FALSE);
5093 ShowWindow( hchild, SW_HIDE );
5094 ok_sequence(WmHideChildInvisibleParentSeq, "ShowWindow:hide child with invisible parent", FALSE);
5095 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should be not set\n");
5096 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5098 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
5099 ok_sequence(WmShowChildInvisibleParentSeq_6, "SetWindowPos:show child with invisible parent", FALSE);
5100 ok(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
5101 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5103 SetWindowPos(hchild, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
5104 ok_sequence(WmHideChildInvisibleParentSeq_2, "SetWindowPos:hide child with invisible parent", FALSE);
5105 ok(!(GetWindowLongA(hchild, GWL_STYLE) & WS_VISIBLE), "WS_VISIBLE should not be set\n");
5106 ok(!IsWindowVisible(hchild), "IsWindowVisible() should return FALSE\n");
5108 SetWindowPos(hchild, 0,0,0,0,0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
5110 DestroyWindow(hchild);
5111 ok_sequence(WmDestroyInvisibleChildSeq, "DestroyInvisibleChildSeq", FALSE);
5113 DestroyWindow(hparent);
5117 /****************** button message test *************************/
5118 #define ID_BUTTON 0x000e
5120 static const struct message WmSetFocusButtonSeq[] =
5122 { HCBT_SETFOCUS, hook },
5123 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5124 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5125 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5126 { WM_SETFOCUS, sent|wparam, 0 },
5127 { WM_CTLCOLORBTN, sent|parent },
5128 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
5129 { WM_APP, sent|wparam|lparam, 0, 0 },
5132 static const struct message WmKillFocusButtonSeq[] =
5134 { HCBT_SETFOCUS, hook },
5135 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5136 { WM_KILLFOCUS, sent|wparam, 0 },
5137 { WM_CTLCOLORBTN, sent|parent },
5138 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_KILLFOCUS) },
5139 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5140 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5141 { WM_APP, sent|wparam|lparam, 0, 0 },
5143 { WM_CTLCOLORBTN, sent|parent },
5146 static const struct message WmSetFocusStaticSeq[] =
5148 { HCBT_SETFOCUS, hook },
5149 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5150 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5151 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5152 { WM_SETFOCUS, sent|wparam, 0 },
5153 { WM_CTLCOLORSTATIC, sent|parent },
5154 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
5155 { WM_COMMAND, sent|wparam|parent|optional, MAKEWPARAM(ID_BUTTON, BN_CLICKED) }, /* radio button */
5156 { WM_APP, sent|wparam|lparam, 0, 0 },
5159 static const struct message WmKillFocusStaticSeq[] =
5161 { HCBT_SETFOCUS, hook },
5162 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5163 { WM_KILLFOCUS, sent|wparam, 0 },
5164 { WM_CTLCOLORSTATIC, sent|parent },
5165 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_KILLFOCUS) },
5166 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5167 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5168 { WM_APP, sent|wparam|lparam, 0, 0 },
5170 { WM_CTLCOLORSTATIC, sent|parent },
5173 static const struct message WmSetFocusOwnerdrawSeq[] =
5175 { HCBT_SETFOCUS, hook },
5176 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
5177 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5178 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5179 { WM_SETFOCUS, sent|wparam, 0 },
5180 { WM_CTLCOLORBTN, sent|parent },
5181 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x001040e4 },
5182 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
5183 { WM_APP, sent|wparam|lparam, 0, 0 },
5186 static const struct message WmKillFocusOwnerdrawSeq[] =
5188 { HCBT_SETFOCUS, hook },
5189 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5190 { WM_KILLFOCUS, sent|wparam, 0 },
5191 { WM_CTLCOLORBTN, sent|parent },
5192 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000040e4 },
5193 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_KILLFOCUS) },
5194 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
5195 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
5196 { WM_APP, sent|wparam|lparam, 0, 0 },
5198 { WM_CTLCOLORBTN, sent|parent },
5199 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000010e4 },
5202 static const struct message WmLButtonDownSeq[] =
5204 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
5205 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
5206 { HCBT_SETFOCUS, hook },
5207 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
5208 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
5209 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5210 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
5211 { WM_CTLCOLORBTN, sent|defwinproc },
5212 { BM_SETSTATE, sent|wparam|defwinproc, TRUE },
5213 { WM_CTLCOLORBTN, sent|defwinproc },
5214 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5217 static const struct message WmLButtonUpSeq[] =
5219 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
5220 { BM_SETSTATE, sent|wparam|defwinproc, FALSE },
5221 { WM_CTLCOLORBTN, sent|defwinproc },
5222 { EVENT_OBJECT_STATECHANGE, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
5223 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
5224 { WM_CAPTURECHANGED, sent|wparam|defwinproc, 0 },
5227 static const struct message WmSetFontButtonSeq[] =
5229 { WM_SETFONT, sent },
5231 { WM_ERASEBKGND, sent|defwinproc|optional },
5232 { WM_CTLCOLORBTN, sent|defwinproc },
5235 static const struct message WmSetStyleButtonSeq[] =
5237 { BM_SETSTYLE, sent },
5238 { WM_APP, sent|wparam|lparam, 0, 0 },
5240 { WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
5241 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5242 { WM_CTLCOLORBTN, sent|parent },
5245 static const struct message WmSetStyleStaticSeq[] =
5247 { BM_SETSTYLE, sent },
5248 { WM_APP, sent|wparam|lparam, 0, 0 },
5250 { WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
5251 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5252 { WM_CTLCOLORSTATIC, sent|parent },
5255 static const struct message WmSetStyleUserSeq[] =
5257 { BM_SETSTYLE, sent },
5258 { WM_APP, sent|wparam|lparam, 0, 0 },
5260 { WM_NCPAINT, sent|defwinproc|optional }, /* FIXME: Wine sends it */
5261 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5262 { WM_CTLCOLORBTN, sent|parent },
5263 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_PAINT) },
5266 static const struct message WmSetStyleOwnerdrawSeq[] =
5268 { BM_SETSTYLE, sent },
5269 { WM_APP, sent|wparam|lparam, 0, 0 },
5271 { WM_NCPAINT, sent|optional }, /* FIXME: Wine sends it */
5272 { WM_ERASEBKGND, sent|defwinproc|optional }, /* Win9x doesn't send it */
5273 { WM_CTLCOLORBTN, sent|parent },
5274 { WM_CTLCOLORBTN, sent|parent|optional }, /* Win9x doesn't send it */
5275 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000010e4 },
5278 static const struct message WmSetStateButtonSeq[] =
5280 { BM_SETSTATE, sent },
5281 { WM_CTLCOLORBTN, sent|parent },
5282 { WM_APP, sent|wparam|lparam, 0, 0 },
5285 static const struct message WmSetStateStaticSeq[] =
5287 { BM_SETSTATE, sent },
5288 { WM_CTLCOLORSTATIC, sent|parent },
5289 { WM_APP, sent|wparam|lparam, 0, 0 },
5292 static const struct message WmSetStateUserSeq[] =
5294 { BM_SETSTATE, sent },
5295 { WM_CTLCOLORBTN, sent|parent },
5296 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_HILITE) },
5297 { WM_APP, sent|wparam|lparam, 0, 0 },
5300 static const struct message WmSetStateOwnerdrawSeq[] =
5302 { BM_SETSTATE, sent },
5303 { WM_CTLCOLORBTN, sent|parent },
5304 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000120e4 },
5305 { WM_APP, sent|wparam|lparam, 0, 0 },
5308 static const struct message WmClearStateButtonSeq[] =
5310 { BM_SETSTATE, sent },
5311 { WM_CTLCOLORBTN, sent|parent },
5312 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_BUTTON, BN_UNHILITE) },
5313 { WM_APP, sent|wparam|lparam, 0, 0 },
5316 static const struct message WmClearStateOwnerdrawSeq[] =
5318 { BM_SETSTATE, sent },
5319 { WM_CTLCOLORBTN, sent|parent },
5320 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_BUTTON, 0x000020e4 },
5321 { WM_APP, sent|wparam|lparam, 0, 0 },
5324 static const struct message WmSetCheckIgnoredSeq[] =
5326 { BM_SETCHECK, sent },
5327 { WM_APP, sent|wparam|lparam, 0, 0 },
5330 static const struct message WmSetCheckStaticSeq[] =
5332 { BM_SETCHECK, sent },
5333 { WM_CTLCOLORSTATIC, sent|parent },
5334 { WM_APP, sent|wparam|lparam, 0, 0 },
5338 static WNDPROC old_button_proc;
5340 static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5342 static LONG defwndproc_counter = 0;
5344 struct recvd_message msg;
5346 if (ignore_message( message )) return 0;
5354 ok(GetCapture() == hwnd, "GetCapture() = %p\n", GetCapture());
5358 msg.message = message;
5359 msg.flags = sent|wparam|lparam;
5360 if (defwndproc_counter) msg.flags |= defwinproc;
5361 msg.wParam = wParam;
5362 msg.lParam = lParam;
5363 msg.descr = "button";
5367 defwndproc_counter++;
5368 ret = CallWindowProcA(old_button_proc, hwnd, message, wParam, lParam);
5369 defwndproc_counter--;
5374 static void subclass_button(void)
5378 if (!GetClassInfoA(0, "button", &cls)) assert(0);
5380 old_button_proc = cls.lpfnWndProc;
5382 cls.hInstance = GetModuleHandle(0);
5383 cls.lpfnWndProc = button_hook_proc;
5384 cls.lpszClassName = "my_button_class";
5385 UnregisterClass(cls.lpszClassName, cls.hInstance);
5386 if (!RegisterClassA(&cls)) assert(0);
5389 static void test_button_messages(void)
5395 const struct message *setfocus;
5396 const struct message *killfocus;
5397 const struct message *setstyle;
5398 const struct message *setstate;
5399 const struct message *clearstate;
5400 const struct message *setcheck;
5402 { BS_PUSHBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
5403 WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleButtonSeq,
5404 WmSetStateButtonSeq, WmSetStateButtonSeq, WmSetCheckIgnoredSeq },
5405 { BS_DEFPUSHBUTTON, DLGC_BUTTON | DLGC_DEFPUSHBUTTON,
5406 WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleButtonSeq,
5407 WmSetStateButtonSeq, WmSetStateButtonSeq, WmSetCheckIgnoredSeq },
5408 { BS_CHECKBOX, DLGC_BUTTON,
5409 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5410 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5411 { BS_AUTOCHECKBOX, DLGC_BUTTON,
5412 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5413 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5414 { BS_RADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
5415 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5416 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5417 { BS_3STATE, DLGC_BUTTON,
5418 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5419 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5420 { BS_AUTO3STATE, DLGC_BUTTON,
5421 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5422 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5423 { BS_GROUPBOX, DLGC_STATIC,
5424 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5425 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckIgnoredSeq },
5426 { BS_USERBUTTON, DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON,
5427 WmSetFocusButtonSeq, WmKillFocusButtonSeq, WmSetStyleUserSeq,
5428 WmSetStateUserSeq, WmClearStateButtonSeq, WmSetCheckIgnoredSeq },
5429 { BS_AUTORADIOBUTTON, DLGC_BUTTON | DLGC_RADIOBUTTON,
5430 WmSetFocusStaticSeq, WmKillFocusStaticSeq, WmSetStyleStaticSeq,
5431 WmSetStateStaticSeq, WmSetStateStaticSeq, WmSetCheckStaticSeq },
5432 { BS_OWNERDRAW, DLGC_BUTTON,
5433 WmSetFocusOwnerdrawSeq, WmKillFocusOwnerdrawSeq, WmSetStyleOwnerdrawSeq,
5434 WmSetStateOwnerdrawSeq, WmClearStateOwnerdrawSeq, WmSetCheckIgnoredSeq },
5441 /* selection with VK_SPACE should capture button window */
5442 hwnd = CreateWindowExA(0, "button", "test", BS_CHECKBOX | WS_VISIBLE | WS_POPUP,
5443 0, 0, 50, 14, 0, 0, 0, NULL);
5444 ok(hwnd != 0, "Failed to create button window\n");
5447 SendMessageA(hwnd, WM_KEYDOWN, VK_SPACE, 0);
5448 ok(GetCapture() == hwnd, "Should be captured on VK_SPACE WM_KEYDOWN\n");
5449 SendMessageA(hwnd, WM_KEYUP, VK_SPACE, 0);
5450 DestroyWindow(hwnd);
5454 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5455 100, 100, 200, 200, 0, 0, 0, NULL);
5456 ok(parent != 0, "Failed to create parent window\n");
5458 for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
5463 trace("button style %08x\n", button[i].style);
5465 hwnd = CreateWindowExA(0, "my_button_class", "test", button[i].style | WS_CHILD | BS_NOTIFY,
5466 0, 0, 50, 14, parent, (HMENU)ID_BUTTON, 0, NULL);
5467 ok(hwnd != 0, "Failed to create button window\n");
5469 style = GetWindowLongA(hwnd, GWL_STYLE);
5470 style &= ~(WS_CHILD | BS_NOTIFY);
5471 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
5472 if (button[i].style == BS_USERBUTTON)
5473 ok(style == BS_PUSHBUTTON, "expected style BS_PUSHBUTTON got %x\n", style);
5475 ok(style == button[i].style, "expected style %x got %x\n", button[i].style, style);
5477 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5478 ok(dlg_code == button[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5480 ShowWindow(hwnd, SW_SHOW);
5487 log_all_parent_messages++;
5489 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5491 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5492 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5493 ok_sequence(button[i].setfocus, "SetFocus(hwnd) on a button", FALSE);
5496 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5497 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5498 ok_sequence(button[i].killfocus, "SetFocus(0) on a button", FALSE);
5500 ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
5502 SendMessage(hwnd, BM_SETSTYLE, button[i].style | BS_BOTTOM, TRUE);
5503 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5504 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5505 ok_sequence(button[i].setstyle, "BM_SETSTYLE on a button", FALSE);
5507 style = GetWindowLongA(hwnd, GWL_STYLE);
5508 style &= ~(WS_VISIBLE | WS_CHILD | BS_NOTIFY);
5509 /* XP doesn't turn a BS_USERBUTTON into BS_PUSHBUTTON here! */
5510 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5512 state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
5513 ok(state == 0, "expected state 0, got %04x\n", state);
5517 SendMessage(hwnd, BM_SETSTATE, TRUE, 0);
5518 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5519 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5520 ok_sequence(button[i].setstate, "BM_SETSTATE/TRUE on a button", FALSE);
5522 state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
5523 ok(state == 0x0004, "expected state 0x0004, got %04x\n", state);
5525 style = GetWindowLongA(hwnd, GWL_STYLE);
5526 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5527 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5531 SendMessage(hwnd, BM_SETSTATE, FALSE, 0);
5532 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5533 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5534 ok_sequence(button[i].clearstate, "BM_SETSTATE/FALSE on a button", FALSE);
5536 state = SendMessage(hwnd, BM_GETSTATE, 0, 0);
5537 ok(state == 0, "expected state 0, got %04x\n", state);
5539 style = GetWindowLongA(hwnd, GWL_STYLE);
5540 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5541 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5543 state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
5544 ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state);
5548 SendMessage(hwnd, BM_SETCHECK, BST_UNCHECKED, 0);
5549 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5550 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5551 ok_sequence(WmSetCheckIgnoredSeq, "BM_SETCHECK on a button", FALSE);
5553 state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
5554 ok(state == BST_UNCHECKED, "expected BST_UNCHECKED, got %04x\n", state);
5556 style = GetWindowLongA(hwnd, GWL_STYLE);
5557 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5558 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5562 SendMessage(hwnd, BM_SETCHECK, BST_CHECKED, 0);
5563 SendMessage(hwnd, WM_APP, 0, 0); /* place a separator mark here */
5564 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
5565 ok_sequence(button[i].setcheck, "BM_SETCHECK on a button", FALSE);
5567 state = SendMessage(hwnd, BM_GETCHECK, 0, 0);
5568 if (button[i].style == BS_PUSHBUTTON ||
5569 button[i].style == BS_DEFPUSHBUTTON ||
5570 button[i].style == BS_GROUPBOX ||
5571 button[i].style == BS_USERBUTTON ||
5572 button[i].style == BS_OWNERDRAW)
5573 ok(state == BST_UNCHECKED, "expected check 0, got %04x\n", state);
5575 ok(state == BST_CHECKED, "expected check 1, got %04x\n", state);
5577 style = GetWindowLongA(hwnd, GWL_STYLE);
5578 style &= ~(WS_CHILD | BS_NOTIFY | WS_VISIBLE);
5579 if (button[i].style == BS_RADIOBUTTON ||
5580 button[i].style == BS_AUTORADIOBUTTON)
5581 ok(style == (button[i].style | WS_TABSTOP), "expected style %04x | WS_TABSTOP got %04x\n", button[i].style, style);
5583 ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
5585 log_all_parent_messages--;
5587 DestroyWindow(hwnd);
5590 DestroyWindow(parent);
5592 hwnd = CreateWindowExA(0, "my_button_class", "test", BS_PUSHBUTTON | WS_POPUP | WS_VISIBLE,
5593 0, 0, 50, 14, 0, 0, 0, NULL);
5594 ok(hwnd != 0, "Failed to create button window\n");
5596 SetForegroundWindow(hwnd);
5599 SetActiveWindow(hwnd);
5603 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
5604 ok_sequence(WmLButtonDownSeq, "WM_LBUTTONDOWN on a button", FALSE);
5606 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
5607 ok_sequence(WmLButtonUpSeq, "WM_LBUTTONUP on a button", FALSE);
5610 zfont = GetStockObject(SYSTEM_FONT);
5611 SendMessageA(hwnd, WM_SETFONT, (WPARAM)zfont, TRUE);
5613 ok_sequence(WmSetFontButtonSeq, "WM_SETFONT on a button", FALSE);
5615 DestroyWindow(hwnd);
5618 /****************** static message test *************************/
5619 static const struct message WmSetFontStaticSeq[] =
5621 { WM_SETFONT, sent },
5622 { WM_PAINT, sent|defwinproc|optional },
5623 { WM_ERASEBKGND, sent|defwinproc|optional },
5624 { WM_CTLCOLORSTATIC, sent|defwinproc|optional },
5628 static WNDPROC old_static_proc;
5630 static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5632 static LONG defwndproc_counter = 0;
5634 struct recvd_message msg;
5636 if (ignore_message( message )) return 0;
5639 msg.message = message;
5640 msg.flags = sent|wparam|lparam;
5641 if (defwndproc_counter) msg.flags |= defwinproc;
5642 msg.wParam = wParam;
5643 msg.lParam = lParam;
5644 msg.descr = "static";
5647 defwndproc_counter++;
5648 ret = CallWindowProcA(old_static_proc, hwnd, message, wParam, lParam);
5649 defwndproc_counter--;
5654 static void subclass_static(void)
5658 if (!GetClassInfoA(0, "static", &cls)) assert(0);
5660 old_static_proc = cls.lpfnWndProc;
5662 cls.hInstance = GetModuleHandle(0);
5663 cls.lpfnWndProc = static_hook_proc;
5664 cls.lpszClassName = "my_static_class";
5665 UnregisterClass(cls.lpszClassName, cls.hInstance);
5666 if (!RegisterClassA(&cls)) assert(0);
5669 static void test_static_messages(void)
5671 /* FIXME: make as comprehensive as the button message test */
5676 const struct message *setfont;
5678 { SS_LEFT, DLGC_STATIC,
5679 WmSetFontStaticSeq }
5687 for (i = 0; i < sizeof(static_ctrl)/sizeof(static_ctrl[0]); i++)
5689 hwnd = CreateWindowExA(0, "my_static_class", "test", static_ctrl[i].style | WS_POPUP,
5690 0, 0, 50, 14, 0, 0, 0, NULL);
5691 ok(hwnd != 0, "Failed to create static window\n");
5693 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
5694 ok(dlg_code == static_ctrl[i].dlg_code, "%u: wrong dlg_code %08x\n", i, dlg_code);
5696 ShowWindow(hwnd, SW_SHOW);
5701 trace("static style %08x\n", static_ctrl[i].style);
5702 SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
5703 ok_sequence(static_ctrl[i].setfont, "WM_SETFONT on a static", FALSE);
5705 DestroyWindow(hwnd);
5709 /****************** ComboBox message test *************************/
5710 #define ID_COMBOBOX 0x000f
5712 static const struct message WmKeyDownComboSeq[] =
5714 { WM_KEYDOWN, sent|wparam|lparam, VK_DOWN, 0 },
5715 { WM_COMMAND, sent|wparam|defwinproc, MAKEWPARAM(1000, LBN_SELCHANGE) },
5716 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELENDOK) },
5717 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_COMBOBOX, CBN_SELCHANGE) },
5718 { WM_CTLCOLOREDIT, sent|parent },
5719 { WM_KEYUP, sent|wparam|lparam, VK_DOWN, 0 },
5723 static WNDPROC old_combobox_proc;
5725 static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5727 static LONG defwndproc_counter = 0;
5729 struct recvd_message msg;
5731 /* do not log painting messages */
5732 if (message != WM_PAINT &&
5733 message != WM_NCPAINT &&
5734 message != WM_SYNCPAINT &&
5735 message != WM_ERASEBKGND &&
5736 message != WM_NCHITTEST &&
5737 message != WM_GETTEXT &&
5738 !ignore_message( message ))
5741 msg.message = message;
5742 msg.flags = sent|wparam|lparam;
5743 if (defwndproc_counter) msg.flags |= defwinproc;
5744 msg.wParam = wParam;
5745 msg.lParam = lParam;
5746 msg.descr = "combo";
5750 defwndproc_counter++;
5751 ret = CallWindowProcA(old_combobox_proc, hwnd, message, wParam, lParam);
5752 defwndproc_counter--;
5757 static void subclass_combobox(void)
5761 if (!GetClassInfoA(0, "ComboBox", &cls)) assert(0);
5763 old_combobox_proc = cls.lpfnWndProc;
5765 cls.hInstance = GetModuleHandle(0);
5766 cls.lpfnWndProc = combobox_hook_proc;
5767 cls.lpszClassName = "my_combobox_class";
5768 UnregisterClass(cls.lpszClassName, cls.hInstance);
5769 if (!RegisterClassA(&cls)) assert(0);
5772 static void test_combobox_messages(void)
5777 subclass_combobox();
5779 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
5780 100, 100, 200, 200, 0, 0, 0, NULL);
5781 ok(parent != 0, "Failed to create parent window\n");
5784 combo = CreateWindowEx(0, "my_combobox_class", "test", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_HASSTRINGS,
5785 0, 0, 100, 150, parent, (HMENU)ID_COMBOBOX, 0, NULL);
5786 ok(combo != 0, "Failed to create combobox window\n");
5788 UpdateWindow(combo);
5790 ret = SendMessage(combo, WM_GETDLGCODE, 0, 0);
5791 ok(ret == (DLGC_WANTCHARS | DLGC_WANTARROWS), "wrong dlg_code %08lx\n", ret);
5793 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 0");
5794 ok(ret == 0, "expected 0, got %ld\n", ret);
5795 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 1");
5796 ok(ret == 1, "expected 1, got %ld\n", ret);
5797 ret = SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)"item 2");
5798 ok(ret == 2, "expected 2, got %ld\n", ret);
5800 SendMessage(combo, CB_SETCURSEL, 0, 0);
5804 log_all_parent_messages++;
5805 SendMessage(combo, WM_KEYDOWN, VK_DOWN, 0);
5806 SendMessage(combo, WM_KEYUP, VK_DOWN, 0);
5807 log_all_parent_messages--;
5808 ok_sequence(WmKeyDownComboSeq, "WM_KEYDOWN/VK_DOWN on a ComboBox", FALSE);
5810 DestroyWindow(combo);
5811 DestroyWindow(parent);
5814 /****************** WM_IME_KEYDOWN message test *******************/
5816 static const struct message WmImeKeydownMsgSeq_0[] =
5818 { WM_IME_KEYDOWN, wparam, VK_RETURN },
5819 { WM_CHAR, wparam, 'A' },
5823 static const struct message WmImeKeydownMsgSeq_1[] =
5825 { WM_KEYDOWN, optional|wparam, VK_RETURN },
5826 { WM_CHAR, optional|wparam, VK_RETURN },
5830 static LRESULT WINAPI wmime_keydown_procA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
5832 struct recvd_message msg;
5835 msg.message = message;
5836 msg.flags = wparam|lparam;
5837 msg.wParam = wParam;
5838 msg.lParam = lParam;
5839 msg.descr = "wmime_keydown";
5842 return DefWindowProcA(hwnd, message, wParam, lParam);
5845 static void register_wmime_keydown_class(void)
5849 ZeroMemory(&cls, sizeof(WNDCLASSA));
5850 cls.lpfnWndProc = wmime_keydown_procA;
5851 cls.hInstance = GetModuleHandleA(0);
5852 cls.lpszClassName = "wmime_keydown_class";
5853 if (!RegisterClassA(&cls)) assert(0);
5856 static void test_wmime_keydown_message(void)
5861 trace("Message sequences by WM_IME_KEYDOWN\n");
5863 register_wmime_keydown_class();
5864 hwnd = CreateWindowExA(0, "wmime_keydown_class", NULL, WS_OVERLAPPEDWINDOW,
5865 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
5870 SendMessage(hwnd, WM_IME_KEYDOWN, VK_RETURN, 0x1c0001);
5871 SendMessage(hwnd, WM_CHAR, 'A', 1);
5872 ok_sequence(WmImeKeydownMsgSeq_0, "WM_IME_KEYDOWN 0", FALSE);
5874 while ( PeekMessage(&msg, 0, 0, 0, PM_REMOVE) )
5876 TranslateMessage(&msg);
5877 DispatchMessage(&msg);
5879 ok_sequence(WmImeKeydownMsgSeq_1, "WM_IME_KEYDOWN 1", FALSE);
5881 DestroyWindow(hwnd);
5884 /************* painting message test ********************/
5886 void dump_region(HRGN hrgn)
5889 RGNDATA *data = NULL;
5894 printf( "null region\n" );
5897 if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
5898 if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
5899 GetRegionData( hrgn, size, data );
5900 printf("%d rects:", data->rdh.nCount );
5901 for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
5902 printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
5904 HeapFree( GetProcessHeap(), 0, data );
5907 static void check_update_rgn( HWND hwnd, HRGN hrgn )
5911 HRGN tmp = CreateRectRgn( 0, 0, 0, 0 );
5912 HRGN update = CreateRectRgn( 0, 0, 0, 0 );
5914 ret = GetUpdateRgn( hwnd, update, FALSE );
5915 ok( ret != ERROR, "GetUpdateRgn failed\n" );
5916 if (ret == NULLREGION)
5918 ok( !hrgn, "Update region shouldn't be empty\n" );
5922 if (CombineRgn( tmp, hrgn, update, RGN_XOR ) != NULLREGION)
5924 ok( 0, "Regions are different\n" );
5925 if (winetest_debug > 0)
5927 printf( "Update region: " );
5928 dump_region( update );
5929 printf( "Wanted region: " );
5930 dump_region( hrgn );
5934 GetRgnBox( update, &r1 );
5935 GetUpdateRect( hwnd, &r2, FALSE );
5936 ok( r1.left == r2.left && r1.top == r2.top && r1.right == r2.right && r1.bottom == r2.bottom,
5937 "Rectangles are different: %d,%d-%d,%d / %d,%d-%d,%d\n",
5938 r1.left, r1.top, r1.right, r1.bottom, r2.left, r2.top, r2.right, r2.bottom );
5940 DeleteObject( tmp );
5941 DeleteObject( update );
5944 static const struct message WmInvalidateRgn[] = {
5945 { WM_NCPAINT, sent },
5946 { WM_GETTEXT, sent|defwinproc|optional },
5950 static const struct message WmGetUpdateRect[] = {
5951 { WM_NCPAINT, sent },
5952 { WM_GETTEXT, sent|defwinproc|optional },
5957 static const struct message WmInvalidateFull[] = {
5958 { WM_NCPAINT, sent|wparam, 1 },
5959 { WM_GETTEXT, sent|defwinproc|optional },
5963 static const struct message WmInvalidateErase[] = {
5964 { WM_NCPAINT, sent|wparam, 1 },
5965 { WM_GETTEXT, sent|defwinproc|optional },
5966 { WM_ERASEBKGND, sent },
5970 static const struct message WmInvalidatePaint[] = {
5972 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5973 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5977 static const struct message WmInvalidateErasePaint[] = {
5979 { WM_NCPAINT, sent|wparam|beginpaint, 1 },
5980 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5981 { WM_ERASEBKGND, sent|beginpaint|optional },
5985 static const struct message WmInvalidateErasePaint2[] = {
5987 { WM_NCPAINT, sent|beginpaint },
5988 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
5989 { WM_ERASEBKGND, sent|beginpaint|optional },
5993 static const struct message WmErase[] = {
5994 { WM_ERASEBKGND, sent },
5998 static const struct message WmPaint[] = {
6003 static const struct message WmParentOnlyPaint[] = {
6004 { WM_PAINT, sent|parent },
6008 static const struct message WmInvalidateParent[] = {
6009 { WM_NCPAINT, sent|parent },
6010 { WM_GETTEXT, sent|defwinproc|parent|optional },
6011 { WM_ERASEBKGND, sent|parent },
6015 static const struct message WmInvalidateParentChild[] = {
6016 { WM_NCPAINT, sent|parent },
6017 { WM_GETTEXT, sent|defwinproc|parent|optional },
6018 { WM_ERASEBKGND, sent|parent },
6019 { WM_NCPAINT, sent },
6020 { WM_GETTEXT, sent|defwinproc|optional },
6021 { WM_ERASEBKGND, sent },
6025 static const struct message WmInvalidateParentChild2[] = {
6026 { WM_ERASEBKGND, sent|parent },
6027 { WM_NCPAINT, sent },
6028 { WM_GETTEXT, sent|defwinproc|optional },
6029 { WM_ERASEBKGND, sent },
6033 static const struct message WmParentPaint[] = {
6034 { WM_PAINT, sent|parent },
6039 static const struct message WmParentPaintNc[] = {
6040 { WM_PAINT, sent|parent },
6042 { WM_NCPAINT, sent|beginpaint },
6043 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6044 { WM_ERASEBKGND, sent|beginpaint|optional },
6048 static const struct message WmChildPaintNc[] = {
6050 { WM_NCPAINT, sent|beginpaint },
6051 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6052 { WM_ERASEBKGND, sent|beginpaint|optional },
6056 static const struct message WmParentErasePaint[] = {
6057 { WM_PAINT, sent|parent },
6058 { WM_NCPAINT, sent|parent|beginpaint },
6059 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
6060 { WM_ERASEBKGND, sent|parent|beginpaint|optional },
6062 { WM_NCPAINT, sent|beginpaint },
6063 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
6064 { WM_ERASEBKGND, sent|beginpaint|optional },
6068 static const struct message WmParentOnlyNcPaint[] = {
6069 { WM_PAINT, sent|parent },
6070 { WM_NCPAINT, sent|parent|beginpaint },
6071 { WM_GETTEXT, sent|parent|beginpaint|defwinproc|optional },
6075 static const struct message WmSetParentStyle[] = {
6076 { WM_STYLECHANGING, sent|parent },
6077 { WM_STYLECHANGED, sent|parent },
6081 static void test_paint_messages(void)
6087 HWND hparent, hchild;
6088 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
6089 HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
6090 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
6091 100, 100, 200, 200, 0, 0, 0, NULL);
6092 ok (hwnd != 0, "Failed to create overlapped window\n");
6094 ShowWindow( hwnd, SW_SHOW );
6095 UpdateWindow( hwnd );
6099 check_update_rgn( hwnd, 0 );
6100 SetRectRgn( hrgn, 10, 10, 20, 20 );
6101 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
6102 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6103 check_update_rgn( hwnd, hrgn );
6104 SetRectRgn( hrgn2, 20, 20, 30, 30 );
6105 ret = RedrawWindow( hwnd, NULL, hrgn2, RDW_INVALIDATE );
6106 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6107 CombineRgn( hrgn, hrgn, hrgn2, RGN_OR );
6108 check_update_rgn( hwnd, hrgn );
6109 /* validate everything */
6110 ret = RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
6111 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6112 check_update_rgn( hwnd, 0 );
6114 /* test empty region */
6115 SetRectRgn( hrgn, 10, 10, 10, 15 );
6116 ret = RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
6117 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6118 check_update_rgn( hwnd, 0 );
6119 /* test empty rect */
6120 SetRect( &rect, 10, 10, 10, 15 );
6121 ret = RedrawWindow( hwnd, &rect, NULL, RDW_INVALIDATE );
6122 ok(ret, "RedrawWindow returned %d instead of TRUE\n", ret);
6123 check_update_rgn( hwnd, 0 );
6125 /* flush pending messages */
6129 GetClientRect( hwnd, &rect );
6130 SetRectRgn( hrgn, 0, 0, rect.right - rect.left, rect.bottom - rect.top );
6131 /* MSDN: if hwnd parameter is NULL, InvalidateRect invalidates and redraws
6132 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6134 trace("testing InvalidateRect(0, NULL, FALSE)\n");
6135 SetRectEmpty( &rect );
6136 ok(InvalidateRect(0, &rect, FALSE), "InvalidateRect(0, &rc, FALSE) should fail\n");
6137 check_update_rgn( hwnd, hrgn );
6138 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
6140 ok_sequence( WmPaint, "Paint", FALSE );
6141 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
6142 check_update_rgn( hwnd, 0 );
6144 /* MSDN: if hwnd parameter is NULL, ValidateRect invalidates and redraws
6145 * all windows and sends WM_ERASEBKGND and WM_NCPAINT.
6147 trace("testing ValidateRect(0, NULL)\n");
6148 SetRectEmpty( &rect );
6149 if (ValidateRect(0, &rect)) /* not supported on Win9x */
6151 check_update_rgn( hwnd, hrgn );
6152 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
6154 ok_sequence( WmPaint, "Paint", FALSE );
6155 RedrawWindow( hwnd, NULL, NULL, RDW_VALIDATE );
6156 check_update_rgn( hwnd, 0 );
6159 trace("testing InvalidateRgn(0, NULL, FALSE)\n");
6160 SetLastError(0xdeadbeef);
6161 ok(!InvalidateRgn(0, NULL, FALSE), "InvalidateRgn(0, NULL, FALSE) should fail\n");
6162 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || GetLastError() == 0xdeadbeef,
6163 "wrong error code %d\n", GetLastError());
6164 check_update_rgn( hwnd, 0 );
6166 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6168 trace("testing ValidateRgn(0, NULL)\n");
6169 SetLastError(0xdeadbeef);
6170 ok(!ValidateRgn(0, NULL), "ValidateRgn(0, NULL) should fail\n");
6171 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
6172 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6173 "wrong error code %d\n", GetLastError());
6174 check_update_rgn( hwnd, 0 );
6176 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6178 trace("testing UpdateWindow(NULL)\n");
6179 SetLastError(0xdeadbeef);
6180 ok(!UpdateWindow(NULL), "UpdateWindow(NULL) should fail\n");
6181 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
6182 broken( GetLastError() == 0xdeadbeef ) /* win9x */,
6183 "wrong error code %d\n", GetLastError());
6184 check_update_rgn( hwnd, 0 );
6186 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
6188 /* now with frame */
6189 SetRectRgn( hrgn, -5, -5, 20, 20 );
6191 /* flush pending messages */
6194 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6195 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
6197 SetRectRgn( hrgn, 0, 0, 20, 20 ); /* GetUpdateRgn clips to client area */
6198 check_update_rgn( hwnd, hrgn );
6201 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
6202 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
6205 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW );
6206 ok_sequence( WmInvalidateFull, "InvalidateFull", FALSE );
6208 GetClientRect( hwnd, &rect );
6209 SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
6210 check_update_rgn( hwnd, hrgn );
6213 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ERASENOW );
6214 ok_sequence( WmInvalidateErase, "InvalidateErase", FALSE );
6217 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW | RDW_UPDATENOW );
6218 ok_sequence( WmInvalidatePaint, "InvalidatePaint", FALSE );
6219 check_update_rgn( hwnd, 0 );
6222 RedrawWindow( hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_UPDATENOW );
6223 ok_sequence( WmInvalidateErasePaint, "InvalidateErasePaint", FALSE );
6224 check_update_rgn( hwnd, 0 );
6227 SetRectRgn( hrgn, 0, 0, 100, 100 );
6228 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE );
6229 SetRectRgn( hrgn, 0, 0, 50, 100 );
6230 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
6231 SetRectRgn( hrgn, 50, 0, 100, 100 );
6232 check_update_rgn( hwnd, hrgn );
6233 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
6234 ok_sequence( WmEmptySeq, "EmptySeq", FALSE ); /* must not generate messages, everything is valid */
6235 check_update_rgn( hwnd, 0 );
6238 SetRectRgn( hrgn, 0, 0, 100, 100 );
6239 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
6240 SetRectRgn( hrgn, 0, 0, 100, 50 );
6241 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_ERASENOW );
6242 ok_sequence( WmErase, "Erase", FALSE );
6243 SetRectRgn( hrgn, 0, 50, 100, 100 );
6244 check_update_rgn( hwnd, hrgn );
6247 SetRectRgn( hrgn, 0, 0, 100, 100 );
6248 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE );
6249 SetRectRgn( hrgn, 0, 0, 50, 50 );
6250 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOERASE | RDW_UPDATENOW );
6251 ok_sequence( WmPaint, "Paint", FALSE );
6254 SetRectRgn( hrgn, -4, -4, -2, -2 );
6255 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6256 SetRectRgn( hrgn, -200, -200, -198, -198 );
6257 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME | RDW_ERASENOW );
6258 ok_sequence( WmEmptySeq, "EmptySeq", FALSE );
6261 SetRectRgn( hrgn, -4, -4, -2, -2 );
6262 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6263 SetRectRgn( hrgn, -4, -4, -3, -3 );
6264 RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOFRAME );
6265 SetRectRgn( hrgn, 0, 0, 1, 1 );
6266 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_UPDATENOW );
6267 ok_sequence( WmPaint, "Paint", FALSE );
6270 SetRectRgn( hrgn, -4, -4, -1, -1 );
6271 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6272 RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW );
6273 /* make sure no WM_PAINT was generated */
6275 ok_sequence( WmInvalidateRgn, "InvalidateRgn", FALSE );
6278 SetRectRgn( hrgn, -4, -4, -1, -1 );
6279 RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_FRAME );
6280 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
6282 if (msg.hwnd == hwnd && msg.message == WM_PAINT)
6284 /* GetUpdateRgn must return empty region since only nonclient area is invalidated */
6285 INT ret = GetUpdateRgn( hwnd, hrgn, FALSE );
6286 ok( ret == NULLREGION, "Invalid GetUpdateRgn result %d\n", ret );
6287 ret = GetUpdateRect( hwnd, &rect, FALSE );
6288 ok( ret, "Invalid GetUpdateRect result %d\n", ret );
6289 /* this will send WM_NCPAINT and validate the non client area */
6290 ret = GetUpdateRect( hwnd, &rect, TRUE );
6291 ok( !ret, "Invalid GetUpdateRect result %d\n", ret );
6293 DispatchMessage( &msg );
6295 ok_sequence( WmGetUpdateRect, "GetUpdateRect", FALSE );
6297 DestroyWindow( hwnd );
6299 /* now test with a child window */
6301 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW,
6302 100, 100, 200, 200, 0, 0, 0, NULL);
6303 ok (hparent != 0, "Failed to create parent window\n");
6305 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE | WS_BORDER,
6306 10, 10, 100, 100, hparent, 0, 0, NULL);
6307 ok (hchild != 0, "Failed to create child window\n");
6309 ShowWindow( hparent, SW_SHOW );
6310 UpdateWindow( hparent );
6311 UpdateWindow( hchild );
6314 log_all_parent_messages++;
6316 SetRect( &rect, 0, 0, 50, 50 );
6317 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6318 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
6319 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild", FALSE );
6321 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6323 MapWindowPoints( hchild, hparent, &pt, 1 );
6324 SetRectRgn( hrgn, 0, 0, 50 - pt.x, 50 - pt.y );
6325 check_update_rgn( hchild, hrgn );
6326 SetRectRgn( hrgn, 0, 0, 50, 50 );
6327 check_update_rgn( hparent, hrgn );
6328 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6329 ok_sequence( WmInvalidateParent, "InvalidateParent", FALSE );
6330 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
6331 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
6334 ok_sequence( WmParentPaintNc, "WmParentPaintNc", FALSE );
6336 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
6337 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6338 ok_sequence( WmInvalidateParent, "InvalidateParent2", FALSE );
6339 RedrawWindow( hchild, NULL, 0, RDW_ERASENOW );
6340 ok_sequence( WmEmptySeq, "EraseNow child", FALSE );
6342 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6343 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW | RDW_ALLCHILDREN );
6344 ok_sequence( WmInvalidateParentChild2, "InvalidateParentChild2", FALSE );
6346 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
6348 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
6349 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6350 ok_sequence( WmInvalidateParentChild, "InvalidateParentChild3", FALSE );
6352 /* flush all paint messages */
6356 /* RDW_UPDATENOW on child with WS_CLIPCHILDREN doesn't change corresponding parent area */
6357 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN );
6358 SetRectRgn( hrgn, 0, 0, 50, 50 );
6359 check_update_rgn( hparent, hrgn );
6360 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
6361 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6362 SetRectRgn( hrgn, 0, 0, 50, 50 );
6363 check_update_rgn( hparent, hrgn );
6365 /* flush all paint messages */
6367 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
6370 /* RDW_UPDATENOW on child without WS_CLIPCHILDREN will validate corresponding parent area */
6371 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6372 SetRectRgn( hrgn, 0, 0, 50, 50 );
6373 check_update_rgn( hparent, hrgn );
6374 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
6375 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6376 SetRectRgn( hrgn2, 10, 10, 50, 50 );
6377 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
6378 check_update_rgn( hparent, hrgn );
6379 /* flush all paint messages */
6383 /* same as above but parent gets completely validated */
6384 SetRect( &rect, 20, 20, 30, 30 );
6385 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6386 SetRectRgn( hrgn, 20, 20, 30, 30 );
6387 check_update_rgn( hparent, hrgn );
6388 RedrawWindow( hchild, NULL, 0, RDW_UPDATENOW );
6389 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6390 check_update_rgn( hparent, 0 ); /* no update region */
6392 ok_sequence( WmEmptySeq, "WmEmpty", FALSE ); /* and no paint messages */
6394 /* make sure RDW_VALIDATE on child doesn't have the same effect */
6396 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6397 SetRectRgn( hrgn, 20, 20, 30, 30 );
6398 check_update_rgn( hparent, hrgn );
6399 RedrawWindow( hchild, NULL, 0, RDW_VALIDATE | RDW_NOERASE );
6400 SetRectRgn( hrgn, 20, 20, 30, 30 );
6401 check_update_rgn( hparent, hrgn );
6403 /* same as above but normal WM_PAINT doesn't validate parent */
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 /* no WM_PAINT in child while parent still pending */
6410 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6411 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6412 while (PeekMessage( &msg, hparent, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6413 ok_sequence( WmParentErasePaint, "WmParentErasePaint", FALSE );
6416 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6417 /* no WM_PAINT in child while parent still pending */
6418 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6419 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6420 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_NOERASE | RDW_NOCHILDREN );
6421 /* now that parent is valid child should get WM_PAINT */
6422 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6423 ok_sequence( WmInvalidateErasePaint2, "WmInvalidateErasePaint2", FALSE );
6424 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6425 ok_sequence( WmEmptySeq, "No other message", FALSE );
6427 /* same thing with WS_CLIPCHILDREN in parent */
6429 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) | WS_CLIPCHILDREN );
6430 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
6431 /* changing style invalidates non client area, but we need to invalidate something else to see it */
6432 RedrawWindow( hparent, &rect, 0, RDW_UPDATENOW );
6433 ok_sequence( WmEmptySeq, "No message", FALSE );
6434 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_UPDATENOW );
6435 ok_sequence( WmParentOnlyNcPaint, "WmParentOnlyNcPaint", FALSE );
6438 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
6439 SetRectRgn( hrgn, 20, 20, 30, 30 );
6440 check_update_rgn( hparent, hrgn );
6441 /* no WM_PAINT in child while parent still pending */
6442 while (PeekMessage( &msg, hchild, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6443 ok_sequence( WmEmptySeq, "No WM_PAINT", FALSE );
6444 /* WM_PAINT in parent first */
6445 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
6446 ok_sequence( WmParentPaintNc, "WmParentPaintNc2", FALSE );
6448 /* no RDW_ERASE in parent still causes RDW_ERASE and RDW_FRAME in child */
6450 SetRect( &rect, 0, 0, 30, 30 );
6451 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN );
6452 SetRectRgn( hrgn, 0, 0, 30, 30 );
6453 check_update_rgn( hparent, hrgn );
6455 ok_sequence( WmParentPaintNc, "WmParentPaintNc3", FALSE );
6457 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6459 SetRect( &rect, -10, 0, 30, 30 );
6460 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
6461 SetRect( &rect, 0, 0, 20, 20 );
6462 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
6463 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
6464 ok_sequence( WmChildPaintNc, "WmChildPaintNc", FALSE );
6466 /* validate doesn't cause RDW_NOERASE or RDW_NOFRAME in child */
6468 SetRect( &rect, -10, 0, 30, 30 );
6469 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE );
6470 SetRect( &rect, 0, 0, 100, 100 );
6471 RedrawWindow( hparent, &rect, 0, RDW_VALIDATE | RDW_ALLCHILDREN );
6472 RedrawWindow( hparent, NULL, 0, RDW_UPDATENOW );
6473 ok_sequence( WmEmptySeq, "WmChildPaintNc2", FALSE );
6474 RedrawWindow( hparent, NULL, 0, RDW_ERASENOW );
6475 ok_sequence( WmEmptySeq, "WmChildPaintNc3", FALSE );
6477 /* test RDW_INTERNALPAINT behavior */
6480 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_NOCHILDREN );
6482 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
6484 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT | RDW_ALLCHILDREN );
6486 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
6488 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
6490 ok_sequence( WmParentOnlyPaint, "WmParentOnlyPaint", FALSE );
6492 assert( GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN );
6493 UpdateWindow( hparent );
6496 trace("testing SWP_FRAMECHANGED on parent with WS_CLIPCHILDREN\n");
6497 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6498 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
6499 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6501 ok_sequence(WmSWP_FrameChanged_clip, "SetWindowPos:FrameChanged_clip", FALSE );
6503 UpdateWindow( hparent );
6506 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent with WS_CLIPCHILDREN\n");
6507 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6508 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
6509 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6511 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
6513 SetWindowLong( hparent, GWL_STYLE, GetWindowLong(hparent,GWL_STYLE) & ~WS_CLIPCHILDREN );
6514 ok_sequence( WmSetParentStyle, "WmSetParentStyle", FALSE );
6515 RedrawWindow( hparent, NULL, 0, RDW_INTERNALPAINT );
6517 ok_sequence( WmParentPaint, "WmParentPaint", FALSE );
6519 assert( !(GetWindowLong(hparent, GWL_STYLE) & WS_CLIPCHILDREN) );
6520 UpdateWindow( hparent );
6523 trace("testing SWP_FRAMECHANGED on parent without WS_CLIPCHILDREN\n");
6524 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6525 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
6526 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6528 ok_sequence(WmSWP_FrameChanged_noclip, "SetWindowPos:FrameChanged_noclip", FALSE );
6530 UpdateWindow( hparent );
6533 trace("testing SWP_FRAMECHANGED|SWP_DEFERERASE on parent without WS_CLIPCHILDREN\n");
6534 RedrawWindow( hchild, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME );
6535 SetWindowPos( hparent, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_DEFERERASE |
6536 SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
6538 ok_sequence(WmSWP_FrameChangedDeferErase, "SetWindowPos:FrameChangedDeferErase", FALSE );
6540 ok(GetWindowLong( hparent, GWL_STYLE ) & WS_VISIBLE, "parent should be visible\n");
6541 ok(GetWindowLong( hchild, GWL_STYLE ) & WS_VISIBLE, "child should be visible\n");
6543 UpdateWindow( hparent );
6546 trace("testing SetWindowPos(-10000, -10000) on child\n");
6547 SetWindowPos( hchild, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
6548 check_update_rgn( hchild, 0 );
6551 #if 0 /* this one doesn't pass under Wine yet */
6552 UpdateWindow( hparent );
6555 trace("testing ShowWindow(SW_MINIMIZE) on child\n");
6556 ShowWindow( hchild, SW_MINIMIZE );
6557 check_update_rgn( hchild, 0 );
6561 UpdateWindow( hparent );
6564 trace("testing SetWindowPos(-10000, -10000) on parent\n");
6565 SetWindowPos( hparent, 0, -10000, -10000, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER );
6566 check_update_rgn( hparent, 0 );
6569 log_all_parent_messages--;
6570 DestroyWindow( hparent );
6571 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6573 /* tests for moving windows off-screen (needs simple WS_POPUP windows) */
6575 hparent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_POPUP | WS_VISIBLE,
6576 100, 100, 200, 200, 0, 0, 0, NULL);
6577 ok (hparent != 0, "Failed to create parent window\n");
6579 hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD | WS_VISIBLE,
6580 10, 10, 100, 100, hparent, 0, 0, NULL);
6581 ok (hchild != 0, "Failed to create child window\n");
6583 ShowWindow( hparent, SW_SHOW );
6584 UpdateWindow( hparent );
6585 UpdateWindow( hchild );
6589 /* moving child outside of parent boundaries changes update region */
6590 SetRect( &rect, 0, 0, 40, 40 );
6591 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6592 SetRectRgn( hrgn, 0, 0, 40, 40 );
6593 check_update_rgn( hchild, hrgn );
6594 MoveWindow( hchild, -10, 10, 100, 100, FALSE );
6595 SetRectRgn( hrgn, 10, 0, 40, 40 );
6596 check_update_rgn( hchild, hrgn );
6597 MoveWindow( hchild, -10, -10, 100, 100, FALSE );
6598 SetRectRgn( hrgn, 10, 10, 40, 40 );
6599 check_update_rgn( hchild, hrgn );
6601 /* moving parent off-screen does too */
6602 SetRect( &rect, 0, 0, 100, 100 );
6603 RedrawWindow( hparent, &rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
6604 SetRectRgn( hrgn, 0, 0, 100, 100 );
6605 check_update_rgn( hparent, hrgn );
6606 SetRectRgn( hrgn, 10, 10, 40, 40 );
6607 check_update_rgn( hchild, hrgn );
6608 MoveWindow( hparent, -20, -20, 200, 200, FALSE );
6609 SetRectRgn( hrgn, 20, 20, 100, 100 );
6610 check_update_rgn( hparent, hrgn );
6611 SetRectRgn( hrgn, 30, 30, 40, 40 );
6612 check_update_rgn( hchild, hrgn );
6614 /* invalidated region is cropped by the parent rects */
6615 SetRect( &rect, 0, 0, 50, 50 );
6616 RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE );
6617 SetRectRgn( hrgn, 30, 30, 50, 50 );
6618 check_update_rgn( hchild, hrgn );
6620 DestroyWindow( hparent );
6621 ok(!IsWindow(hchild), "child must be destroyed with its parent\n");
6624 DeleteObject( hrgn );
6625 DeleteObject( hrgn2 );
6636 static DWORD WINAPI thread_proc(void *param)
6639 struct wnd_event *wnd_event = param;
6641 wnd_event->hwnd = CreateWindowExA(0, "TestWindowClass", "window caption text", WS_OVERLAPPEDWINDOW,
6642 100, 100, 200, 200, 0, 0, 0, NULL);
6643 ok(wnd_event->hwnd != 0, "Failed to create overlapped window\n");
6645 SetEvent(wnd_event->start_event);
6647 while (GetMessage(&msg, 0, 0, 0))
6649 TranslateMessage(&msg);
6650 DispatchMessage(&msg);
6653 ok(IsWindow(wnd_event->hwnd), "window should still exist\n");
6658 static DWORD CALLBACK create_grand_child_thread( void *param )
6660 struct wnd_event *wnd_event = param;
6664 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
6665 WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, wnd_event->hwnd, 0, 0, NULL);
6666 ok (hchild != 0, "Failed to create child window\n");
6669 SetEvent( wnd_event->start_event );
6673 MsgWaitForMultipleObjects(0, NULL, FALSE, 1000, QS_ALLINPUT);
6674 if (!IsWindow( hchild )) break; /* will be destroyed when parent thread exits */
6675 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
6680 static DWORD CALLBACK create_child_thread( void *param )
6682 struct wnd_event *wnd_event = param;
6683 struct wnd_event child_event;
6687 child_event.hwnd = CreateWindowExA(0, "TestWindowClass", "Test child",
6688 WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, wnd_event->hwnd, 0, 0, NULL);
6689 ok (child_event.hwnd != 0, "Failed to create child window\n");
6690 SetFocus( child_event.hwnd );
6693 child_event.start_event = wnd_event->start_event;
6694 wnd_event->grand_child = CreateThread(NULL, 0, create_grand_child_thread, &child_event, 0, &tid);
6697 DWORD ret = MsgWaitForMultipleObjects(1, &child_event.start_event, FALSE, 1000, QS_SENDMESSAGE);
6698 if (ret != 1) break;
6699 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
6701 ret = WaitForSingleObject( wnd_event->stop_event, 5000 );
6702 ok( !ret, "WaitForSingleObject failed %x\n", ret );
6706 static void test_interthread_messages(void)
6713 int len, expected_len;
6714 struct wnd_event wnd_event;
6717 wnd_event.start_event = CreateEventW(NULL, 0, 0, NULL);
6718 if (!wnd_event.start_event)
6720 win_skip("skipping interthread message test under win9x\n");
6724 hThread = CreateThread(NULL, 0, thread_proc, &wnd_event, 0, &tid);
6725 ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
6727 ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6729 CloseHandle(wnd_event.start_event);
6731 SetLastError(0xdeadbeef);
6732 ok(!DestroyWindow(wnd_event.hwnd), "DestroyWindow succeded\n");
6733 ok(GetLastError() == ERROR_ACCESS_DENIED || GetLastError() == 0xdeadbeef,
6734 "wrong error code %d\n", GetLastError());
6736 proc = (WNDPROC)GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6737 ok(proc != NULL, "GetWindowLongPtrA(GWLP_WNDPROC) error %d\n", GetLastError());
6739 expected_len = lstrlenA("window caption text");
6740 memset(buf, 0, sizeof(buf));
6741 SetLastError(0xdeadbeef);
6742 len = CallWindowProcA(proc, wnd_event.hwnd, WM_GETTEXT, sizeof(buf), (LPARAM)buf);
6743 ok(len == expected_len, "CallWindowProcA(WM_GETTEXT) error %d, len %d, expected len %d\n", GetLastError(), len, expected_len);
6744 ok(!lstrcmpA(buf, "window caption text"), "window text mismatch\n");
6746 msg.hwnd = wnd_event.hwnd;
6747 msg.message = WM_GETTEXT;
6748 msg.wParam = sizeof(buf);
6749 msg.lParam = (LPARAM)buf;
6750 memset(buf, 0, sizeof(buf));
6751 SetLastError(0xdeadbeef);
6752 len = DispatchMessageA(&msg);
6753 ok((!len && GetLastError() == ERROR_MESSAGE_SYNC_ONLY) || broken(len), /* nt4 */
6754 "DispatchMessageA(WM_GETTEXT) succeded on another thread window: ret %d, error %d\n", len, GetLastError());
6756 /* the following test causes an exception in user.exe under win9x */
6757 msg.hwnd = wnd_event.hwnd;
6758 msg.message = WM_TIMER;
6760 msg.lParam = GetWindowLongPtrA(wnd_event.hwnd, GWLP_WNDPROC);
6761 SetLastError(0xdeadbeef);
6762 len = DispatchMessageA(&msg);
6763 ok(!len && GetLastError() == 0xdeadbeef,
6764 "DispatchMessageA(WM_TIMER) failed on another thread window: ret %d, error %d\n", len, GetLastError());
6766 ret = PostMessageA(wnd_event.hwnd, WM_QUIT, 0, 0);
6767 ok( ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
6769 ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
6770 CloseHandle(hThread);
6772 ok(!IsWindow(wnd_event.hwnd), "window should be destroyed on thread exit\n");
6774 wnd_event.hwnd = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
6775 100, 100, 200, 200, 0, 0, 0, NULL);
6776 ok (wnd_event.hwnd != 0, "Failed to create parent window\n");
6778 log_all_parent_messages++;
6779 wnd_event.start_event = CreateEventA( NULL, TRUE, FALSE, NULL );
6780 wnd_event.stop_event = CreateEventA( NULL, TRUE, FALSE, NULL );
6781 hThread = CreateThread( NULL, 0, create_child_thread, &wnd_event, 0, &tid );
6784 ret = MsgWaitForMultipleObjects(1, &wnd_event.start_event, FALSE, 1000, QS_SENDMESSAGE);
6785 if (ret != 1) break;
6786 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
6788 ok( !ret, "MsgWaitForMultipleObjects failed %x\n", ret );
6789 /* now wait for the thread without processing messages; this shouldn't deadlock */
6790 SetEvent( wnd_event.stop_event );
6791 ret = WaitForSingleObject( hThread, 5000 );
6792 ok( !ret, "WaitForSingleObject failed %x\n", ret );
6793 CloseHandle( hThread );
6795 ret = WaitForSingleObject( wnd_event.grand_child, 5000 );
6796 ok( !ret, "WaitForSingleObject failed %x\n", ret );
6797 CloseHandle( wnd_event.grand_child );
6799 CloseHandle( wnd_event.start_event );
6800 CloseHandle( wnd_event.stop_event );
6802 ok_sequence(WmExitThreadSeq, "destroy child on thread exit", FALSE);
6803 log_all_parent_messages--;
6804 DestroyWindow( wnd_event.hwnd );
6808 static const struct message WmVkN[] = {
6809 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6810 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6811 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6812 { WM_CHAR, wparam|lparam, 'n', 1 },
6813 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1002,1), 0 },
6814 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6815 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6816 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6819 static const struct message WmShiftVkN[] = {
6820 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6821 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6822 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6823 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6824 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6825 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6826 { WM_CHAR, wparam|lparam, 'N', 1 },
6827 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1001,1), 0 },
6828 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6829 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6830 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6831 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6832 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6833 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6836 static const struct message WmCtrlVkN[] = {
6837 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6838 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6839 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6840 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6841 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6842 { WM_KEYDOWN, sent|wparam|lparam, 'N', 1 },
6843 { WM_CHAR, wparam|lparam, 0x000e, 1 },
6844 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6845 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6846 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6847 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6848 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6849 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6850 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6853 static const struct message WmCtrlVkN_2[] = {
6854 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6855 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6856 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6857 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6858 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6859 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1000,1), 0 },
6860 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6861 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6862 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6863 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6864 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6865 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6868 static const struct message WmAltVkN[] = {
6869 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6870 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6871 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6872 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6873 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6874 { WM_SYSKEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6875 { WM_SYSCHAR, wparam|lparam, 'n', 0x20000001 },
6876 { WM_SYSCHAR, sent|wparam|lparam, 'n', 0x20000001 },
6877 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 'n' },
6878 { HCBT_SYSCOMMAND, hook },
6879 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6880 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6881 { 0x00AE, sent|defwinproc|optional }, /* XP */
6882 { WM_GETTEXT, sent|defwinproc|optional }, /* XP */
6883 { WM_INITMENU, sent|defwinproc },
6884 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6885 { WM_MENUCHAR, sent|defwinproc|wparam, MAKEWPARAM('n',MF_SYSMENU) },
6886 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
6887 { WM_CAPTURECHANGED, sent|defwinproc },
6888 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,0xffff) },
6889 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
6890 { WM_EXITMENULOOP, sent|defwinproc },
6891 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) }, /* Win95 bug */
6892 { WM_EXITMENULOOP, sent|defwinproc|optional }, /* Win95 bug */
6893 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6894 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6895 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6896 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6897 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6898 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6901 static const struct message WmAltVkN_2[] = {
6902 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6903 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6904 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6905 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6906 { WM_SYSKEYDOWN, wparam|lparam, 'N', 0x20000001 },
6907 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1003,1), 0 },
6908 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6909 { WM_SYSKEYUP, wparam|lparam, 'N', 0xe0000001 },
6910 { WM_SYSKEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6911 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6912 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6913 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6916 static const struct message WmCtrlAltVkN[] = {
6917 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6918 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6919 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6920 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6921 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6922 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6923 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6924 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6925 { WM_KEYDOWN, sent|wparam|lparam, 'N', 0x20000001 },
6926 { WM_CHAR, optional },
6927 { WM_CHAR, sent|optional },
6928 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6929 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6930 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6931 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6932 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6933 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6934 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6935 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6936 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6939 static const struct message WmCtrlShiftVkN[] = {
6940 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6941 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6942 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6943 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
6944 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
6945 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
6946 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
6947 { WM_KEYDOWN, wparam|lparam, 'N', 1 },
6948 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1004,1), 0 },
6949 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
6950 { WM_KEYUP, wparam|lparam, 'N', 0xc0000001 },
6951 { WM_KEYUP, sent|wparam|lparam, 'N', 0xc0000001 },
6952 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
6953 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
6954 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
6955 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6956 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6957 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6960 static const struct message WmCtrlAltShiftVkN[] = {
6961 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 1 }, /* XP */
6962 { WM_KEYDOWN, wparam|lparam, VK_CONTROL, 1 },
6963 { WM_KEYDOWN, sent|wparam|lparam, VK_CONTROL, 1 },
6964 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6965 { WM_KEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6966 { WM_KEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6967 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0x20000001 }, /* XP */
6968 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0x20000001 },
6969 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x20000001 },
6970 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x20000001 }, /* XP */
6971 { WM_KEYDOWN, wparam|lparam, 'N', 0x20000001 },
6972 { WM_COMMAND, sent|wparam|lparam, MAKEWPARAM(1005,1), 0 },
6973 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xe0000001 }, /* XP */
6974 { WM_KEYUP, wparam|lparam, 'N', 0xe0000001 },
6975 { WM_KEYUP, sent|wparam|lparam, 'N', 0xe0000001 },
6976 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xe0000001 }, /* XP */
6977 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xe0000001 },
6978 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xe0000001 },
6979 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6980 { WM_KEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6981 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6982 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_CONTROL, 0xc0000001 }, /* XP */
6983 { WM_KEYUP, wparam|lparam, VK_CONTROL, 0xc0000001 },
6984 { WM_KEYUP, sent|wparam|lparam, VK_CONTROL, 0xc0000001 },
6987 static const struct message WmAltPressRelease[] = {
6988 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 }, /* XP */
6989 { WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0x20000001 },
6990 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
6991 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
6992 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
6993 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
6994 { WM_SYSCOMMAND, sent|defwinproc|wparam|lparam, SC_KEYMENU, 0 },
6995 { HCBT_SYSCOMMAND, hook },
6996 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
6997 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
6998 { WM_INITMENU, sent|defwinproc },
6999 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7000 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
7001 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7003 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x30000001 }, /* XP */
7005 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7006 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
7007 { WM_CAPTURECHANGED, sent|defwinproc },
7008 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
7009 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7010 { WM_EXITMENULOOP, sent|defwinproc },
7011 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 }, /* XP */
7012 { WM_SYSKEYUP, wparam|lparam, VK_MENU, 0xc0000001 },
7013 { WM_SYSKEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
7016 static const struct message WmShiftMouseButton[] = {
7017 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
7018 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
7019 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 1 },
7020 { WM_MOUSEMOVE, wparam|optional, 0, 0 },
7021 { WM_MOUSEMOVE, sent|wparam|optional, 0, 0 },
7022 { WM_LBUTTONDOWN, wparam, MK_LBUTTON|MK_SHIFT, 0 },
7023 { WM_LBUTTONDOWN, sent|wparam, MK_LBUTTON|MK_SHIFT, 0 },
7024 { WM_LBUTTONUP, wparam, MK_SHIFT, 0 },
7025 { WM_LBUTTONUP, sent|wparam, MK_SHIFT, 0 },
7026 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xc0000001 }, /* XP */
7027 { WM_KEYUP, wparam|lparam, VK_SHIFT, 0xc0000001 },
7028 { WM_KEYUP, sent|wparam|lparam, VK_SHIFT, 0xc0000001 },
7031 static const struct message WmF1Seq[] = {
7032 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 1 }, /* XP */
7033 { WM_KEYDOWN, wparam|lparam, VK_F1, 1 },
7034 { WM_KEYDOWN, sent|wparam|lparam, VK_F1, 0x00000001 },
7035 { WM_KEYF1, wparam|lparam, 0, 0 },
7036 { WM_KEYF1, sent|wparam|lparam, 0, 0 },
7037 { WM_HELP, sent|defwinproc },
7038 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F1, 0xc0000001 }, /* XP */
7039 { WM_KEYUP, wparam|lparam, VK_F1, 0xc0000001 },
7040 { WM_KEYUP, sent|wparam|lparam, VK_F1, 0xc0000001 },
7043 static const struct message WmVkAppsSeq[] = {
7044 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 1 }, /* XP */
7045 { WM_KEYDOWN, wparam|lparam, VK_APPS, 1 },
7046 { WM_KEYDOWN, sent|wparam|lparam, VK_APPS, 0x00000001 },
7047 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_APPS, 0xc0000001 }, /* XP */
7048 { WM_KEYUP, wparam|lparam, VK_APPS, 0xc0000001 },
7049 { WM_KEYUP, sent|wparam|lparam, VK_APPS, 0xc0000001 },
7050 { WM_CONTEXTMENU, lparam, /*hwnd*/0, -1 },
7051 { WM_CONTEXTMENU, sent|lparam, /*hwnd*/0, -1 },
7054 static const struct message WmVkF10Seq[] = {
7055 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 1 }, /* XP */
7056 { WM_SYSKEYDOWN, wparam|lparam, VK_F10, 1 },
7057 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_F10, 0x00000001 },
7058 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0xc0000001 }, /* XP */
7059 { WM_SYSKEYUP, wparam|lparam, VK_F10, 0xc0000001 },
7060 { WM_SYSKEYUP, sent|wparam|lparam, VK_F10, 0xc0000001 },
7061 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_KEYMENU },
7062 { HCBT_SYSCOMMAND, hook },
7063 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7064 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
7065 { WM_INITMENU, sent|defwinproc },
7066 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7067 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
7068 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
7070 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0x10000001 }, /* XP */
7072 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 1 }, /* XP */
7073 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7074 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0, },
7075 { WM_CAPTURECHANGED, sent|defwinproc },
7076 { WM_MENUSELECT, sent|defwinproc|wparam|optional, MAKEWPARAM(0,0xffff) },
7077 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_SYSMENU, 0 },
7078 { WM_EXITMENULOOP, sent|defwinproc },
7079 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0xc0000001 }, /* XP */
7080 { WM_SYSKEYUP, wparam|lparam, VK_F10, 0xc0000001 },
7081 { WM_SYSKEYUP, sent|wparam|lparam, VK_F10, 0xc0000001 },
7084 static const struct message WmShiftF10Seq[] = {
7085 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 1 }, /* XP */
7086 { WM_KEYDOWN, wparam|lparam, VK_SHIFT, 1 },
7087 { WM_KEYDOWN, sent|wparam|lparam, VK_SHIFT, 0x00000001 },
7088 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 1 }, /* XP */
7089 { WM_SYSKEYDOWN, wparam|lparam, VK_F10, 1 },
7090 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_F10, 0x00000001 },
7091 { WM_CONTEXTMENU, sent|defwinproc|lparam, /*hwnd*/0, -1 },
7092 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_F10, 0xc0000001 }, /* XP */
7093 { WM_SYSKEYUP, wparam|lparam, VK_F10, 0xc0000001 },
7094 { WM_SYSKEYUP, sent|wparam|lparam, VK_F10, 0xc0000001 },
7095 { WM_SYSCOMMAND, sent|defwinproc|wparam, SC_KEYMENU },
7096 { HCBT_SYSCOMMAND, hook },
7097 { WM_ENTERMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7098 { WM_INITMENU, sent|defwinproc },
7099 { WM_MENUSELECT, sent|defwinproc|wparam, MAKEWPARAM(0,MF_SYSMENU|MF_POPUP|MF_HILITE) },
7100 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_SHIFT, 0xd0000001 }, /* XP */
7101 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 0x10000001 }, /* XP */
7102 { WM_CAPTURECHANGED, sent|defwinproc|wparam|lparam, 0, 0 },
7103 { WM_MENUSELECT, sent|defwinproc|wparam|lparam, 0xffff0000, 0 },
7104 { WM_EXITMENULOOP, sent|defwinproc|wparam|lparam, 0, 0 },
7105 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 0xc0000001 }, /* XP */
7106 { WM_KEYUP, wparam|lparam, VK_ESCAPE, 0xc0000001 },
7107 { WM_KEYUP, sent|wparam|lparam, VK_ESCAPE, 0xc0000001 },
7111 static void pump_msg_loop(HWND hwnd, HACCEL hAccel)
7115 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
7117 struct recvd_message log_msg;
7119 /* ignore some unwanted messages */
7120 if (msg.message == WM_MOUSEMOVE ||
7121 msg.message == WM_TIMER ||
7122 ignore_message( msg.message ))
7125 log_msg.hwnd = msg.hwnd;
7126 log_msg.message = msg.message;
7127 log_msg.flags = wparam|lparam;
7128 log_msg.wParam = msg.wParam;
7129 log_msg.lParam = msg.lParam;
7130 log_msg.descr = "accel";
7131 add_message(&log_msg);
7133 if (!hAccel || !TranslateAccelerator(hwnd, hAccel, &msg))
7135 TranslateMessage(&msg);
7136 DispatchMessage(&msg);
7141 static void test_accelerators(void)
7147 HWND hwnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
7148 100, 100, 200, 200, 0, 0, 0, NULL);
7157 ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
7159 state = GetKeyState(VK_SHIFT);
7160 ok(!(state & 0x8000), "wrong Shift state %04x\n", state);
7161 state = GetKeyState(VK_CAPITAL);
7162 ok(state == 0, "wrong CapsLock state %04x\n", state);
7164 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(1));
7165 assert(hAccel != 0);
7168 pump_msg_loop(hwnd, 0);
7171 trace("testing VK_N press/release\n");
7173 keybd_event('N', 0, 0, 0);
7174 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7175 pump_msg_loop(hwnd, hAccel);
7176 if (!sequence_cnt) /* we didn't get any message */
7178 skip( "queuing key events not supported\n" );
7181 ok_sequence(WmVkN, "VK_N press/release", FALSE);
7183 trace("testing Shift+VK_N press/release\n");
7185 keybd_event(VK_SHIFT, 0, 0, 0);
7186 keybd_event('N', 0, 0, 0);
7187 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7188 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7189 pump_msg_loop(hwnd, hAccel);
7190 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
7192 trace("testing Ctrl+VK_N press/release\n");
7194 keybd_event(VK_CONTROL, 0, 0, 0);
7195 keybd_event('N', 0, 0, 0);
7196 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7197 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7198 pump_msg_loop(hwnd, hAccel);
7199 ok_sequence(WmCtrlVkN, "Ctrl+VK_N press/release", FALSE);
7201 trace("testing Alt+VK_N press/release\n");
7203 keybd_event(VK_MENU, 0, 0, 0);
7204 keybd_event('N', 0, 0, 0);
7205 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7206 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7207 pump_msg_loop(hwnd, hAccel);
7208 ok_sequence(WmAltVkN, "Alt+VK_N press/release", FALSE);
7210 trace("testing Ctrl+Alt+VK_N press/release 1\n");
7212 keybd_event(VK_CONTROL, 0, 0, 0);
7213 keybd_event(VK_MENU, 0, 0, 0);
7214 keybd_event('N', 0, 0, 0);
7215 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7216 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7217 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7218 pump_msg_loop(hwnd, hAccel);
7219 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 1", FALSE);
7221 ret = DestroyAcceleratorTable(hAccel);
7222 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
7224 hAccel = LoadAccelerators(GetModuleHandleA(0), MAKEINTRESOURCE(2));
7225 assert(hAccel != 0);
7227 trace("testing VK_N press/release\n");
7229 keybd_event('N', 0, 0, 0);
7230 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7231 pump_msg_loop(hwnd, hAccel);
7232 ok_sequence(WmVkN, "VK_N press/release", FALSE);
7234 trace("testing Shift+VK_N press/release\n");
7236 keybd_event(VK_SHIFT, 0, 0, 0);
7237 keybd_event('N', 0, 0, 0);
7238 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7239 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7240 pump_msg_loop(hwnd, hAccel);
7241 ok_sequence(WmShiftVkN, "Shift+VK_N press/release", FALSE);
7243 trace("testing Ctrl+VK_N press/release 2\n");
7245 keybd_event(VK_CONTROL, 0, 0, 0);
7246 keybd_event('N', 0, 0, 0);
7247 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7248 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7249 pump_msg_loop(hwnd, hAccel);
7250 ok_sequence(WmCtrlVkN_2, "Ctrl+VK_N press/release 2", FALSE);
7252 trace("testing Alt+VK_N press/release 2\n");
7254 keybd_event(VK_MENU, 0, 0, 0);
7255 keybd_event('N', 0, 0, 0);
7256 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7257 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7258 pump_msg_loop(hwnd, hAccel);
7259 ok_sequence(WmAltVkN_2, "Alt+VK_N press/release 2", FALSE);
7261 trace("testing Ctrl+Alt+VK_N press/release 2\n");
7263 keybd_event(VK_CONTROL, 0, 0, 0);
7264 keybd_event(VK_MENU, 0, 0, 0);
7265 keybd_event('N', 0, 0, 0);
7266 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7267 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7268 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7269 pump_msg_loop(hwnd, hAccel);
7270 ok_sequence(WmCtrlAltVkN, "Ctrl+Alt+VK_N press/release 2", FALSE);
7272 trace("testing Ctrl+Shift+VK_N press/release\n");
7274 keybd_event(VK_CONTROL, 0, 0, 0);
7275 keybd_event(VK_SHIFT, 0, 0, 0);
7276 keybd_event('N', 0, 0, 0);
7277 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7278 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7279 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7280 pump_msg_loop(hwnd, hAccel);
7281 ok_sequence(WmCtrlShiftVkN, "Ctrl+Shift+VK_N press/release", FALSE);
7283 trace("testing Ctrl+Alt+Shift+VK_N press/release\n");
7285 keybd_event(VK_CONTROL, 0, 0, 0);
7286 keybd_event(VK_MENU, 0, 0, 0);
7287 keybd_event(VK_SHIFT, 0, 0, 0);
7288 keybd_event('N', 0, 0, 0);
7289 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
7290 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7291 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7292 keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
7293 pump_msg_loop(hwnd, hAccel);
7294 ok_sequence(WmCtrlAltShiftVkN, "Ctrl+Alt+Shift+VK_N press/release", FALSE);
7296 ret = DestroyAcceleratorTable(hAccel);
7297 ok( ret, "DestroyAcceleratorTable error %d\n", GetLastError());
7300 trace("testing Alt press/release\n");
7302 keybd_event(VK_MENU, 0, 0, 0);
7303 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7304 keybd_event(VK_MENU, 0, 0, 0);
7305 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
7306 pump_msg_loop(hwnd, 0);
7307 /* this test doesn't pass in Wine for managed windows */
7308 ok_sequence(WmAltPressRelease, "Alt press/release", TRUE);
7310 trace("testing VK_F1 press/release\n");
7311 keybd_event(VK_F1, 0, 0, 0);
7312 keybd_event(VK_F1, 0, KEYEVENTF_KEYUP, 0);
7313 pump_msg_loop(hwnd, 0);
7314 ok_sequence(WmF1Seq, "F1 press/release", FALSE);
7316 trace("testing VK_APPS press/release\n");
7317 keybd_event(VK_APPS, 0, 0, 0);
7318 keybd_event(VK_APPS, 0, KEYEVENTF_KEYUP, 0);
7319 pump_msg_loop(hwnd, 0);
7320 ok_sequence(WmVkAppsSeq, "VK_APPS press/release", FALSE);
7322 trace("testing VK_F10 press/release\n");
7323 keybd_event(VK_F10, 0, 0, 0);
7324 keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
7325 keybd_event(VK_F10, 0, 0, 0);
7326 keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
7327 pump_msg_loop(hwnd, 0);
7328 ok_sequence(WmVkF10Seq, "VK_F10 press/release", TRUE);
7330 trace("testing SHIFT+F10 press/release\n");
7331 keybd_event(VK_SHIFT, 0, 0, 0);
7332 keybd_event(VK_F10, 0, 0, 0);
7333 keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
7334 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7335 keybd_event(VK_ESCAPE, 0, 0, 0);
7336 keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
7337 pump_msg_loop(hwnd, 0);
7338 ok_sequence(WmShiftF10Seq, "SHIFT+F10 press/release", TRUE);
7340 trace("testing Shift+MouseButton press/release\n");
7341 /* first, move mouse pointer inside of the window client area */
7342 GetClientRect(hwnd, &rc);
7343 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
7344 rc.left += (rc.right - rc.left)/2;
7345 rc.top += (rc.bottom - rc.top)/2;
7346 SetCursorPos(rc.left, rc.top);
7347 SetActiveWindow(hwnd);
7352 if (pt.x == rc.left && pt.y == rc.top)
7355 keybd_event(VK_SHIFT, 0, 0, 0);
7356 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
7357 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
7358 keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
7359 pump_msg_loop(hwnd, 0);
7360 for (i = 0; i < sequence_cnt; i++) if (sequence[i].message == WM_LBUTTONDOWN) break;
7361 if (i < sequence_cnt)
7362 ok_sequence(WmShiftMouseButton, "Shift+MouseButton press/release", FALSE);
7364 skip( "Shift+MouseButton event didn't get to the window\n" );
7368 if (hAccel) DestroyAcceleratorTable(hAccel);
7369 DestroyWindow(hwnd);
7372 /************* window procedures ********************/
7374 static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
7375 WPARAM wParam, LPARAM lParam)
7377 static LONG defwndproc_counter = 0;
7378 static LONG beginpaint_counter = 0;
7380 struct recvd_message msg;
7382 if (ignore_message( message )) return 0;
7388 LONG style = GetWindowLongA(hwnd, GWL_STYLE);
7389 ok((BOOL)wParam == !(style & WS_DISABLED),
7390 "wrong WS_DISABLED state: %ld != %d\n", wParam, !(style & WS_DISABLED));
7394 case WM_CAPTURECHANGED:
7395 if (test_DestroyWindow_flag)
7397 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
7398 if (style & WS_CHILD)
7399 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
7400 else if (style & WS_POPUP)
7401 lParam = WND_POPUP_ID;
7403 lParam = WND_PARENT_ID;
7411 ok(!GetWindow(hwnd, GW_CHILD), "children should be unlinked at this point\n");
7412 capture = GetCapture();
7415 ok(capture == hwnd, "capture should NOT be released at this point (capture %p)\n", capture);
7416 trace("current capture %p, releasing...\n", capture);
7423 ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
7424 if (test_DestroyWindow_flag)
7426 DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
7427 if (style & WS_CHILD)
7428 lParam = GetWindowLongPtrA(hwnd, GWLP_ID);
7429 else if (style & WS_POPUP)
7430 lParam = WND_POPUP_ID;
7432 lParam = WND_PARENT_ID;
7436 /* test_accelerators() depends on this */
7442 case WM_MOUSEACTIVATE:
7443 case WM_NCMOUSEMOVE:
7450 msg.message = message;
7451 msg.flags = sent|wparam|lparam;
7452 if (defwndproc_counter) msg.flags |= defwinproc;
7453 if (beginpaint_counter) msg.flags |= beginpaint;
7454 msg.wParam = wParam;
7455 msg.lParam = lParam;
7456 msg.descr = "MsgCheckProc";
7459 if (message == WM_GETMINMAXINFO && (GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD))
7461 HWND parent = GetParent(hwnd);
7463 MINMAXINFO *minmax = (MINMAXINFO *)lParam;
7465 GetClientRect(parent, &rc);
7466 trace("parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
7467 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
7468 minmax->ptReserved.x, minmax->ptReserved.y,
7469 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
7470 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
7471 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
7472 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
7474 ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %d != %d\n",
7475 minmax->ptMaxSize.x, rc.right);
7476 ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %d != %d\n",
7477 minmax->ptMaxSize.y, rc.bottom);
7480 if (message == WM_PAINT)
7483 beginpaint_counter++;
7484 BeginPaint( hwnd, &ps );
7485 beginpaint_counter--;
7486 EndPaint( hwnd, &ps );
7490 defwndproc_counter++;
7491 ret = unicode ? DefWindowProcW(hwnd, message, wParam, lParam)
7492 : DefWindowProcA(hwnd, message, wParam, lParam);
7493 defwndproc_counter--;
7498 static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7500 return MsgCheckProc (FALSE, hwnd, message, wParam, lParam);
7503 static LRESULT WINAPI MsgCheckProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7505 return MsgCheckProc (TRUE, hwnd, message, wParam, lParam);
7508 static LRESULT WINAPI PopupMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7510 static LONG defwndproc_counter = 0;
7512 struct recvd_message msg;
7514 if (ignore_message( message )) return 0;
7518 case WM_QUERYENDSESSION:
7520 lParam &= ~0x01; /* Vista adds a 0x01 flag */
7525 msg.message = message;
7526 msg.flags = sent|wparam|lparam;
7527 if (defwndproc_counter) msg.flags |= defwinproc;
7528 msg.wParam = wParam;
7529 msg.lParam = lParam;
7530 msg.descr = "popup";
7533 if (message == WM_CREATE)
7535 DWORD style = GetWindowLongA(hwnd, GWL_STYLE) | WS_VISIBLE;
7536 SetWindowLongA(hwnd, GWL_STYLE, style);
7539 defwndproc_counter++;
7540 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7541 defwndproc_counter--;
7546 static LRESULT WINAPI ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7548 static LONG defwndproc_counter = 0;
7549 static LONG beginpaint_counter = 0;
7551 struct recvd_message msg;
7553 if (ignore_message( message )) return 0;
7555 if (log_all_parent_messages ||
7556 message == WM_PARENTNOTIFY || message == WM_CANCELMODE ||
7557 message == WM_SETFOCUS || message == WM_KILLFOCUS ||
7558 message == WM_ENABLE || message == WM_ENTERIDLE ||
7559 message == WM_DRAWITEM || message == WM_COMMAND ||
7560 message == WM_IME_SETCONTEXT)
7569 case WM_NCMOUSEMOVE:
7575 INT ret = GetClipBox((HDC)wParam, &rc);
7577 trace("WM_ERASEBKGND: GetClipBox()=%d, (%d,%d-%d,%d)\n",
7578 ret, rc.left, rc.top, rc.right, rc.bottom);
7584 msg.message = message;
7585 msg.flags = sent|parent|wparam|lparam;
7586 if (defwndproc_counter) msg.flags |= defwinproc;
7587 if (beginpaint_counter) msg.flags |= beginpaint;
7588 msg.wParam = wParam;
7589 msg.lParam = lParam;
7590 msg.descr = "parent";
7594 if (message == WM_PAINT)
7597 beginpaint_counter++;
7598 BeginPaint( hwnd, &ps );
7599 beginpaint_counter--;
7600 EndPaint( hwnd, &ps );
7604 defwndproc_counter++;
7605 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7606 defwndproc_counter--;
7611 static LRESULT WINAPI TestDlgProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7613 static LONG defwndproc_counter = 0;
7615 struct recvd_message msg;
7617 if (ignore_message( message )) return 0;
7621 DefDlgProcA(hwnd, DM_SETDEFID, 1, 0);
7622 ret = DefDlgProcA(hwnd, DM_GETDEFID, 0, 0);
7623 if (after_end_dialog)
7624 ok( ret == 0, "DM_GETDEFID should return 0 after EndDialog, got %lx\n", ret );
7626 ok(HIWORD(ret) == DC_HASDEFID, "DM_GETDEFID should return DC_HASDEFID, got %lx\n", ret);
7630 msg.message = message;
7631 msg.flags = sent|wparam|lparam;
7632 if (defwndproc_counter) msg.flags |= defwinproc;
7633 msg.wParam = wParam;
7634 msg.lParam = lParam;
7635 msg.descr = "dialog";
7638 defwndproc_counter++;
7639 ret = DefDlgProcA(hwnd, message, wParam, lParam);
7640 defwndproc_counter--;
7645 static LRESULT WINAPI ShowWindowProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7647 static LONG defwndproc_counter = 0;
7649 struct recvd_message msg;
7651 /* log only specific messages we are interested in */
7654 #if 0 /* probably log these as well */
7662 case WM_GETMINMAXINFO:
7663 case WM_WINDOWPOSCHANGING:
7664 case WM_WINDOWPOSCHANGED:
7667 default: /* ignore */
7668 /*trace("showwindow: %p, %04x, %08x, %08lx\n", hwnd, message, wParam, lParam);*/
7669 return DefWindowProcA(hwnd, message, wParam, lParam);
7673 msg.message = message;
7674 msg.flags = sent|wparam|lparam;
7675 if (defwndproc_counter) msg.flags |= defwinproc;
7676 msg.wParam = wParam;
7677 msg.lParam = lParam;
7681 defwndproc_counter++;
7682 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7683 defwndproc_counter--;
7688 static LRESULT WINAPI PaintLoopProcA(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
7692 case WM_CREATE: return 0;
7701 if (PeekMessageA(&msg2, 0, 0, 0, 1))
7703 TranslateMessage(&msg2);
7704 DispatchMessage(&msg2);
7708 else ok(broken(1), "infinite loop\n");
7710 paint_loop_done = 1;
7711 return DefWindowProcA(hWnd,msg,wParam,lParam);
7714 return DefWindowProcA(hWnd,msg,wParam,lParam);
7717 static LRESULT WINAPI HotkeyMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
7719 static LONG defwndproc_counter = 0;
7721 struct recvd_message msg;
7724 if (ignore_message( message )) return 0;
7726 if ((message >= WM_KEYFIRST && message <= WM_KEYLAST) ||
7727 message == WM_HOTKEY || message >= WM_APP)
7730 msg.message = message;
7731 msg.flags = sent|wparam|lparam;
7732 if (defwndproc_counter) msg.flags |= defwinproc;
7733 msg.wParam = wParam;
7734 msg.lParam = lParam;
7735 msg.descr = "HotkeyMsgCheckProcA";
7739 defwndproc_counter++;
7740 ret = DefWindowProcA(hwnd, message, wParam, lParam);
7741 defwndproc_counter--;
7743 if (message == WM_APP)
7745 queue_status = GetQueueStatus(QS_HOTKEY);
7746 ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
7747 queue_status = GetQueueStatus(QS_POSTMESSAGE);
7748 ok((queue_status & (QS_POSTMESSAGE << 16)) == QS_POSTMESSAGE << 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status);
7749 PostMessageA(hwnd, WM_APP+1, 0, 0);
7751 else if (message == WM_APP+1)
7753 queue_status = GetQueueStatus(QS_HOTKEY);
7754 ok((queue_status & (QS_HOTKEY << 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status);
7760 static BOOL RegisterWindowClasses(void)
7766 cls.lpfnWndProc = MsgCheckProcA;
7769 cls.hInstance = GetModuleHandleA(0);
7771 cls.hCursor = LoadCursorA(0, IDC_ARROW);
7772 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
7773 cls.lpszMenuName = NULL;
7774 cls.lpszClassName = "TestWindowClass";
7775 if(!RegisterClassA(&cls)) return FALSE;
7777 cls.lpfnWndProc = HotkeyMsgCheckProcA;
7778 cls.lpszClassName = "HotkeyWindowClass";
7779 if(!RegisterClassA(&cls)) return FALSE;
7781 cls.lpfnWndProc = ShowWindowProcA;
7782 cls.lpszClassName = "ShowWindowClass";
7783 if(!RegisterClassA(&cls)) return FALSE;
7785 cls.lpfnWndProc = PopupMsgCheckProcA;
7786 cls.lpszClassName = "TestPopupClass";
7787 if(!RegisterClassA(&cls)) return FALSE;
7789 cls.lpfnWndProc = ParentMsgCheckProcA;
7790 cls.lpszClassName = "TestParentClass";
7791 if(!RegisterClassA(&cls)) return FALSE;
7793 cls.lpfnWndProc = DefWindowProcA;
7794 cls.lpszClassName = "SimpleWindowClass";
7795 if(!RegisterClassA(&cls)) return FALSE;
7797 cls.lpfnWndProc = PaintLoopProcA;
7798 cls.lpszClassName = "PaintLoopWindowClass";
7799 if(!RegisterClassA(&cls)) return FALSE;
7801 cls.style = CS_NOCLOSE;
7802 cls.lpszClassName = "NoCloseWindowClass";
7803 if(!RegisterClassA(&cls)) return FALSE;
7805 ok(GetClassInfoA(0, "#32770", &cls), "GetClassInfo failed\n");
7807 cls.hInstance = GetModuleHandleA(0);
7808 cls.hbrBackground = 0;
7809 cls.lpfnWndProc = TestDlgProcA;
7810 cls.lpszClassName = "TestDialogClass";
7811 if(!RegisterClassA(&cls)) return FALSE;
7814 clsW.lpfnWndProc = MsgCheckProcW;
7815 clsW.cbClsExtra = 0;
7816 clsW.cbWndExtra = 0;
7817 clsW.hInstance = GetModuleHandleW(0);
7819 clsW.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
7820 clsW.hbrBackground = GetStockObject(WHITE_BRUSH);
7821 clsW.lpszMenuName = NULL;
7822 clsW.lpszClassName = testWindowClassW;
7823 RegisterClassW(&clsW); /* ignore error, this fails on Win9x */
7828 static BOOL is_our_logged_class(HWND hwnd)
7832 if (GetClassNameA(hwnd, buf, sizeof(buf)))
7834 if (!lstrcmpiA(buf, "TestWindowClass") ||
7835 !lstrcmpiA(buf, "ShowWindowClass") ||
7836 !lstrcmpiA(buf, "TestParentClass") ||
7837 !lstrcmpiA(buf, "TestPopupClass") ||
7838 !lstrcmpiA(buf, "SimpleWindowClass") ||
7839 !lstrcmpiA(buf, "TestDialogClass") ||
7840 !lstrcmpiA(buf, "MDI_frame_class") ||
7841 !lstrcmpiA(buf, "MDI_client_class") ||
7842 !lstrcmpiA(buf, "MDI_child_class") ||
7843 !lstrcmpiA(buf, "my_button_class") ||
7844 !lstrcmpiA(buf, "my_edit_class") ||
7845 !lstrcmpiA(buf, "static") ||
7846 !lstrcmpiA(buf, "ListBox") ||
7847 !lstrcmpiA(buf, "ComboBox") ||
7848 !lstrcmpiA(buf, "MyDialogClass") ||
7849 !lstrcmpiA(buf, "#32770") ||
7850 !lstrcmpiA(buf, "#32768"))
7856 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
7860 ok(cbt_hook_thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7862 if (nCode == HCBT_CLICKSKIPPED)
7864 /* ignore this event, XP sends it a lot when switching focus between windows */
7865 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7868 if (nCode == HCBT_SYSCOMMAND || nCode == HCBT_KEYSKIPPED)
7870 struct recvd_message msg;
7873 msg.message = nCode;
7874 msg.flags = hook|wparam|lparam;
7875 msg.wParam = wParam;
7876 msg.lParam = lParam;
7880 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7883 if (nCode == HCBT_DESTROYWND)
7885 if (test_DestroyWindow_flag)
7887 DWORD style = GetWindowLongA((HWND)wParam, GWL_STYLE);
7888 if (style & WS_CHILD)
7889 lParam = GetWindowLongPtrA((HWND)wParam, GWLP_ID);
7890 else if (style & WS_POPUP)
7891 lParam = WND_POPUP_ID;
7893 lParam = WND_PARENT_ID;
7897 /* Log also SetFocus(0) calls */
7898 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
7900 if (is_our_logged_class(hwnd))
7902 struct recvd_message msg;
7905 msg.message = nCode;
7906 msg.flags = hook|wparam|lparam;
7907 msg.wParam = wParam;
7908 msg.lParam = lParam;
7912 return CallNextHookEx(hCBT_hook, nCode, wParam, lParam);
7915 static void CALLBACK win_event_proc(HWINEVENTHOOK hevent,
7923 ok(thread_id == GetCurrentThreadId(), "we didn't ask for events from other threads\n");
7925 /* ignore mouse cursor events */
7926 if (object_id == OBJID_CURSOR) return;
7928 if (!hwnd || is_our_logged_class(hwnd))
7930 struct recvd_message msg;
7933 msg.message = event;
7934 msg.flags = winevent_hook|wparam|lparam;
7935 msg.wParam = object_id;
7936 msg.lParam = child_id;
7942 static const WCHAR wszUnicode[] = {'U','n','i','c','o','d','e',0};
7943 static const WCHAR wszAnsi[] = {'U',0};
7945 static LRESULT CALLBACK MsgConversionProcW(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
7949 case CB_FINDSTRINGEXACT:
7950 trace("String: %p\n", (LPCWSTR)lParam);
7951 if (!lstrcmpW((LPCWSTR)lParam, wszUnicode))
7953 if (!lstrcmpW((LPCWSTR)lParam, wszAnsi))
7957 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7960 static const struct message WmGetTextLengthAfromW[] = {
7961 { WM_GETTEXTLENGTH, sent },
7962 { WM_GETTEXT, sent|optional },
7966 static const WCHAR dummy_window_text[] = {'d','u','m','m','y',' ','t','e','x','t',0};
7968 /* dummy window proc for WM_GETTEXTLENGTH test */
7969 static LRESULT CALLBACK get_text_len_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
7973 case WM_GETTEXTLENGTH:
7974 return lstrlenW(dummy_window_text) + 37; /* some random length */
7976 lstrcpynW( (LPWSTR)lp, dummy_window_text, wp );
7977 return lstrlenW( (LPWSTR)lp );
7979 return DefWindowProcW( hwnd, msg, wp, lp );
7983 static void test_message_conversion(void)
7985 static const WCHAR wszMsgConversionClass[] =
7986 {'M','s','g','C','o','n','v','e','r','s','i','o','n','C','l','a','s','s',0};
7990 WNDPROC wndproc, newproc;
7994 cls.lpfnWndProc = MsgConversionProcW;
7997 cls.hInstance = GetModuleHandleW(NULL);
7999 cls.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
8000 cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
8001 cls.lpszMenuName = NULL;
8002 cls.lpszClassName = wszMsgConversionClass;
8003 /* this call will fail on Win9x, but that doesn't matter as this test is
8004 * meaningless on those platforms */
8005 if(!RegisterClassW(&cls)) return;
8007 hwnd = CreateWindowExW(0, wszMsgConversionClass, NULL, WS_OVERLAPPED,
8008 100, 100, 200, 200, 0, 0, 0, NULL);
8009 ok(hwnd != NULL, "Window creation failed\n");
8013 wndproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_WNDPROC);
8014 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8015 ok(lRes == 0, "String should have been converted\n");
8016 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8017 ok(lRes == 1, "String shouldn't have been converted\n");
8021 wndproc = (WNDPROC)GetWindowLongPtrW(hwnd, GWLP_WNDPROC);
8022 lRes = CallWindowProcA(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8023 ok(lRes == 1, "String shouldn't have been converted\n");
8024 lRes = CallWindowProcW(wndproc, hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8025 ok(lRes == 1, "String shouldn't have been converted\n");
8027 /* Synchronous messages */
8029 lRes = SendMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8030 ok(lRes == 0, "String should have been converted\n");
8031 lRes = SendMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8032 ok(lRes == 1, "String shouldn't have been converted\n");
8034 /* Asynchronous messages */
8037 lRes = PostMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8038 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8039 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8041 lRes = PostMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8042 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8043 "PostMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8045 lRes = PostThreadMessageA(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8046 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8047 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8049 lRes = PostThreadMessageW(GetCurrentThreadId(), CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8050 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8051 "PosThreadtMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8053 lRes = SendNotifyMessageA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8054 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8055 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8057 lRes = SendNotifyMessageW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode);
8058 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8059 "SendNotifyMessage on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8061 lRes = SendMessageCallbackA(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
8062 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8063 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8065 lRes = SendMessageCallbackW(hwnd, CB_FINDSTRINGEXACT, 0, (LPARAM)wszUnicode, NULL, 0);
8066 ok(lRes == 0 && (GetLastError() == ERROR_MESSAGE_SYNC_ONLY || GetLastError() == ERROR_INVALID_PARAMETER),
8067 "SendMessageCallback on sync only message returned %ld, last error %d\n", lRes, GetLastError());
8069 /* Check WM_GETTEXTLENGTH A->W behaviour, whether WM_GETTEXT is also sent or not */
8071 hwnd = CreateWindowW (testWindowClassW, wszUnicode,
8072 WS_OVERLAPPEDWINDOW,
8073 100, 100, 200, 200, 0, 0, 0, NULL);
8076 lRes = SendMessageA (hwnd, WM_GETTEXTLENGTH, 0, 0);
8077 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
8078 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
8079 "got bad length %ld\n", lRes );
8082 lRes = CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ),
8083 hwnd, WM_GETTEXTLENGTH, 0, 0);
8084 ok_sequence(WmGetTextLengthAfromW, "ANSI WM_GETTEXTLENGTH to Unicode window", FALSE);
8085 ok( lRes == WideCharToMultiByte( CP_ACP, 0, wszUnicode, lstrlenW(wszUnicode), NULL, 0, NULL, NULL ),
8086 "got bad length %ld\n", lRes );
8088 wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)get_text_len_proc );
8089 newproc = (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC );
8090 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
8091 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
8092 NULL, 0, NULL, NULL ) ||
8093 broken(lRes == lstrlenW(dummy_window_text) + 37),
8094 "got bad length %ld\n", lRes );
8096 SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)wndproc ); /* restore old wnd proc */
8097 lRes = CallWindowProcA( newproc, hwnd, WM_GETTEXTLENGTH, 0, 0 );
8098 ok( lRes == WideCharToMultiByte( CP_ACP, 0, dummy_window_text, lstrlenW(dummy_window_text),
8099 NULL, 0, NULL, NULL ) ||
8100 broken(lRes == lstrlenW(dummy_window_text) + 37),
8101 "got bad length %ld\n", lRes );
8103 ret = DestroyWindow(hwnd);
8104 ok( ret, "DestroyWindow() error %d\n", GetLastError());
8114 static VOID CALLBACK tfunc(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
8118 static VOID CALLBACK tfunc_crash(HWND hwnd, UINT uMsg, UINT_PTR id, DWORD dwTime)
8120 /* Crash on purpose */
8121 *(volatile int *)0 = 2;
8124 #define TIMER_ID 0x19
8126 static DWORD WINAPI timer_thread_proc(LPVOID x)
8128 struct timer_info *info = x;
8131 r = KillTimer(info->hWnd, 0x19);
8132 ok(r,"KillTimer failed in thread\n");
8133 r = SetTimer(info->hWnd,TIMER_ID,10000,tfunc);
8134 ok(r,"SetTimer failed in thread\n");
8135 ok(r==TIMER_ID,"SetTimer id different\n");
8136 r = SetEvent(info->handles[0]);
8137 ok(r,"SetEvent failed in thread\n");
8141 static void test_timers(void)
8143 struct timer_info info;
8147 info.hWnd = CreateWindow ("TestWindowClass", NULL,
8148 WS_OVERLAPPEDWINDOW ,
8149 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8152 info.id = SetTimer(info.hWnd,TIMER_ID,10000,tfunc);
8153 ok(info.id, "SetTimer failed\n");
8154 ok(info.id==TIMER_ID, "SetTimer timer ID different\n");
8155 info.handles[0] = CreateEvent(NULL,0,0,NULL);
8156 info.handles[1] = CreateThread(NULL,0,timer_thread_proc,&info,0,&id);
8158 WaitForMultipleObjects(2, info.handles, FALSE, INFINITE);
8160 WaitForSingleObject(info.handles[1], INFINITE);
8162 CloseHandle(info.handles[0]);
8163 CloseHandle(info.handles[1]);
8165 ok( KillTimer(info.hWnd, TIMER_ID), "KillTimer failed\n");
8167 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
8169 /* Test timer callback with crash */
8170 SetLastError(0xdeadbeef);
8171 info.hWnd = CreateWindowW(testWindowClassW, NULL,
8172 WS_OVERLAPPEDWINDOW ,
8173 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8175 if ((!info.hWnd && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || /* Win9x/Me */
8176 (!pGetMenuInfo)) /* Win95/NT4 */
8178 win_skip("Test would crash on Win9x/WinMe/NT4\n");
8179 DestroyWindow(info.hWnd);
8182 info.id = SetTimer(info.hWnd, TIMER_ID, 0, tfunc_crash);
8183 ok(info.id, "SetTimer failed\n");
8185 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8187 ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
8190 static int count = 0;
8191 static VOID CALLBACK callback_count(
8201 static void test_timers_no_wnd(void)
8207 id = SetTimer(NULL, 0, 100, callback_count);
8208 ok(id != 0, "did not get id from SetTimer.\n");
8209 id2 = SetTimer(NULL, id, 200, callback_count);
8210 ok(id2 == id, "did not get same id from SetTimer when replacing (%li expected %li).\n", id2, id);
8212 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8213 ok(count == 0, "did not get zero count as expected (%i).\n", count);
8215 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8216 ok(count == 1, "did not get one count as expected (%i).\n", count);
8217 KillTimer(NULL, id);
8219 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
8220 ok(count == 1, "killing replaced timer did not work (%i).\n", count);
8223 /* Various win events with arbitrary parameters */
8224 static const struct message WmWinEventsSeq[] = {
8225 { EVENT_SYSTEM_SOUND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
8226 { EVENT_SYSTEM_ALERT, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
8227 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
8228 { EVENT_SYSTEM_MENUSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
8229 { EVENT_SYSTEM_MENUEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
8230 { EVENT_SYSTEM_MENUPOPUPSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
8231 { EVENT_SYSTEM_MENUPOPUPEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
8232 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
8233 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
8234 /* our win event hook ignores OBJID_CURSOR events */
8235 /*{ EVENT_SYSTEM_MOVESIZESTART, winevent_hook|wparam|lparam, OBJID_CURSOR, 9 },*/
8236 { EVENT_SYSTEM_MOVESIZEEND, winevent_hook|wparam|lparam, OBJID_ALERT, 10 },
8237 { EVENT_SYSTEM_CONTEXTHELPSTART, winevent_hook|wparam|lparam, OBJID_SOUND, 11 },
8238 { EVENT_SYSTEM_CONTEXTHELPEND, winevent_hook|wparam|lparam, OBJID_QUERYCLASSNAMEIDX, 12 },
8239 { EVENT_SYSTEM_DRAGDROPSTART, winevent_hook|wparam|lparam, OBJID_NATIVEOM, 13 },
8240 { EVENT_SYSTEM_DRAGDROPEND, winevent_hook|wparam|lparam, OBJID_WINDOW, 0 },
8241 { EVENT_SYSTEM_DIALOGSTART, winevent_hook|wparam|lparam, OBJID_SYSMENU, 1 },
8242 { EVENT_SYSTEM_DIALOGEND, winevent_hook|wparam|lparam, OBJID_TITLEBAR, 2 },
8243 { EVENT_SYSTEM_SCROLLINGSTART, winevent_hook|wparam|lparam, OBJID_MENU, 3 },
8244 { EVENT_SYSTEM_SCROLLINGEND, winevent_hook|wparam|lparam, OBJID_CLIENT, 4 },
8245 { EVENT_SYSTEM_SWITCHSTART, winevent_hook|wparam|lparam, OBJID_VSCROLL, 5 },
8246 { EVENT_SYSTEM_SWITCHEND, winevent_hook|wparam|lparam, OBJID_HSCROLL, 6 },
8247 { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, OBJID_SIZEGRIP, 7 },
8248 { EVENT_SYSTEM_MINIMIZEEND, winevent_hook|wparam|lparam, OBJID_CARET, 8 },
8251 static const struct message WmWinEventCaretSeq[] = {
8252 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
8253 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
8254 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 2 */
8255 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1 */
8258 static const struct message WmWinEventCaretSeq_2[] = {
8259 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
8260 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
8261 { EVENT_OBJECT_NAMECHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 }, /* hook 1/2 */
8264 static const struct message WmWinEventAlertSeq[] = {
8265 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 0 },
8268 static const struct message WmWinEventAlertSeq_2[] = {
8269 /* create window in the thread proc */
8270 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_WINDOW, 2 },
8271 /* our test event */
8272 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_ALERT, 2 },
8275 static const struct message WmGlobalHookSeq_1[] = {
8276 /* create window in the thread proc */
8277 { HCBT_CREATEWND, hook|lparam, 0, 2 },
8278 /* our test events */
8279 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 },
8280 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 },
8283 static const struct message WmGlobalHookSeq_2[] = {
8284 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 0 }, /* old local hook */
8285 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_NEXTWINDOW, 2 }, /* new global hook */
8286 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 0 }, /* old local hook */
8287 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_PREVWINDOW, 2 }, /* new global hook */
8291 static const struct message WmMouseLLHookSeq[] = {
8292 { WM_MOUSEMOVE, hook },
8293 { WM_LBUTTONUP, hook },
8294 { WM_MOUSEMOVE, hook },
8298 static void CALLBACK win_event_global_hook_proc(HWINEVENTHOOK hevent,
8308 if (GetClassNameA(hwnd, buf, sizeof(buf)))
8310 if (!lstrcmpiA(buf, "TestWindowClass") ||
8311 !lstrcmpiA(buf, "static"))
8313 struct recvd_message msg;
8316 msg.message = event;
8317 msg.flags = winevent_hook|wparam|lparam;
8318 msg.wParam = object_id;
8319 msg.lParam = (thread_id == GetCurrentThreadId()) ? child_id : (child_id + 2);
8320 msg.descr = "WEH_2";
8326 static HHOOK hCBT_global_hook;
8327 static DWORD cbt_global_hook_thread_id;
8329 static LRESULT CALLBACK cbt_global_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
8334 if (nCode == HCBT_SYSCOMMAND)
8336 struct recvd_message msg;
8339 msg.message = nCode;
8340 msg.flags = hook|wparam|lparam;
8341 msg.wParam = wParam;
8342 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
8343 msg.descr = "CBT_2";
8346 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
8348 /* WH_MOUSE_LL hook */
8349 if (nCode == HC_ACTION)
8351 MSLLHOOKSTRUCT *mhll = (MSLLHOOKSTRUCT *)lParam;
8353 /* we can't test for real mouse events */
8354 if (mhll->flags & LLMHF_INJECTED)
8356 struct recvd_message msg;
8358 memset (&msg, 0, sizeof (msg));
8359 msg.message = wParam;
8361 msg.descr = "CBT_2";
8364 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
8367 /* Log also SetFocus(0) calls */
8368 hwnd = wParam ? (HWND)wParam : (HWND)lParam;
8370 if (GetClassNameA(hwnd, buf, sizeof(buf)))
8372 if (!lstrcmpiA(buf, "TestWindowClass") ||
8373 !lstrcmpiA(buf, "static"))
8375 struct recvd_message msg;
8378 msg.message = nCode;
8379 msg.flags = hook|wparam|lparam;
8380 msg.wParam = wParam;
8381 msg.lParam = (cbt_global_hook_thread_id == GetCurrentThreadId()) ? 1 : 2;
8382 msg.descr = "CBT_2";
8386 return CallNextHookEx(hCBT_global_hook, nCode, wParam, lParam);
8389 static DWORD WINAPI win_event_global_thread_proc(void *param)
8393 HANDLE hevent = *(HANDLE *)param;
8395 assert(pNotifyWinEvent);
8397 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
8399 trace("created thread window %p\n", hwnd);
8401 *(HWND *)param = hwnd;
8404 /* this event should be received only by our new hook proc,
8405 * an old one does not expect an event from another thread.
8407 pNotifyWinEvent(EVENT_OBJECT_LOCATIONCHANGE, hwnd, OBJID_ALERT, 0);
8410 while (GetMessage(&msg, 0, 0, 0))
8412 TranslateMessage(&msg);
8413 DispatchMessage(&msg);
8418 static DWORD WINAPI cbt_global_hook_thread_proc(void *param)
8422 HANDLE hevent = *(HANDLE *)param;
8425 /* these events should be received only by our new hook proc,
8426 * an old one does not expect an event from another thread.
8429 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
8431 trace("created thread window %p\n", hwnd);
8433 *(HWND *)param = hwnd;
8435 /* Windows doesn't like when a thread plays games with the focus,
8436 that leads to all kinds of misbehaviours and failures to activate
8437 a window. So, better keep next lines commented out.
8441 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
8442 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
8446 while (GetMessage(&msg, 0, 0, 0))
8448 TranslateMessage(&msg);
8449 DispatchMessage(&msg);
8454 static DWORD WINAPI mouse_ll_global_thread_proc(void *param)
8458 HANDLE hevent = *(HANDLE *)param;
8460 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
8462 trace("created thread window %p\n", hwnd);
8464 *(HWND *)param = hwnd;
8468 /* Windows doesn't like when a thread plays games with the focus,
8469 * that leads to all kinds of misbehaviours and failures to activate
8470 * a window. So, better don't generate a mouse click message below.
8472 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8473 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
8474 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8477 while (GetMessage(&msg, 0, 0, 0))
8479 TranslateMessage(&msg);
8480 DispatchMessage(&msg);
8485 static void test_winevents(void)
8491 HANDLE hthread, hevent;
8493 HWINEVENTHOOK hhook;
8494 const struct message *events = WmWinEventsSeq;
8496 hwnd = CreateWindowExA(0, "TestWindowClass", NULL,
8497 WS_OVERLAPPEDWINDOW,
8498 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
8502 /****** start of global hook test *************/
8503 hCBT_global_hook = SetWindowsHookExA(WH_CBT, cbt_global_hook_proc, GetModuleHandleA(0), 0);
8504 if (!hCBT_global_hook)
8506 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8507 skip( "cannot set global hook\n" );
8511 hevent = CreateEventA(NULL, 0, 0, NULL);
8515 hthread = CreateThread(NULL, 0, cbt_global_hook_thread_proc, &hwnd2, 0, &tid);
8516 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8518 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8520 ok_sequence(WmGlobalHookSeq_1, "global hook 1", FALSE);
8523 /* this one should be received only by old hook proc */
8524 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0);
8525 /* this one should be received only by old hook proc */
8526 DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_PREVWINDOW, 0);
8528 ok_sequence(WmGlobalHookSeq_2, "global hook 2", FALSE);
8530 ret = UnhookWindowsHookEx(hCBT_global_hook);
8531 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
8533 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8534 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8535 CloseHandle(hthread);
8536 CloseHandle(hevent);
8537 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8538 /****** end of global hook test *************/
8540 if (!pSetWinEventHook || !pNotifyWinEvent || !pUnhookWinEvent)
8542 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8550 /* this test doesn't pass under Win9x */
8551 /* win2k ignores events with hwnd == 0 */
8552 SetLastError(0xdeadbeef);
8553 pNotifyWinEvent(events[0].message, 0, events[0].wParam, events[0].lParam);
8554 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || /* Win2k */
8555 GetLastError() == 0xdeadbeef, /* Win9x */
8556 "unexpected error %d\n", GetLastError());
8557 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
8560 for (i = 0; i < sizeof(WmWinEventsSeq)/sizeof(WmWinEventsSeq[0]); i++)
8561 pNotifyWinEvent(events[i].message, hwnd, events[i].wParam, events[i].lParam);
8563 ok_sequence(WmWinEventsSeq, "notify winevents", FALSE);
8565 /****** start of event filtering test *************/
8566 hhook = pSetWinEventHook(
8567 EVENT_OBJECT_SHOW, /* 0x8002 */
8568 EVENT_OBJECT_LOCATIONCHANGE, /* 0x800B */
8569 GetModuleHandleA(0), win_event_global_hook_proc,
8570 GetCurrentProcessId(), 0,
8571 WINEVENT_INCONTEXT);
8572 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
8574 hevent = CreateEventA(NULL, 0, 0, NULL);
8578 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
8579 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8581 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8583 ok_sequence(WmWinEventAlertSeq, "alert winevent", FALSE);
8586 /* this one should be received only by old hook proc */
8587 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
8588 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
8589 /* this one should be received only by old hook proc */
8590 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
8592 ok_sequence(WmWinEventCaretSeq, "caret winevent", FALSE);
8594 ret = pUnhookWinEvent(hhook);
8595 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8597 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8598 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8599 CloseHandle(hthread);
8600 CloseHandle(hevent);
8601 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8602 /****** end of event filtering test *************/
8604 /****** start of out of context event test *************/
8605 hhook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0,
8606 win_event_global_hook_proc, GetCurrentProcessId(), 0,
8607 WINEVENT_OUTOFCONTEXT);
8608 ok(hhook != 0, "SetWinEventHook error %d\n", GetLastError());
8610 hevent = CreateEventA(NULL, 0, 0, NULL);
8616 hthread = CreateThread(NULL, 0, win_event_global_thread_proc, &hwnd2, 0, &tid);
8617 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8619 ok(WaitForSingleObject(hevent, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8621 ok_sequence(WmEmptySeq, "empty notify winevents", FALSE);
8622 /* process pending winevent messages */
8623 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
8624 ok_sequence(WmWinEventAlertSeq_2, "alert winevent for out of context proc", FALSE);
8627 /* this one should be received only by old hook proc */
8628 pNotifyWinEvent(EVENT_OBJECT_CREATE, hwnd, OBJID_CARET, 0); /* 0x8000 */
8629 pNotifyWinEvent(EVENT_OBJECT_SHOW, hwnd, OBJID_CARET, 0); /* 0x8002 */
8630 /* this one should be received only by old hook proc */
8631 pNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, hwnd, OBJID_CARET, 0); /* 0x800C */
8633 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for incontext proc", FALSE);
8634 /* process pending winevent messages */
8635 ok(!PeekMessageA(&msg, 0, 0, 0, PM_NOREMOVE), "msg queue should be empty\n");
8636 ok_sequence(WmWinEventCaretSeq_2, "caret winevent for out of context proc", FALSE);
8638 ret = pUnhookWinEvent(hhook);
8639 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8641 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8642 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8643 CloseHandle(hthread);
8644 CloseHandle(hevent);
8645 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8646 /****** end of out of context event test *************/
8648 /****** start of MOUSE_LL hook test *************/
8649 hCBT_global_hook = SetWindowsHookExA(WH_MOUSE_LL, cbt_global_hook_proc, GetModuleHandleA(0), 0);
8650 /* WH_MOUSE_LL is not supported on Win9x platforms */
8651 if (!hCBT_global_hook)
8653 win_skip("Skipping WH_MOUSE_LL test on this platform\n");
8654 goto skip_mouse_ll_hook_test;
8657 hevent = CreateEventA(NULL, 0, 0, NULL);
8661 hthread = CreateThread(NULL, 0, mouse_ll_global_thread_proc, &hwnd2, 0, &tid);
8662 ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
8664 while (WaitForSingleObject(hevent, 100) == WAIT_TIMEOUT)
8665 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
8667 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook other thread", FALSE);
8670 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
8671 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
8672 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
8674 ok_sequence(WmMouseLLHookSeq, "MOUSE_LL hook same thread", FALSE);
8676 ret = UnhookWindowsHookEx(hCBT_global_hook);
8677 ok( ret, "UnhookWindowsHookEx error %d\n", GetLastError());
8679 PostThreadMessageA(tid, WM_QUIT, 0, 0);
8680 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
8681 CloseHandle(hthread);
8682 CloseHandle(hevent);
8683 ok(!IsWindow(hwnd2), "window should be destroyed on thread exit\n");
8684 /****** end of MOUSE_LL hook test *************/
8685 skip_mouse_ll_hook_test:
8687 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8690 static void test_set_hook(void)
8694 HWINEVENTHOOK hwinevent_hook;
8696 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, GetModuleHandleA(0), GetCurrentThreadId());
8697 ok(hhook != 0, "local hook does not require hModule set to 0\n");
8698 UnhookWindowsHookEx(hhook);
8702 /* this test doesn't pass under Win9x: BUG! */
8703 SetLastError(0xdeadbeef);
8704 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, 0);
8705 ok(!hhook, "global hook requires hModule != 0\n");
8706 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD, "unexpected error %d\n", GetLastError());
8709 SetLastError(0xdeadbeef);
8710 hhook = SetWindowsHookExA(WH_CBT, 0, GetModuleHandleA(0), GetCurrentThreadId());
8711 ok(!hhook, "SetWinEventHook with invalid proc should fail\n");
8712 ok(GetLastError() == ERROR_INVALID_FILTER_PROC || /* Win2k */
8713 GetLastError() == 0xdeadbeef, /* Win9x */
8714 "unexpected error %d\n", GetLastError());
8716 SetLastError(0xdeadbeef);
8717 ok(!UnhookWindowsHookEx((HHOOK)0xdeadbeef), "UnhookWindowsHookEx succeeded\n");
8718 ok(GetLastError() == ERROR_INVALID_HOOK_HANDLE || /* Win2k */
8719 GetLastError() == 0xdeadbeef, /* Win9x */
8720 "unexpected error %d\n", GetLastError());
8722 if (!pSetWinEventHook || !pUnhookWinEvent) return;
8724 /* even process local incontext hooks require hmodule */
8725 SetLastError(0xdeadbeef);
8726 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8727 GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
8728 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8729 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8730 GetLastError() == 0xdeadbeef, /* Win9x */
8731 "unexpected error %d\n", GetLastError());
8733 /* even thread local incontext hooks require hmodule */
8734 SetLastError(0xdeadbeef);
8735 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8736 GetCurrentProcessId(), GetCurrentThreadId(), WINEVENT_INCONTEXT);
8737 ok(!hwinevent_hook, "WINEVENT_INCONTEXT requires hModule != 0\n");
8738 ok(GetLastError() == ERROR_HOOK_NEEDS_HMOD || /* Win2k */
8739 GetLastError() == 0xdeadbeef, /* Win9x */
8740 "unexpected error %d\n", GetLastError());
8744 /* these 3 tests don't pass under Win9x */
8745 SetLastError(0xdeadbeef);
8746 hwinevent_hook = pSetWinEventHook(1, 0, 0, win_event_proc,
8747 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8748 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8749 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8751 SetLastError(0xdeadbeef);
8752 hwinevent_hook = pSetWinEventHook(-1, 1, 0, win_event_proc,
8753 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8754 ok(!hwinevent_hook, "SetWinEventHook with invalid event range should fail\n");
8755 ok(GetLastError() == ERROR_INVALID_HOOK_FILTER, "unexpected error %d\n", GetLastError());
8757 SetLastError(0xdeadbeef);
8758 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8759 0, 0xdeadbeef, WINEVENT_OUTOFCONTEXT);
8760 ok(!hwinevent_hook, "SetWinEventHook with invalid tid should fail\n");
8761 ok(GetLastError() == ERROR_INVALID_THREAD_ID, "unexpected error %d\n", GetLastError());
8764 SetLastError(0xdeadbeef);
8765 hwinevent_hook = pSetWinEventHook(0, 0, 0, win_event_proc,
8766 GetCurrentProcessId(), 0, WINEVENT_OUTOFCONTEXT);
8767 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8768 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8769 ret = pUnhookWinEvent(hwinevent_hook);
8770 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8773 /* This call succeeds under win2k SP4, but fails under Wine.
8774 Does win2k test/use passed process id? */
8775 SetLastError(0xdeadbeef);
8776 hwinevent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX, 0, win_event_proc,
8777 0xdeadbeef, 0, WINEVENT_OUTOFCONTEXT);
8778 ok(hwinevent_hook != 0, "SetWinEventHook error %d\n", GetLastError());
8779 ok(GetLastError() == 0xdeadbeef, "unexpected error %d\n", GetLastError());
8780 ret = pUnhookWinEvent(hwinevent_hook);
8781 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
8784 SetLastError(0xdeadbeef);
8785 ok(!pUnhookWinEvent((HWINEVENTHOOK)0xdeadbeef), "UnhookWinEvent succeeded\n");
8786 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
8787 GetLastError() == 0xdeadbeef, /* Win9x */
8788 "unexpected error %d\n", GetLastError());
8791 static const struct message ScrollWindowPaint1[] = {
8793 { WM_ERASEBKGND, sent|beginpaint },
8794 { WM_GETTEXTLENGTH, sent|optional },
8795 { WM_PAINT, sent|optional },
8796 { WM_NCPAINT, sent|beginpaint|optional },
8797 { WM_GETTEXT, sent|beginpaint|optional },
8798 { WM_GETTEXT, sent|beginpaint|optional },
8799 { WM_GETTEXT, sent|beginpaint|optional },
8800 { WM_GETTEXT, sent|beginpaint|defwinproc|optional },
8801 { WM_ERASEBKGND, sent|beginpaint|optional },
8805 static const struct message ScrollWindowPaint2[] = {
8810 static void test_scrollwindowex(void)
8813 RECT rect={0,0,130,130};
8815 hwnd = CreateWindowExA(0, "TestWindowClass", "Test Scroll",
8816 WS_VISIBLE|WS_OVERLAPPEDWINDOW,
8817 100, 100, 200, 200, 0, 0, 0, NULL);
8818 ok (hwnd != 0, "Failed to create overlapped window\n");
8819 hchild = CreateWindowExA(0, "TestWindowClass", "Test child",
8820 WS_VISIBLE|WS_CAPTION|WS_CHILD,
8821 10, 10, 150, 150, hwnd, 0, 0, NULL);
8822 ok (hchild != 0, "Failed to create child\n");
8827 /* scroll without the child window */
8828 trace("start scroll\n");
8829 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8830 SW_ERASE|SW_INVALIDATE);
8831 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8832 trace("end scroll\n");
8835 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8839 /* Now without the SW_ERASE flag */
8840 trace("start scroll\n");
8841 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL, SW_INVALIDATE);
8842 ok_sequence(WmEmptySeq, "ScrollWindowEx", 0);
8843 trace("end scroll\n");
8846 ok_sequence(ScrollWindowPaint2, "ScrollWindowEx", 0);
8850 /* now scroll the child window as well */
8851 trace("start scroll\n");
8852 ScrollWindowEx( hwnd, 10, 10, &rect, NULL, NULL, NULL,
8853 SW_SCROLLCHILDREN|SW_ERASE|SW_INVALIDATE);
8854 /* wine sends WM_POSCHANGING, WM_POSCHANGED messages */
8855 /* windows sometimes a WM_MOVE */
8856 ok_sequence(WmEmptySeq, "ScrollWindowEx", TRUE);
8857 trace("end scroll\n");
8860 ok_sequence(ScrollWindowPaint1, "ScrollWindowEx", 0);
8864 /* now scroll with ScrollWindow() */
8865 trace("start scroll with ScrollWindow\n");
8866 ScrollWindow( hwnd, 5, 5, NULL, NULL);
8867 trace("end scroll\n");
8870 ok_sequence(ScrollWindowPaint1, "ScrollWindow", 0);
8872 ok(DestroyWindow(hchild), "failed to destroy window\n");
8873 ok(DestroyWindow(hwnd), "failed to destroy window\n");
8877 static const struct message destroy_window_with_children[] = {
8878 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8879 { HCBT_DESTROYWND, hook|lparam, 0, WND_PARENT_ID }, /* parent */
8880 { 0x0090, sent|optional },
8881 { HCBT_DESTROYWND, hook|lparam, 0, WND_POPUP_ID }, /* popup */
8882 { 0x0090, sent|optional },
8883 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* popup */
8884 { WM_DESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8885 { WM_CAPTURECHANGED, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8886 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_POPUP_ID }, /* popup */
8887 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, 0, 0 }, /* parent */
8888 { WM_DESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8889 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8890 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8891 { WM_DESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8892 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 2 }, /* child2 */
8893 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 3 }, /* child3 */
8894 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_CHILD_ID + 1 }, /* child1 */
8895 { WM_NCDESTROY, sent|wparam|lparam, 0, WND_PARENT_ID }, /* parent */
8899 static void test_DestroyWindow(void)
8902 HWND parent, child1, child2, child3, child4, test;
8903 UINT_PTR child_id = WND_CHILD_ID + 1;
8905 parent = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
8906 100, 100, 200, 200, 0, 0, 0, NULL);
8907 assert(parent != 0);
8908 child1 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8909 0, 0, 50, 50, parent, (HMENU)child_id++, 0, NULL);
8910 assert(child1 != 0);
8911 child2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8912 0, 0, 50, 50, GetDesktopWindow(), (HMENU)child_id++, 0, NULL);
8913 assert(child2 != 0);
8914 child3 = CreateWindowExA(0, "TestWindowClass", NULL, WS_CHILD,
8915 0, 0, 50, 50, child1, (HMENU)child_id++, 0, NULL);
8916 assert(child3 != 0);
8917 child4 = CreateWindowExA(0, "TestWindowClass", NULL, WS_POPUP,
8918 0, 0, 50, 50, parent, 0, 0, NULL);
8919 assert(child4 != 0);
8921 /* test owner/parent of child2 */
8922 test = GetParent(child2);
8923 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8924 ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8926 test = pGetAncestor(child2, GA_PARENT);
8927 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8929 test = GetWindow(child2, GW_OWNER);
8930 ok(!test, "wrong owner %p\n", test);
8932 test = SetParent(child2, parent);
8933 ok(test == GetDesktopWindow(), "wrong old parent %p\n", test);
8935 /* test owner/parent of the parent */
8936 test = GetParent(parent);
8937 ok(!test, "wrong parent %p\n", test);
8938 ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
8940 test = pGetAncestor(parent, GA_PARENT);
8941 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8943 test = GetWindow(parent, GW_OWNER);
8944 ok(!test, "wrong owner %p\n", test);
8946 /* test owner/parent of child1 */
8947 test = GetParent(child1);
8948 ok(test == parent, "wrong parent %p\n", test);
8949 ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
8951 test = pGetAncestor(child1, GA_PARENT);
8952 ok(test == parent, "wrong parent %p\n", test);
8954 test = GetWindow(child1, GW_OWNER);
8955 ok(!test, "wrong owner %p\n", test);
8957 /* test owner/parent of child2 */
8958 test = GetParent(child2);
8959 ok(test == parent, "wrong parent %p\n", test);
8960 ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
8962 test = pGetAncestor(child2, GA_PARENT);
8963 ok(test == parent, "wrong parent %p\n", test);
8965 test = GetWindow(child2, GW_OWNER);
8966 ok(!test, "wrong owner %p\n", test);
8968 /* test owner/parent of child3 */
8969 test = GetParent(child3);
8970 ok(test == child1, "wrong parent %p\n", test);
8971 ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
8973 test = pGetAncestor(child3, GA_PARENT);
8974 ok(test == child1, "wrong parent %p\n", test);
8976 test = GetWindow(child3, GW_OWNER);
8977 ok(!test, "wrong owner %p\n", test);
8979 /* test owner/parent of child4 */
8980 test = GetParent(child4);
8981 ok(test == parent, "wrong parent %p\n", test);
8982 ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
8984 test = pGetAncestor(child4, GA_PARENT);
8985 ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
8987 test = GetWindow(child4, GW_OWNER);
8988 ok(test == parent, "wrong owner %p\n", test);
8992 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
8993 parent, child1, child2, child3, child4);
8996 test = GetCapture();
8997 ok(test == child4, "wrong capture window %p\n", test);
8999 test_DestroyWindow_flag = TRUE;
9000 ret = DestroyWindow(parent);
9001 ok( ret, "DestroyWindow() error %d\n", GetLastError());
9002 test_DestroyWindow_flag = FALSE;
9003 ok_sequence(destroy_window_with_children, "destroy window with children", 0);
9005 ok(!IsWindow(parent), "parent still exists\n");
9006 ok(!IsWindow(child1), "child1 still exists\n");
9007 ok(!IsWindow(child2), "child2 still exists\n");
9008 ok(!IsWindow(child3), "child3 still exists\n");
9009 ok(!IsWindow(child4), "child4 still exists\n");
9011 test = GetCapture();
9012 ok(!test, "wrong capture window %p\n", test);
9016 static const struct message WmDispatchPaint[] = {
9017 { WM_NCPAINT, sent },
9018 { WM_GETTEXT, sent|defwinproc|optional },
9019 { WM_GETTEXT, sent|defwinproc|optional },
9020 { WM_ERASEBKGND, sent },
9024 static LRESULT WINAPI DispatchMessageCheckProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9026 if (message == WM_PAINT) return 0;
9027 return MsgCheckProcA( hwnd, message, wParam, lParam );
9030 static void test_DispatchMessage(void)
9035 HWND hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
9036 100, 100, 200, 200, 0, 0, 0, NULL);
9037 ShowWindow( hwnd, SW_SHOW );
9038 UpdateWindow( hwnd );
9041 SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)DispatchMessageCheckProc );
9043 SetRect( &rect, -5, -5, 5, 5 );
9044 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
9046 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
9048 if (msg.message != WM_PAINT) DispatchMessage( &msg );
9052 DispatchMessage( &msg );
9053 /* DispatchMessage will send WM_NCPAINT if non client area is still invalid after WM_PAINT */
9054 if (!count) ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
9055 else ok_sequence( WmEmptySeq, "WmEmpty", FALSE );
9056 if (++count > 10) break;
9059 ok( msg.message == WM_PAINT && count > 10, "WM_PAINT messages stopped\n" );
9061 trace("now without DispatchMessage\n");
9063 RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
9065 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
9067 if (msg.message != WM_PAINT) DispatchMessage( &msg );
9070 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
9072 /* this will send WM_NCCPAINT just like DispatchMessage does */
9073 GetUpdateRgn( hwnd, hrgn, TRUE );
9074 ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
9075 DeleteObject( hrgn );
9076 GetClientRect( hwnd, &rect );
9077 ValidateRect( hwnd, &rect ); /* this will stop WM_PAINTs */
9078 ok( !count, "Got multiple WM_PAINTs\n" );
9079 if (++count > 10) break;
9082 DestroyWindow(hwnd);
9086 static const struct message WmUser[] = {
9098 static DWORD CALLBACK send_msg_thread( LPVOID arg )
9100 struct sendmsg_info *info = arg;
9101 SetLastError( 0xdeadbeef );
9102 info->ret = SendMessageTimeoutA( info->hwnd, WM_USER, 0, 0, 0, info->timeout, NULL );
9103 if (!info->ret) ok( GetLastError() == ERROR_TIMEOUT ||
9104 broken(GetLastError() == 0), /* win9x */
9105 "unexpected error %d\n", GetLastError());
9109 static void wait_for_thread( HANDLE thread )
9111 while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_SENDMESSAGE) != WAIT_OBJECT_0)
9114 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage(&msg);
9118 static LRESULT WINAPI send_msg_delay_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9120 if (message == WM_USER) Sleep(200);
9121 return MsgCheckProcA( hwnd, message, wParam, lParam );
9124 static void test_SendMessageTimeout(void)
9127 struct sendmsg_info info;
9131 info.hwnd = CreateWindowA( "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
9132 100, 100, 200, 200, 0, 0, 0, NULL);
9136 info.timeout = 1000;
9137 info.ret = 0xdeadbeef;
9138 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9139 wait_for_thread( thread );
9140 CloseHandle( thread );
9141 ok( info.ret == 1, "SendMessageTimeout failed\n" );
9142 ok_sequence( WmUser, "WmUser", FALSE );
9145 info.ret = 0xdeadbeef;
9146 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9147 Sleep(100); /* SendMessageTimeout should time out here */
9148 wait_for_thread( thread );
9149 CloseHandle( thread );
9150 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
9151 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
9153 /* 0 means infinite timeout (but not on win9x) */
9155 info.ret = 0xdeadbeef;
9156 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9158 wait_for_thread( thread );
9159 CloseHandle( thread );
9160 is_win9x = !info.ret;
9161 if (is_win9x) ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
9162 else ok_sequence( WmUser, "WmUser", FALSE );
9164 /* timeout is treated as signed despite the prototype (but not on win9x) */
9165 info.timeout = 0x7fffffff;
9166 info.ret = 0xdeadbeef;
9167 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9169 wait_for_thread( thread );
9170 CloseHandle( thread );
9171 ok( info.ret == 1, "SendMessageTimeout failed\n" );
9172 ok_sequence( WmUser, "WmUser", FALSE );
9174 info.timeout = 0x80000000;
9175 info.ret = 0xdeadbeef;
9176 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9178 wait_for_thread( thread );
9179 CloseHandle( thread );
9182 ok( info.ret == 1, "SendMessageTimeout failed\n" );
9183 ok_sequence( WmUser, "WmUser", FALSE );
9187 ok( info.ret == 0, "SendMessageTimeout succeeded\n" );
9188 ok_sequence( WmEmptySeq, "WmEmptySeq", FALSE );
9191 /* now check for timeout during message processing */
9192 SetWindowLongPtrA( info.hwnd, GWLP_WNDPROC, (LONG_PTR)send_msg_delay_proc );
9194 info.ret = 0xdeadbeef;
9195 thread = CreateThread( NULL, 0, send_msg_thread, &info, 0, &tid );
9196 wait_for_thread( thread );
9197 CloseHandle( thread );
9198 /* we should time out but still get the message */
9199 ok( info.ret == 0, "SendMessageTimeout failed\n" );
9200 ok_sequence( WmUser, "WmUser", FALSE );
9202 DestroyWindow( info.hwnd );
9206 /****************** edit message test *************************/
9207 #define ID_EDIT 0x1234
9208 static const struct message sl_edit_setfocus[] =
9210 { HCBT_SETFOCUS, hook },
9211 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9212 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9213 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9214 { WM_SETFOCUS, sent|wparam, 0 },
9215 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9216 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 15 },
9217 { WM_CTLCOLOREDIT, sent|parent },
9218 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9219 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9220 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9221 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9224 static const struct message ml_edit_setfocus[] =
9226 { HCBT_SETFOCUS, hook },
9227 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
9228 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9229 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9230 { WM_SETFOCUS, sent|wparam, 0 },
9231 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
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 sl_edit_killfocus[] =
9240 { HCBT_SETFOCUS, hook },
9241 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9242 { WM_KILLFOCUS, sent|wparam, 0 },
9243 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9244 { EVENT_OBJECT_DESTROY, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9245 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_KILLFOCUS) },
9246 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
9247 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
9250 static const struct message sl_edit_lbutton_dblclk[] =
9252 { WM_LBUTTONDBLCLK, sent },
9253 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
9256 static const struct message sl_edit_lbutton_down[] =
9258 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
9259 { HCBT_SETFOCUS, hook },
9260 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
9261 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9262 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9263 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
9264 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9265 { WM_CTLCOLOREDIT, sent|parent },
9266 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9267 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9268 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9269 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9270 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9271 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
9272 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9273 { WM_CTLCOLOREDIT, sent|parent|optional },
9274 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9275 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9276 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9279 static const struct message ml_edit_lbutton_down[] =
9281 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, 0 },
9282 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
9283 { HCBT_SETFOCUS, hook },
9284 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
9285 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
9286 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
9287 { WM_SETFOCUS, sent|wparam|defwinproc, 0 },
9288 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
9289 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
9290 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9291 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9292 { WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_EDIT, EN_SETFOCUS) },
9295 static const struct message sl_edit_lbutton_up[] =
9297 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
9298 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9299 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
9300 { WM_CAPTURECHANGED, sent|defwinproc },
9301 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
9304 static const struct message ml_edit_lbutton_up[] =
9306 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
9307 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
9308 { WM_CAPTURECHANGED, sent|defwinproc },
9312 static WNDPROC old_edit_proc;
9314 static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
9316 static LONG defwndproc_counter = 0;
9318 struct recvd_message msg;
9320 if (ignore_message( message )) return 0;
9323 msg.message = message;
9324 msg.flags = sent|wparam|lparam;
9325 if (defwndproc_counter) msg.flags |= defwinproc;
9326 msg.wParam = wParam;
9327 msg.lParam = lParam;
9331 defwndproc_counter++;
9332 ret = CallWindowProcA(old_edit_proc, hwnd, message, wParam, lParam);
9333 defwndproc_counter--;
9338 static void subclass_edit(void)
9342 if (!GetClassInfoA(0, "edit", &cls)) assert(0);
9344 old_edit_proc = cls.lpfnWndProc;
9346 cls.hInstance = GetModuleHandle(0);
9347 cls.lpfnWndProc = edit_hook_proc;
9348 cls.lpszClassName = "my_edit_class";
9349 UnregisterClass(cls.lpszClassName, cls.hInstance);
9350 if (!RegisterClassA(&cls)) assert(0);
9353 static void test_edit_messages(void)
9359 log_all_parent_messages++;
9361 parent = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
9362 100, 100, 200, 200, 0, 0, 0, NULL);
9363 ok (parent != 0, "Failed to create parent window\n");
9365 /* test single line edit */
9366 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD,
9367 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
9368 ok(hwnd != 0, "Failed to create edit window\n");
9370 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
9371 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS), "wrong dlg_code %08x\n", dlg_code);
9373 ShowWindow(hwnd, SW_SHOW);
9379 ok_sequence(sl_edit_setfocus, "SetFocus(hwnd) on an edit", FALSE);
9382 ok_sequence(sl_edit_killfocus, "SetFocus(0) on an edit", FALSE);
9388 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
9389 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on an edit", FALSE);
9395 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
9396 ok_sequence(sl_edit_lbutton_down, "WM_LBUTTONDOWN on an edit", FALSE);
9398 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
9399 ok_sequence(sl_edit_lbutton_up, "WM_LBUTTONUP on an edit", FALSE);
9401 DestroyWindow(hwnd);
9403 /* test multiline edit */
9404 hwnd = CreateWindowExA(0, "my_edit_class", "test", WS_CHILD | ES_MULTILINE,
9405 0, 0, 80, 20, parent, (HMENU)ID_EDIT, 0, NULL);
9406 ok(hwnd != 0, "Failed to create edit window\n");
9408 dlg_code = SendMessageA(hwnd, WM_GETDLGCODE, 0, 0);
9409 ok(dlg_code == (DLGC_WANTCHARS|DLGC_HASSETSEL|DLGC_WANTARROWS|DLGC_WANTALLKEYS),
9410 "wrong dlg_code %08x\n", dlg_code);
9412 ShowWindow(hwnd, SW_SHOW);
9418 ok_sequence(ml_edit_setfocus, "SetFocus(hwnd) on multiline edit", FALSE);
9421 ok_sequence(sl_edit_killfocus, "SetFocus(0) on multiline edit", FALSE);
9427 SendMessageA(hwnd, WM_LBUTTONDBLCLK, 0, 0);
9428 ok_sequence(sl_edit_lbutton_dblclk, "WM_LBUTTONDBLCLK on multiline edit", FALSE);
9434 SendMessageA(hwnd, WM_LBUTTONDOWN, 0, 0);
9435 ok_sequence(ml_edit_lbutton_down, "WM_LBUTTONDOWN on multiline edit", FALSE);
9437 SendMessageA(hwnd, WM_LBUTTONUP, 0, 0);
9438 ok_sequence(ml_edit_lbutton_up, "WM_LBUTTONUP on multiline edit", FALSE);
9440 DestroyWindow(hwnd);
9441 DestroyWindow(parent);
9443 log_all_parent_messages--;
9446 /**************************** End of Edit test ******************************/
9448 static const struct message WmKeyDownSkippedSeq[] =
9450 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 1 }, /* XP */
9453 static const struct message WmKeyDownWasDownSkippedSeq[] =
9455 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0x40000001 }, /* XP */
9458 static const struct message WmKeyUpSkippedSeq[] =
9460 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
9463 static const struct message WmUserKeyUpSkippedSeq[] =
9466 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'N', 0xc0000001 }, /* XP */
9471 #define EV_SENDMSG 1
9477 HANDLE hevent[3]; /* 0 - start/stop, 1 - SendMessage, 2 - ack */
9480 static DWORD CALLBACK send_msg_thread_2(void *param)
9483 struct peekmsg_info *info = param;
9485 trace("thread: looping\n");
9486 SetEvent(info->hevent[EV_ACK]);
9490 ret = WaitForMultipleObjects(2, info->hevent, FALSE, INFINITE);
9494 case WAIT_OBJECT_0 + EV_STOP:
9495 trace("thread: exiting\n");
9498 case WAIT_OBJECT_0 + EV_SENDMSG:
9499 trace("thread: sending message\n");
9500 ok( SendNotifyMessageA(info->hwnd, WM_USER, 0, 0),
9501 "SendNotifyMessageA failed error %u\n", GetLastError());
9502 SetEvent(info->hevent[EV_ACK]);
9506 trace("unexpected return: %04x\n", ret);
9514 static void test_PeekMessage(void)
9519 UINT qs_all_input = QS_ALLINPUT;
9520 UINT qs_input = QS_INPUT;
9522 struct peekmsg_info info;
9524 info.hwnd = CreateWindowA("TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
9525 100, 100, 200, 200, 0, 0, 0, NULL);
9527 ShowWindow(info.hwnd, SW_SHOW);
9528 UpdateWindow(info.hwnd);
9529 SetFocus(info.hwnd);
9531 info.hevent[EV_STOP] = CreateEventA(NULL, 0, 0, NULL);
9532 info.hevent[EV_SENDMSG] = CreateEventA(NULL, 0, 0, NULL);
9533 info.hevent[EV_ACK] = CreateEventA(NULL, 0, 0, NULL);
9535 hthread = CreateThread(NULL, 0, send_msg_thread_2, &info, 0, &tid);
9536 WaitForSingleObject(info.hevent[EV_ACK], 10000);
9541 SetLastError(0xdeadbeef);
9542 qstatus = GetQueueStatus(qs_all_input);
9543 if (GetLastError() == ERROR_INVALID_FLAGS)
9545 trace("QS_RAWINPUT not supported on this platform\n");
9546 qs_all_input &= ~QS_RAWINPUT;
9547 qs_input &= ~QS_RAWINPUT;
9549 if (qstatus & QS_POSTMESSAGE)
9551 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) /* nothing */ ;
9552 qstatus = GetQueueStatus(qs_all_input);
9554 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9556 trace("signalling to send message\n");
9557 SetEvent(info.hevent[EV_SENDMSG]);
9558 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9560 /* pass invalid QS_xxxx flags */
9561 SetLastError(0xdeadbeef);
9562 qstatus = GetQueueStatus(0xffffffff);
9563 ok(qstatus == 0 || broken(qstatus) /* win9x */, "GetQueueStatus should fail: %08x\n", qstatus);
9566 ok(GetLastError() == ERROR_INVALID_FLAGS, "wrong error %d\n", GetLastError());
9567 qstatus = GetQueueStatus(qs_all_input);
9569 qstatus &= ~MAKELONG( 0x4000, 0x4000 ); /* sometimes set on Win95 */
9570 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE),
9571 "wrong qstatus %08x\n", qstatus);
9574 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9576 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9578 ok_sequence(WmUser, "WmUser", FALSE);
9580 qstatus = GetQueueStatus(qs_all_input);
9581 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9583 keybd_event('N', 0, 0, 0);
9584 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
9585 qstatus = GetQueueStatus(qs_all_input);
9586 if (!(qstatus & MAKELONG(QS_KEY, QS_KEY)))
9588 skip( "queuing key events not supported\n" );
9591 ok(qstatus == MAKELONG(QS_KEY, QS_KEY) ||
9592 /* keybd_event seems to trigger a sent message on NT4 */
9593 qstatus == MAKELONG(QS_KEY|QS_SENDMESSAGE, QS_KEY|QS_SENDMESSAGE),
9594 "wrong qstatus %08x\n", qstatus);
9596 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9597 qstatus = GetQueueStatus(qs_all_input);
9598 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY) ||
9599 qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY|QS_SENDMESSAGE),
9600 "wrong qstatus %08x\n", qstatus);
9602 InvalidateRect(info.hwnd, NULL, FALSE);
9603 qstatus = GetQueueStatus(qs_all_input);
9604 ok(qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY) ||
9605 qstatus == MAKELONG(QS_PAINT, QS_PAINT|QS_POSTMESSAGE|QS_KEY|QS_SENDMESSAGE),
9606 "wrong qstatus %08x\n", qstatus);
9608 trace("signalling to send message\n");
9609 SetEvent(info.hevent[EV_SENDMSG]);
9610 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9612 qstatus = GetQueueStatus(qs_all_input);
9613 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9614 "wrong qstatus %08x\n", qstatus);
9617 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (qs_input << 16));
9618 if (ret && msg.message == WM_CHAR)
9620 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9624 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9626 if (!sequence_cnt) /* nt4 doesn't fetch anything with PM_QS_* flags */
9628 win_skip( "PM_QS_* flags not supported in PeekMessage\n" );
9631 ok_sequence(WmUser, "WmUser", FALSE);
9633 qstatus = GetQueueStatus(qs_all_input);
9634 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9635 "wrong qstatus %08x\n", qstatus);
9637 trace("signalling to send message\n");
9638 SetEvent(info.hevent[EV_SENDMSG]);
9639 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9641 qstatus = GetQueueStatus(qs_all_input);
9642 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9643 "wrong qstatus %08x\n", qstatus);
9646 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE );
9648 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9650 ok_sequence(WmUser, "WmUser", FALSE);
9652 qstatus = GetQueueStatus(qs_all_input);
9653 ok(qstatus == MAKELONG(0, QS_PAINT|QS_POSTMESSAGE|QS_KEY),
9654 "wrong qstatus %08x\n", qstatus);
9657 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
9658 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9659 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9660 ret, msg.message, msg.wParam);
9661 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9663 qstatus = GetQueueStatus(qs_all_input);
9664 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
9665 "wrong qstatus %08x\n", qstatus);
9668 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_POSTMESSAGE);
9670 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9672 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9674 qstatus = GetQueueStatus(qs_all_input);
9675 ok(qstatus == MAKELONG(0, QS_PAINT|QS_KEY),
9676 "wrong qstatus %08x\n", qstatus);
9679 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
9680 ok(ret && msg.message == WM_PAINT,
9681 "got %d and %04x instead of TRUE and WM_PAINT\n", ret, msg.message);
9682 DispatchMessageA(&msg);
9683 ok_sequence(WmPaint, "WmPaint", FALSE);
9685 qstatus = GetQueueStatus(qs_all_input);
9686 ok(qstatus == MAKELONG(0, QS_KEY),
9687 "wrong qstatus %08x\n", qstatus);
9690 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_PAINT);
9692 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9694 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9696 qstatus = GetQueueStatus(qs_all_input);
9697 ok(qstatus == MAKELONG(0, QS_KEY),
9698 "wrong qstatus %08x\n", qstatus);
9700 trace("signalling to send message\n");
9701 SetEvent(info.hevent[EV_SENDMSG]);
9702 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9704 qstatus = GetQueueStatus(qs_all_input);
9705 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_KEY),
9706 "wrong qstatus %08x\n", qstatus);
9708 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9710 qstatus = GetQueueStatus(qs_all_input);
9711 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9712 "wrong qstatus %08x\n", qstatus);
9715 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
9716 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9717 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9718 ret, msg.message, msg.wParam);
9719 ok_sequence(WmUser, "WmUser", FALSE);
9721 qstatus = GetQueueStatus(qs_all_input);
9722 ok(qstatus == MAKELONG(0, QS_KEY),
9723 "wrong qstatus %08x\n", qstatus);
9726 ret = PeekMessageA(&msg, 0, WM_CHAR, WM_CHAR, PM_REMOVE);
9728 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9730 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9732 qstatus = GetQueueStatus(qs_all_input);
9733 ok(qstatus == MAKELONG(0, QS_KEY),
9734 "wrong qstatus %08x\n", qstatus);
9736 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9738 qstatus = GetQueueStatus(qs_all_input);
9739 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY),
9740 "wrong qstatus %08x\n", qstatus);
9742 trace("signalling to send message\n");
9743 SetEvent(info.hevent[EV_SENDMSG]);
9744 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9746 qstatus = GetQueueStatus(qs_all_input);
9747 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9748 "wrong qstatus %08x\n", qstatus);
9751 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_KEY << 16));
9753 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9755 ok_sequence(WmUser, "WmUser", FALSE);
9757 qstatus = GetQueueStatus(qs_all_input);
9758 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE|QS_KEY),
9759 "wrong qstatus %08x\n", qstatus);
9762 if (qs_all_input & QS_RAWINPUT) /* use QS_RAWINPUT only if supported */
9763 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | (QS_RAWINPUT << 16));
9764 else /* workaround for a missing QS_RAWINPUT support */
9765 ret = PeekMessageA(&msg, 0, WM_KEYDOWN, WM_KEYDOWN, PM_REMOVE);
9766 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9767 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9768 ret, msg.message, msg.wParam);
9769 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", 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_KEYUP, WM_KEYUP, PM_REMOVE);
9780 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
9781 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYUP wParam 'N'\n",
9782 ret, msg.message, msg.wParam);
9783 ok_sequence(WmKeyUpSkippedSeq, "WmKeyUpSkippedSeq", FALSE);
9785 qstatus = GetQueueStatus(qs_all_input);
9786 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9787 "wrong qstatus %08x\n", qstatus);
9790 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
9792 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9794 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9796 qstatus = GetQueueStatus(qs_all_input);
9797 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9798 "wrong qstatus %08x\n", qstatus);
9801 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9802 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9803 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9804 ret, msg.message, msg.wParam);
9805 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9807 qstatus = GetQueueStatus(qs_all_input);
9809 "wrong qstatus %08x\n", qstatus);
9812 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9814 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9816 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9818 qstatus = GetQueueStatus(qs_all_input);
9820 "wrong qstatus %08x\n", qstatus);
9822 /* test whether presence of the quit flag in the queue affects
9825 PostQuitMessage(0x1234abcd);
9827 qstatus = GetQueueStatus(qs_all_input);
9828 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9829 "wrong qstatus %08x\n", qstatus);
9831 PostMessageA(info.hwnd, WM_USER, 0, 0);
9833 qstatus = GetQueueStatus(qs_all_input);
9834 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE),
9835 "wrong qstatus %08x\n", qstatus);
9838 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9839 ok(ret && msg.message == WM_USER,
9840 "got %d and %04x instead of TRUE and WM_USER\n", ret, msg.message);
9841 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9843 qstatus = GetQueueStatus(qs_all_input);
9844 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9845 "wrong qstatus %08x\n", qstatus);
9848 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9849 ok(ret && msg.message == WM_QUIT,
9850 "got %d and %04x instead of TRUE and WM_QUIT\n", ret, msg.message);
9851 ok(msg.wParam == 0x1234abcd, "got wParam %08lx instead of 0x1234abcd\n", msg.wParam);
9852 ok(msg.lParam == 0, "got lParam %08lx instead of 0\n", msg.lParam);
9853 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9855 qstatus = GetQueueStatus(qs_all_input);
9857 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE),
9858 "wrong qstatus %08x\n", qstatus);
9862 ret = PeekMessageA(&msg, 0, 0, 0, PM_REMOVE);
9864 "PeekMessageA should have returned FALSE instead of msg %04x\n",
9866 ok_sequence(WmEmptySeq, "WmEmptySeq", FALSE);
9868 qstatus = GetQueueStatus(qs_all_input);
9870 "wrong qstatus %08x\n", qstatus);
9872 /* some GetMessage tests */
9874 keybd_event('N', 0, 0, 0);
9875 qstatus = GetQueueStatus(qs_all_input);
9876 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9878 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9879 qstatus = GetQueueStatus(qs_all_input);
9880 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9884 ret = GetMessageA( &msg, 0, 0, 0 );
9885 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9886 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9887 ret, msg.message, msg.wParam);
9888 qstatus = GetQueueStatus(qs_all_input);
9889 ok(qstatus == MAKELONG(0, QS_KEY), "wrong qstatus %08x\n", qstatus);
9894 ret = GetMessageA( &msg, 0, 0, 0 );
9895 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9896 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9897 ret, msg.message, msg.wParam);
9898 ok_sequence(WmKeyDownSkippedSeq, "WmKeyDownSkippedSeq", FALSE);
9899 qstatus = GetQueueStatus(qs_all_input);
9900 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9903 keybd_event('N', 0, 0, 0);
9904 qstatus = GetQueueStatus(qs_all_input);
9905 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9907 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9908 qstatus = GetQueueStatus(qs_all_input);
9909 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9911 if (qstatus & (QS_KEY << 16))
9913 ret = GetMessageA( &msg, 0, WM_KEYDOWN, WM_KEYUP );
9914 ok(ret && msg.message == WM_KEYDOWN && msg.wParam == 'N',
9915 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9916 ret, msg.message, msg.wParam);
9917 ok_sequence(WmKeyDownWasDownSkippedSeq, "WmKeyDownWasDownSkippedSeq", FALSE);
9918 qstatus = GetQueueStatus(qs_all_input);
9919 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), "wrong qstatus %08x\n", qstatus);
9924 ret = GetMessageA( &msg, 0, WM_CHAR, WM_CHAR );
9925 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9926 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9927 ret, msg.message, msg.wParam);
9928 qstatus = GetQueueStatus(qs_all_input);
9929 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9932 keybd_event('N', 0, KEYEVENTF_KEYUP, 0);
9933 qstatus = GetQueueStatus(qs_all_input);
9934 ok(qstatus == MAKELONG(QS_KEY, QS_KEY), "wrong qstatus %08x\n", qstatus);
9936 PostMessageA(info.hwnd, WM_CHAR, 'z', 0);
9937 qstatus = GetQueueStatus(qs_all_input);
9938 ok(qstatus == MAKELONG(QS_POSTMESSAGE, QS_POSTMESSAGE|QS_KEY), "wrong qstatus %08x\n", qstatus);
9940 trace("signalling to send message\n");
9941 SetEvent(info.hevent[EV_SENDMSG]);
9942 WaitForSingleObject(info.hevent[EV_ACK], INFINITE);
9943 qstatus = GetQueueStatus(qs_all_input);
9944 ok(qstatus == MAKELONG(QS_SENDMESSAGE, QS_SENDMESSAGE|QS_POSTMESSAGE|QS_KEY),
9945 "wrong qstatus %08x\n", qstatus);
9947 if (qstatus & (QS_KEY << 16))
9949 ret = GetMessageA( &msg, 0, WM_KEYDOWN, WM_KEYUP );
9950 ok(ret && msg.message == WM_KEYUP && msg.wParam == 'N',
9951 "got %d and %04x wParam %08lx instead of TRUE and WM_KEYDOWN wParam 'N'\n",
9952 ret, msg.message, msg.wParam);
9953 ok_sequence(WmUserKeyUpSkippedSeq, "WmUserKeyUpSkippedSeq", FALSE);
9954 qstatus = GetQueueStatus(qs_all_input);
9955 ok(qstatus == MAKELONG(0, QS_POSTMESSAGE), "wrong qstatus %08x\n", qstatus);
9960 ret = GetMessageA( &msg, 0, WM_CHAR, WM_CHAR );
9961 ok(ret && msg.message == WM_CHAR && msg.wParam == 'z',
9962 "got %d and %04x wParam %08lx instead of TRUE and WM_CHAR wParam 'z'\n",
9963 ret, msg.message, msg.wParam);
9964 qstatus = GetQueueStatus(qs_all_input);
9965 ok(qstatus == 0, "wrong qstatus %08x\n", qstatus);
9968 trace("signalling to exit\n");
9969 SetEvent(info.hevent[EV_STOP]);
9971 WaitForSingleObject(hthread, INFINITE);
9973 CloseHandle(hthread);
9974 CloseHandle(info.hevent[0]);
9975 CloseHandle(info.hevent[1]);
9976 CloseHandle(info.hevent[2]);
9978 DestroyWindow(info.hwnd);
9981 static void wait_move_event(HWND hwnd, int x, int y)
9988 time = GetTickCount();
9989 while (GetTickCount() - time < 200 && !go) {
9990 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
9991 go = ret && msg.pt.x > x && msg.pt.y > y;
9992 if (!ret) MsgWaitForMultipleObjects( 0, NULL, FALSE, GetTickCount() - time, QS_ALLINPUT );
9997 static void test_PeekMessage2(void)
10003 DWORD time1, time2, time3;
10004 int x1, y1, x2, y2, x3, y3;
10007 time1 = time2 = time3 = 0;
10008 x1 = y1 = x2 = y2 = x3 = y3 = 0;
10010 /* Initialise window and make sure it is ready for events */
10011 hwnd = CreateWindow("TestWindowClass", "PeekMessage2", WS_OVERLAPPEDWINDOW,
10012 10, 10, 800, 800, NULL, NULL, NULL, NULL);
10014 trace("Window for test_PeekMessage2 %p\n", hwnd);
10015 ShowWindow(hwnd, SW_SHOW);
10016 UpdateWindow(hwnd);
10018 GetCursorPos(&pos);
10019 SetCursorPos(100, 100);
10020 mouse_event(MOUSEEVENTF_MOVE, -STEP, -STEP, 0, 0);
10023 /* Do initial mousemove, wait until we can see it
10024 and then do our test peek with PM_NOREMOVE. */
10025 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
10026 wait_move_event(hwnd, 100-STEP, 100-STEP);
10028 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10031 skip( "queuing mouse events not supported\n" );
10036 trace("1st move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
10037 message = msg.message;
10041 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
10044 /* Allow time to advance a bit, and then simulate the user moving their
10045 * mouse around. After that we peek again with PM_NOREMOVE.
10046 * Although the previous mousemove message was never removed, the
10047 * mousemove we now peek should reflect the recent mouse movements
10048 * because the input queue will merge the move events. */
10050 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
10051 wait_move_event(hwnd, x1, y1);
10053 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10054 ok(ret, "no message available\n");
10056 trace("2nd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
10057 message = msg.message;
10061 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
10062 ok(time2 > time1, "message time not advanced: %x %x\n", time1, time2);
10063 ok(x2 != x1 && y2 != y1, "coords not changed: (%d %d) (%d %d)\n", x1, y1, x2, y2);
10066 /* Have another go, to drive the point home */
10068 mouse_event(MOUSEEVENTF_MOVE, STEP, STEP, 0, 0);
10069 wait_move_event(hwnd, x2, y2);
10071 ret = PeekMessageA(&msg, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_NOREMOVE);
10072 ok(ret, "no message available\n");
10074 trace("3rd move event: %04x %x %d %d\n", msg.message, msg.time, msg.pt.x, msg.pt.y);
10075 message = msg.message;
10079 ok(message == WM_MOUSEMOVE, "message not WM_MOUSEMOVE, %04x instead\n", message);
10080 ok(time3 > time2, "message time not advanced: %x %x\n", time2, time3);
10081 ok(x3 != x2 && y3 != y2, "coords not changed: (%d %d) (%d %d)\n", x2, y2, x3, y3);
10085 DestroyWindow(hwnd);
10086 SetCursorPos(pos.x, pos.y);
10090 static INT_PTR CALLBACK wm_quit_dlg_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
10092 struct recvd_message msg;
10094 if (ignore_message( message )) return 0;
10097 msg.message = message;
10098 msg.flags = sent|wparam|lparam;
10101 msg.descr = "dialog";
10106 case WM_INITDIALOG:
10107 PostMessage(hwnd, WM_QUIT, 0x1234, 0x5678);
10108 PostMessage(hwnd, WM_USER, 0xdead, 0xbeef);
10111 case WM_GETDLGCODE:
10115 EndDialog(hwnd, 0);
10122 static const struct message WmQuitDialogSeq[] = {
10123 { HCBT_CREATEWND, hook },
10124 { WM_SETFONT, sent },
10125 { WM_INITDIALOG, sent },
10126 { WM_CHANGEUISTATE, sent|optional },
10127 { HCBT_DESTROYWND, hook },
10128 { 0x0090, sent|optional }, /* Vista */
10129 { WM_DESTROY, sent },
10130 { WM_NCDESTROY, sent },
10134 static void test_quit_message(void)
10139 /* test using PostQuitMessage */
10141 PostQuitMessage(0xbeef);
10143 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
10144 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
10145 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10146 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
10148 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
10149 ok(ret, "PostMessage failed with error %d\n", GetLastError());
10151 ret = GetMessage(&msg, NULL, 0, 0);
10152 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
10153 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
10155 /* note: WM_QUIT message received after WM_USER message */
10156 ret = GetMessage(&msg, NULL, 0, 0);
10157 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
10158 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10159 ok(msg.wParam == 0xbeef, "wParam was 0x%lx instead of 0xbeef\n", msg.wParam);
10161 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
10162 ok( !ret || msg.message != WM_QUIT, "Received WM_QUIT again\n" );
10164 /* now test with PostThreadMessage - different behaviour! */
10165 PostThreadMessage(GetCurrentThreadId(), WM_QUIT, 0xdead, 0);
10167 ret = PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
10168 ok(ret, "PeekMessage failed with error %d\n", GetLastError());
10169 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10170 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
10172 ret = PostThreadMessage(GetCurrentThreadId(), WM_USER, 0, 0);
10173 ok(ret, "PostMessage failed with error %d\n", GetLastError());
10175 /* note: we receive the WM_QUIT message first this time */
10176 ret = GetMessage(&msg, NULL, 0, 0);
10177 ok(!ret, "GetMessage return %d with error %d instead of FALSE\n", ret, GetLastError());
10178 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10179 ok(msg.wParam == 0xdead, "wParam was 0x%lx instead of 0xdead\n", msg.wParam);
10181 ret = GetMessage(&msg, NULL, 0, 0);
10182 ok(ret > 0, "GetMessage failed with error %d\n", GetLastError());
10183 ok(msg.message == WM_USER, "Received message 0x%04x instead of WM_USER\n", msg.message);
10187 ret = DialogBoxParam(GetModuleHandle(0), "TEST_EMPTY_DIALOG", 0, wm_quit_dlg_proc, 0);
10188 ok(ret == 1, "expected 1, got %d\n", ret);
10189 ok_sequence(WmQuitDialogSeq, "WmQuitDialogSeq", FALSE);
10190 memset(&msg, 0xab, sizeof(msg));
10191 ret = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
10192 ok(ret, "PeekMessage failed\n");
10193 ok(msg.message == WM_QUIT, "Received message 0x%04x instead of WM_QUIT\n", msg.message);
10194 ok(msg.wParam == 0x1234, "wParam was 0x%lx instead of 0x1234\n", msg.wParam);
10195 ok(msg.lParam == 0, "lParam was 0x%lx instead of 0\n", msg.lParam);
10198 static const struct message WmMouseHoverSeq[] = {
10199 { WM_MOUSEACTIVATE, sent|optional }, /* we can get those when moving the mouse in focus-follow-mouse mode under X11 */
10200 { WM_MOUSEACTIVATE, sent|optional },
10201 { WM_TIMER, sent|optional }, /* XP sends it */
10202 { WM_SYSTIMER, sent },
10203 { WM_MOUSEHOVER, sent|wparam, 0 },
10207 static void pump_msg_loop_timeout(DWORD timeout, BOOL inject_mouse_move)
10210 DWORD start_ticks, end_ticks;
10212 start_ticks = GetTickCount();
10213 /* add some deviation (50%) to cover not expected delays */
10214 start_ticks += timeout / 2;
10218 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
10220 /* Timer proc messages are not dispatched to the window proc,
10221 * and therefore not logged.
10223 if ((msg.message == WM_TIMER || msg.message == WM_SYSTIMER) && msg.hwnd)
10225 struct recvd_message s_msg;
10227 s_msg.hwnd = msg.hwnd;
10228 s_msg.message = msg.message;
10229 s_msg.flags = sent|wparam|lparam;
10230 s_msg.wParam = msg.wParam;
10231 s_msg.lParam = msg.lParam;
10232 s_msg.descr = "msg_loop";
10233 add_message(&s_msg);
10235 DispatchMessage(&msg);
10238 end_ticks = GetTickCount();
10240 /* inject WM_MOUSEMOVE to see how it changes tracking */
10241 if (inject_mouse_move && start_ticks + timeout / 2 >= end_ticks)
10243 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
10244 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
10246 inject_mouse_move = FALSE;
10248 } while (start_ticks + timeout >= end_ticks);
10251 static void test_TrackMouseEvent(void)
10253 TRACKMOUSEEVENT tme;
10256 RECT rc_parent, rc_child;
10257 UINT default_hover_time, hover_width = 0, hover_height = 0;
10259 #define track_hover(track_hwnd, track_hover_time) \
10260 tme.cbSize = sizeof(tme); \
10261 tme.dwFlags = TME_HOVER; \
10262 tme.hwndTrack = track_hwnd; \
10263 tme.dwHoverTime = track_hover_time; \
10264 SetLastError(0xdeadbeef); \
10265 ret = pTrackMouseEvent(&tme); \
10266 ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
10268 #define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
10269 tme.cbSize = sizeof(tme); \
10270 tme.dwFlags = TME_QUERY; \
10271 tme.hwndTrack = (HWND)0xdeadbeef; \
10272 tme.dwHoverTime = 0xdeadbeef; \
10273 SetLastError(0xdeadbeef); \
10274 ret = pTrackMouseEvent(&tme); \
10275 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
10276 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
10277 ok(tme.dwFlags == (expected_track_flags), \
10278 "wrong tme.dwFlags %08x, expected %08x\n", tme.dwFlags, (expected_track_flags)); \
10279 ok(tme.hwndTrack == (expected_track_hwnd), \
10280 "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, (expected_track_hwnd)); \
10281 ok(tme.dwHoverTime == (expected_hover_time), \
10282 "wrong tme.dwHoverTime %u, expected %u\n", tme.dwHoverTime, (expected_hover_time))
10284 #define track_hover_cancel(track_hwnd) \
10285 tme.cbSize = sizeof(tme); \
10286 tme.dwFlags = TME_HOVER | TME_CANCEL; \
10287 tme.hwndTrack = track_hwnd; \
10288 tme.dwHoverTime = 0xdeadbeef; \
10289 SetLastError(0xdeadbeef); \
10290 ret = pTrackMouseEvent(&tme); \
10291 ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
10293 default_hover_time = 0xdeadbeef;
10294 SetLastError(0xdeadbeef);
10295 ret = SystemParametersInfo(SPI_GETMOUSEHOVERTIME, 0, &default_hover_time, 0);
10296 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
10297 "SystemParametersInfo(SPI_GETMOUSEHOVERTIME) error %u\n", GetLastError());
10298 if (!ret) default_hover_time = 400;
10299 trace("SPI_GETMOUSEHOVERTIME returned %u ms\n", default_hover_time);
10301 SetLastError(0xdeadbeef);
10302 ret = SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH, 0, &hover_width, 0);
10303 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
10304 "SystemParametersInfo(SPI_GETMOUSEHOVERWIDTH) error %u\n", GetLastError());
10305 if (!ret) hover_width = 4;
10306 SetLastError(0xdeadbeef);
10307 ret = SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT, 0, &hover_height, 0);
10308 ok(ret || broken(GetLastError() == 0xdeadbeef), /* win9x */
10309 "SystemParametersInfo(SPI_GETMOUSEHOVERHEIGHT) error %u\n", GetLastError());
10310 if (!ret) hover_height = 4;
10311 trace("hover rect is %u x %d\n", hover_width, hover_height);
10313 hwnd = CreateWindowEx(0, "TestWindowClass", NULL,
10314 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
10315 CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
10319 hchild = CreateWindowEx(0, "TestWindowClass", NULL,
10320 WS_CHILD | WS_BORDER | WS_VISIBLE,
10321 50, 50, 200, 200, hwnd,
10325 SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
10330 tme.dwFlags = TME_QUERY;
10331 tme.hwndTrack = (HWND)0xdeadbeef;
10332 tme.dwHoverTime = 0xdeadbeef;
10333 SetLastError(0xdeadbeef);
10334 ret = pTrackMouseEvent(&tme);
10335 ok(!ret, "TrackMouseEvent should fail\n");
10336 ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef),
10337 "not expected error %u\n", GetLastError());
10339 tme.cbSize = sizeof(tme);
10340 tme.dwFlags = TME_HOVER;
10341 tme.hwndTrack = (HWND)0xdeadbeef;
10342 tme.dwHoverTime = 0xdeadbeef;
10343 SetLastError(0xdeadbeef);
10344 ret = pTrackMouseEvent(&tme);
10345 ok(!ret, "TrackMouseEvent should fail\n");
10346 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
10347 "not expected error %u\n", GetLastError());
10349 tme.cbSize = sizeof(tme);
10350 tme.dwFlags = TME_HOVER | TME_CANCEL;
10351 tme.hwndTrack = (HWND)0xdeadbeef;
10352 tme.dwHoverTime = 0xdeadbeef;
10353 SetLastError(0xdeadbeef);
10354 ret = pTrackMouseEvent(&tme);
10355 ok(!ret, "TrackMouseEvent should fail\n");
10356 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef),
10357 "not expected error %u\n", GetLastError());
10359 GetWindowRect(hwnd, &rc_parent);
10360 GetWindowRect(hchild, &rc_child);
10361 SetCursorPos(rc_child.left - 10, rc_child.top - 10);
10363 /* Process messages so that the system updates its internal current
10364 * window and hittest, otherwise TrackMouseEvent calls don't have any
10370 track_query(0, NULL, 0);
10371 track_hover(hchild, 0);
10372 track_query(0, NULL, 0);
10377 track_hover(hwnd, 0);
10378 tme.cbSize = sizeof(tme);
10379 tme.dwFlags = TME_QUERY;
10380 tme.hwndTrack = (HWND)0xdeadbeef;
10381 tme.dwHoverTime = 0xdeadbeef;
10382 SetLastError(0xdeadbeef);
10383 ret = pTrackMouseEvent(&tme);
10384 ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());
10385 ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize);
10388 skip( "Cursor not inside window, skipping TrackMouseEvent tests\n" );
10389 DestroyWindow( hwnd );
10392 ok(tme.dwFlags == TME_HOVER, "wrong tme.dwFlags %08x, expected TME_HOVER\n", tme.dwFlags);
10393 ok(tme.hwndTrack == hwnd, "wrong tme.hwndTrack %p, expected %p\n", tme.hwndTrack, hwnd);
10394 ok(tme.dwHoverTime == default_hover_time, "wrong tme.dwHoverTime %u, expected %u\n",
10395 tme.dwHoverTime, default_hover_time);
10397 pump_msg_loop_timeout(default_hover_time, FALSE);
10398 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
10400 track_query(0, NULL, 0);
10402 track_hover(hwnd, HOVER_DEFAULT);
10403 track_query(TME_HOVER, hwnd, default_hover_time);
10405 Sleep(default_hover_time / 2);
10406 mouse_event(MOUSEEVENTF_MOVE, -1, 0, 0, 0);
10407 mouse_event(MOUSEEVENTF_MOVE, 1, 0, 0, 0);
10409 track_query(TME_HOVER, hwnd, default_hover_time);
10411 pump_msg_loop_timeout(default_hover_time, FALSE);
10412 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
10414 track_query(0, NULL, 0);
10416 track_hover(hwnd, HOVER_DEFAULT);
10417 track_query(TME_HOVER, hwnd, default_hover_time);
10419 pump_msg_loop_timeout(default_hover_time, TRUE);
10420 ok_sequence(WmMouseHoverSeq, "WmMouseHoverSeq", FALSE);
10422 track_query(0, NULL, 0);
10424 track_hover(hwnd, HOVER_DEFAULT);
10425 track_query(TME_HOVER, hwnd, default_hover_time);
10426 track_hover_cancel(hwnd);
10428 DestroyWindow(hwnd);
10432 #undef track_hover_cancel
10436 static const struct message WmSetWindowRgn[] = {
10437 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10438 { WM_NCCALCSIZE, sent|wparam, 1 },
10439 { WM_NCPAINT, sent|optional }, /* wparam != 1 */
10440 { WM_GETTEXT, sent|defwinproc|optional },
10441 { WM_ERASEBKGND, sent|optional },
10442 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10443 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10447 static const struct message WmSetWindowRgn_no_redraw[] = {
10448 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
10449 { WM_NCCALCSIZE, sent|wparam, 1 },
10450 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW },
10451 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10455 static const struct message WmSetWindowRgn_clear[] = {
10456 { WM_WINDOWPOSCHANGING, sent/*|wparam*/, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE/*|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE only on some Windows versions */ },
10457 { WM_NCCALCSIZE, sent|wparam, 1 },
10458 { WM_NCPAINT, sent|optional },
10459 { WM_GETTEXT, sent|defwinproc|optional },
10460 { WM_ERASEBKGND, sent|optional }, /* FIXME: remove optional once Wine is fixed */
10461 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10462 { WM_NCCALCSIZE, sent|wparam|optional, 1 },
10463 { WM_NCPAINT, sent|optional },
10464 { WM_GETTEXT, sent|defwinproc|optional },
10465 { WM_ERASEBKGND, sent|optional },
10466 { WM_WINDOWPOSCHANGING, sent|optional },
10467 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
10468 { WM_NCPAINT, sent|optional },
10469 { WM_GETTEXT, sent|defwinproc|optional },
10470 { WM_ERASEBKGND, sent|optional },
10471 { WM_WINDOWPOSCHANGED, sent|optional|wparam, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOMOVE },
10472 { WM_NCCALCSIZE, sent|optional|wparam, 1 },
10473 { WM_NCPAINT, sent|optional },
10474 { WM_GETTEXT, sent|defwinproc|optional },
10475 { WM_ERASEBKGND, sent|optional },
10476 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10477 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
10481 static void test_SetWindowRgn(void)
10484 HWND hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
10485 100, 100, 200, 200, 0, 0, 0, NULL);
10486 ok( hwnd != 0, "Failed to create overlapped window\n" );
10488 ShowWindow( hwnd, SW_SHOW );
10489 UpdateWindow( hwnd );
10493 trace("testing SetWindowRgn\n");
10494 hrgn = CreateRectRgn( 0, 0, 150, 150 );
10495 SetWindowRgn( hwnd, hrgn, TRUE );
10496 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn", FALSE );
10498 hrgn = CreateRectRgn( 30, 30, 160, 160 );
10499 SetWindowRgn( hwnd, hrgn, FALSE );
10500 ok_sequence( WmSetWindowRgn_no_redraw, "WmSetWindowRgn_no_redraw", FALSE );
10502 hrgn = CreateRectRgn( 0, 0, 180, 180 );
10503 SetWindowRgn( hwnd, hrgn, TRUE );
10504 ok_sequence( WmSetWindowRgn, "WmSetWindowRgn2", FALSE );
10506 SetWindowRgn( hwnd, 0, TRUE );
10507 ok_sequence( WmSetWindowRgn_clear, "WmSetWindowRgn_clear", FALSE );
10509 DestroyWindow( hwnd );
10512 /*************************** ShowWindow() test ******************************/
10513 static const struct message WmShowNormal[] = {
10514 { WM_SHOWWINDOW, sent|wparam, 1 },
10515 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10516 { HCBT_ACTIVATE, hook },
10517 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
10518 { HCBT_SETFOCUS, hook },
10519 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10522 static const struct message WmShow[] = {
10523 { WM_SHOWWINDOW, sent|wparam, 1 },
10524 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10525 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10526 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10527 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10528 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10531 static const struct message WmShowNoActivate_1[] = {
10532 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
10533 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10534 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10535 { WM_MOVE, sent|defwinproc|optional },
10536 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
10539 static const struct message WmShowNoActivate_2[] = {
10540 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE },
10541 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10542 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10543 { WM_MOVE, sent|defwinproc },
10544 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
10545 { HCBT_SETFOCUS, hook|optional },
10546 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
10547 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
10548 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10549 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
10552 static const struct message WmShowNA_1[] = {
10553 { WM_SHOWWINDOW, sent|wparam, 1 },
10554 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
10555 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10558 static const struct message WmShowNA_2[] = {
10559 { WM_SHOWWINDOW, sent|wparam, 1 },
10560 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
10561 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10564 static const struct message WmRestore_1[] = {
10565 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
10566 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10567 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10568 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10569 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10570 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10571 { WM_MOVE, sent|defwinproc },
10572 { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED },
10573 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
10576 static const struct message WmRestore_2[] = {
10577 { WM_SHOWWINDOW, sent|wparam, 1 },
10578 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10579 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10580 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10581 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10582 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10585 static const struct message WmRestore_3[] = {
10586 { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE },
10587 { WM_GETMINMAXINFO, sent },
10588 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10589 { HCBT_ACTIVATE, hook|optional }, /* win2003 doesn't send it */
10590 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2003 doesn't send it */
10591 { HCBT_SETFOCUS, hook|optional }, /* win2003 doesn't send it */
10592 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10593 { WM_MOVE, sent|defwinproc },
10594 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10595 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
10598 static const struct message WmRestore_4[] = {
10599 { HCBT_MINMAX, hook|lparam|optional, 0, SW_RESTORE },
10600 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10601 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10602 { WM_MOVE, sent|defwinproc|optional },
10603 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_RESTORED },
10606 static const struct message WmRestore_5[] = {
10607 { HCBT_MINMAX, hook|lparam|optional, 0, SW_SHOWNORMAL },
10608 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10609 { HCBT_ACTIVATE, hook|optional },
10610 { HCBT_SETFOCUS, hook|optional },
10611 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10612 { WM_MOVE, sent|defwinproc|optional },
10613 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_RESTORED },
10616 static const struct message WmHide_1[] = {
10617 { WM_SHOWWINDOW, sent|wparam, 0 },
10618 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE, 0, SWP_NOACTIVATE },
10619 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE, 0, SWP_NOACTIVATE },
10620 { HCBT_ACTIVATE, hook|optional },
10621 { HCBT_SETFOCUS, hook|optional }, /* win2000 sends it */
10624 static const struct message WmHide_2[] = {
10625 { WM_SHOWWINDOW, sent|wparam, 0 },
10626 { WM_WINDOWPOSCHANGING, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10627 { WM_WINDOWPOSCHANGED, sent /*|wparam, SWP_HIDEWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE*/ }, /* win2000 doesn't add SWP_NOACTIVATE */
10628 { HCBT_ACTIVATE, hook|optional },
10631 static const struct message WmHide_3[] = {
10632 { WM_SHOWWINDOW, sent|wparam, 0 },
10633 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
10634 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10635 { HCBT_SETFOCUS, hook|optional },
10636 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10639 static const struct message WmShowMinimized_1[] = {
10640 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
10641 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10642 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10643 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10644 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10645 { WM_MOVE, sent|defwinproc },
10646 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10649 static const struct message WmMinimize_1[] = {
10650 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10651 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10652 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
10653 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10654 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10655 { WM_MOVE, sent|defwinproc },
10656 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10659 static const struct message WmMinimize_2[] = {
10660 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10661 { HCBT_SETFOCUS, hook|optional },
10662 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10663 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10664 { WM_MOVE, sent|defwinproc },
10665 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10668 static const struct message WmMinimize_3[] = {
10669 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10670 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10671 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10672 { WM_MOVE, sent|defwinproc },
10673 { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 },
10676 static const struct message WmShowMinNoActivate[] = {
10677 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
10678 { WM_WINDOWPOSCHANGING, sent },
10679 { WM_WINDOWPOSCHANGED, sent },
10680 { WM_MOVE, sent|defwinproc|optional },
10681 { WM_SIZE, sent|wparam|lparam|defwinproc|optional, SIZE_MINIMIZED, 0 },
10684 static const struct message WmMinMax_1[] = {
10685 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINIMIZED },
10688 static const struct message WmMinMax_2[] = {
10689 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10690 { WM_GETMINMAXINFO, sent|optional },
10691 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED },
10692 { HCBT_ACTIVATE, hook|optional },
10693 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
10694 { HCBT_SETFOCUS, hook|optional },
10695 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
10696 { WM_MOVE, sent|defwinproc|optional },
10697 { WM_SIZE, sent|wparam|defwinproc|optional, SIZE_MAXIMIZED },
10698 { HCBT_SETFOCUS, hook|optional },
10701 static const struct message WmMinMax_3[] = {
10702 { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE },
10703 { HCBT_SETFOCUS, hook|optional },
10704 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10705 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10706 { WM_MOVE, sent|defwinproc|optional },
10707 { WM_SIZE, sent|wparam|lparam|defwinproc|optional, SIZE_MINIMIZED, 0 },
10710 static const struct message WmMinMax_4[] = {
10711 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMINNOACTIVE },
10714 static const struct message WmShowMaximized_1[] = {
10715 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10716 { WM_GETMINMAXINFO, sent },
10717 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10718 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10719 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10720 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10721 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10722 { WM_MOVE, sent|defwinproc },
10723 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10724 { HCBT_SETFOCUS, hook|optional }, /* win2003 sends it */
10727 static const struct message WmShowMaximized_2[] = {
10728 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10729 { WM_GETMINMAXINFO, sent },
10730 { WM_WINDOWPOSCHANGING, sent|optional },
10731 { HCBT_ACTIVATE, hook|optional },
10732 { WM_WINDOWPOSCHANGED, sent|optional },
10733 { WM_MOVE, sent|optional }, /* Win9x doesn't send it */
10734 { WM_SIZE, sent|wparam|optional, SIZE_MAXIMIZED }, /* Win9x doesn't send it */
10735 { WM_WINDOWPOSCHANGING, sent|optional },
10736 { HCBT_SETFOCUS, hook|optional },
10737 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED },
10738 { WM_MOVE, sent|defwinproc },
10739 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10740 { HCBT_SETFOCUS, hook|optional },
10743 static const struct message WmShowMaximized_3[] = {
10744 { HCBT_MINMAX, hook|lparam, 0, SW_SHOWMAXIMIZED },
10745 { WM_GETMINMAXINFO, sent|optional },
10746 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10747 { HCBT_ACTIVATE, hook|optional }, /* win2000 doesn't send it */
10748 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, /* win2000 doesn't send it */
10749 { HCBT_SETFOCUS, hook|optional }, /* win2000 doesn't send it */
10750 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED, 0, SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE|SWP_NOSIZE|SWP_NOMOVE },
10751 { WM_MOVE, sent|defwinproc|optional },
10752 { WM_SIZE, sent|wparam|defwinproc, SIZE_MAXIMIZED },
10756 static void test_ShowWindow(void)
10758 /* ShowWindow commands in random order */
10759 static const struct
10761 INT cmd; /* ShowWindow command */
10762 LPARAM ret; /* ShowWindow return value */
10763 DWORD style; /* window style after the command */
10764 const struct message *msg; /* message sequence the command produces */
10765 INT wp_cmd, wp_flags; /* window placement after the command */
10766 POINT wp_min, wp_max; /* window placement after the command */
10767 BOOL todo_msg; /* message sequence doesn't match what Wine does */
10770 /* 1 */ { SW_SHOWNORMAL, FALSE, WS_VISIBLE, WmShowNormal,
10771 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10772 /* 2 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmEmptySeq,
10773 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10774 /* 3 */ { SW_HIDE, TRUE, 0, WmHide_1,
10775 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10776 /* 4 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10777 SW_SHOWNORMAL, 0, {-1,-1}, {-1,-1}, FALSE },
10778 /* 5 */ { SW_SHOWMINIMIZED, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinimized_1,
10779 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10780 /* 6 */ { SW_SHOWMINIMIZED, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_1,
10781 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10782 /* 7 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_1,
10783 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10784 /* 8 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq,
10785 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10786 /* 9 */ { SW_SHOWMAXIMIZED, FALSE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_1,
10787 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10788 /* 10 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2,
10789 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10790 /* 11 */ { SW_HIDE, TRUE, WS_MAXIMIZE, WmHide_1,
10791 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10792 /* 12 */ { SW_HIDE, FALSE, WS_MAXIMIZE, WmEmptySeq,
10793 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10794 /* 13 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_1,
10795 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10796 /* 14 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq,
10797 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10798 /* 15 */ { SW_HIDE, TRUE, 0, WmHide_2,
10799 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10800 /* 16 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10801 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10802 /* 17 */ { SW_SHOW, FALSE, WS_VISIBLE, WmShow,
10803 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10804 /* 18 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq,
10805 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10806 /* 19 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1,
10807 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10808 /* 20 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3,
10809 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10810 /* 21 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10811 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10812 /* 22 */ { SW_SHOWMINNOACTIVE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowMinNoActivate,
10813 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, TRUE },
10814 /* 23 */ { SW_SHOWMINNOACTIVE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_4,
10815 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10816 /* 24 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10817 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10818 /* 25 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq,
10819 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10820 /* 26 */ { SW_SHOWNA, FALSE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_1,
10821 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10822 /* 27 */ { SW_SHOWNA, TRUE, WS_VISIBLE|WS_MINIMIZE, WmShowNA_2,
10823 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10824 /* 28 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10825 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10826 /* 29 */ { SW_HIDE, FALSE, WS_MINIMIZE, WmEmptySeq,
10827 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10828 /* 30 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_1,
10829 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10830 /* 31 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq,
10831 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10832 /* 32 */ { SW_HIDE, TRUE, 0, WmHide_3,
10833 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10834 /* 33 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10835 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10836 /* 34 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq, /* what does this mean?! */
10837 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10838 /* 35 */ { SW_NORMALNA, FALSE, 0, WmEmptySeq,
10839 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10840 /* 36 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10841 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10842 /* 37 */ { SW_RESTORE, FALSE, WS_VISIBLE, WmRestore_2,
10843 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10844 /* 38 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmEmptySeq,
10845 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10846 /* 39 */ { SW_SHOWNOACTIVATE, TRUE, WS_VISIBLE, WmEmptySeq,
10847 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10848 /* 40 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_2,
10849 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10850 /* 41 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3,
10851 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10852 /* 42 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_2,
10853 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10854 /* 43 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmMinMax_2,
10855 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10856 /* 44 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_1,
10857 SW_SHOWMINIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10858 /* 45 */ { SW_MINIMIZE, TRUE, WS_VISIBLE|WS_MINIMIZE, WmMinMax_3,
10859 SW_SHOWMINIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10860 /* 46 */ { SW_RESTORE, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmRestore_3,
10861 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10862 /* 47 */ { SW_RESTORE, TRUE, WS_VISIBLE, WmRestore_4,
10863 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10864 /* 48 */ { SW_SHOWMAXIMIZED, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmShowMaximized_3,
10865 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10866 /* 49 */ { SW_SHOW, TRUE, WS_VISIBLE|WS_MAXIMIZE, WmEmptySeq,
10867 SW_SHOWMAXIMIZED, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10868 /* 50 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5,
10869 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10870 /* 51 */ { SW_SHOWNORMAL, TRUE, WS_VISIBLE, WmRestore_5,
10871 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10872 /* 52 */ { SW_HIDE, TRUE, 0, WmHide_1,
10873 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10874 /* 53 */ { SW_HIDE, FALSE, 0, WmEmptySeq,
10875 SW_SHOWNORMAL, WPF_RESTORETOMAXIMIZED, {-32000,-32000}, {-1,-1}, FALSE },
10876 /* 54 */ { SW_MINIMIZE, FALSE, WS_VISIBLE|WS_MINIMIZE, WmMinimize_3,
10877 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10878 /* 55 */ { SW_HIDE, TRUE, WS_MINIMIZE, WmHide_2,
10879 SW_SHOWMINIMIZED, 0, {-32000,-32000}, {-1,-1}, FALSE },
10880 /* 56 */ { SW_SHOWNOACTIVATE, FALSE, WS_VISIBLE, WmShowNoActivate_2,
10881 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE },
10882 /* 57 */ { SW_SHOW, TRUE, WS_VISIBLE, WmEmptySeq,
10883 SW_SHOWNORMAL, 0, {-32000,-32000}, {-1,-1}, FALSE }
10889 WINDOWPLACEMENT wp;
10890 RECT win_rc, work_rc = {0, 0, 0, 0};
10892 #define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
10893 hwnd = CreateWindowEx(0, "ShowWindowClass", NULL, WS_BASE,
10898 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
10899 ok(style == 0, "expected style 0, got %08x\n", style);
10904 if (pGetMonitorInfoA && pMonitorFromPoint)
10910 SetLastError(0xdeadbeef);
10911 hmon = pMonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
10912 ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
10914 mi.cbSize = sizeof(mi);
10915 SetLastError(0xdeadbeef);
10916 ret = pGetMonitorInfoA(hmon, &mi);
10917 ok(ret, "GetMonitorInfo error %u\n", GetLastError());
10918 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
10919 mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
10920 mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom);
10921 work_rc = mi.rcWork;
10924 GetWindowRect(hwnd, &win_rc);
10925 OffsetRect(&win_rc, -work_rc.left, -work_rc.top);
10927 wp.length = sizeof(wp);
10928 SetLastError(0xdeadbeaf);
10929 ret = GetWindowPlacement(hwnd, &wp);
10930 ok(ret, "GetWindowPlacement error %u\n", GetLastError());
10931 ok(wp.flags == 0, "expected 0, got %#x\n", wp.flags);
10932 ok(wp.showCmd == SW_SHOWNORMAL, "expected SW_SHOWNORMAL, got %d\n", wp.showCmd);
10933 ok(wp.ptMinPosition.x == -1 && wp.ptMinPosition.y == -1,
10934 "expected -1,-1 got %d,%d\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
10935 ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
10936 "expected -1,-1 got %d,%d\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
10937 if (work_rc.left || work_rc.top) todo_wine /* FIXME: remove once Wine is fixed */
10938 ok(EqualRect(&win_rc, &wp.rcNormalPosition),
10939 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10940 win_rc.left, win_rc.top, win_rc.right, win_rc.bottom,
10941 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
10942 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
10944 ok(EqualRect(&win_rc, &wp.rcNormalPosition),
10945 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
10946 win_rc.left, win_rc.top, win_rc.right, win_rc.bottom,
10947 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
10948 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
10950 for (i = 0; i < sizeof(sw)/sizeof(sw[0]); i++)
10952 static const char * const sw_cmd_name[13] =
10954 "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
10955 "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE", "SW_SHOWMINNOACTIVE",
10956 "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE",
10957 "SW_NORMALNA" /* 0xCC */
10960 INT idx; /* index into the above array of names */
10962 idx = (sw[i].cmd == SW_NORMALNA) ? 12 : sw[i].cmd;
10964 style = GetWindowLong(hwnd, GWL_STYLE);
10965 trace("%d: sending %s, current window style %08x\n", i+1, sw_cmd_name[idx], style);
10966 ret = ShowWindow(hwnd, sw[i].cmd);
10967 ok(!ret == !sw[i].ret, "%d: cmd %s: expected ret %lu, got %lu\n", i+1, sw_cmd_name[idx], sw[i].ret, ret);
10968 style = GetWindowLong(hwnd, GWL_STYLE) & ~WS_BASE;
10969 ok(style == sw[i].style, "%d: expected style %08x, got %08x\n", i+1, sw[i].style, style);
10971 sprintf(comment, "%d: ShowWindow(%s)", i+1, sw_cmd_name[idx]);
10972 ok_sequence(sw[i].msg, comment, sw[i].todo_msg);
10974 wp.length = sizeof(wp);
10975 SetLastError(0xdeadbeaf);
10976 ret = GetWindowPlacement(hwnd, &wp);
10977 ok(ret, "GetWindowPlacement error %u\n", GetLastError());
10978 ok(wp.flags == sw[i].wp_flags, "expected %#x, got %#x\n", sw[i].wp_flags, wp.flags);
10979 ok(wp.showCmd == sw[i].wp_cmd, "expected %d, got %d\n", sw[i].wp_cmd, wp.showCmd);
10981 /* NT moves the minimized window to -32000,-32000, win9x to 3000,3000 */
10982 if ((wp.ptMinPosition.x + work_rc.left == -32000 && wp.ptMinPosition.y + work_rc.top == -32000) ||
10983 (wp.ptMinPosition.x + work_rc.left == 3000 && wp.ptMinPosition.y + work_rc.top == 3000))
10985 ok((wp.ptMinPosition.x + work_rc.left == sw[i].wp_min.x && wp.ptMinPosition.y + work_rc.top == sw[i].wp_min.y) ||
10986 (wp.ptMinPosition.x + work_rc.left == 3000 && wp.ptMinPosition.y + work_rc.top == 3000),
10987 "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
10991 if (wp.ptMinPosition.x != sw[i].wp_min.x || wp.ptMinPosition.y != sw[i].wp_min.y)
10993 ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y,
10994 "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
10996 ok(wp.ptMinPosition.x == sw[i].wp_min.x && wp.ptMinPosition.y == sw[i].wp_min.y,
10997 "expected %d,%d got %d,%d\n", sw[i].wp_min.x, sw[i].wp_min.y, wp.ptMinPosition.x, wp.ptMinPosition.y);
11000 if (wp.ptMaxPosition.x != sw[i].wp_max.x || wp.ptMaxPosition.y != sw[i].wp_max.y)
11002 ok(wp.ptMaxPosition.x == sw[i].wp_max.x && wp.ptMaxPosition.y == sw[i].wp_max.y,
11003 "expected %d,%d got %d,%d\n", sw[i].wp_max.x, sw[i].wp_max.y, wp.ptMaxPosition.x, wp.ptMaxPosition.y);
11005 ok(wp.ptMaxPosition.x == sw[i].wp_max.x && wp.ptMaxPosition.y == sw[i].wp_max.y,
11006 "expected %d,%d got %d,%d\n", sw[i].wp_max.x, sw[i].wp_max.y, wp.ptMaxPosition.x, wp.ptMaxPosition.y);
11008 if (0) /* FIXME: Wine behaves completely different here */
11009 ok(EqualRect(&win_rc, &wp.rcNormalPosition),
11010 "expected %d,%d-%d,%d got %d,%d-%d,%d\n",
11011 win_rc.left, win_rc.top, win_rc.right, win_rc.bottom,
11012 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
11013 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom);
11019 DestroyWindow(hwnd);
11022 static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
11024 struct recvd_message msg;
11026 if (ignore_message( message )) return 0;
11029 msg.message = message;
11030 msg.flags = sent|wparam|lparam;
11031 msg.wParam = wParam;
11032 msg.lParam = lParam;
11033 msg.descr = "dialog";
11036 /* calling DefDlgProc leads to a recursion under XP */
11040 case WM_INITDIALOG:
11041 case WM_GETDLGCODE:
11047 static const struct message WmDefDlgSetFocus_1[] = {
11048 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
11049 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
11050 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
11051 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
11052 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11053 { HCBT_SETFOCUS, hook },
11054 { WM_IME_SETCONTEXT, sent|wparam|optional, 1 },
11055 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11056 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
11057 { WM_SETFOCUS, sent|wparam, 0 },
11058 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 10 },
11059 { WM_CTLCOLOREDIT, sent },
11060 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 11 },
11061 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11062 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11063 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11064 { WM_COMMAND, sent|wparam, MAKEWPARAM(1, EN_SETFOCUS) },
11067 static const struct message WmDefDlgSetFocus_2[] = {
11068 { WM_GETDLGCODE, sent|wparam|lparam, 0, 0 },
11069 { WM_GETTEXTLENGTH, sent|wparam|lparam|optional, 0, 0 }, /* XP */
11070 { WM_GETTEXT, sent|wparam|optional, 6 }, /* XP */
11071 { WM_GETTEXT, sent|wparam|optional, 12 }, /* XP */
11072 { EM_SETSEL, sent|wparam, 0 }, /* XP sets lparam to text length, Win9x to -2 */
11073 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11074 { WM_CTLCOLOREDIT, sent|optional }, /* XP */
11075 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, OBJID_CARET, 0 },
11078 /* Creation of a dialog */
11079 static const struct message WmCreateDialogParamSeq_1[] = {
11080 { HCBT_CREATEWND, hook },
11081 { WM_NCCREATE, sent },
11082 { WM_NCCALCSIZE, sent|wparam, 0 },
11083 { WM_CREATE, sent },
11084 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
11085 { WM_SIZE, sent|wparam, SIZE_RESTORED },
11087 { WM_SETFONT, sent },
11088 { WM_INITDIALOG, sent },
11089 { WM_CHANGEUISTATE, sent|optional },
11092 /* Creation of a dialog */
11093 static const struct message WmCreateDialogParamSeq_2[] = {
11094 { HCBT_CREATEWND, hook },
11095 { WM_NCCREATE, sent },
11096 { WM_NCCALCSIZE, sent|wparam, 0 },
11097 { WM_CREATE, sent },
11098 { EVENT_OBJECT_CREATE, winevent_hook|wparam|lparam, 0, 0 },
11099 { WM_SIZE, sent|wparam, SIZE_RESTORED },
11101 { WM_CHANGEUISTATE, sent|optional },
11105 static void test_dialog_messages(void)
11108 HWND hdlg, hedit1, hedit2, hfocus;
11111 #define set_selection(hctl, start, end) \
11112 ret = SendMessage(hctl, EM_SETSEL, start, end); \
11113 ok(ret == 1, "EM_SETSEL returned %ld\n", ret);
11115 #define check_selection(hctl, start, end) \
11116 ret = SendMessage(hctl, EM_GETSEL, 0, 0); \
11117 ok(ret == MAKELRESULT(start, end), "wrong selection (%d - %d)\n", LOWORD(ret), HIWORD(ret));
11121 hdlg = CreateWindowEx(WS_EX_DLGMODALFRAME, "TestDialogClass", NULL,
11122 WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_DLGFRAME,
11123 0, 0, 100, 100, 0, 0, 0, NULL);
11124 ok(hdlg != 0, "Failed to create custom dialog window\n");
11126 hedit1 = CreateWindowEx(0, "my_edit_class", NULL,
11127 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
11128 0, 0, 80, 20, hdlg, (HMENU)1, 0, NULL);
11129 ok(hedit1 != 0, "Failed to create edit control\n");
11130 hedit2 = CreateWindowEx(0, "my_edit_class", NULL,
11131 WS_CHILD|WS_BORDER|WS_VISIBLE|WS_TABSTOP,
11132 0, 40, 80, 20, hdlg, (HMENU)2, 0, NULL);
11133 ok(hedit2 != 0, "Failed to create edit control\n");
11135 SendMessage(hedit1, WM_SETTEXT, 0, (LPARAM)"hello");
11136 SendMessage(hedit2, WM_SETTEXT, 0, (LPARAM)"bye");
11138 hfocus = GetFocus();
11139 ok(hfocus == hdlg, "wrong focus %p\n", hfocus);
11142 hfocus = GetFocus();
11143 ok(hfocus == hedit2, "wrong focus %p\n", hfocus);
11145 check_selection(hedit1, 0, 0);
11146 check_selection(hedit2, 0, 0);
11148 set_selection(hedit2, 0, -1);
11149 check_selection(hedit2, 0, 3);
11152 hfocus = GetFocus();
11153 ok(hfocus == 0, "wrong focus %p\n", hfocus);
11156 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
11157 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
11158 ok_sequence(WmDefDlgSetFocus_1, "DefDlgProc(WM_SETFOCUS) 1", FALSE);
11160 hfocus = GetFocus();
11161 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
11163 check_selection(hedit1, 0, 5);
11164 check_selection(hedit2, 0, 3);
11167 ret = DefDlgProc(hdlg, WM_SETFOCUS, 0, 0);
11168 ok(ret == 0, "WM_SETFOCUS returned %ld\n", ret);
11169 ok_sequence(WmDefDlgSetFocus_2, "DefDlgProc(WM_SETFOCUS) 2", FALSE);
11171 hfocus = GetFocus();
11172 ok(hfocus == hedit1, "wrong focus %p\n", hfocus);
11174 check_selection(hedit1, 0, 5);
11175 check_selection(hedit2, 0, 3);
11177 EndDialog(hdlg, 0);
11178 DestroyWindow(hedit1);
11179 DestroyWindow(hedit2);
11180 DestroyWindow(hdlg);
11183 #undef set_selection
11184 #undef check_selection
11186 ok(GetClassInfo(0, "#32770", &cls), "GetClassInfo failed\n");
11187 cls.lpszClassName = "MyDialogClass";
11188 cls.hInstance = GetModuleHandle(0);
11189 /* need a cast since a dlgproc is used as a wndproc */
11190 cls.lpfnWndProc = (WNDPROC)test_dlg_proc;
11191 if (!RegisterClass(&cls)) assert(0);
11193 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, test_dlg_proc, 0);
11194 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
11195 ok_sequence(WmCreateDialogParamSeq_1, "CreateDialogParam_1", FALSE);
11196 EndDialog(hdlg, 0);
11197 DestroyWindow(hdlg);
11200 hdlg = CreateDialogParam(0, "CLASS_TEST_DIALOG_2", 0, NULL, 0);
11201 ok(IsWindow(hdlg), "CreateDialogParam failed\n");
11202 ok_sequence(WmCreateDialogParamSeq_2, "CreateDialogParam_2", FALSE);
11203 EndDialog(hdlg, 0);
11204 DestroyWindow(hdlg);
11207 UnregisterClass(cls.lpszClassName, cls.hInstance);
11210 static void test_nullCallback(void)
11214 hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
11215 100, 100, 200, 200, 0, 0, 0, NULL);
11216 ok (hwnd != 0, "Failed to create overlapped window\n");
11218 SendMessageCallbackA(hwnd,WM_NULL,0,0,NULL,0);
11220 DestroyWindow(hwnd);
11223 /* SetActiveWindow( 0 ) hwnd visible */
11224 static const struct message SetActiveWindowSeq0[] =
11226 { HCBT_ACTIVATE, hook|optional },
11227 { WM_NCACTIVATE, sent|wparam, 0 },
11228 { WM_GETTEXT, sent|defwinproc|optional },
11229 { WM_ACTIVATE, sent|wparam, 0 },
11230 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
11231 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
11232 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11233 { WM_KILLFOCUS, sent|optional },
11234 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11235 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
11236 { WM_NCACTIVATE, sent|wparam|optional, 1 },
11237 { WM_GETTEXT, sent|defwinproc|optional },
11238 { WM_ACTIVATE, sent|wparam|optional, 1 },
11239 { HCBT_SETFOCUS, hook|optional },
11240 { WM_KILLFOCUS, sent|defwinproc|optional },
11241 { WM_IME_SETCONTEXT, sent|defwinproc|optional },
11242 { WM_IME_SETCONTEXT, sent|defwinproc|optional },
11243 { WM_IME_SETCONTEXT, sent|optional },
11244 { WM_IME_SETCONTEXT, sent|optional },
11245 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
11246 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11247 { WM_SETFOCUS, sent|defwinproc|optional },
11248 { WM_GETTEXT, sent|optional },
11251 /* SetActiveWindow( hwnd ) hwnd visible */
11252 static const struct message SetActiveWindowSeq1[] =
11254 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11257 /* SetActiveWindow( popup ) hwnd visible, popup visible */
11258 static const struct message SetActiveWindowSeq2[] =
11260 { HCBT_ACTIVATE, hook },
11261 { WM_NCACTIVATE, sent|wparam, 0 },
11262 { WM_GETTEXT, sent|defwinproc|optional },
11263 { WM_ACTIVATE, sent|wparam, 0 },
11264 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11265 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
11266 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11267 { WM_NCPAINT, sent|optional },
11268 { WM_GETTEXT, sent|defwinproc|optional },
11269 { WM_ERASEBKGND, sent|optional },
11270 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11271 { WM_NCACTIVATE, sent|wparam, 1 },
11272 { WM_GETTEXT, sent|defwinproc|optional },
11273 { WM_ACTIVATE, sent|wparam, 1 },
11274 { HCBT_SETFOCUS, hook },
11275 { WM_KILLFOCUS, sent|defwinproc },
11276 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
11277 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11278 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
11279 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11280 { WM_SETFOCUS, sent|defwinproc },
11281 { WM_GETTEXT, sent|optional },
11285 /* SetActiveWindow( hwnd ) hwnd not visible */
11286 static const struct message SetActiveWindowSeq3[] =
11288 { HCBT_ACTIVATE, hook },
11289 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11290 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11291 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
11292 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOACTIVATE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11293 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11294 { WM_ACTIVATEAPP, sent|wparam, 1 },
11295 { WM_ACTIVATEAPP, sent|wparam, 1 },
11296 { WM_NCACTIVATE, sent|wparam, 1 },
11297 { WM_ACTIVATE, sent|wparam, 1 },
11298 { HCBT_SETFOCUS, hook },
11299 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11300 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11301 { WM_SETFOCUS, sent|defwinproc },
11304 /* SetActiveWindow( popup ) hwnd not visible, popup not visible */
11305 static const struct message SetActiveWindowSeq4[] =
11307 { HCBT_ACTIVATE, hook },
11308 { WM_NCACTIVATE, sent|wparam, 0 },
11309 { WM_GETTEXT, sent|defwinproc|optional },
11310 { WM_ACTIVATE, sent|wparam, 0 },
11311 { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 },
11312 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE },
11313 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
11314 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11315 { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
11316 { WM_NCACTIVATE, sent|wparam, 1 },
11317 { WM_GETTEXT, sent|defwinproc|optional },
11318 { WM_ACTIVATE, sent|wparam, 1 },
11319 { HCBT_SETFOCUS, hook },
11320 { WM_KILLFOCUS, sent|defwinproc },
11321 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 0 },
11322 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11323 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 1 },
11324 { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 },
11325 { WM_SETFOCUS, sent|defwinproc },
11330 static void test_SetActiveWindow(void)
11332 HWND hwnd, popup, ret;
11334 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11335 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11336 100, 100, 200, 200, 0, 0, 0, NULL);
11338 popup = CreateWindowExA(0, "TestWindowClass", "Test SetActiveWindow",
11339 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_POPUP,
11340 100, 100, 200, 200, hwnd, 0, 0, NULL);
11342 ok(hwnd != 0, "Failed to create overlapped window\n");
11343 ok(popup != 0, "Failed to create popup window\n");
11344 SetForegroundWindow( popup );
11347 trace("SetActiveWindow(0)\n");
11348 ret = SetActiveWindow(0);
11349 ok( ret == popup, "Failed to SetActiveWindow(0)\n");
11350 ok_sequence(SetActiveWindowSeq0, "SetActiveWindow(0)", FALSE);
11353 trace("SetActiveWindow(hwnd), hwnd visible\n");
11354 ret = SetActiveWindow(hwnd);
11355 if (ret == hwnd) ok_sequence(SetActiveWindowSeq1, "SetActiveWindow(hwnd), hwnd visible", TRUE);
11358 trace("SetActiveWindow(popup), hwnd visible, popup visible\n");
11359 ret = SetActiveWindow(popup);
11360 ok( ret == hwnd, "Failed to SetActiveWindow(popup), popup visible\n");
11361 ok_sequence(SetActiveWindowSeq2, "SetActiveWindow(popup), hwnd visible, popup visible", FALSE);
11364 ShowWindow(hwnd, SW_HIDE);
11365 ShowWindow(popup, SW_HIDE);
11368 trace("SetActiveWindow(hwnd), hwnd not visible\n");
11369 ret = SetActiveWindow(hwnd);
11370 ok( ret == NULL, "SetActiveWindow(hwnd), hwnd not visible, previous is %p\n", ret );
11371 ok_sequence(SetActiveWindowSeq3, "SetActiveWindow(hwnd), hwnd not visible", TRUE);
11374 trace("SetActiveWindow(popup), hwnd not visible, popup not visible\n");
11375 ret = SetActiveWindow(popup);
11376 ok( ret == hwnd, "Failed to SetActiveWindow(popup)\n");
11377 ok_sequence(SetActiveWindowSeq4, "SetActiveWindow(popup), hwnd not visible, popup not visible", TRUE);
11382 DestroyWindow(hwnd);
11385 static const struct message SetForegroundWindowSeq[] =
11387 { WM_NCACTIVATE, sent|wparam, 0 },
11388 { WM_GETTEXT, sent|defwinproc|optional },
11389 { WM_ACTIVATE, sent|wparam, 0 },
11390 { WM_ACTIVATEAPP, sent|wparam, 0 },
11391 { WM_KILLFOCUS, sent },
11392 { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
11393 { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 },
11397 static void test_SetForegroundWindow(void)
11401 hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow",
11402 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11403 100, 100, 200, 200, 0, 0, 0, NULL);
11404 ok (hwnd != 0, "Failed to create overlapped window\n");
11405 SetForegroundWindow( hwnd );
11408 trace("SetForegroundWindow( 0 )\n");
11409 SetForegroundWindow( 0 );
11410 ok_sequence(WmEmptySeq, "SetForegroundWindow( 0 ) away from foreground top level window", FALSE);
11411 trace("SetForegroundWindow( GetDesktopWindow() )\n");
11412 SetForegroundWindow( GetDesktopWindow() );
11413 ok_sequence(SetForegroundWindowSeq, "SetForegroundWindow( desktop ) away from "
11414 "foreground top level window", FALSE);
11417 DestroyWindow(hwnd);
11420 static void test_dbcs_wm_char(void)
11423 WCHAR wch, bad_wch;
11431 struct message wmCharSeq[2];
11433 if (!pGetCPInfoExA)
11435 win_skip("GetCPInfoExA is not available\n");
11439 pGetCPInfoExA( CP_ACP, 0, &cpinfo );
11440 if (cpinfo.MaxCharSize != 2)
11442 skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
11446 dbch[0] = dbch[1] = 0;
11448 bad_wch = cpinfo.UnicodeDefaultChar;
11449 for (i = 0; !wch && i < MAX_LEADBYTES && cpinfo.LeadByte[i]; i += 2)
11450 for (j = cpinfo.LeadByte[i]; !wch && j <= cpinfo.LeadByte[i+1]; j++)
11451 for (k = 128; k <= 255; k++)
11457 if (MultiByteToWideChar( CP_ACP, 0, str, 2, wstr, 2 ) == 1 &&
11458 WideCharToMultiByte( CP_ACP, 0, wstr, 1, str, 2, NULL, NULL ) == 2 &&
11459 (BYTE)str[0] == j && (BYTE)str[1] == k &&
11460 HIBYTE(wstr[0]) && HIBYTE(wstr[0]) != 0xff)
11471 skip( "Skipping DBCS WM_CHAR test, no appropriate char found\n" );
11474 trace( "using dbcs char %02x,%02x wchar %04x bad wchar %04x codepage '%s'\n",
11475 dbch[0], dbch[1], wch, bad_wch, cpinfo.CodePageName );
11477 hwnd = CreateWindowExW(0, testWindowClassW, NULL,
11478 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
11479 hwnd2 = CreateWindowExW(0, testWindowClassW, NULL,
11480 WS_OVERLAPPEDWINDOW, 100, 100, 200, 200, 0, 0, 0, NULL);
11481 ok (hwnd != 0, "Failed to create overlapped window\n");
11482 ok (hwnd2 != 0, "Failed to create overlapped window\n");
11485 memset( wmCharSeq, 0, sizeof(wmCharSeq) );
11486 wmCharSeq[0].message = WM_CHAR;
11487 wmCharSeq[0].flags = sent|wparam;
11488 wmCharSeq[0].wParam = wch;
11490 /* posted message */
11491 PostMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11492 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11493 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11494 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11495 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11496 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
11497 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11499 /* posted thread message */
11500 PostThreadMessageA( GetCurrentThreadId(), WM_CHAR, dbch[0], 0 );
11501 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11502 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11503 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11504 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11505 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
11506 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11510 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11511 ok_sequence( WmEmptySeq, "no messages", FALSE );
11512 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11513 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11514 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11516 /* sent message with timeout */
11518 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
11519 ok_sequence( WmEmptySeq, "no messages", FALSE );
11520 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
11521 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11522 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11524 /* sent message with timeout and callback */
11526 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[0], 0, SMTO_NORMAL, 0, &res );
11527 ok_sequence( WmEmptySeq, "no messages", FALSE );
11528 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
11529 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11530 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11532 /* sent message with callback */
11534 SendNotifyMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11535 ok_sequence( WmEmptySeq, "no messages", FALSE );
11536 SendMessageCallbackA( hwnd, WM_CHAR, dbch[1], 0, NULL, 0 );
11537 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11538 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11540 /* direct window proc call */
11542 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
11543 ok_sequence( WmEmptySeq, "no messages", FALSE );
11544 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
11545 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11547 /* dispatch message */
11549 msg.message = WM_CHAR;
11550 msg.wParam = dbch[0];
11552 DispatchMessageA( &msg );
11553 ok_sequence( WmEmptySeq, "no messages", FALSE );
11554 msg.wParam = dbch[1];
11555 DispatchMessageA( &msg );
11556 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11558 /* window handle is irrelevant */
11560 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
11561 ok_sequence( WmEmptySeq, "no messages", FALSE );
11562 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11563 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11564 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11566 /* interleaved post and send */
11568 PostMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
11569 SendMessageA( hwnd2, WM_CHAR, dbch[0], 0 );
11570 ok_sequence( WmEmptySeq, "no messages", FALSE );
11571 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11572 PostMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11573 ok_sequence( WmEmptySeq, "no messages", FALSE );
11574 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11575 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11576 ok( msg.wParam == wch, "bad wparam %lx/%x\n", msg.wParam, wch );
11577 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11578 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11579 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11580 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11582 /* interleaved sent message and winproc */
11584 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11585 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
11586 ok_sequence( WmEmptySeq, "no messages", FALSE );
11587 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11588 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11589 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
11590 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11592 /* interleaved winproc and dispatch */
11594 msg.message = WM_CHAR;
11595 msg.wParam = dbch[0];
11597 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[0], 0 );
11598 DispatchMessageA( &msg );
11599 ok_sequence( WmEmptySeq, "no messages", FALSE );
11600 msg.wParam = dbch[1];
11601 DispatchMessageA( &msg );
11602 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11603 CallWindowProcA( (WNDPROC)GetWindowLongPtrA( hwnd, GWLP_WNDPROC ), hwnd, WM_CHAR, dbch[1], 0 );
11604 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11606 /* interleaved sends */
11608 SendMessageA( hwnd, WM_CHAR, dbch[0], 0 );
11609 SendMessageCallbackA( hwnd, WM_CHAR, dbch[0], 0, NULL, 0 );
11610 ok_sequence( WmEmptySeq, "no messages", FALSE );
11611 SendMessageTimeoutA( hwnd, WM_CHAR, dbch[1], 0, SMTO_NORMAL, 0, &res );
11612 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11613 SendMessageA( hwnd, WM_CHAR, dbch[1], 0 );
11614 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11618 SendMessageA( hwnd2, WM_CHAR, (dbch[1] << 8) | dbch[0], 0 );
11619 ok_sequence( wmCharSeq, "Unicode WM_CHAR", FALSE );
11620 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11622 /* other char messages are not magic */
11623 PostMessageA( hwnd, WM_SYSCHAR, dbch[0], 0 );
11624 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11625 ok( msg.message == WM_SYSCHAR, "unexpected message %x\n", msg.message );
11626 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
11627 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11628 PostMessageA( hwnd, WM_DEADCHAR, dbch[0], 0 );
11629 ok( PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11630 ok( msg.message == WM_DEADCHAR, "unexpected message %x\n", msg.message );
11631 ok( msg.wParam == bad_wch, "bad wparam %lx/%x\n", msg.wParam, bad_wch );
11632 ok( !PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11634 /* test retrieving messages */
11636 PostMessageW( hwnd, WM_CHAR, wch, 0 );
11637 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11638 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11639 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11640 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11641 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11642 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11643 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11644 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11645 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11647 /* message filters */
11648 PostMessageW( hwnd, WM_CHAR, wch, 0 );
11649 ok( PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "no message\n" );
11650 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11651 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11652 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11653 /* message id is filtered, hwnd is not */
11654 ok( !PeekMessageA( &msg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ), "no message\n" );
11655 ok( PeekMessageA( &msg, hwnd2, 0, 0, PM_REMOVE ), "no message\n" );
11656 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11657 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11658 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11659 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11661 /* mixing GetMessage and PostMessage */
11662 PostMessageW( hwnd, WM_CHAR, wch, 0xbeef );
11663 ok( GetMessageA( &msg, hwnd, 0, 0 ), "no message\n" );
11664 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11665 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11666 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11667 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
11670 ok( time - GetTickCount() <= 100, "bad time %x\n", msg.time );
11671 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
11672 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11673 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11674 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11675 ok( msg.lParam == 0xbeef, "bad lparam %lx\n", msg.lParam );
11676 ok( msg.time == time, "bad time %x/%x\n", msg.time, time );
11677 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 );
11678 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11680 /* without PM_REMOVE */
11681 PostMessageW( hwnd, WM_CHAR, wch, 0 );
11682 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
11683 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11684 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11685 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11686 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
11687 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11688 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11689 ok( msg.wParam == dbch[0], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11690 ok( PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ), "no message\n" );
11691 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11692 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11693 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11694 ok( PeekMessageA( &msg, 0, 0, 0, PM_REMOVE ), "no message\n" );
11695 ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd );
11696 ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message );
11697 ok( msg.wParam == dbch[1], "bad wparam %lx/%x\n", msg.wParam, dbch[0] );
11698 ok( !PeekMessageA( &msg, hwnd, 0, 0, PM_REMOVE ), "got message %x\n", msg.message );
11700 DestroyWindow(hwnd);
11701 DestroyWindow(hwnd2);
11704 #define ID_LISTBOX 0x000f
11706 static const struct message wm_lb_setcursel_0[] =
11708 { LB_SETCURSEL, sent|wparam|lparam, 0, 0 },
11709 { WM_CTLCOLORLISTBOX, sent|parent },
11710 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
11711 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11712 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11715 static const struct message wm_lb_setcursel_1[] =
11717 { LB_SETCURSEL, sent|wparam|lparam, 1, 0 },
11718 { WM_CTLCOLORLISTBOX, sent|parent },
11719 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000020f2 },
11720 { WM_CTLCOLORLISTBOX, sent|parent },
11721 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000121f2 },
11722 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
11723 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 2 },
11726 static const struct message wm_lb_setcursel_2[] =
11728 { LB_SETCURSEL, sent|wparam|lparam, 2, 0 },
11729 { WM_CTLCOLORLISTBOX, sent|parent },
11730 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000021f2 },
11731 { WM_CTLCOLORLISTBOX, sent|parent },
11732 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000122f2 },
11733 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
11734 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
11737 static const struct message wm_lb_click_0[] =
11739 { WM_LBUTTONDOWN, sent|wparam|lparam, 0, MAKELPARAM(1,1) },
11740 { HCBT_SETFOCUS, hook },
11741 { WM_KILLFOCUS, sent|parent },
11742 { WM_IME_SETCONTEXT, sent|wparam|optional|parent, 0 },
11743 { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 },
11744 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
11745 { WM_SETFOCUS, sent|defwinproc },
11747 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001142f2 },
11748 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SETFOCUS) },
11749 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 3 },
11750 { WM_LBTRACKPOINT, sent|wparam|lparam|parent, 0, MAKELPARAM(1,1) },
11751 { EVENT_SYSTEM_CAPTURESTART, winevent_hook|wparam|lparam, 0, 0 },
11753 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000142f2 },
11754 { WM_CTLCOLORLISTBOX, sent|parent },
11755 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000022f2 },
11756 { WM_CTLCOLORLISTBOX, sent|parent },
11757 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x000120f2 },
11758 { WM_DRAWITEM, sent|wparam|lparam|parent, ID_LISTBOX, 0x001140f2 },
11760 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11761 { EVENT_OBJECT_SELECTION, winevent_hook|wparam|lparam, OBJID_CLIENT, 1 },
11763 { WM_LBUTTONUP, sent|wparam|lparam, 0, 0 },
11764 { EVENT_SYSTEM_CAPTUREEND, winevent_hook|wparam|lparam, 0, 0 },
11765 { WM_CAPTURECHANGED, sent|wparam|lparam|defwinproc, 0, 0 },
11766 { WM_COMMAND, sent|wparam|parent, MAKEWPARAM(ID_LISTBOX, LBN_SELCHANGE) },
11769 static const struct message wm_lb_deletestring[] =
11771 { LB_DELETESTRING, sent|wparam|lparam, 0, 0 },
11772 { WM_DELETEITEM, sent|wparam|parent|optional, ID_LISTBOX, 0 },
11773 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11774 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11777 static const struct message wm_lb_deletestring_reset[] =
11779 { LB_DELETESTRING, sent|wparam|lparam, 0, 0 },
11780 { LB_RESETCONTENT, sent|wparam|lparam|defwinproc|optional, 0, 0 },
11781 { WM_DELETEITEM, sent|wparam|parent|optional, ID_LISTBOX, 0 },
11782 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11783 { WM_DRAWITEM, sent|wparam|parent|optional, ID_LISTBOX },
11787 #define check_lb_state(a1, a2, a3, a4, a5) check_lb_state_dbg(a1, a2, a3, a4, a5, __LINE__)
11789 static LRESULT (WINAPI *listbox_orig_proc)(HWND, UINT, WPARAM, LPARAM);
11791 static LRESULT WINAPI listbox_hook_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
11793 static LONG defwndproc_counter = 0;
11795 struct recvd_message msg;
11797 /* do not log painting messages */
11798 if (message != WM_PAINT &&
11799 message != WM_NCPAINT &&
11800 message != WM_SYNCPAINT &&
11801 message != WM_ERASEBKGND &&
11802 message != WM_NCHITTEST &&
11803 message != WM_GETTEXT &&
11804 !ignore_message( message ))
11807 msg.message = message;
11808 msg.flags = sent|wparam|lparam;
11809 if (defwndproc_counter) msg.flags |= defwinproc;
11812 msg.descr = "listbox";
11816 defwndproc_counter++;
11817 ret = CallWindowProcA(listbox_orig_proc, hwnd, message, wp, lp);
11818 defwndproc_counter--;
11823 static void check_lb_state_dbg(HWND listbox, int count, int cur_sel,
11824 int caret_index, int top_index, int line)
11828 /* calling an orig proc helps to avoid unnecessary message logging */
11829 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCOUNT, 0, 0);
11830 ok_(__FILE__, line)(ret == count, "expected count %d, got %ld\n", count, ret);
11831 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCURSEL, 0, 0);
11832 ok_(__FILE__, line)(ret == cur_sel, "expected cur sel %d, got %ld\n", cur_sel, ret);
11833 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETCARETINDEX, 0, 0);
11834 ok_(__FILE__, line)(ret == caret_index ||
11835 broken(cur_sel == -1 && caret_index == 0 && ret == -1), /* nt4 */
11836 "expected caret index %d, got %ld\n", caret_index, ret);
11837 ret = CallWindowProcA(listbox_orig_proc, listbox, LB_GETTOPINDEX, 0, 0);
11838 ok_(__FILE__, line)(ret == top_index, "expected top index %d, got %ld\n", top_index, ret);
11841 static void test_listbox_messages(void)
11843 HWND parent, listbox;
11846 parent = CreateWindowExA(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
11847 100, 100, 200, 200, 0, 0, 0, NULL);
11848 listbox = CreateWindowExA(WS_EX_NOPARENTNOTIFY, "ListBox", NULL,
11849 WS_CHILD | LBS_NOTIFY | LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | WS_VISIBLE,
11850 10, 10, 80, 80, parent, (HMENU)ID_LISTBOX, 0, NULL);
11851 listbox_orig_proc = (WNDPROC)SetWindowLongPtrA(listbox, GWLP_WNDPROC, (ULONG_PTR)listbox_hook_proc);
11853 check_lb_state(listbox, 0, LB_ERR, 0, 0);
11855 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 0");
11856 ok(ret == 0, "expected 0, got %ld\n", ret);
11857 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 1");
11858 ok(ret == 1, "expected 1, got %ld\n", ret);
11859 ret = SendMessage(listbox, LB_ADDSTRING, 0, (LPARAM)"item 2");
11860 ok(ret == 2, "expected 2, got %ld\n", ret);
11862 check_lb_state(listbox, 3, LB_ERR, 0, 0);
11866 log_all_parent_messages++;
11868 trace("selecting item 0\n");
11869 ret = SendMessage(listbox, LB_SETCURSEL, 0, 0);
11870 ok(ret == 0, "expected 0, got %ld\n", ret);
11871 ok_sequence(wm_lb_setcursel_0, "LB_SETCURSEL 0", FALSE );
11872 check_lb_state(listbox, 3, 0, 0, 0);
11875 trace("selecting item 1\n");
11876 ret = SendMessage(listbox, LB_SETCURSEL, 1, 0);
11877 ok(ret == 1, "expected 1, got %ld\n", ret);
11878 ok_sequence(wm_lb_setcursel_1, "LB_SETCURSEL 1", FALSE );
11879 check_lb_state(listbox, 3, 1, 1, 0);
11881 trace("selecting item 2\n");
11882 ret = SendMessage(listbox, LB_SETCURSEL, 2, 0);
11883 ok(ret == 2, "expected 2, got %ld\n", ret);
11884 ok_sequence(wm_lb_setcursel_2, "LB_SETCURSEL 2", FALSE );
11885 check_lb_state(listbox, 3, 2, 2, 0);
11887 trace("clicking on item 0\n");
11888 ret = SendMessage(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(1, 1));
11889 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
11890 ret = SendMessage(listbox, WM_LBUTTONUP, 0, 0);
11891 ok(ret == LB_OKAY, "expected LB_OKAY, got %ld\n", ret);
11892 ok_sequence(wm_lb_click_0, "WM_LBUTTONDOWN 0", FALSE );
11893 check_lb_state(listbox, 3, 0, 0, 0);
11896 trace("deleting item 0\n");
11897 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
11898 ok(ret == 2, "expected 2, got %ld\n", ret);
11899 ok_sequence(wm_lb_deletestring, "LB_DELETESTRING 0", FALSE );
11900 check_lb_state(listbox, 2, -1, 0, 0);
11903 trace("deleting item 0\n");
11904 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
11905 ok(ret == 1, "expected 1, got %ld\n", ret);
11906 ok_sequence(wm_lb_deletestring, "LB_DELETESTRING 0", FALSE );
11907 check_lb_state(listbox, 1, -1, 0, 0);
11910 trace("deleting item 0\n");
11911 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
11912 ok(ret == 0, "expected 0, got %ld\n", ret);
11913 ok_sequence(wm_lb_deletestring_reset, "LB_DELETESTRING 0", FALSE );
11914 check_lb_state(listbox, 0, -1, 0, 0);
11917 trace("deleting item 0\n");
11918 ret = SendMessage(listbox, LB_DELETESTRING, 0, 0);
11919 ok(ret == LB_ERR, "expected LB_ERR, got %ld\n", ret);
11920 check_lb_state(listbox, 0, -1, 0, 0);
11923 log_all_parent_messages--;
11925 DestroyWindow(listbox);
11926 DestroyWindow(parent);
11929 /*************************** Menu test ******************************/
11930 static const struct message wm_popup_menu_1[] =
11932 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
11933 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
11934 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0x20000001 },
11935 { WM_SYSKEYDOWN, sent|wparam|lparam, 'E', 0x20000001 },
11936 { WM_SYSCHAR, sent|wparam|lparam, 'e', 0x20000001 },
11937 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'e' },
11938 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
11939 { WM_INITMENU, sent|lparam, 0, 0 },
11940 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(1,MF_HILITE|MF_POPUP) },
11941 { WM_INITMENUPOPUP, sent|lparam, 0, 1 },
11942 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't create a window */
11943 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(200,MF_HILITE) },
11944 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'E', 0xf0000001 },
11945 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
11946 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001, 0, 0x40000000 },
11947 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't create a window */
11948 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11949 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
11950 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
11951 { WM_MENUCOMMAND, sent }, /* |wparam, 200 - Win9x */
11952 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
11953 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
11956 static const struct message wm_popup_menu_2[] =
11958 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
11959 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
11960 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
11961 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
11962 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
11963 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
11964 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
11965 { WM_INITMENU, sent|lparam, 0, 0 },
11966 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
11967 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
11968 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
11969 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
11970 { HCBT_CREATEWND, hook },
11971 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
11972 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
11973 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
11974 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
11975 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
11976 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
11977 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
11978 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
11979 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
11980 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
11981 { HCBT_DESTROYWND, hook },
11982 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11983 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
11984 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
11985 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
11986 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
11987 { WM_MENUCOMMAND, sent }, /* |wparam, 100 - Win9x */
11988 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
11989 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
11992 static const struct message wm_popup_menu_3[] =
11994 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
11995 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
11996 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0x20000001 },
11997 { WM_SYSKEYDOWN, sent|wparam|lparam, 'F', 0x20000001 },
11998 { WM_SYSCHAR, sent|wparam|lparam, 'f', 0x20000001 },
11999 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'f' },
12000 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
12001 { WM_INITMENU, sent|lparam, 0, 0 },
12002 { WM_MENUSELECT, sent|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) },
12003 { WM_INITMENUPOPUP, sent|lparam, 0, 0 },
12004 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(0,MF_HILITE|MF_POPUP) }, /* Win9x */
12005 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x */
12006 { HCBT_CREATEWND, hook },
12007 { WM_MENUSELECT, sent }, /*|wparam, MAKEWPARAM(0,MF_HILITE|MF_POPUP) - XP
12008 |wparam, MAKEWPARAM(100,MF_HILITE) - Win9x */
12009 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'F', 0xf0000001 },
12010 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xd0000001 },
12011 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0x10000001 },
12012 { WM_INITMENUPOPUP, sent|lparam|optional, 0, 0 }, /* Win9x doesn't send it */
12013 { HCBT_CREATEWND, hook|optional }, /* Win9x doesn't send it */
12014 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(100,MF_HILITE) },
12015 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RIGHT, 0xd0000001 },
12016 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0x10000001 },
12017 { HCBT_DESTROYWND, hook },
12018 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12019 { HCBT_DESTROYWND, hook|optional }, /* Win9x doesn't send it */
12020 { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 },
12021 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
12022 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
12023 { WM_COMMAND, sent|wparam|lparam, 100, 0 },
12024 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_RETURN, 0xc0000001 },
12025 { WM_KEYUP, sent|wparam|lparam, VK_RETURN, 0xc0000001 },
12029 static const struct message wm_single_menu_item[] =
12031 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0x20000001 },
12032 { WM_SYSKEYDOWN, sent|wparam|lparam, VK_MENU, 0x20000001 },
12033 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'Q', 0x20000001 },
12034 { WM_SYSKEYDOWN, sent|wparam|lparam, 'Q', 0x20000001 },
12035 { WM_SYSCHAR, sent|wparam|lparam, 'q', 0x20000001 },
12036 { HCBT_SYSCOMMAND, hook|wparam|lparam, SC_KEYMENU, 'q' },
12037 { WM_ENTERMENULOOP, sent|wparam|lparam, 0, 0 },
12038 { WM_INITMENU, sent|lparam, 0, 0 },
12039 { WM_MENUSELECT, sent|wparam|optional, MAKEWPARAM(300,MF_HILITE) },
12040 { WM_MENUSELECT, sent|wparam|lparam, MAKEWPARAM(0,0xffff), 0 },
12041 { WM_EXITMENULOOP, sent|wparam|lparam, 0, 0 },
12042 { WM_MENUCOMMAND, sent },
12043 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 'Q', 0xe0000001 },
12044 { WM_SYSKEYUP, sent|wparam|lparam, 'Q', 0xe0000001 },
12045 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_MENU, 0xc0000001 },
12046 { WM_KEYUP, sent|wparam|lparam, VK_MENU, 0xc0000001 },
12048 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 1 },
12049 { WM_KEYDOWN, sent|wparam|lparam, VK_ESCAPE, 1 },
12050 { WM_CHAR, sent|wparam|lparam, VK_ESCAPE, 0x00000001 },
12051 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_ESCAPE, 0xc0000001 },
12052 { WM_KEYUP, sent|wparam|lparam, VK_ESCAPE, 0xc0000001 },
12056 static LRESULT WINAPI parent_menu_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
12058 if (message == WM_ENTERIDLE ||
12059 message == WM_INITMENU ||
12060 message == WM_INITMENUPOPUP ||
12061 message == WM_MENUSELECT ||
12062 message == WM_PARENTNOTIFY ||
12063 message == WM_ENTERMENULOOP ||
12064 message == WM_EXITMENULOOP ||
12065 message == WM_UNINITMENUPOPUP ||
12066 message == WM_KEYDOWN ||
12067 message == WM_KEYUP ||
12068 message == WM_CHAR ||
12069 message == WM_SYSKEYDOWN ||
12070 message == WM_SYSKEYUP ||
12071 message == WM_SYSCHAR ||
12072 message == WM_COMMAND ||
12073 message == WM_MENUCOMMAND)
12075 struct recvd_message msg;
12078 msg.message = message;
12079 msg.flags = sent|wparam|lparam;
12082 msg.descr = "parent_menu_proc";
12086 return DefWindowProcA(hwnd, message, wp, lp);
12089 static void set_menu_style(HMENU hmenu, DWORD style)
12094 mi.cbSize = sizeof(mi);
12095 mi.fMask = MIM_STYLE;
12096 mi.dwStyle = style;
12097 SetLastError(0xdeadbeef);
12098 ret = pSetMenuInfo(hmenu, &mi);
12099 ok(ret, "SetMenuInfo error %u\n", GetLastError());
12102 static DWORD get_menu_style(HMENU hmenu)
12107 mi.cbSize = sizeof(mi);
12108 mi.fMask = MIM_STYLE;
12110 SetLastError(0xdeadbeef);
12111 ret = pGetMenuInfo(hmenu, &mi);
12112 ok(ret, "GetMenuInfo error %u\n", GetLastError());
12117 static void test_menu_messages(void)
12121 HMENU hmenu, hmenu_popup;
12125 if (!pGetMenuInfo || !pSetMenuInfo)
12127 win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
12131 cls.lpfnWndProc = parent_menu_proc;
12132 cls.cbClsExtra = 0;
12133 cls.cbWndExtra = 0;
12134 cls.hInstance = GetModuleHandleA(0);
12136 cls.hCursor = LoadCursorA(0, IDC_ARROW);
12137 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
12138 cls.lpszMenuName = NULL;
12139 cls.lpszClassName = "TestMenuClass";
12140 UnregisterClass(cls.lpszClassName, cls.hInstance);
12141 if (!RegisterClassA(&cls)) assert(0);
12143 SetLastError(0xdeadbeef);
12144 hwnd = CreateWindowExA(0, "TestMenuClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
12145 100, 100, 200, 200, 0, 0, 0, NULL);
12146 ok(hwnd != 0, "LoadMenuA error %u\n", GetLastError());
12148 SetLastError(0xdeadbeef);
12149 hmenu = LoadMenuA(GetModuleHandle(0), MAKEINTRESOURCE(1));
12150 ok(hmenu != 0, "LoadMenuA error %u\n", GetLastError());
12152 SetMenu(hwnd, hmenu);
12153 SetForegroundWindow( hwnd );
12155 set_menu_style(hmenu, MNS_NOTIFYBYPOS);
12156 style = get_menu_style(hmenu);
12157 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
12159 hmenu_popup = GetSubMenu(hmenu, 0);
12160 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12161 style = get_menu_style(hmenu_popup);
12162 ok(style == 0, "expected 0, got %u\n", style);
12164 hmenu_popup = GetSubMenu(hmenu_popup, 0);
12165 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12166 style = get_menu_style(hmenu_popup);
12167 ok(style == 0, "expected 0, got %u\n", style);
12170 trace("testing a popup menu command\n");
12172 keybd_event(VK_MENU, 0, 0, 0);
12173 keybd_event('E', 0, 0, 0);
12174 keybd_event('E', 0, KEYEVENTF_KEYUP, 0);
12175 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12176 keybd_event(VK_RETURN, 0, 0, 0);
12177 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
12178 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12180 TranslateMessage(&msg);
12181 DispatchMessage(&msg);
12183 if (!sequence_cnt) /* we didn't get any message */
12185 skip( "queuing key events not supported\n" );
12188 /* win98 queues only a WM_KEYUP and doesn't start menu tracking */
12189 if (sequence[0].message == WM_KEYUP && sequence[0].wParam == VK_MENU)
12191 win_skip( "menu tracking through VK_MENU not supported\n" );
12194 ok_sequence(wm_popup_menu_1, "popup menu command", FALSE);
12196 /* Alt+F, Right, Enter */
12197 trace("testing submenu of a popup menu command\n");
12199 keybd_event(VK_MENU, 0, 0, 0);
12200 keybd_event('F', 0, 0, 0);
12201 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
12202 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12203 keybd_event(VK_RIGHT, 0, 0, 0);
12204 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
12205 keybd_event(VK_RETURN, 0, 0, 0);
12206 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
12207 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12209 TranslateMessage(&msg);
12210 DispatchMessage(&msg);
12212 ok_sequence(wm_popup_menu_2, "submenu of a popup menu command", FALSE);
12214 trace("testing single menu item command\n");
12216 keybd_event(VK_MENU, 0, 0, 0);
12217 keybd_event('Q', 0, 0, 0);
12218 keybd_event('Q', 0, KEYEVENTF_KEYUP, 0);
12219 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12220 keybd_event(VK_ESCAPE, 0, 0, 0);
12221 keybd_event(VK_ESCAPE, 0, KEYEVENTF_KEYUP, 0);
12222 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12224 TranslateMessage(&msg);
12225 DispatchMessage(&msg);
12227 ok_sequence(wm_single_menu_item, "single menu item command", FALSE);
12229 set_menu_style(hmenu, 0);
12230 style = get_menu_style(hmenu);
12231 ok(style == 0, "expected 0, got %u\n", style);
12233 hmenu_popup = GetSubMenu(hmenu, 0);
12234 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12235 set_menu_style(hmenu_popup, MNS_NOTIFYBYPOS);
12236 style = get_menu_style(hmenu_popup);
12237 ok(style == MNS_NOTIFYBYPOS, "expected MNS_NOTIFYBYPOS, got %u\n", style);
12239 hmenu_popup = GetSubMenu(hmenu_popup, 0);
12240 ok(hmenu_popup != 0, "GetSubMenu returned 0 for submenu 0\n");
12241 style = get_menu_style(hmenu_popup);
12242 ok(style == 0, "expected 0, got %u\n", style);
12244 /* Alt+F, Right, Enter */
12245 trace("testing submenu of a popup menu command\n");
12247 keybd_event(VK_MENU, 0, 0, 0);
12248 keybd_event('F', 0, 0, 0);
12249 keybd_event('F', 0, KEYEVENTF_KEYUP, 0);
12250 keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0);
12251 keybd_event(VK_RIGHT, 0, 0, 0);
12252 keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0);
12253 keybd_event(VK_RETURN, 0, 0, 0);
12254 keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
12255 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
12257 TranslateMessage(&msg);
12258 DispatchMessage(&msg);
12260 ok_sequence(wm_popup_menu_3, "submenu of a popup menu command", FALSE);
12263 DestroyWindow(hwnd);
12264 DestroyMenu(hmenu);
12268 static void test_paintingloop(void)
12272 paint_loop_done = 0;
12273 hwnd = CreateWindowExA(0x0,"PaintLoopWindowClass",
12274 "PaintLoopWindowClass",WS_OVERLAPPEDWINDOW,
12275 100, 100, 100, 100, 0, 0, 0, NULL );
12276 ok(hwnd != 0, "PaintLoop window error %u\n", GetLastError());
12277 ShowWindow(hwnd,SW_NORMAL);
12280 while (!paint_loop_done)
12283 if (PeekMessageA(&msg, 0, 0, 0, 1))
12285 TranslateMessage(&msg);
12286 DispatchMessage(&msg);
12289 DestroyWindow(hwnd);
12292 static void test_defwinproc(void)
12296 int gotwmquit = FALSE;
12297 hwnd = CreateWindowExA(0, "static", "test_defwndproc", WS_POPUP, 0,0,0,0,0,0,0, NULL);
12299 DefWindowProcA( hwnd, WM_ENDSESSION, 1, 0);
12300 while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) {
12301 if( msg.message == WM_QUIT) gotwmquit = TRUE;
12302 DispatchMessageA( &msg );
12304 ok( gotwmquit == FALSE, "Unexpected WM_QUIT message!\n");
12305 DestroyWindow( hwnd);
12308 #define clear_clipboard(hwnd) clear_clipboard_(__LINE__, (hwnd))
12309 static void clear_clipboard_(int line, HWND hWnd)
12312 succ = OpenClipboard(hWnd);
12313 ok_(__FILE__, line)(succ, "OpenClipboard failed, err=%u\n", GetLastError());
12314 succ = EmptyClipboard();
12315 ok_(__FILE__, line)(succ, "EmptyClipboard failed, err=%u\n", GetLastError());
12316 succ = CloseClipboard();
12317 ok_(__FILE__, line)(succ, "CloseClipboard failed, err=%u\n", GetLastError());
12320 #define expect_HWND(expected, got) expect_HWND_(__LINE__, (expected), (got))
12321 static void expect_HWND_(int line, HWND expected, HWND got)
12323 ok_(__FILE__, line)(got==expected, "Expected %p, got %p\n", expected, got);
12326 static WNDPROC pOldViewerProc;
12328 static LRESULT CALLBACK recursive_viewer_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12330 static BOOL recursion_guard;
12332 if (message == WM_DRAWCLIPBOARD && !recursion_guard)
12334 recursion_guard = TRUE;
12335 clear_clipboard(hWnd);
12336 recursion_guard = FALSE;
12338 return CallWindowProcA(pOldViewerProc, hWnd, message, wParam, lParam);
12341 static void test_clipboard_viewers(void)
12343 static struct message wm_change_cb_chain[] =
12345 { WM_CHANGECBCHAIN, sent|wparam|lparam, 0, 0 },
12348 static const struct message wm_clipboard_destroyed[] =
12350 { WM_DESTROYCLIPBOARD, sent|wparam|lparam, 0, 0 },
12353 static struct message wm_clipboard_changed[] =
12355 { WM_DRAWCLIPBOARD, sent|wparam|lparam, 0, 0 },
12358 static struct message wm_clipboard_changed_and_owned[] =
12360 { WM_DESTROYCLIPBOARD, sent|wparam|lparam, 0, 0 },
12361 { WM_DRAWCLIPBOARD, sent|wparam|lparam, 0, 0 },
12365 HINSTANCE hInst = GetModuleHandleA(NULL);
12366 HWND hWnd1, hWnd2, hWnd3;
12370 hWnd1 = CreateWindowExA(0, "TestWindowClass", "Clipboard viewer test wnd 1",
12371 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
12372 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
12373 GetDesktopWindow(), NULL, hInst, NULL);
12374 hWnd2 = CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 2",
12375 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
12376 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
12377 GetDesktopWindow(), NULL, hInst, NULL);
12378 hWnd3 = CreateWindowExA(0, "SimpleWindowClass", "Clipboard viewer test wnd 3",
12379 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
12380 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
12381 GetDesktopWindow(), NULL, hInst, NULL);
12382 trace("clipbd viewers: hWnd1=%p, hWnd2=%p, hWnd3=%p\n", hWnd1, hWnd2, hWnd3);
12383 assert(hWnd1 && hWnd2 && hWnd3);
12387 /* Test getting the clipboard viewer and setting the viewer to NULL. */
12388 hOrigViewer = GetClipboardViewer();
12389 hRet = SetClipboardViewer(NULL);
12390 ok_sequence(WmEmptySeq, "set viewer to NULL", FALSE);
12391 expect_HWND(hOrigViewer, hRet);
12392 expect_HWND(NULL, GetClipboardViewer());
12394 /* Test registering hWnd1 as a viewer. */
12395 hRet = SetClipboardViewer(hWnd1);
12396 wm_clipboard_changed[0].wParam = (WPARAM) GetClipboardOwner();
12397 ok_sequence(wm_clipboard_changed, "set viewer NULL->1", FALSE);
12398 expect_HWND(NULL, hRet);
12399 expect_HWND(hWnd1, GetClipboardViewer());
12401 /* Test that changing the clipboard actually refreshes the registered viewer. */
12402 clear_clipboard(hWnd1);
12403 wm_clipboard_changed[0].wParam = (WPARAM) GetClipboardOwner();
12404 ok_sequence(wm_clipboard_changed, "clear clipbd (viewer=owner=1)", FALSE);
12406 /* Again, but with different owner. */
12407 clear_clipboard(hWnd2);
12408 wm_clipboard_changed_and_owned[1].wParam = (WPARAM) GetClipboardOwner();
12409 ok_sequence(wm_clipboard_changed_and_owned, "clear clipbd (viewer=1, owner=2)", FALSE);
12411 /* Test re-registering same window. */
12412 hRet = SetClipboardViewer(hWnd1);
12413 wm_clipboard_changed[0].wParam = (WPARAM) GetClipboardOwner();
12414 ok_sequence(wm_clipboard_changed, "set viewer 1->1", FALSE);
12415 expect_HWND(hWnd1, hRet);
12416 expect_HWND(hWnd1, GetClipboardViewer());
12418 /* Test ChangeClipboardChain. */
12419 ChangeClipboardChain(hWnd2, hWnd3);
12420 wm_change_cb_chain[0].wParam = (WPARAM) hWnd2;
12421 wm_change_cb_chain[0].lParam = (LPARAM) hWnd3;
12422 ok_sequence(wm_change_cb_chain, "change chain (viewer=1, remove=2, next=3)", FALSE);
12423 expect_HWND(hWnd1, GetClipboardViewer());
12425 ChangeClipboardChain(hWnd2, NULL);
12426 wm_change_cb_chain[0].wParam = (WPARAM) hWnd2;
12427 wm_change_cb_chain[0].lParam = 0;
12428 ok_sequence(wm_change_cb_chain, "change chain (viewer=1, remove=2, next=NULL)", FALSE);
12429 expect_HWND(hWnd1, GetClipboardViewer());
12431 ChangeClipboardChain(NULL, hWnd2);
12432 ok_sequence(WmEmptySeq, "change chain (viewer=1, remove=NULL, next=2)", TRUE);
12433 expect_HWND(hWnd1, GetClipboardViewer());
12435 /* Actually change clipboard viewer with ChangeClipboardChain. */
12436 ChangeClipboardChain(hWnd1, hWnd2);
12437 ok_sequence(WmEmptySeq, "change chain (viewer=remove=1, next=2)", FALSE);
12438 expect_HWND(hWnd2, GetClipboardViewer());
12440 /* Test that no refresh messages are sent when viewer has unregistered. */
12441 clear_clipboard(hWnd2);
12442 ok_sequence(WmEmptySeq, "clear clipd (viewer=2, owner=1)", FALSE);
12444 /* Register hWnd1 again. */
12445 ChangeClipboardChain(hWnd2, hWnd1);
12446 ok_sequence(WmEmptySeq, "change chain (viewer=remove=2, next=1)", FALSE);
12447 expect_HWND(hWnd1, GetClipboardViewer());
12449 /* Subclass hWnd1 so that when it receives a WM_DRAWCLIPBOARD message, it
12450 * changes the clipboard. When this happens, the system shouldn't send
12451 * another WM_DRAWCLIPBOARD (as this could cause an infinite loop).
12453 pOldViewerProc = (WNDPROC) SetWindowLongPtrA(hWnd1, GWLP_WNDPROC, (LONG_PTR) recursive_viewer_proc);
12454 clear_clipboard(hWnd2);
12455 /* The clipboard owner is changed in recursive_viewer_proc: */
12456 wm_clipboard_changed[0].wParam = (WPARAM) hWnd2;
12457 ok_sequence(wm_clipboard_changed, "recursive clear clipbd (viewer=1, owner=2)", TRUE);
12459 /* Test unregistering. */
12460 ChangeClipboardChain(hWnd1, NULL);
12461 ok_sequence(WmEmptySeq, "change chain (viewer=remove=1, next=NULL)", FALSE);
12462 expect_HWND(NULL, GetClipboardViewer());
12464 clear_clipboard(hWnd1);
12465 ok_sequence(wm_clipboard_destroyed, "clear clipbd (no viewer, owner=1)", FALSE);
12467 DestroyWindow(hWnd1);
12468 DestroyWindow(hWnd2);
12469 DestroyWindow(hWnd3);
12470 SetClipboardViewer(hOrigViewer);
12473 static void test_PostMessage(void)
12475 static const struct
12481 { HWND_TOP /* 0 */, TRUE },
12482 { HWND_BROADCAST, TRUE },
12483 { HWND_BOTTOM, TRUE },
12484 { HWND_TOPMOST, TRUE },
12485 { HWND_NOTOPMOST, FALSE },
12486 { HWND_MESSAGE, FALSE },
12487 { (HWND)0xdeadbeef, FALSE }
12493 static const WCHAR staticW[] = {'s','t','a','t','i','c',0};
12495 SetLastError(0xdeadbeef);
12496 hwnd = CreateWindowExW(0, staticW, NULL, WS_POPUP, 0,0,0,0,0,0,0, NULL);
12497 if (!hwnd && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
12499 win_skip("Skipping some PostMessage tests on Win9x/WinMe\n");
12506 PostMessage(hwnd, WM_USER+1, 0x1234, 0x5678);
12507 PostMessage(0, WM_USER+2, 0x5678, 0x1234);
12509 for (i = 0; i < sizeof(data)/sizeof(data[0]); i++)
12511 memset(&msg, 0xab, sizeof(msg));
12512 ret = PeekMessageA(&msg, data[i].hwnd, 0, 0, PM_NOREMOVE);
12513 ok(ret == data[i].ret, "%d: hwnd %p expected %d, got %d\n", i, data[i].hwnd, data[i].ret, ret);
12517 ok(ret && msg.hwnd == 0 && msg.message == WM_USER+2 &&
12518 msg.wParam == 0x5678 && msg.lParam == 0x1234,
12519 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/0/WM_USER+2/0x5678/0x1234\n",
12520 i, ret, msg.hwnd, msg.message, msg.wParam, msg.lParam);
12522 ok(ret && msg.hwnd == hwnd && msg.message == WM_USER+1 &&
12523 msg.wParam == 0x1234 && msg.lParam == 0x5678,
12524 "%d: got ret %d hwnd %p msg %04x wParam %08lx lParam %08lx instead of TRUE/%p/WM_USER+1/0x1234/0x5678\n",
12525 i, ret, msg.hwnd, msg.message, msg.wParam, msg.lParam, msg.hwnd);
12529 DestroyWindow(hwnd);
12533 static const struct
12537 } wait_idle_expect[] =
12539 /* 0 */ { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12540 { WAIT_TIMEOUT, 0, FALSE },
12541 { WAIT_TIMEOUT, 0, FALSE },
12542 { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12543 { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12544 /* 5 */ { WAIT_TIMEOUT, 0, FALSE },
12545 { WAIT_TIMEOUT, 0, FALSE },
12546 { WAIT_TIMEOUT, WAIT_TIMEOUT, FALSE },
12549 /* 10 */ { 0, 0, FALSE },
12551 { 0, WAIT_TIMEOUT, FALSE },
12554 /* 15 */ { 0, 0, FALSE },
12555 { WAIT_TIMEOUT, 0, FALSE },
12556 { WAIT_TIMEOUT, 0, FALSE },
12557 { WAIT_TIMEOUT, 0, FALSE },
12558 { WAIT_TIMEOUT, 0, FALSE },
12559 /* 20 */ { WAIT_TIMEOUT, 0, FALSE },
12562 static DWORD CALLBACK do_wait_idle_child_thread( void *arg )
12566 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12568 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
12572 static void do_wait_idle_child( int arg )
12579 HANDLE start_event = OpenEventA( EVENT_ALL_ACCESS, FALSE, "test_WaitForInputIdle_start" );
12580 HANDLE end_event = OpenEventA( EVENT_ALL_ACCESS, FALSE, "test_WaitForInputIdle_end" );
12582 memset( &cls, 0, sizeof(cls) );
12583 cls.lpfnWndProc = DefWindowProc;
12584 cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
12585 cls.hCursor = LoadCursor(0, IDC_ARROW);
12586 cls.lpszClassName = "TestClass";
12587 RegisterClass( &cls );
12589 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ); /* create the msg queue */
12591 ok( start_event != 0, "failed to create start event, error %u\n", GetLastError() );
12592 ok( end_event != 0, "failed to create end event, error %u\n", GetLastError() );
12597 SetEvent( start_event );
12600 SetEvent( start_event );
12602 PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
12605 SetEvent( start_event );
12607 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12608 PostThreadMessage( GetCurrentThreadId(), WM_COMMAND, 0x1234, 0xabcd );
12609 PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
12612 SetEvent( start_event );
12614 SendMessage( HWND_BROADCAST, WM_WININICHANGE, 0, 0 );
12617 SetEvent( start_event );
12619 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12620 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessage( &msg );
12623 SetEvent( start_event );
12625 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12626 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
12629 SetEvent( start_event );
12631 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12632 while (PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ))
12634 GetMessage( &msg, 0, 0, 0 );
12635 DispatchMessage( &msg );
12639 SetEvent( start_event );
12641 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12642 SetTimer( hwnd, 3, 1, NULL );
12644 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE|PM_NOYIELD )) DispatchMessage( &msg );
12647 SetEvent( start_event );
12649 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12650 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
12653 SetEvent( start_event );
12655 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12656 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
12657 for (;;) GetMessage( &msg, 0, 0, 0 );
12660 SetEvent( start_event );
12662 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
12663 SetTimer( hwnd, 3, 1, NULL );
12665 while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
12668 SetEvent( start_event );
12670 return; /* exiting the process makes WaitForInputIdle return success too */
12672 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12674 MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT );
12675 SetEvent( start_event );
12678 SetEvent( start_event );
12679 PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE );
12681 thread = CreateThread( NULL, 0, do_wait_idle_child_thread, NULL, 0, &id );
12682 WaitForSingleObject( thread, 10000 );
12683 CloseHandle( thread );
12686 SetEvent( start_event );
12688 PeekMessage( &msg, HWND_TOPMOST, 0, 0, PM_NOREMOVE );
12691 SetEvent( start_event );
12693 PeekMessage( &msg, HWND_BROADCAST, 0, 0, PM_NOREMOVE );
12696 SetEvent( start_event );
12698 PeekMessage( &msg, HWND_BOTTOM, 0, 0, PM_NOREMOVE );
12701 SetEvent( start_event );
12703 PeekMessage( &msg, (HWND)0xdeadbeef, 0, 0, PM_NOREMOVE );
12706 SetEvent( start_event );
12708 PeekMessage( &msg, HWND_NOTOPMOST, 0, 0, PM_NOREMOVE );
12711 SetEvent( start_event );
12713 PeekMessage( &msg, HWND_MESSAGE, 0, 0, PM_NOREMOVE );
12716 SetEvent( start_event );
12718 PeekMessage( &msg, GetDesktopWindow(), 0, 0, PM_NOREMOVE );
12721 WaitForSingleObject( end_event, 2000 );
12722 CloseHandle( start_event );
12723 CloseHandle( end_event );
12724 if (hwnd) DestroyWindow( hwnd );
12727 static LRESULT CALLBACK wait_idle_proc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
12729 if (msg == WM_WININICHANGE) Sleep( 200 ); /* make sure the child waits */
12730 return DefWindowProcA( hwnd, msg, wp, lp );
12733 static DWORD CALLBACK wait_idle_thread( void *arg )
12739 memset( &cls, 0, sizeof(cls) );
12740 cls.lpfnWndProc = wait_idle_proc;
12741 cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
12742 cls.hCursor = LoadCursor(0, IDC_ARROW);
12743 cls.lpszClassName = "TestClass";
12744 RegisterClass( &cls );
12746 hwnd = CreateWindowExA(0, "TestClass", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
12747 while (GetMessage( &msg, 0, 0, 0 )) DispatchMessage( &msg );
12748 DestroyWindow(hwnd);
12752 static void test_WaitForInputIdle( char *argv0 )
12754 char path[MAX_PATH];
12755 PROCESS_INFORMATION pi;
12756 STARTUPINFOA startup;
12758 HANDLE start_event, end_event, thread;
12761 const IMAGE_DOS_HEADER *dos = (const IMAGE_DOS_HEADER *)GetModuleHandleA(0);
12762 const IMAGE_NT_HEADERS *nt = (const IMAGE_NT_HEADERS *)((const char *)dos + dos->e_lfanew);
12763 BOOL console_app = (nt->OptionalHeader.Subsystem != IMAGE_SUBSYSTEM_WINDOWS_GUI);
12765 if (console_app) /* build the test with -mwindows for better coverage */
12766 trace( "not built as a GUI app, WaitForInputIdle may not be fully tested\n" );
12768 start_event = CreateEventA(NULL, 0, 0, "test_WaitForInputIdle_start");
12769 end_event = CreateEventA(NULL, 0, 0, "test_WaitForInputIdle_end");
12770 ok(start_event != 0, "failed to create start event, error %u\n", GetLastError());
12771 ok(end_event != 0, "failed to create end event, error %u\n", GetLastError());
12773 memset( &startup, 0, sizeof(startup) );
12774 startup.cb = sizeof(startup);
12775 startup.dwFlags = STARTF_USESHOWWINDOW;
12776 startup.wShowWindow = SW_SHOWNORMAL;
12778 thread = CreateThread( NULL, 0, wait_idle_thread, NULL, 0, &id );
12780 for (i = 0; i < sizeof(wait_idle_expect)/sizeof(wait_idle_expect[0]); i++)
12782 ResetEvent( start_event );
12783 ResetEvent( end_event );
12784 sprintf( path, "%s msg %u", argv0, i );
12785 ret = CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &pi );
12786 ok( ret, "CreateProcess '%s' failed err %u.\n", path, GetLastError() );
12789 ret = WaitForSingleObject( start_event, 5000 );
12790 ok( ret == WAIT_OBJECT_0, "%u: WaitForSingleObject failed\n", i );
12791 if (ret == WAIT_OBJECT_0)
12793 ret = WaitForInputIdle( pi.hProcess, 1000 );
12794 if (ret == WAIT_FAILED)
12796 ret == wait_idle_expect[i].exp ||
12797 broken(ret == wait_idle_expect[i].broken),
12798 "%u: WaitForInputIdle error %08x expected %08x\n",
12799 i, ret, wait_idle_expect[i].exp );
12800 else if (wait_idle_expect[i].todo)
12802 ok( ret == wait_idle_expect[i].exp || broken(ret == wait_idle_expect[i].broken),
12803 "%u: WaitForInputIdle error %08x expected %08x\n",
12804 i, ret, wait_idle_expect[i].exp );
12806 ok( ret == wait_idle_expect[i].exp || broken(ret == wait_idle_expect[i].broken),
12807 "%u: WaitForInputIdle error %08x expected %08x\n",
12808 i, ret, wait_idle_expect[i].exp );
12809 SetEvent( end_event );
12810 WaitForSingleObject( pi.hProcess, 1000 ); /* give it a chance to exit on its own */
12812 TerminateProcess( pi.hProcess, 0 ); /* just in case */
12813 winetest_wait_child_process( pi.hProcess );
12814 ret = WaitForInputIdle( pi.hProcess, 100 );
12815 ok( ret == WAIT_FAILED, "%u: WaitForInputIdle after exit error %08x\n", i, ret );
12816 CloseHandle( pi.hProcess );
12817 CloseHandle( pi.hThread );
12820 CloseHandle( start_event );
12821 PostThreadMessage( id, WM_QUIT, 0, 0 );
12822 WaitForSingleObject( thread, 10000 );
12823 CloseHandle( thread );
12826 static const struct message WmSetParentSeq_1[] = {
12827 { WM_SHOWWINDOW, sent|wparam, 0 },
12828 { EVENT_OBJECT_PARENTCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12829 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
12830 { WM_CHILDACTIVATE, sent },
12831 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOSIZE|SWP_NOREDRAW|SWP_NOCLIENTSIZE },
12832 { WM_MOVE, sent|defwinproc|wparam, 0 },
12833 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12834 { WM_SHOWWINDOW, sent|wparam, 1 },
12838 static const struct message WmSetParentSeq_2[] = {
12839 { WM_SHOWWINDOW, sent|wparam, 0 },
12840 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE },
12841 { EVENT_OBJECT_HIDE, winevent_hook|wparam|lparam, 0, 0 },
12842 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
12843 { HCBT_SETFOCUS, hook|optional },
12844 { WM_NCACTIVATE, sent|wparam|optional, 0 },
12845 { WM_ACTIVATE, sent|wparam|optional, 0 },
12846 { WM_ACTIVATEAPP, sent|wparam|optional, 0 },
12847 { WM_KILLFOCUS, sent|wparam, 0 },
12848 { EVENT_OBJECT_PARENTCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12849 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE },
12850 { HCBT_ACTIVATE, hook },
12851 { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 },
12852 { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE },
12853 { WM_NCACTIVATE, sent|wparam|optional, 1 },
12854 { WM_ACTIVATE, sent|wparam|optional, 1 },
12855 { HCBT_SETFOCUS, hook },
12856 { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 },
12857 { WM_SETFOCUS, sent|optional|defwinproc },
12858 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOREDRAW|SWP_NOSIZE|SWP_NOCLIENTSIZE },
12859 { WM_MOVE, sent|defwinproc|wparam, 0 },
12860 { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 },
12861 { WM_SHOWWINDOW, sent|wparam, 1 },
12862 { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE },
12863 { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 },
12864 { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE },
12869 static void test_SetParent(void)
12871 HWND parent1, parent2, child, popup;
12874 parent1 = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
12875 100, 100, 200, 200, 0, 0, 0, NULL);
12876 ok(parent1 != 0, "Failed to create parent1 window\n");
12878 parent2 = CreateWindowEx(0, "TestParentClass", NULL, WS_OVERLAPPEDWINDOW,
12879 400, 100, 200, 200, 0, 0, 0, NULL);
12880 ok(parent2 != 0, "Failed to create parent2 window\n");
12882 /* WS_CHILD window */
12883 child = CreateWindowEx(0, "TestWindowClass", NULL, WS_CHILD | WS_VISIBLE,
12884 10, 10, 150, 150, parent1, 0, 0, NULL);
12885 ok(child != 0, "Failed to create child window\n");
12887 GetWindowRect(parent1, &rc);
12888 trace("parent1 (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
12889 GetWindowRect(child, &rc_old);
12890 MapWindowPoints(0, parent1, (POINT *)&rc_old, 2);
12891 trace("child (%d,%d)-(%d,%d)\n", rc_old.left, rc_old.top, rc_old.right, rc_old.bottom);
12895 SetParent(child, parent2);
12897 ok_sequence(WmSetParentSeq_1, "SetParent() visible WS_CHILD", TRUE);
12899 ok(GetWindowLongA(child, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
12900 ok(!IsWindowVisible(child), "IsWindowVisible() should return FALSE\n");
12902 GetWindowRect(parent2, &rc);
12903 trace("parent2 (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
12904 GetWindowRect(child, &rc);
12905 MapWindowPoints(0, parent2, (POINT *)&rc, 2);
12906 trace("child (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
12908 ok(EqualRect(&rc_old, &rc), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
12909 rc_old.left, rc_old.top, rc_old.right, rc_old.bottom,
12910 rc.left, rc.top, rc.right, rc.bottom );
12912 /* WS_POPUP window */
12913 popup = CreateWindowEx(0, "TestWindowClass", NULL, WS_POPUP | WS_VISIBLE,
12914 20, 20, 100, 100, 0, 0, 0, NULL);
12915 ok(popup != 0, "Failed to create popup window\n");
12917 GetWindowRect(popup, &rc_old);
12918 trace("popup (%d,%d)-(%d,%d)\n", rc_old.left, rc_old.top, rc_old.right, rc_old.bottom);
12922 SetParent(popup, child);
12924 ok_sequence(WmSetParentSeq_2, "SetParent() visible WS_POPUP", TRUE);
12926 ok(GetWindowLongA(popup, GWL_STYLE) & WS_VISIBLE, "WS_VISIBLE should be set\n");
12927 ok(!IsWindowVisible(popup), "IsWindowVisible() should return FALSE\n");
12929 GetWindowRect(child, &rc);
12930 trace("parent2 (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
12931 GetWindowRect(popup, &rc);
12932 MapWindowPoints(0, child, (POINT *)&rc, 2);
12933 trace("popup (%d,%d)-(%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
12935 ok(EqualRect(&rc_old, &rc), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
12936 rc_old.left, rc_old.top, rc_old.right, rc_old.bottom,
12937 rc.left, rc.top, rc.right, rc.bottom );
12939 DestroyWindow(popup);
12940 DestroyWindow(child);
12941 DestroyWindow(parent1);
12942 DestroyWindow(parent2);
12947 static const struct message WmKeyReleaseOnly[] = {
12948 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0x80000001 },
12949 { WM_KEYUP, sent|wparam|lparam, 0x41, 0x80000001 },
12952 static const struct message WmKeyPressNormal[] = {
12953 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0x1 },
12954 { WM_KEYDOWN, sent|wparam|lparam, 0x41, 0x1 },
12957 static const struct message WmKeyPressRepeat[] = {
12958 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0x40000001 },
12959 { WM_KEYDOWN, sent|wparam|lparam, 0x41, 0x40000001 },
12962 static const struct message WmKeyReleaseNormal[] = {
12963 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, 0x41, 0xc0000001 },
12964 { WM_KEYUP, sent|wparam|lparam, 0x41, 0xc0000001 },
12968 static void test_keyflags(void)
12972 BYTE keyboard_state[256];
12975 test_window = CreateWindowEx(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
12976 100, 100, 200, 200, 0, 0, 0, NULL);
12980 /* keyup without a keydown */
12981 keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
12982 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
12983 DispatchMessage(&msg);
12984 ok_sequence(WmKeyReleaseOnly, "key release only", TRUE);
12986 key_state = GetAsyncKeyState(0x41);
12987 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
12989 key_state = GetKeyState(0x41);
12990 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
12993 keybd_event(0x41, 0, 0, 0);
12994 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
12995 DispatchMessage(&msg);
12996 ok_sequence(WmKeyPressNormal, "key press only", FALSE);
12998 key_state = GetAsyncKeyState(0x41);
12999 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13001 key_state = GetKeyState(0x41);
13002 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13004 /* keydown repeat */
13005 keybd_event(0x41, 0, 0, 0);
13006 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13007 DispatchMessage(&msg);
13008 ok_sequence(WmKeyPressRepeat, "key press repeat", FALSE);
13010 key_state = GetAsyncKeyState(0x41);
13011 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13013 key_state = GetKeyState(0x41);
13014 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13017 keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
13018 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13019 DispatchMessage(&msg);
13020 ok_sequence(WmKeyReleaseNormal, "key release repeat", FALSE);
13022 key_state = GetAsyncKeyState(0x41);
13023 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13025 key_state = GetKeyState(0x41);
13026 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13028 /* set the key state in this thread */
13029 GetKeyboardState(keyboard_state);
13030 keyboard_state[0x41] = 0x80;
13031 SetKeyboardState(keyboard_state);
13033 key_state = GetAsyncKeyState(0x41);
13034 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13037 keybd_event(0x41, 0, 0, 0);
13038 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13039 DispatchMessage(&msg);
13040 ok_sequence(WmKeyPressRepeat, "key press after setkeyboardstate", TRUE);
13042 key_state = GetAsyncKeyState(0x41);
13043 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13045 key_state = GetKeyState(0x41);
13046 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13048 /* clear the key state in this thread */
13049 GetKeyboardState(keyboard_state);
13050 keyboard_state[0x41] = 0;
13051 SetKeyboardState(keyboard_state);
13053 key_state = GetAsyncKeyState(0x41);
13054 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13057 keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);
13058 while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE))
13059 DispatchMessage(&msg);
13060 ok_sequence(WmKeyReleaseOnly, "key release after setkeyboardstate", TRUE);
13062 key_state = GetAsyncKeyState(0x41);
13063 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13065 key_state = GetKeyState(0x41);
13066 ok((key_state & 0x8000) == 0, "unexpected key state %x\n", key_state);
13068 DestroyWindow(test_window);
13072 static const struct message WmHotkeyPressLWIN[] = {
13073 { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED },
13074 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 },
13075 { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 },
13078 static const struct message WmHotkeyPress[] = {
13079 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13080 { WM_HOTKEY, sent|wparam, 5 },
13083 static const struct message WmHotkeyRelease[] = {
13084 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13085 { HCBT_KEYSKIPPED, hook|lparam|optional, 0, 0x80000001 },
13086 { WM_KEYUP, sent|lparam, 0, 0x80000001 },
13089 static const struct message WmHotkeyReleaseLWIN[] = {
13090 { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP },
13091 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 },
13092 { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 },
13095 static const struct message WmHotkeyCombined[] = {
13096 { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED },
13097 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13098 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13099 { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP },
13100 { WM_APP, sent, 0, 0 },
13101 { WM_HOTKEY, sent|wparam, 5 },
13102 { WM_APP+1, sent, 0, 0 },
13103 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 },
13104 { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 },
13105 { HCBT_KEYSKIPPED, hook|optional, 0, 0x80000001 },
13106 { WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13107 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 },
13108 { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 },
13111 static const struct message WmHotkeyPrevious[] = {
13112 { WM_KEYDOWN, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED },
13113 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13114 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13115 { WM_KEYUP, kbd_hook|wparam|lparam, VK_LWIN, LLKHF_INJECTED|LLKHF_UP },
13116 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 1 },
13117 { WM_KEYDOWN, sent|wparam|lparam, VK_LWIN, 1 },
13118 { HCBT_KEYSKIPPED, hook|lparam|optional, 0, 1 },
13119 { WM_KEYDOWN, sent|lparam, 0, 1 },
13120 { HCBT_KEYSKIPPED, hook|optional|lparam, 0, 0xc0000001 },
13121 { WM_KEYUP, sent|lparam, 0, 0xc0000001 },
13122 { HCBT_KEYSKIPPED, hook|wparam|lparam|optional, VK_LWIN, 0xc0000001 },
13123 { WM_KEYUP, sent|wparam|lparam, VK_LWIN, 0xc0000001 },
13126 static const struct message WmHotkeyNew[] = {
13127 { WM_KEYDOWN, kbd_hook|lparam, 0, LLKHF_INJECTED },
13128 { WM_KEYUP, kbd_hook|lparam, 0, LLKHF_INJECTED|LLKHF_UP },
13129 { WM_HOTKEY, sent|wparam, 5 },
13130 { HCBT_KEYSKIPPED, hook|optional, 0, 0x80000001 },
13131 { WM_KEYUP, sent, 0, 0x80000001 }, /* lparam not checked so the sequence isn't a todo */
13135 static int hotkey_letter;
13137 static LRESULT CALLBACK KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
13139 struct recvd_message msg;
13141 if (nCode == HC_ACTION)
13143 KBDLLHOOKSTRUCT *kdbhookstruct = (KBDLLHOOKSTRUCT*)lParam;
13146 msg.message = wParam;
13147 msg.flags = kbd_hook|wparam|lparam;
13148 msg.wParam = kdbhookstruct->vkCode;
13149 msg.lParam = kdbhookstruct->flags;
13150 msg.descr = "KeyboardHookProc";
13153 if (wParam == WM_KEYUP || wParam == WM_KEYDOWN)
13155 ok(kdbhookstruct->vkCode == VK_LWIN || kdbhookstruct->vkCode == hotkey_letter,
13156 "unexpected keycode %x\n", kdbhookstruct->vkCode);
13160 return CallNextHookEx(hKBD_hook, nCode, wParam, lParam);
13163 static void test_hotkey(void)
13165 HWND test_window, taskbar_window;
13168 DWORD queue_status;
13171 SetLastError(0xdeadbeef);
13172 ret = UnregisterHotKey(NULL, 0);
13173 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13174 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13175 "unexpected error %d\n", GetLastError());
13179 skip("hotkeys not supported\n");
13183 test_window = CreateWindowEx(0, "HotkeyWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
13184 100, 100, 200, 200, 0, 0, 0, NULL);
13188 SetLastError(0xdeadbeef);
13189 ret = UnregisterHotKey(test_window, 0);
13190 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13191 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13192 "unexpected error %d\n", GetLastError());
13194 /* Search for a Windows Key + letter combination that hasn't been registered */
13195 for (hotkey_letter = 0x41; hotkey_letter <= 0x51; hotkey_letter ++)
13197 SetLastError(0xdeadbeef);
13198 ret = RegisterHotKey(test_window, 5, MOD_WIN, hotkey_letter);
13206 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13207 "unexpected error %d\n", GetLastError());
13211 if (hotkey_letter == 0x52)
13213 ok(0, "Couldn't find any free Windows Key + letter combination\n");
13217 hKBD_hook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProc, GetModuleHandle(NULL), 0);
13218 if (!hKBD_hook) win_skip("WH_KEYBOARD_LL is not supported\n");
13220 /* Same key combination, different id */
13221 SetLastError(0xdeadbeef);
13222 ret = RegisterHotKey(test_window, 4, MOD_WIN, hotkey_letter);
13223 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13224 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13225 "unexpected error %d\n", GetLastError());
13227 /* Same key combination, different window */
13228 SetLastError(0xdeadbeef);
13229 ret = RegisterHotKey(NULL, 5, MOD_WIN, hotkey_letter);
13230 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13231 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13232 "unexpected error %d\n", GetLastError());
13234 /* Register the same hotkey twice */
13235 SetLastError(0xdeadbeef);
13236 ret = RegisterHotKey(test_window, 5, MOD_WIN, hotkey_letter);
13237 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13238 ok(GetLastError() == ERROR_HOTKEY_ALREADY_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13239 "unexpected error %d\n", GetLastError());
13241 /* Window on another thread */
13242 taskbar_window = FindWindowA("Shell_TrayWnd", NULL);
13243 if (!taskbar_window)
13245 skip("no taskbar?\n");
13249 SetLastError(0xdeadbeef);
13250 ret = RegisterHotKey(taskbar_window, 5, 0, hotkey_letter);
13251 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13252 ok(GetLastError() == ERROR_WINDOW_OF_OTHER_THREAD || broken(GetLastError() == 0xdeadbeef),
13253 "unexpected error %d\n", GetLastError());
13256 /* Inject the appropriate key sequence */
13257 keybd_event(VK_LWIN, 0, 0, 0);
13258 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13259 DispatchMessage(&msg);
13260 ok_sequence(WmHotkeyPressLWIN, "window hotkey press LWIN", FALSE);
13262 keybd_event(hotkey_letter, 0, 0, 0);
13263 queue_status = GetQueueStatus(QS_HOTKEY);
13264 ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
13265 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13267 if (msg.message == WM_HOTKEY)
13269 ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
13270 ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13272 DispatchMessage(&msg);
13274 ok_sequence(WmHotkeyPress, "window hotkey press", FALSE);
13276 queue_status = GetQueueStatus(QS_HOTKEY);
13277 ok((queue_status & (QS_HOTKEY << 16)) == 0, "expected QS_HOTKEY << 16 cleared, got %x\n", queue_status);
13279 key_state = GetAsyncKeyState(hotkey_letter);
13280 ok((key_state & 0x8000) == 0x8000, "unexpected key state %x\n", key_state);
13282 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13283 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13284 DispatchMessage(&msg);
13285 ok_sequence(WmHotkeyRelease, "window hotkey release", TRUE);
13287 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13288 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13289 DispatchMessage(&msg);
13290 ok_sequence(WmHotkeyReleaseLWIN, "window hotkey release LWIN", FALSE);
13292 /* normal posted WM_HOTKEY messages set QS_HOTKEY */
13293 PostMessage(test_window, WM_HOTKEY, 0, 0);
13294 queue_status = GetQueueStatus(QS_HOTKEY);
13295 ok((queue_status & (QS_HOTKEY << 16)) == QS_HOTKEY << 16, "expected QS_HOTKEY << 16 set, got %x\n", queue_status);
13296 queue_status = GetQueueStatus(QS_POSTMESSAGE);
13297 ok((queue_status & (QS_POSTMESSAGE << 16)) == QS_POSTMESSAGE << 16, "expected QS_POSTMESSAGE << 16 set, got %x\n", queue_status);
13298 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13299 DispatchMessage(&msg);
13302 /* Send and process all messages at once */
13303 PostMessage(test_window, WM_APP, 0, 0);
13304 keybd_event(VK_LWIN, 0, 0, 0);
13305 keybd_event(hotkey_letter, 0, 0, 0);
13306 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13307 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13309 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13311 if (msg.message == WM_HOTKEY)
13313 ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
13314 ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13316 DispatchMessage(&msg);
13318 ok_sequence(WmHotkeyCombined, "window hotkey combined", FALSE);
13320 /* Register same hwnd/id with different key combination */
13321 ret = RegisterHotKey(test_window, 5, 0, hotkey_letter);
13322 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13324 /* Previous key combination does not work */
13325 keybd_event(VK_LWIN, 0, 0, 0);
13326 keybd_event(hotkey_letter, 0, 0, 0);
13327 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13328 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13330 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13331 DispatchMessage(&msg);
13332 ok_sequence(WmHotkeyPrevious, "window hotkey previous", FALSE);
13334 /* New key combination works */
13335 keybd_event(hotkey_letter, 0, 0, 0);
13336 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13338 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13340 if (msg.message == WM_HOTKEY)
13342 ok(msg.hwnd == test_window, "unexpected hwnd %p\n", msg.hwnd);
13343 ok(msg.lParam == MAKELPARAM(0, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13345 DispatchMessage(&msg);
13347 ok_sequence(WmHotkeyNew, "window hotkey new", FALSE);
13349 /* Unregister hotkey properly */
13350 ret = UnregisterHotKey(test_window, 5);
13351 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13353 /* Unregister hotkey again */
13354 SetLastError(0xdeadbeef);
13355 ret = UnregisterHotKey(test_window, 5);
13356 ok(ret == FALSE, "expected FALSE, got %i\n", ret);
13357 ok(GetLastError() == ERROR_HOTKEY_NOT_REGISTERED || broken(GetLastError() == 0xdeadbeef),
13358 "unexpected error %d\n", GetLastError());
13360 /* Register thread hotkey */
13361 ret = RegisterHotKey(NULL, 5, MOD_WIN, hotkey_letter);
13362 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13364 /* Inject the appropriate key sequence */
13365 keybd_event(VK_LWIN, 0, 0, 0);
13366 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13368 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13369 DispatchMessage(&msg);
13371 ok_sequence(WmHotkeyPressLWIN, "thread hotkey press LWIN", FALSE);
13373 keybd_event(hotkey_letter, 0, 0, 0);
13374 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13376 if (msg.message == WM_HOTKEY)
13378 struct recvd_message message;
13379 ok(msg.hwnd == NULL, "unexpected hwnd %p\n", msg.hwnd);
13380 ok(msg.lParam == MAKELPARAM(MOD_WIN, hotkey_letter), "unexpected WM_HOTKEY lparam %lx\n", msg.lParam);
13381 message.message = msg.message;
13382 message.flags = sent|wparam|lparam;
13383 message.wParam = msg.wParam;
13384 message.lParam = msg.lParam;
13385 message.descr = "test_hotkey thread message";
13386 add_message(&message);
13389 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13390 DispatchMessage(&msg);
13392 ok_sequence(WmHotkeyPress, "thread hotkey press", FALSE);
13394 keybd_event(hotkey_letter, 0, KEYEVENTF_KEYUP, 0);
13395 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13397 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13398 DispatchMessage(&msg);
13400 ok_sequence(WmHotkeyRelease, "thread hotkey release", TRUE);
13402 keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
13403 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
13405 ok(msg.hwnd != NULL, "unexpected thread message %x\n", msg.message);
13406 DispatchMessage(&msg);
13408 ok_sequence(WmHotkeyReleaseLWIN, "thread hotkey release LWIN", FALSE);
13410 /* Unregister thread hotkey */
13411 ret = UnregisterHotKey(NULL, 5);
13412 ok(ret == TRUE, "expected TRUE, got %i, err=%d\n", ret, GetLastError());
13414 if (hKBD_hook) UnhookWindowsHookEx(hKBD_hook);
13418 UnregisterHotKey(NULL, 5);
13419 UnregisterHotKey(test_window, 5);
13420 DestroyWindow(test_window);
13428 BOOL (WINAPI *pIsWinEventHookInstalled)(DWORD)= 0;/*GetProcAddress(user32, "IsWinEventHookInstalled");*/
13429 HMODULE hModuleImm32;
13430 BOOL (WINAPI *pImmDisableIME)(DWORD);
13432 int argc = winetest_get_mainargs( &test_argv );
13436 /* Child process. */
13437 sscanf (test_argv[2], "%d", (unsigned int *) &arg);
13438 do_wait_idle_child( arg );
13444 hModuleImm32 = LoadLibrary("imm32.dll");
13445 if (hModuleImm32) {
13446 pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME");
13447 if (pImmDisableIME)
13450 pImmDisableIME = NULL;
13451 FreeLibrary(hModuleImm32);
13453 if (!RegisterWindowClasses()) assert(0);
13455 if (pSetWinEventHook)
13457 hEvent_hook = pSetWinEventHook(EVENT_MIN, EVENT_MAX,
13458 GetModuleHandleA(0), win_event_proc,
13459 0, GetCurrentThreadId(),
13460 WINEVENT_INCONTEXT);
13461 if (pIsWinEventHookInstalled && hEvent_hook)
13464 for (event = EVENT_MIN; event <= EVENT_MAX; event++)
13465 ok(pIsWinEventHookInstalled(event), "IsWinEventHookInstalled(%u) failed\n", event);
13468 if (!hEvent_hook) win_skip( "no win event hook support\n" );
13470 cbt_hook_thread_id = GetCurrentThreadId();
13471 hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
13472 if (!hCBT_hook) win_skip( "cannot set global hook, will skip hook tests\n" );
13476 /* Fix message sequences before removing 4 lines below */
13478 if (pUnhookWinEvent && hEvent_hook)
13480 ret = pUnhookWinEvent(hEvent_hook);
13481 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
13482 pUnhookWinEvent = 0;
13488 test_PostMessage();
13490 test_PeekMessage();
13491 test_PeekMessage2();
13492 test_WaitForInputIdle( test_argv[0] );
13493 test_scrollwindowex();
13495 test_setwindowpos();
13497 invisible_parent_tests();
13498 test_mdi_messages();
13499 test_button_messages();
13500 test_static_messages();
13501 test_listbox_messages();
13502 test_combobox_messages();
13503 test_wmime_keydown_message();
13504 test_paint_messages();
13505 test_interthread_messages();
13506 test_message_conversion();
13507 test_accelerators();
13509 test_timers_no_wnd();
13510 if (hCBT_hook) test_set_hook();
13511 test_DestroyWindow();
13512 test_DispatchMessage();
13513 test_SendMessageTimeout();
13514 test_edit_messages();
13515 test_quit_message();
13516 test_SetActiveWindow();
13518 if (!pTrackMouseEvent)
13519 win_skip("TrackMouseEvent is not available\n");
13521 test_TrackMouseEvent();
13523 test_SetWindowRgn();
13525 test_dialog_messages();
13526 test_nullCallback();
13527 test_dbcs_wm_char();
13528 test_menu_messages();
13529 test_paintingloop();
13531 test_clipboard_viewers();
13534 /* keep it the last test, under Windows it tends to break the tests
13535 * which rely on active/foreground windows being correct.
13537 test_SetForegroundWindow();
13539 UnhookWindowsHookEx(hCBT_hook);
13540 if (pUnhookWinEvent && hEvent_hook)
13542 ret = pUnhookWinEvent(hEvent_hook);
13543 ok( ret, "UnhookWinEvent error %d\n", GetLastError());
13544 SetLastError(0xdeadbeef);
13545 ok(!pUnhookWinEvent(hEvent_hook), "UnhookWinEvent succeeded\n");
13546 ok(GetLastError() == ERROR_INVALID_HANDLE || /* Win2k */
13547 GetLastError() == 0xdeadbeef, /* Win9x */
13548 "unexpected error %d\n", GetLastError());